SlideShare a Scribd company logo
1 of 24
LECTURE 5
First Order Logic
Instructor : Yousef Aburawi
Cs411 -Artificial Intelligence
Misurata University
Faculty of Information Technology
Spring 2022/2023
First Order Logic
Outline
I. Syntax of FOL
II. Quantifiers
III. Model for FOL
IV. Assertions & queries in FOL
I. Propositional Logic: Strength and Weakness
 Programming languages lack a general mechanism for deriving facts
from other facts.
 They lack the expressiveness required to handle partial information.
 Propositional logic addresses the above issues.
 It also has compositionality – the meaning of a sentence is a function
of the meanings of its parts.
¬ rain ∨ ¬ outside ∨ wet
 It lacks the expressive power to describe an environment with many objects.
𝐵1,1 ⇔ (𝑃1,2 ∨ 𝑃2,1)
𝐵1,2 ⇔ (𝑃1,1 ∨ 𝑃1,3 ∨ 𝑃2,2)
⋮
// Squares adjacent to pits are breezy.
 Propositional logic assumes the world contains facts only.
Combining Formal and Natural Languages
 Objects: people, houses, cars, trees, colors, days, …
 Relations:
 unary properties such as big, windy, …
 𝑛-ary properties such as bigger than, parent of, on, owns, …
 Functions: square of, best friend, age, …
First-order logic
 built around objects and relations
 capable of expressing facts about some or all objects
Formal Languages
Alphabet of First-Order Logic
 Logical symbols
 connectives: ∧, ∨, ⇒, ⇔, ¬
 quantifiers: ∀ (universal quantification), ∃ (existential quantification)
 parenthesis: (, ) and punctuation ,
 variables: 𝑥, 𝑦, 𝑧, … ; 𝑥1, 𝑥2, …
 equality: =
 Non-logical symbols
 constants: Socrates, Turing, 1, earth, …
 predicate symbols: true, false Father(𝑥, 𝑦) // 𝑥 is father of 𝑦
Female(𝑥) // 𝑥 is female
 function symbols:
gcd(𝑥, 𝑦) // greatest common divisor of 𝑥 and 𝑦
FatherOf(𝑥) // father of 𝑥
Terms and Atomic Sentences
 Terms
 variables: 𝑥, 𝑦, 𝑧, … ; 𝑥1, 𝑥2, …
 constants: Socrates, Turing, 1, earth, …
 functions: gcd(𝑥, 𝑦), FatherOf(𝑥), …
𝑓(𝑥1, 𝑥2, … , 𝑥𝑛)
function symbol terms
 Atomic sentences
 predicates: true, false
Mother(Aphrodite, Harmonia)
Male(John)
FatherOf(Apollo) = Zeus
 term equalities
Complex Sentences
 made of atomic sentences using logical connectives
Father(𝑥, 𝑦) ⇒ Male(𝑥)
Likes(Mary, John) ⇔ Likes(John, Mary)
(Parent(𝑥, 𝑦) ∧ Parent(𝑦, 𝑧)) ⇒ GrandParent(𝑥, 𝑧)
Female(𝑥) ∨ ¬Mother(𝑥, 𝑦)
 universal quantification
∀𝑥 Circle 𝑥 ⇒ Ellipse(𝑥) // Every circle is an ellipse.
¬∀𝑥 Likes 𝑥, sushi // Not everyone likes sushi.
 existential quantification
∃𝑥 Star 𝑥 ∧ ¬ (𝑥 = Sun)
∃𝑥 Whale 𝑥 ∧ (Age(𝑥) = 200)
∀𝑥 Integer 𝑥 ⇒ (Even 𝑥 ∨ Odd 𝑥 ) // Every integer is either even or odd.
// There are stars other than the sun.
// Some whales live to 200 years.
Syntax of First-Order Logic
II. Scope of a Quantifier
 Quantifiers ∀ and ∃ have the lowest precedence.
∀𝑥 𝑃 𝑥 ⇒ 𝑄 𝑥 ≡ ∀𝑥 (𝑃 𝑥 ⇒ 𝑄 𝑥 )
scope of ∀
∀𝑥 𝑃 𝑥 ⇒ 𝑄 𝑥 ∨ ∃𝑦 𝑅(𝑥, 𝑦) ∨ 𝑆 𝑦 ∧ 𝑇 𝑥, 𝑦
≡ ∀𝑥 (𝑃 𝑥 ⇒ (𝑄 𝑥 ∨ ∃𝑦 (𝑅 𝑥, 𝑦 ∨ (𝑆 𝑦 ∧ 𝑇 𝑥, 𝑦 ))))
scope of ∃
scope of ∀
 Each of ∀ and ∃ quantifies the remaining scope of the innermost
pair of parentheses containing it.
⋯ ⋯ ⋯ ⋯ ∀𝑥 ⋯ ⋯ ⋯ ⋯
scope of ∀
Free and Bound Variables
A variable occurrence is free in a formula if it is not quantified.
A variable occurrence is bound in a formula if it is quantified.
∀𝑥 Father(𝑥, 𝑦) ⇒ Male(𝑥) 𝑥 is bound while 𝑦 is free.
¬∀𝑥∃𝑦∃𝑧∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡) 𝑥, 𝑦, 𝑧, 𝑠, 𝑡 are all bound
∀𝑥 ∀𝑦 (𝑃(𝑥) ⇒ 𝑄(𝑥, 𝑓(𝑦), 𝑧)) 𝑥, 𝑦 are bound while 𝑧 is free.
𝑃 𝑥 ⇒ ∃𝑥 𝑄(𝑥)
Free and bound variables can have the same name.
free bound
𝑃 𝑥 ⇒ (∃𝑥 𝑄 𝑥 ) ∧ 𝑅(𝑥)
same free variable
different bound
variable
Nested Quantifiers
∀𝑥∃𝑦 Student 𝑥 ∧ Course(y) ∧ Enrolled(𝑥, 𝑦)
∀𝑥∃𝑦 Brother 𝑥, 𝑦 ⇒ Sibiling(𝑥, 𝑦)
Order matters for quantifiers of different types:
∀𝑥∃𝑦 Loves 𝑥, 𝑦 // Everybody (𝑥) loves somebody (𝑦)
∃𝑥∀𝑦 Loves 𝑦, 𝑥 // There is someone (𝑥) whom everyone (𝑦) loves.
∃𝑥∃𝑦 Loves 𝑥, 𝑦 ≡ ∃𝑦∃𝑥 Loves 𝑥, 𝑦
∀𝑥∀𝑦 (Brother 𝑥, 𝑦 ⇒ Sibiling(𝑥, 𝑦))
≡ ∀𝑦∀𝑥 (Brother 𝑥, 𝑦 ⇒ Sibiling(𝑥, 𝑦))
but not for those of the same type and appearing next to each other:
Connections Between ∀ and ∃ Through ¬
∀𝑥 ¬Likes 𝑥, Parsnips ≡ ¬ ∃𝑥 Likes 𝑥, Parsnips
∀𝑥 Likes 𝑥, Icecream ≡ ¬ ∃𝑥 ¬ Likes 𝑥, Icecream
De Morgan’s rules still apply:
¬∀𝑥 𝑃(𝑥) ≡ ∃𝑥 ¬𝑃(𝑥)
¬∃𝑥 𝑃 𝑥 ≡ ∀𝑥 ¬𝑃(𝑥)
¬∀𝑥∃𝑦∃𝑧∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡) ≡ ∃𝑥¬∃𝑦∃𝑧∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡)
≡ ∃𝑥∀𝑦¬∃𝑧∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡)
≡ ∃𝑥∀𝑦∀𝑧¬∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡)
≡ ∃𝑥∀𝑦∀𝑧∃𝑠¬∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡)
≡ ∃𝑥∀𝑦∀𝑧∃𝑠∃𝑡 ¬𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡)
Move negation inward,
flipping the quantifiers:
III. Model for First-Order Logic
 Sentences are true with respect to a model 𝑀.
 The model 𝑀 contains objects (called domain elements) and
interpretations of symbols.
 constant symbols → objects in domain 𝐷
 predicate symbols → relations
 function symbols → functional relations
 Each predicate 𝑃(𝑥1, … , 𝑥𝑘) is mapped to a relation over 𝐷.
 Each function 𝑓(𝑥1, … , 𝑥𝑘) is mapped to a function to 𝐷.
Model Example
Model for the family relationships of the Greek gods (incomplete).
domain 𝐷
Zeus
Ares
Hera
Aphrodite
Harmonia
Hermes
Athena
Artemis
Dionysus
Hades
Apollo Poseidon
Demeter
Hephaestus
Persephone
⋮
Father(Zeus, Hermes)
Mother(Hera, Ares)
Mother(Aphrodite, Harmonia)
Father(Zeus, Athena)
predicates
Weapon(Zeus) // ≡ Thunderbolt
Carry(Hermes) // ≡ Flute
Weapon(Apollo) // ≡ BowAndArrows
Carry(Aphrodite) // ≡ Apple
⋮
functions
Truth in First-Order Logic
 A predicate 𝑃 𝑡1, … , 𝑡𝑘 is true if the objects referred to by the terms
𝑡1, … , 𝑡𝑘 are in the relation referred to by the predicate.
 𝑡1 = 𝑡2 is true if the two terms 𝑡1 and 𝑡2 refer to the same object.
 The semantics of sentences formed with logical connectives are
identical to those in propositional logic.
Quantifiers allow us to express properties of a collection of objects
instead of enumerating them by name.
∀ (universal): “for all”
∃ (existential): “there exists”
Truths with Quantifications
 ∀𝑥 𝑃 𝑥 is true in a model 𝑀 iff 𝑃(𝑥) is true with 𝑥 assuming
every object in the model
∀𝑥 Father(𝑥, 𝑦) ⇒ Male(𝑥) true (in every model)
∀𝑥 Ellipse(𝑥) ⇒ Circle 𝑥 true (in every model)
 ∃𝑥 𝑃 𝑥 is true in a model 𝑀 iff 𝑃(𝑥) is true with 𝑥 assuming
some object in the model.
∃𝑥 Mother(𝑥, Ares) ∧ Mother(𝑥, Harmonia) false (in the model of
Greek mythology)
∃𝑥 ¬ Likes 𝑥, sushi true (in a model that includes
all the people in the world)
IV. Using FOL
A domain is some part of the world about which we wish to express
some knowledge.
Knowledge engineering represents information about the world
in a form that can be utilized by a computer to solve complex tasks
such as:
 medical diagnosis
 dialog in a natural language
 etc.
 Knowledge representation (logical rules, semantic nets, etc.)
 Automated reasoning (inference engines, theorem provers, etc.)
Assertions and Queries in FOL
 Add sentences, called assertions, to a KB using TELL.
TELL(KB, ∀𝑥∃𝑦 Brother 𝑥, 𝑦 ⇒ Sibiling(𝑥, 𝑦))
TELL(KB, Father(Zeus, Athena))
TELL(KB, Likes(John, Icecream))
 Ask the KB questions using ASK.
ASK(KB, Likes(John, Icecream))
Query: question asked
Any query is entailed by the KB should be answered affirmatively.
Substitution
Suppose another KB has the following predicates:
Bird(Swan), Bird(Crane), Bird(Parrot),
ASK(KB, ∃𝑥 Bird(𝑥))
 To know what values of 𝑥 make the sentence true
{𝑥/ Swan}, {𝑥/ Crane}, and {𝑥/ Parrot}
substitution or binding list
returns true
 Quantified query
ASKVARS(KB, Bird(𝑥))
The query returns
The Kinship Domain
Kinship relations are represented by binary predicates.
∀𝑚, 𝑐 Mother 𝑐 = 𝑚 ⇔ Female(𝑚) ∧ Parent(𝑚, 𝑐)
∀𝑤, ℎ Husband ℎ, 𝑤 ⇔ Male(ℎ) ∧ Spouse(ℎ, 𝑤)
// One’s mother is the person’s female parent.
// One’s husband is the person’s male spouse.
∀𝑝, 𝑐 Parent 𝑝, 𝑐 ⇔ Child(𝑐, 𝑝)
// Parent and child are inverse relations.
∀𝑔, 𝑐 GrandParent 𝑔, 𝑐 ⇔ ∃𝑝 (Parent(𝑔, 𝑝) ∧ Parent(𝑝, 𝑐))
// A grand parent is a parent of one’s parent
∀𝑥, 𝑠 Sibling 𝑥, 𝑠 ⇔ 𝑥 ≠ 𝑠 ∧ ∃𝑝 (Parent(𝑝, 𝑥) ∧ Parent(𝑝, 𝑠))
// A sibling is another child of one’s parent
Axioms
Axioms and Theorems
 Theorems are logical sentences entailed by axioms.
∀𝑥, 𝑦 Sibling 𝑥, 𝑦 ⇔ Sibling(𝑦, 𝑥)
// entailed by
// ∀𝑥, 𝑠 Sibling 𝑥, 𝑠 ⇔ 𝑥 ≠ 𝑠 ∧ ∃𝑝 (Parent(𝑝, 𝑥) ∧ Parent(𝑝, 𝑠))
ASK(KB, ∀𝑥, 𝑦 Sibling 𝑥, 𝑦 ⇔ Sibling(𝑦, 𝑥)) should return true.
 Axioms in a domain are logical sentences that are taken to be
true without being derived.
Readings
 Chapters 8 of Textbox.
1-23
The End

More Related Content

Similar to AI_05_First Order Logic.pptx

FERMAT’S LAST THEOREM PROVED BY INDUCTION (accompanied by a philosophical com...
FERMAT’S LAST THEOREM PROVED BY INDUCTION (accompanied by a philosophical com...FERMAT’S LAST THEOREM PROVED BY INDUCTION (accompanied by a philosophical com...
FERMAT’S LAST THEOREM PROVED BY INDUCTION (accompanied by a philosophical com...
Vasil Penchev
 
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdfPLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
amarndsons
 
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.pptdfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
NobitaNobi489694
 
Knowledge Representation and Reasoning.pptx
Knowledge Representation and Reasoning.pptxKnowledge Representation and Reasoning.pptx
Knowledge Representation and Reasoning.pptx
MohanKumarP34
 

Similar to AI_05_First Order Logic.pptx (20)

Basic Knowledge Representation in First Order Logic.ppt
Basic Knowledge Representation in First Order Logic.pptBasic Knowledge Representation in First Order Logic.ppt
Basic Knowledge Representation in First Order Logic.ppt
 
Semantics
SemanticsSemantics
Semantics
 
Homogeneous Components of a CDH Fuzzy Space
Homogeneous Components of a CDH Fuzzy SpaceHomogeneous Components of a CDH Fuzzy Space
Homogeneous Components of a CDH Fuzzy Space
 
FERMAT’S LAST THEOREM PROVED BY INDUCTION (accompanied by a philosophical com...
FERMAT’S LAST THEOREM PROVED BY INDUCTION (accompanied by a philosophical com...FERMAT’S LAST THEOREM PROVED BY INDUCTION (accompanied by a philosophical com...
FERMAT’S LAST THEOREM PROVED BY INDUCTION (accompanied by a philosophical com...
 
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdfPLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
 
lec13.ppt
lec13.pptlec13.ppt
lec13.ppt
 
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.pptdfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
dfgsdfdsgdfgfdgdrgdfgffdhyrthfgnhgjhgdfs.ppt
 
The Intersection Axiom of Conditional Probability
The Intersection Axiom of Conditional ProbabilityThe Intersection Axiom of Conditional Probability
The Intersection Axiom of Conditional Probability
 
Knowledge Representation and Reasoning.pptx
Knowledge Representation and Reasoning.pptxKnowledge Representation and Reasoning.pptx
Knowledge Representation and Reasoning.pptx
 
"reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli..."reflections on the probability space induced by moment conditions with impli...
"reflections on the probability space induced by moment conditions with impli...
 
Presentation X-SHS - 27 oct 2015 - Topologie et perception
Presentation X-SHS - 27 oct 2015 - Topologie et perceptionPresentation X-SHS - 27 oct 2015 - Topologie et perception
Presentation X-SHS - 27 oct 2015 - Topologie et perception
 
MAT-314 Relations and Functions
MAT-314 Relations and FunctionsMAT-314 Relations and Functions
MAT-314 Relations and Functions
 
First order logic
First order logicFirst order logic
First order logic
 
Module_5_1.pptx
Module_5_1.pptxModule_5_1.pptx
Module_5_1.pptx
 
Unification and Lifting
Unification and LiftingUnification and Lifting
Unification and Lifting
 
One solution for many linear partial differential equations with terms of equ...
One solution for many linear partial differential equations with terms of equ...One solution for many linear partial differential equations with terms of equ...
One solution for many linear partial differential equations with terms of equ...
 
ESSLLI2016 DTS Lecture Day 2: Dependent Type Semantics (DTS)
ESSLLI2016 DTS Lecture Day 2: Dependent Type Semantics (DTS)ESSLLI2016 DTS Lecture Day 2: Dependent Type Semantics (DTS)
ESSLLI2016 DTS Lecture Day 2: Dependent Type Semantics (DTS)
 
On some types of slight homogeneity
On some types of slight homogeneity On some types of slight homogeneity
On some types of slight homogeneity
 
Dependent Types in Natural Language Semantics
Dependent Types in Natural Language SemanticsDependent Types in Natural Language Semantics
Dependent Types in Natural Language Semantics
 
Dependent Types and Dynamics of Natural Language
Dependent Types and Dynamics of Natural LanguageDependent Types and Dynamics of Natural Language
Dependent Types and Dynamics of Natural Language
 

More from Yousef Aburawi (7)

AI_07_Deep Learning.pptx
AI_07_Deep Learning.pptxAI_07_Deep Learning.pptx
AI_07_Deep Learning.pptx
 
AI_06_Machine Learning.pptx
AI_06_Machine Learning.pptxAI_06_Machine Learning.pptx
AI_06_Machine Learning.pptx
 
AI_04_Logical Agents.pptx
AI_04_Logical Agents.pptxAI_04_Logical Agents.pptx
AI_04_Logical Agents.pptx
 
AI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptxAI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptx
 
AI_02_Intelligent Agents.pptx
AI_02_Intelligent Agents.pptxAI_02_Intelligent Agents.pptx
AI_02_Intelligent Agents.pptx
 
AI_01_introduction.pptx
AI_01_introduction.pptxAI_01_introduction.pptx
AI_01_introduction.pptx
 
AI_08_NLP.pptx
AI_08_NLP.pptxAI_08_NLP.pptx
AI_08_NLP.pptx
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

AI_05_First Order Logic.pptx

  • 1. LECTURE 5 First Order Logic Instructor : Yousef Aburawi Cs411 -Artificial Intelligence Misurata University Faculty of Information Technology Spring 2022/2023
  • 2. First Order Logic Outline I. Syntax of FOL II. Quantifiers III. Model for FOL IV. Assertions & queries in FOL
  • 3. I. Propositional Logic: Strength and Weakness  Programming languages lack a general mechanism for deriving facts from other facts.  They lack the expressiveness required to handle partial information.  Propositional logic addresses the above issues.  It also has compositionality – the meaning of a sentence is a function of the meanings of its parts. ¬ rain ∨ ¬ outside ∨ wet  It lacks the expressive power to describe an environment with many objects. 𝐵1,1 ⇔ (𝑃1,2 ∨ 𝑃2,1) 𝐵1,2 ⇔ (𝑃1,1 ∨ 𝑃1,3 ∨ 𝑃2,2) ⋮ // Squares adjacent to pits are breezy.  Propositional logic assumes the world contains facts only.
  • 4. Combining Formal and Natural Languages  Objects: people, houses, cars, trees, colors, days, …  Relations:  unary properties such as big, windy, …  𝑛-ary properties such as bigger than, parent of, on, owns, …  Functions: square of, best friend, age, … First-order logic  built around objects and relations  capable of expressing facts about some or all objects
  • 6. Alphabet of First-Order Logic  Logical symbols  connectives: ∧, ∨, ⇒, ⇔, ¬  quantifiers: ∀ (universal quantification), ∃ (existential quantification)  parenthesis: (, ) and punctuation ,  variables: 𝑥, 𝑦, 𝑧, … ; 𝑥1, 𝑥2, …  equality: =  Non-logical symbols  constants: Socrates, Turing, 1, earth, …  predicate symbols: true, false Father(𝑥, 𝑦) // 𝑥 is father of 𝑦 Female(𝑥) // 𝑥 is female  function symbols: gcd(𝑥, 𝑦) // greatest common divisor of 𝑥 and 𝑦 FatherOf(𝑥) // father of 𝑥
  • 7. Terms and Atomic Sentences  Terms  variables: 𝑥, 𝑦, 𝑧, … ; 𝑥1, 𝑥2, …  constants: Socrates, Turing, 1, earth, …  functions: gcd(𝑥, 𝑦), FatherOf(𝑥), … 𝑓(𝑥1, 𝑥2, … , 𝑥𝑛) function symbol terms  Atomic sentences  predicates: true, false Mother(Aphrodite, Harmonia) Male(John) FatherOf(Apollo) = Zeus  term equalities
  • 8. Complex Sentences  made of atomic sentences using logical connectives Father(𝑥, 𝑦) ⇒ Male(𝑥) Likes(Mary, John) ⇔ Likes(John, Mary) (Parent(𝑥, 𝑦) ∧ Parent(𝑦, 𝑧)) ⇒ GrandParent(𝑥, 𝑧) Female(𝑥) ∨ ¬Mother(𝑥, 𝑦)  universal quantification ∀𝑥 Circle 𝑥 ⇒ Ellipse(𝑥) // Every circle is an ellipse. ¬∀𝑥 Likes 𝑥, sushi // Not everyone likes sushi.  existential quantification ∃𝑥 Star 𝑥 ∧ ¬ (𝑥 = Sun) ∃𝑥 Whale 𝑥 ∧ (Age(𝑥) = 200) ∀𝑥 Integer 𝑥 ⇒ (Even 𝑥 ∨ Odd 𝑥 ) // Every integer is either even or odd. // There are stars other than the sun. // Some whales live to 200 years.
  • 10. II. Scope of a Quantifier  Quantifiers ∀ and ∃ have the lowest precedence. ∀𝑥 𝑃 𝑥 ⇒ 𝑄 𝑥 ≡ ∀𝑥 (𝑃 𝑥 ⇒ 𝑄 𝑥 ) scope of ∀ ∀𝑥 𝑃 𝑥 ⇒ 𝑄 𝑥 ∨ ∃𝑦 𝑅(𝑥, 𝑦) ∨ 𝑆 𝑦 ∧ 𝑇 𝑥, 𝑦 ≡ ∀𝑥 (𝑃 𝑥 ⇒ (𝑄 𝑥 ∨ ∃𝑦 (𝑅 𝑥, 𝑦 ∨ (𝑆 𝑦 ∧ 𝑇 𝑥, 𝑦 )))) scope of ∃ scope of ∀  Each of ∀ and ∃ quantifies the remaining scope of the innermost pair of parentheses containing it. ⋯ ⋯ ⋯ ⋯ ∀𝑥 ⋯ ⋯ ⋯ ⋯ scope of ∀
  • 11. Free and Bound Variables A variable occurrence is free in a formula if it is not quantified. A variable occurrence is bound in a formula if it is quantified. ∀𝑥 Father(𝑥, 𝑦) ⇒ Male(𝑥) 𝑥 is bound while 𝑦 is free. ¬∀𝑥∃𝑦∃𝑧∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡) 𝑥, 𝑦, 𝑧, 𝑠, 𝑡 are all bound ∀𝑥 ∀𝑦 (𝑃(𝑥) ⇒ 𝑄(𝑥, 𝑓(𝑦), 𝑧)) 𝑥, 𝑦 are bound while 𝑧 is free. 𝑃 𝑥 ⇒ ∃𝑥 𝑄(𝑥) Free and bound variables can have the same name. free bound 𝑃 𝑥 ⇒ (∃𝑥 𝑄 𝑥 ) ∧ 𝑅(𝑥) same free variable different bound variable
  • 12. Nested Quantifiers ∀𝑥∃𝑦 Student 𝑥 ∧ Course(y) ∧ Enrolled(𝑥, 𝑦) ∀𝑥∃𝑦 Brother 𝑥, 𝑦 ⇒ Sibiling(𝑥, 𝑦) Order matters for quantifiers of different types: ∀𝑥∃𝑦 Loves 𝑥, 𝑦 // Everybody (𝑥) loves somebody (𝑦) ∃𝑥∀𝑦 Loves 𝑦, 𝑥 // There is someone (𝑥) whom everyone (𝑦) loves. ∃𝑥∃𝑦 Loves 𝑥, 𝑦 ≡ ∃𝑦∃𝑥 Loves 𝑥, 𝑦 ∀𝑥∀𝑦 (Brother 𝑥, 𝑦 ⇒ Sibiling(𝑥, 𝑦)) ≡ ∀𝑦∀𝑥 (Brother 𝑥, 𝑦 ⇒ Sibiling(𝑥, 𝑦)) but not for those of the same type and appearing next to each other:
  • 13. Connections Between ∀ and ∃ Through ¬ ∀𝑥 ¬Likes 𝑥, Parsnips ≡ ¬ ∃𝑥 Likes 𝑥, Parsnips ∀𝑥 Likes 𝑥, Icecream ≡ ¬ ∃𝑥 ¬ Likes 𝑥, Icecream De Morgan’s rules still apply: ¬∀𝑥 𝑃(𝑥) ≡ ∃𝑥 ¬𝑃(𝑥) ¬∃𝑥 𝑃 𝑥 ≡ ∀𝑥 ¬𝑃(𝑥) ¬∀𝑥∃𝑦∃𝑧∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡) ≡ ∃𝑥¬∃𝑦∃𝑧∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡) ≡ ∃𝑥∀𝑦¬∃𝑧∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡) ≡ ∃𝑥∀𝑦∀𝑧¬∀𝑠∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡) ≡ ∃𝑥∀𝑦∀𝑧∃𝑠¬∀𝑡 𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡) ≡ ∃𝑥∀𝑦∀𝑧∃𝑠∃𝑡 ¬𝑃(𝑥, 𝑦, 𝑧, 𝑠, 𝑡) Move negation inward, flipping the quantifiers:
  • 14. III. Model for First-Order Logic  Sentences are true with respect to a model 𝑀.  The model 𝑀 contains objects (called domain elements) and interpretations of symbols.  constant symbols → objects in domain 𝐷  predicate symbols → relations  function symbols → functional relations  Each predicate 𝑃(𝑥1, … , 𝑥𝑘) is mapped to a relation over 𝐷.  Each function 𝑓(𝑥1, … , 𝑥𝑘) is mapped to a function to 𝐷.
  • 15. Model Example Model for the family relationships of the Greek gods (incomplete). domain 𝐷 Zeus Ares Hera Aphrodite Harmonia Hermes Athena Artemis Dionysus Hades Apollo Poseidon Demeter Hephaestus Persephone ⋮ Father(Zeus, Hermes) Mother(Hera, Ares) Mother(Aphrodite, Harmonia) Father(Zeus, Athena) predicates Weapon(Zeus) // ≡ Thunderbolt Carry(Hermes) // ≡ Flute Weapon(Apollo) // ≡ BowAndArrows Carry(Aphrodite) // ≡ Apple ⋮ functions
  • 16. Truth in First-Order Logic  A predicate 𝑃 𝑡1, … , 𝑡𝑘 is true if the objects referred to by the terms 𝑡1, … , 𝑡𝑘 are in the relation referred to by the predicate.  𝑡1 = 𝑡2 is true if the two terms 𝑡1 and 𝑡2 refer to the same object.  The semantics of sentences formed with logical connectives are identical to those in propositional logic. Quantifiers allow us to express properties of a collection of objects instead of enumerating them by name. ∀ (universal): “for all” ∃ (existential): “there exists”
  • 17. Truths with Quantifications  ∀𝑥 𝑃 𝑥 is true in a model 𝑀 iff 𝑃(𝑥) is true with 𝑥 assuming every object in the model ∀𝑥 Father(𝑥, 𝑦) ⇒ Male(𝑥) true (in every model) ∀𝑥 Ellipse(𝑥) ⇒ Circle 𝑥 true (in every model)  ∃𝑥 𝑃 𝑥 is true in a model 𝑀 iff 𝑃(𝑥) is true with 𝑥 assuming some object in the model. ∃𝑥 Mother(𝑥, Ares) ∧ Mother(𝑥, Harmonia) false (in the model of Greek mythology) ∃𝑥 ¬ Likes 𝑥, sushi true (in a model that includes all the people in the world)
  • 18. IV. Using FOL A domain is some part of the world about which we wish to express some knowledge. Knowledge engineering represents information about the world in a form that can be utilized by a computer to solve complex tasks such as:  medical diagnosis  dialog in a natural language  etc.  Knowledge representation (logical rules, semantic nets, etc.)  Automated reasoning (inference engines, theorem provers, etc.)
  • 19. Assertions and Queries in FOL  Add sentences, called assertions, to a KB using TELL. TELL(KB, ∀𝑥∃𝑦 Brother 𝑥, 𝑦 ⇒ Sibiling(𝑥, 𝑦)) TELL(KB, Father(Zeus, Athena)) TELL(KB, Likes(John, Icecream))  Ask the KB questions using ASK. ASK(KB, Likes(John, Icecream)) Query: question asked Any query is entailed by the KB should be answered affirmatively.
  • 20. Substitution Suppose another KB has the following predicates: Bird(Swan), Bird(Crane), Bird(Parrot), ASK(KB, ∃𝑥 Bird(𝑥))  To know what values of 𝑥 make the sentence true {𝑥/ Swan}, {𝑥/ Crane}, and {𝑥/ Parrot} substitution or binding list returns true  Quantified query ASKVARS(KB, Bird(𝑥)) The query returns
  • 21. The Kinship Domain Kinship relations are represented by binary predicates. ∀𝑚, 𝑐 Mother 𝑐 = 𝑚 ⇔ Female(𝑚) ∧ Parent(𝑚, 𝑐) ∀𝑤, ℎ Husband ℎ, 𝑤 ⇔ Male(ℎ) ∧ Spouse(ℎ, 𝑤) // One’s mother is the person’s female parent. // One’s husband is the person’s male spouse. ∀𝑝, 𝑐 Parent 𝑝, 𝑐 ⇔ Child(𝑐, 𝑝) // Parent and child are inverse relations. ∀𝑔, 𝑐 GrandParent 𝑔, 𝑐 ⇔ ∃𝑝 (Parent(𝑔, 𝑝) ∧ Parent(𝑝, 𝑐)) // A grand parent is a parent of one’s parent ∀𝑥, 𝑠 Sibling 𝑥, 𝑠 ⇔ 𝑥 ≠ 𝑠 ∧ ∃𝑝 (Parent(𝑝, 𝑥) ∧ Parent(𝑝, 𝑠)) // A sibling is another child of one’s parent Axioms
  • 22. Axioms and Theorems  Theorems are logical sentences entailed by axioms. ∀𝑥, 𝑦 Sibling 𝑥, 𝑦 ⇔ Sibling(𝑦, 𝑥) // entailed by // ∀𝑥, 𝑠 Sibling 𝑥, 𝑠 ⇔ 𝑥 ≠ 𝑠 ∧ ∃𝑝 (Parent(𝑝, 𝑥) ∧ Parent(𝑝, 𝑠)) ASK(KB, ∀𝑥, 𝑦 Sibling 𝑥, 𝑦 ⇔ Sibling(𝑦, 𝑥)) should return true.  Axioms in a domain are logical sentences that are taken to be true without being derived.
  • 23. Readings  Chapters 8 of Textbox. 1-23