0% found this document useful (0 votes)
52 views37 pages

Lec11 Pred Intro Nosol

The document discusses translating English sentences to predicate logic formulas. It introduces predicate logic elements like domains, relations, and quantifiers. It provides examples of translating sentences about animals liking honey to predicate logic and discusses handling multiple quantifiers. The document is a lecture on translating between English and predicate logic formulas.

Uploaded by

Karus Insania
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)
52 views37 pages

Lec11 Pred Intro Nosol

The document discusses translating English sentences to predicate logic formulas. It introduces predicate logic elements like domains, relations, and quantifiers. It provides examples of translating sentences about animals liking honey to predicate logic and discusses handling multiple quantifiers. The document is a lecture on translating between English and predicate logic formulas.

Uploaded by

Karus Insania
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/ 37

Predicate Logic:

Introduction and Translations


Alice Gao

Lecture 11

CS 245 Logic and Computation Fall 2019 1 / 37


Outline

Learning goals

Introduction and Motivation

Elements of Predicate Logic

Translating between English and Predicate Logic


Interpreting the Quantifiers
Why do we need functions?
A Summary of Translation Idioms
At least, at most, and exactly

Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 2 / 37


Learning goals

By the end of this lecture, you should be able to


(Introduction to Predicate Logic)
▶ Give examples of English sentences that can be modeled using
predicate logic but cannot be modeled using propositional
logic.
(Translations)
▶ Translate an English sentence into a predicate formula.
▶ Translate a predicate formula into an English sentence.

CS 245 Logic and Computation Fall 2019 3 / 37


Outline

Learning goals

Introduction and Motivation

Elements of Predicate Logic

Translating between English and Predicate Logic

Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 4 / 37


Translate the following argument into propositional logic

Consider the argument below.


1. Every human is mortal.
2. Socrates is a human.
From these two sentences, one should be able to conclude that
3. Socrates is mortal.
In propositional logic, how would you express this argument?

CS 245 Logic and Computation Fall 2019 5 / 37


What can we NOT express in propositional logic?

A few things that are difficult to express using propositional logic:


▶ Relationships among individuals:
“Alice is a friend of Bob and Alice is not a friend of Cate.“
▶ Generalizing patterns:
“Every bear likes honey.“
▶ Infinite domains:
“Define what it means for a natural number to be prime.“

We can use predicate logic (first-order logic) to express all of these.

CS 245 Logic and Computation Fall 2019 6 / 37


Would you really use predicate logic?

Examples of predicate logic in CS245 so far:


1. Every well-formed formula has an equal number of left and
right brackets.
2. If there does not exist a formal deduction proof from the
premises to the conclusion, then the premises do not logically
imply the conclusion.
3. There exists a truth valuation 𝑡 such that
for every 𝐴 ∈ Σ, 𝐴𝑡 = 1.

CS 245 Logic and Computation Fall 2019 7 / 37


Would you really use predicate logic?

Examples of predicate logic in Computer Science:


1. Data structure: Every key stored in the left subtree of a node
𝑁 is smaller than the key stored at 𝑁 .
2. Algorithms: In the worst case, every comparison sort requires
at least 𝑐𝑛 log 𝑛 comparisons to sort 𝑛 values, for some
constant 𝑐 > 0.
3. Java example: There is no path via references from any
variable in scope to any memory location available for garbage
collection...
4. Database query: Select a person whose age is greater than or
equal to the age of every other person in the table.

CS 245 Logic and Computation Fall 2019 8 / 37


Outline

Learning goals

Introduction and Motivation

Elements of Predicate Logic

Translating between English and Predicate Logic

Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 9 / 37


Elements of predicate logic

Predicate logic generalizes propositional logic.

New things in predicate logic:


▶ Domains
▶ Relations
▶ Quantifiers

CS 245 Logic and Computation Fall 2019 10 / 37


Domains

A domain is
▶ a non-empty set of objects/individuals.
▶ a world that our statement is situated within.
Examples: natural numbers, people, animals, etc.

Why is it important to specify a domain?


▶ A statement can have different truth values in different
domains.
▶ There exists a number whose square is 2.
Is this sentence true when the domain is ℕ? ℝ?

CS 245 Logic and Computation Fall 2019 11 / 37


Objects in a domain

Individuals: concrete objects in the domain


▶ Natural numbers: 0, 6, 100, ...
▶ Alice, Bob, Eve, ...
▶ Animals: Winnie the Pooh, Micky Mouse, Simba, ...

Variables: placeholders for concrete objects.


▶ e.g. 𝑢, 𝑣, 𝑤, 𝑥, 𝑦, 𝑧.
▶ refers to an object without specifying a particular object.

CS 245 Logic and Computation Fall 2019 12 / 37


Relations
A relation represents
▶ a property of an individual, or
▶ a relationship among multiple individuals.
▶ a n-ary function which takes constants and/or variables as
inputs and outputs 1/0

Examples:
▶ Define 𝑆(𝑥) to mean “𝑥 is a student”. (unary predicate)
▶ Bob is a student: 𝑆(𝐵𝑜𝑏)
▶ Micky Mouse is not a student: (¬𝑆(Micky Mouse))
▶ 𝑢 is a student: 𝑆(𝑢)
▶ Define 𝑌 (𝑥, 𝑦) to mean “𝑥 is younger than 𝑦”. (binary
predicate)
▶ Alex is younger than Sam: 𝑌 (Alex, Sam)
▶ 𝑢 is younger than 𝑣: 𝑌 (𝑢, 𝑣)

CS 245 Logic and Computation Fall 2019 13 / 37


Quantifiers

For how many objects in the domain is the statement true?


▶ The universal quantifier ∀:
the statement is true for every object in the domain.
▶ The existential quantifier ∃:
the statement is true for one or more objects in the domain.

CS 245 Logic and Computation Fall 2019 14 / 37


Outline

Learning goals

Introduction and Motivation

Elements of Predicate Logic

Translating between English and Predicate Logic


Interpreting the Quantifiers
Why do we need functions?
A Summary of Translation Idioms
At least, at most, and exactly

Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 15 / 37


CQ Translating English into Predicate Logic

Let the domain be the set of animals.


𝐻(𝑥) means that 𝑥 likes honey. 𝐵(𝑥) means that 𝑥 is a bear.

Are the following translations correct?


1. At least one animal likes honey. (∃𝑥 𝐻(𝑥)).
2. Not every animal likes honey. (¬(∀𝑥 𝐻(𝑥))).

(A) Both are correct.


(B) 1 is correct and 2 is wrong.
(C) 1 is wrong and 2 is correct.
(D) Both are wrong.

CS 245 Logic and Computation Fall 2019 16 / 37


Translating English into Predicate Logic

Let the domain be the set of animals.


𝐻(𝑥) means that 𝑥 likes honey. 𝐵(𝑥) means that 𝑥 is a bear.

Translate the following sentences into predicate logic.


1. All animals like honey.
2. At least one animal likes honey.
3. Not every animal likes honey.
4. No animal likes honey.

CS 245 Logic and Computation Fall 2019 17 / 37


Translating English into Predicate Logic

Let the domain be the set of animals.


𝐻(𝑥) means that 𝑥 likes honey. 𝐵(𝑥) means that 𝑥 is a bear.

Translate the following sentences into predicate logic.


5. No animal dislikes honey.
6. Not every animal dislikes honey.
7. Some animal dislikes honey.
8. Every animal dislikes honey.

CS 245 Logic and Computation Fall 2019 18 / 37


CQ Translating English into Predicate Logic

Consider this sentence: Every bear likes honey.

Which one is the correct translation into predicate logic?


(A) ∀𝑥 (𝐵(𝑥) ∧ 𝐻(𝑥))
(B) ∀𝑥 (𝐵(𝑥) ∨ 𝐻(𝑥))
(C) ∀𝑥 (𝐵(𝑥) → 𝐻(𝑥))
(D) ∀𝑥 (𝐻(𝑥) → 𝐵(𝑥))

Let the domain be the set of animals. 𝐻(𝑥) means that 𝑥 likes
honey. 𝐵(𝑥) means that 𝑥 is a bear.

CS 245 Logic and Computation Fall 2019 19 / 37


CQ Translating English into Predicate Logic

Consider this sentence: Some bear likes honey.


(At least one bear likes honey.)

Which one is the correct translation into predicate logic?


(A) ∃𝑥 (𝐵(𝑥) ∧ 𝐻(𝑥))
(B) ∃𝑥 (𝐵(𝑥) ∨ 𝐻(𝑥))
(C) ∃𝑥 (𝐵(𝑥) → 𝐻(𝑥))
(D) ∃𝑥 (𝐻(𝑥) → 𝐵(𝑥))

Let the domain be the set of animals. 𝐻(𝑥) means that 𝑥 likes
honey. 𝐵(𝑥) means that 𝑥 is a bear.

CS 245 Logic and Computation Fall 2019 20 / 37


Multiple Quantifiers

Let the domain be the set of people. Let 𝐿(𝑥, 𝑦) mean that person
𝑥 likes person 𝑦.
Translate the following formulas into English.
1. ∀𝑥 (∀𝑦 𝐿(𝑥, 𝑦))
2. ∃𝑥 (∃𝑦 𝐿(𝑥, 𝑦))
3. ∀𝑥 (∃𝑦 𝐿(𝑥, 𝑦))
4. ∃𝑦 (∀𝑥 𝐿(𝑥, 𝑦))

CS 245 Logic and Computation Fall 2019 21 / 37


CQ Translations

Translate the sentence “every student has taken some course.”


into a predicate formula.
Let 𝑥 refer to a student and let 𝑦 refer to a course.
What quantifiers should we use for 𝑥 and 𝑦?
(A) ∀𝑥 and ∀𝑦
(B) ∀𝑥 and ∃𝑦
(C) ∃𝑥 and ∀𝑦
(D) ∃𝑥 and ∃𝑦
Let the domain contain the set of all students and courses.
Define the following predicates: 𝑆(𝑥): 𝑥 is a student.
𝐶(𝑦): 𝑦 is a course. 𝑇 (𝑥, 𝑦): student 𝑥 has taken course 𝑦.

CS 245 Logic and Computation Fall 2019 22 / 37


CQ Translations

Translate the sentence “every student has taken some course.”


into a predicate formula.
Which of the following is a correct translation?
(A) ∀𝑥 (𝑆(𝑥) → (∃𝑦 𝐶(𝑦) → 𝑇 (𝑥, 𝑦)))
(B) ∀𝑥 (𝑆(𝑥) → (∃𝑦 𝐶(𝑦) ∧ 𝑇 (𝑥, 𝑦)))
(C) ∀𝑥 (𝑆(𝑥) ∧ (∃𝑦 𝐶(𝑦) → 𝑇 (𝑥, 𝑦)))
(D) ∀𝑥 (𝑆(𝑥) ∧ (∃𝑦 𝐶(𝑦) ∧ 𝑇 (𝑥, 𝑦)))
Let the domain contain the set of all students and courses.
Define the following predicates: 𝑆(𝑥): 𝑥 is a student.
𝐶(𝑦): 𝑦 is a course. 𝑇 (𝑥, 𝑦): student 𝑥 has taken course 𝑦.

CS 245 Logic and Computation Fall 2019 23 / 37


CQ Translations

Translate the sentence “some student has not taken any course.”
into a predicate formula.
Let 𝑥 refer to a student and let 𝑦 refer to a course.
What quantifiers should we use for 𝑥 and 𝑦?
(A) ∀𝑥 and ∀𝑦
(B) ∀𝑥 and ∃𝑦
(C) ∃𝑥 and ∀𝑦
(D) ∃𝑥 and ∃𝑦
Let the domain contain the set of all students and courses.
Define the following predicates: 𝑆(𝑥): 𝑥 is a student.
𝐶(𝑦): 𝑦 is a course. 𝑇 (𝑥, 𝑦): student 𝑥 has taken course 𝑦.

CS 245 Logic and Computation Fall 2019 24 / 37


CQ Translations

Translate the sentence “some student has not taken any course.”
into a predicate formula.
Which of the following is a correct translation?
(A) ∃𝑥 (𝑆(𝑥) → (∀𝑦 𝐶(𝑦) → ¬𝑇 (𝑥, 𝑦)))
(B) ∃𝑥 (𝑆(𝑥) → (∀𝑦 𝐶(𝑦) ∧ (¬𝑇 (𝑥, 𝑦)))
(C) ∃𝑥 (𝑆(𝑥) ∧ (∀𝑦 𝐶(𝑦) → ¬𝑇 (𝑥, 𝑦)))
(D) ∃𝑥 (𝑆(𝑥) ∧ (∀𝑦 𝐶(𝑦) ∧ ¬𝑇 (𝑥, 𝑦)))
Let the domain contain the set of all students and courses.
Define the following predicates: 𝑆(𝑥): 𝑥 is a student.
𝐶(𝑦): 𝑦 is a course. 𝑇 (𝑥, 𝑦): student 𝑥 has taken course 𝑦.

CS 245 Logic and Computation Fall 2019 25 / 37


Outline

Learning goals

Introduction and Motivation

Elements of Predicate Logic

Translating between English and Predicate Logic


Interpreting the Quantifiers
Why do we need functions?
A Summary of Translation Idioms
At least, at most, and exactly

Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 26 / 37


CQ Interpreting the quantifiers

Let the domain be {𝐴𝑙𝑖𝑐𝑒, 𝐵𝑜𝑏, 𝐸𝑣𝑒}.


Let 𝐶(𝑥) mean that person 𝑥 likes chocolates.
Which of the following is equivalent to ∀𝑥 𝐶(𝑥)?
(A) ((𝐶(𝐴𝑙𝑖𝑐𝑒) ∧ 𝐶(𝐵𝑜𝑏)) ∧ 𝐶(𝐸𝑣𝑒))
(B) ((𝐶(𝐴𝑙𝑖𝑐𝑒) ∨ 𝐶(𝐵𝑜𝑏)) ∨ 𝐶(𝐸𝑣𝑒))
(C) ((𝐶(𝐴𝑙𝑖𝑐𝑒) → 𝐶(𝐵𝑜𝑏)) → 𝐶(𝐸𝑣𝑒))
(D) ((𝐶(𝐴𝑙𝑖𝑐𝑒) ↔ 𝐶(𝐵𝑜𝑏)) ↔ 𝐶(𝐸𝑣𝑒))
(E) None of the above

CS 245 Logic and Computation Fall 2019 27 / 37


CQ Interpreting the quantifiers

Let the domain be {𝐴𝑙𝑖𝑐𝑒, 𝐵𝑜𝑏, 𝐸𝑣𝑒}.


Let 𝐶(𝑥) mean that person 𝑥 likes chocolates.
Which of the following is equivalent to ∃𝑥 𝐶(𝑥)?
(A) ((𝐶(𝐴𝑙𝑖𝑐𝑒) ∧ 𝐶(𝐵𝑜𝑏)) ∧ 𝐶(𝐸𝑣𝑒))
(B) ((𝐶(𝐴𝑙𝑖𝑐𝑒) ∨ 𝐶(𝐵𝑜𝑏)) ∨ 𝐶(𝐸𝑣𝑒))
(C) ((𝐶(𝐴𝑙𝑖𝑐𝑒) → 𝐶(𝐵𝑜𝑏)) → 𝐶(𝐸𝑣𝑒))
(D) ((𝐶(𝐴𝑙𝑖𝑐𝑒) ↔ 𝐶(𝐵𝑜𝑏)) ↔ 𝐶(𝐸𝑣𝑒))
(E) None of the above

CS 245 Logic and Computation Fall 2019 28 / 37


Interpreting the quantifiers

Let 𝐷 = {𝑑1 , 𝑑2 , ..., 𝑑𝑛 }.


∀ is a big AND:

∀𝑥 𝑃 (𝑥) is equivalent to ...(𝑃 (𝑑1 ) ∧ 𝑃 (𝑑2 )) ∧ ... ∧ 𝑃 (𝑑𝑛 ).

∃ is a big OR:

∃𝑥 𝑃 (𝑥) is equivalent to ...(𝑃 (𝑑1 ) ∨ 𝑃 (𝑑2 )) ∨ ... ∨ 𝑃 (𝑑𝑛 ).

CS 245 Logic and Computation Fall 2019 29 / 37


Negating a quantified formula

“Generalized De Morgan’s Laws”


▶ ¬(∀𝑥 𝑃 (𝑥)) ⊨⊨ ∃𝑥 (¬𝑃 (𝑥))
▶ ¬(∃𝑥 𝑃 (𝑥)) ⊨⊨ ∀𝑥 (¬𝑃 (𝑥))

CS 245 Logic and Computation Fall 2019 30 / 37


Outline

Learning goals

Introduction and Motivation

Elements of Predicate Logic

Translating between English and Predicate Logic


Interpreting the Quantifiers
Why do we need functions?
A Summary of Translation Idioms
At least, at most, and exactly

Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 31 / 37


Why do we need functions?

Translate the sentence. “every child is younger than their mother.”


1. The domain is the set of people.
𝐶ℎ𝑖𝑙𝑑(𝑥) means 𝑥 is a child.
𝐼𝑠𝑀 𝑜𝑡ℎ𝑒𝑟(𝑥, 𝑦) means 𝑥 is 𝑦’s mother.
𝐼𝑠𝑌 𝑜𝑢𝑛𝑔𝑒𝑟(𝑥, 𝑦) means 𝑥 is younger than 𝑦.
2. Use the same set of definitions above
and the function 𝑚𝑜𝑡ℎ𝑒𝑟(𝑥) which returns 𝑥’s mother.

CS 245 Logic and Computation Fall 2019 32 / 37


Why do we need functions?

Using functions allows us


to avoid ugly/inelegant predicate formulas.
Try translating the following sentence with and without functions.
“Andy and Paul have the same maternal grandmother.”

CS 245 Logic and Computation Fall 2019 33 / 37


A Summary of Translation Idioms

▶ Every/All/Each/Any
∀𝑥
▶ Some/At least one/There exists a/There is a
∃𝑥
▶ None/No x
¬(∃𝑥 … )
▶ Not every/Not all
¬(∀𝑥 … )
▶ Every P-ish x has property Q
∀𝑥 𝑃 (𝑥) → 𝑄(𝑥)
▶ Some P-ish x has property Q
∃𝑥 𝑃 (𝑥) ∧ 𝑄(𝑥)

CS 245 Logic and Computation Fall 2019 34 / 37


Outline

Learning goals

Introduction and Motivation

Elements of Predicate Logic

Translating between English and Predicate Logic


Interpreting the Quantifiers
Why do we need functions?
A Summary of Translation Idioms
At least, at most, and exactly

Revisiting the learning goals

CS 245 Logic and Computation Fall 2019 35 / 37


At least, at most, and exactly

Let the domain be the set of animals. Let 𝐵(𝑥) be that 𝑥 is a bear.
1. There are at least two bears.
2. There are at most one bear.
3. There are exactly one bear.

CS 245 Logic and Computation Fall 2019 36 / 37


Revisiting the learning goals

By the end of this lecture, you should be able to


(Introduction to Predicate Logic)
▶ Give examples of English sentences that can be modeled using
predicate logic but cannot be modeled using propositional
logic.
(Translations)
▶ Translate an English sentence into a predicate formula.
▶ Translate a predicate formula into an English sentence.

CS 245 Logic and Computation Fall 2019 37 / 37

You might also like