SlideShare a Scribd company logo
First Order Logic
Lecture 2: Sep 9
This Lecture
Last time we talked about propositional logic, a logic on simple statements.
This time we will talk about first order logic, a logic on quantified statements.
First order logic is much more expressive than propositional logic.
The topics on first order logic are:
 Quantifiers
 Negation
 Multiple quantifiers
 Arguments of quantified statements
Propositional logic – logic of simple statements
Limitation of Propositional Logic
How to formulate Pythagoreans’ theorem using propositional logic?
cb
a
How to formulate the statement that there are infinitely many primes?
Predicates are propositions (i.e. statements) with variables
x + 2 = yExample: P (x,y) ::=
Predicates
x = 1 and y = 3: P(1,3) is true
x = 1 and y = 4: P(1,4) is false
¬P(1,4) is true
The domain of a variable is the set of all values
that may be substituted in place of the variable.
When there is a variable, we need to specify what to put in the variables.
Set
We have not defined formally what is a set, and will do so later in the course.
For now, it is enough for our discussion to recall some well-known examples.
Z: the set of all integers
Z+
: the set of all positive integers
Z-
: the set of all negative integers
R: the set of all real numbers
Q: the set of all rational numbers
for ALL x∀x
The Universal Quantifier
cb
a
∀ x Z ∀ y Z, x + y = y + x.
The universal quantifier
Pythagorean’s theorem
Example:
Example:
This statement is true if the domain is Z, but not true if the domain is R.
The truth of a predicate depends on the domain.
∀ x Z+
P(x) means P(1)  P(2)  P(3)  …Example:
The Existential Quantifier
∃y There EXISTS some y
.x y x y∀ ∃ <
Domain Truth value
positive integers +
integers 
negative integers -
negative reals R-
T
e.g.
The truth of a predicate depends on the domain.
T
F
T
∃ y Z+
P(y) means P(1)  P(2)  P(3)  …
Translating Mathematical Theorem
Fermat (1637): If an integer n is greater than 2,
then the equation an
+ bn
= cn
has no solutions in non-zero integers a, b, and c.
Andrew Wiles (1994) http://en.wikipedia.org/wiki/Fermat's_last_theorem
Goldbach’s conjecture: Every even number is the sum of two prime numbers.
How to write prime(p)?
Translating Mathematical Theorem
Suppose we have a predicate prime(x) to determine if x is a prime number.
 Quantifiers
 Negation
 Multiple quantifiers
 Arguments of quantified statements
Negations of Quantified Statements
Everyone likes football.
What is the negation of this statement?
(generalized) DeMorgan’s Law
Not everyone likes football = There exists someone who doesn’t like football.
Say the domain has only three values.
The same idea can be used to prove it for any number of variables.
Negations of Quantified Statements
There is a plant that can fly.
What is the negation of this statement?
Not exists a plant that can fly = every plant cannot fly.
(generalized) DeMorgan’s Law Say the domain has only three values.
The same idea can be used to prove it for any number of variables.
 Quantifiers
 Negation
 Multiple quantifiers
 Arguments of quantified statements
Order of Quantifiers
There is an anti-virus program killing every computer virus.
How to interpret this sentence?
For every computer virus, there is an anti-virus program that kills it.
• For every attack, I have a defense:
• against MYDOOM, use Defender
• against ILOVEYOU, use Norton
• against BABLAS, use Zonealarm …
 is expensive!
Order of Quantifiers
There is an anti-virus program killing every computer virus.
There is one single anti-virus program that kills all computer viruses.
How to interpret this sentence?
I have one defense good against every attack.
Example: P is CSE-antivirus,
protects against ALL viruses
That’s much better!
Order of quantifiers is very important!
Order of Quantifiers
Let’s say we have an array A of size 6x6.
1
1 1 1
1
1 1
1
1
Then this table satisfies the statement.
Order of Quantifiers
Let’s say we have an array A of size 6x6.
1
1 1 1
1
1 1
1
1
But if the order of the quantifiers are changes,
then this table no longer satisfies the new statement.
Order of Quantifiers
Let’s say we have an array A of size 6x6.
1 1 1 1 1 1
To satisfy the new statement, there must be a row with all ones.
Questions
Are these statements equivalent?
Are these statements equivalent?
Yes, in general, you can change the order of two “foralls”,
and you can change the order of two “exists”.
More Negations
There is an anti-virus program killing every computer virus.
What is the negation of the above sentence?
For every program, there is some virus that it can not kill.
Exercises
1. There is a smallest positive integer.
2. There is no smallest positive real number.
In words, there is always a larger positive real number.
Exercises
3. There are infinitely many prime numbers.
In words, there exists a prime (first part)
and there is no largest prime (second part, similar to the previous question).
Formulating sentences using first order logic is useful in logic programming
and database queries.
 Quantifiers
 Negation
 Multiple quantifiers
 Arguments of quantified statements
True no matter what
• the Domain is,
• or the predicates are.
∀z [Q(z)  P(z)] → [∀x.Q(x)  ∀y.P(y)]
Predicate Calculus Validity
True no matter what the truth values of A and B are
( ) ( )A B B A→ ∨ →
Propositional validity
Predicate calculus validity
That is, logically correct, independent of the specific content.
Arguments with Quantified Statements
Universal instantiation:
Universal modus ponens:
Universal modus tollens:
Universal Generalization
( )
. ( )
A R c
A x R x
→
→ ∀
valid rule
providing c is independent of A
e.g. given any number c, 2c is an even number
=> for all x, 2x is an even number.
Informally, if we could prove that R(c) is true for an arbitrary c
(in a sense, c is a “variable”), then we could prove the for all statement.
Remark: Universal generalization is often difficult to prove, we will
introduce mathematical induction to prove the validity of for all statements.
Proof: Give countermodel, where
∀z [Q(z)  P(z)] is true,
but ∀x.Q(x)  ∀y.P(y) is false.
In this example, let domain be integers,
Q(z) be true if z is an even number, i.e. Q(z)=even(z)
P(z) be true if z is an odd number, i.e. P(z)=odd(z)
∀z [Q(z)  P(z)] → [∀x.Q(x)  ∀y.P(y)]
Valid Rule?
Find a domain,
and a predicate.
Then ∀z [Q(z)  P(z)] is true, because every number is either even or odd.
But ∀x.Q(x) is not true, since not every number is an even number.
Similarly ∀y.P(y) is not true, and so ∀x.Q(x)  ∀y.P(y) is not true.
Proof: Assume ∀z [Q(z)P(z)].
So Q(z)P(z) holds for all z in the domain D.
Now let c be some element in the domain D.
So Q(c)P(c) holds (by instantiation), and therefore Q(c) by itself holds.
But c could have been any element of the domain D.
So we conclude ∀x.Q(x). (by generalization)
We conclude ∀y.P(y) similarly (by generalization). Therefore,
∀x.Q(x)  ∀y.P(y) QED.
∀z D [Q(z)  P(z)] → [∀x D Q(x)  ∀y D P(y)]
Valid Rule?
• Express (quantified) statements using logic formula
• Use simple logic rules (e.g. DeMorgan, contrapositive, etc)
• Fluent with arguments and logical equivalence
Summary
This finishes the introduction to logic, half of the first part.
In the other half we will use logic to do mathematical proofs.
At this point, you should be able to:
(Optional) More About Logic
Ideally, we can come up with a “perfect” logical system, which is consistent
(not having contradictions) and is powerful (can derive everything that is true).
But Gödel proved that there is no perfect logical system.
This is called the Gödel’s incompleteness theorem.
It is an important and surprising result in mathematics.
The ideas in his proof are also influential in computer
science,
to prove that certain problem is not computable,
e.g. it is impossible to write a program to check whether
another program will loop forever on a particular input
(i.e. a perfect debugger doesn’t exist).
Applications of Logic (Optional)
Logic programming
Database
Digital circuit
solve problems by logic
making queries, data mining

More Related Content

PDF
Artificial Intelligence Notes Unit 2
PPTX
Knowledge representation and Predicate logic
PDF
Recurrence relations
PPTX
Predicates and quantifiers
PDF
Ch 7 Knowledge Representation.pdf
PDF
9. chapter 8 np hard and np complete problems
PPTX
Propositional logic
PPTX
Frames
Artificial Intelligence Notes Unit 2
Knowledge representation and Predicate logic
Recurrence relations
Predicates and quantifiers
Ch 7 Knowledge Representation.pdf
9. chapter 8 np hard and np complete problems
Propositional logic
Frames

What's hot (20)

PDF
I.BEST FIRST SEARCH IN AI
PDF
AI PPT-ALR_Unit-3-1.pdf
PPTX
knowledge representation using rules
PPTX
Dijkstra’S Algorithm
PDF
Divide and Conquer
PPTX
Unification and Lifting
PPTX
Np hard
PPTX
Bressenham’s Midpoint Circle Drawing Algorithm
PPTX
Propositional logic & inference
PPTX
Forward and Backward chaining in AI
PPTX
Tsp branch and-bound
PDF
Introduction to the theory of optimization
PPT
Logic&proof
PPT
Prolog basics
PPTX
Prolog Programming : Basics
PPTX
CMSC 56 | Lecture 5: Proofs Methods and Strategy
PPT
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
PPTX
Tsp is NP-Complete
PDF
Metaheuristic Algorithms: A Critical Analysis
PPTX
Dijkstra s algorithm
I.BEST FIRST SEARCH IN AI
AI PPT-ALR_Unit-3-1.pdf
knowledge representation using rules
Dijkstra’S Algorithm
Divide and Conquer
Unification and Lifting
Np hard
Bressenham’s Midpoint Circle Drawing Algorithm
Propositional logic & inference
Forward and Backward chaining in AI
Tsp branch and-bound
Introduction to the theory of optimization
Logic&proof
Prolog basics
Prolog Programming : Basics
CMSC 56 | Lecture 5: Proofs Methods and Strategy
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Tsp is NP-Complete
Metaheuristic Algorithms: A Critical Analysis
Dijkstra s algorithm
Ad

Viewers also liked (20)

PPTX
Jarrar: First Order Logic
PPT
First order logic
PPT
Discrete Math Lecture 01: Propositional Logic
PPT
First order logic in knowledge representation
PPT
Class first order logic
PPT
Discrete math ppt
PPT
Predicate Logic
PPT
Propositional And First-Order Logic
PDF
16 1 predicate resolution
PPT
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
PPT
3 fol examples v2
PPT
Inference in first order logic12
PPTX
Jarrar: First Order Logic- Inference Methods
PPTX
Jarrar: Propositional Logic Inference Methods
PPT
Logic Notes
PPT
Attacks in MANET
PPT
Syntax and semantics of propositional logic
PDF
Discrete Structures lecture 2
PPT
Math task 3
Jarrar: First Order Logic
First order logic
Discrete Math Lecture 01: Propositional Logic
First order logic in knowledge representation
Class first order logic
Discrete math ppt
Predicate Logic
Propositional And First-Order Logic
16 1 predicate resolution
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
3 fol examples v2
Inference in first order logic12
Jarrar: First Order Logic- Inference Methods
Jarrar: Propositional Logic Inference Methods
Logic Notes
Attacks in MANET
Syntax and semantics of propositional logic
Discrete Structures lecture 2
Math task 3
Ad

Similar to Discrete Math Lecture 02: First Order Logic (20)

PPT
First_Order_Logic In Discrete Mathematics
PPTX
Chapter 1.4.pptx Chapter 1.4.pptx DISCREATE MATH
PDF
Predicate_Logic.pdf
PDF
Chapter 01 - p2.pdf
PPTX
Chapter1p2.pptx
PPT
Predicate &amp; quantifier
PDF
02 Predicates and Quantifiers is about predicates
PPTX
m.a.t.h.e.m.a.t.i.c.s.d.i.s.c.r.e.t.e.pptx
PPTX
Unit 1 quantifiers
PDF
Formal Logic - Lesson 8 - Predicates and Quantifiers
PPTX
Ex 1.5 Nested Quantifiers.pptxd dnsnsnndj
PPTX
CMSC 56 | Lecture 3: Predicates & Quantifiers
PPTX
Quantification
PPTX
Predicates and Quantifiers
PDF
Lecture 2 predicates quantifiers and rules of inference
PPTX
Quantifiers and its Types
PDF
Discrete Structure Lecture #5 & 6.pdf
PPTX
LEC 2 ORal patholgy chemistry by nhy.pptx
PPTX
Propositional Logic.pptx discrete mathmatics
PPTX
Predicates and quantifiers presentation topics
First_Order_Logic In Discrete Mathematics
Chapter 1.4.pptx Chapter 1.4.pptx DISCREATE MATH
Predicate_Logic.pdf
Chapter 01 - p2.pdf
Chapter1p2.pptx
Predicate &amp; quantifier
02 Predicates and Quantifiers is about predicates
m.a.t.h.e.m.a.t.i.c.s.d.i.s.c.r.e.t.e.pptx
Unit 1 quantifiers
Formal Logic - Lesson 8 - Predicates and Quantifiers
Ex 1.5 Nested Quantifiers.pptxd dnsnsnndj
CMSC 56 | Lecture 3: Predicates & Quantifiers
Quantification
Predicates and Quantifiers
Lecture 2 predicates quantifiers and rules of inference
Quantifiers and its Types
Discrete Structure Lecture #5 & 6.pdf
LEC 2 ORal patholgy chemistry by nhy.pptx
Propositional Logic.pptx discrete mathmatics
Predicates and quantifiers presentation topics

Recently uploaded (20)

PDF
Pre independence Education in Inndia.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
GDM (1) (1).pptx small presentation for students
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Pharma ospi slides which help in ospi learning
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
RMMM.pdf make it easy to upload and study
Pre independence Education in Inndia.pdf
01-Introduction-to-Information-Management.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Complications of Minimal Access Surgery at WLH
Anesthesia in Laparoscopic Surgery in India
FourierSeries-QuestionsWithAnswers(Part-A).pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Renaissance Architecture: A Journey from Faith to Humanism
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
GDM (1) (1).pptx small presentation for students
O5-L3 Freight Transport Ops (International) V1.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Pharma ospi slides which help in ospi learning
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
VCE English Exam - Section C Student Revision Booklet
Microbial diseases, their pathogenesis and prophylaxis
RMMM.pdf make it easy to upload and study

Discrete Math Lecture 02: First Order Logic

  • 2. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about first order logic, a logic on quantified statements. First order logic is much more expressive than propositional logic. The topics on first order logic are:  Quantifiers  Negation  Multiple quantifiers  Arguments of quantified statements
  • 3. Propositional logic – logic of simple statements Limitation of Propositional Logic How to formulate Pythagoreans’ theorem using propositional logic? cb a How to formulate the statement that there are infinitely many primes?
  • 4. Predicates are propositions (i.e. statements) with variables x + 2 = yExample: P (x,y) ::= Predicates x = 1 and y = 3: P(1,3) is true x = 1 and y = 4: P(1,4) is false ¬P(1,4) is true The domain of a variable is the set of all values that may be substituted in place of the variable. When there is a variable, we need to specify what to put in the variables.
  • 5. Set We have not defined formally what is a set, and will do so later in the course. For now, it is enough for our discussion to recall some well-known examples. Z: the set of all integers Z+ : the set of all positive integers Z- : the set of all negative integers R: the set of all real numbers Q: the set of all rational numbers
  • 6. for ALL x∀x The Universal Quantifier cb a ∀ x Z ∀ y Z, x + y = y + x. The universal quantifier Pythagorean’s theorem Example: Example: This statement is true if the domain is Z, but not true if the domain is R. The truth of a predicate depends on the domain. ∀ x Z+ P(x) means P(1)  P(2)  P(3)  …Example:
  • 7. The Existential Quantifier ∃y There EXISTS some y .x y x y∀ ∃ < Domain Truth value positive integers + integers  negative integers - negative reals R- T e.g. The truth of a predicate depends on the domain. T F T ∃ y Z+ P(y) means P(1)  P(2)  P(3)  …
  • 8. Translating Mathematical Theorem Fermat (1637): If an integer n is greater than 2, then the equation an + bn = cn has no solutions in non-zero integers a, b, and c. Andrew Wiles (1994) http://en.wikipedia.org/wiki/Fermat's_last_theorem
  • 9. Goldbach’s conjecture: Every even number is the sum of two prime numbers. How to write prime(p)? Translating Mathematical Theorem Suppose we have a predicate prime(x) to determine if x is a prime number.
  • 10.  Quantifiers  Negation  Multiple quantifiers  Arguments of quantified statements
  • 11. Negations of Quantified Statements Everyone likes football. What is the negation of this statement? (generalized) DeMorgan’s Law Not everyone likes football = There exists someone who doesn’t like football. Say the domain has only three values. The same idea can be used to prove it for any number of variables.
  • 12. Negations of Quantified Statements There is a plant that can fly. What is the negation of this statement? Not exists a plant that can fly = every plant cannot fly. (generalized) DeMorgan’s Law Say the domain has only three values. The same idea can be used to prove it for any number of variables.
  • 13.  Quantifiers  Negation  Multiple quantifiers  Arguments of quantified statements
  • 14. Order of Quantifiers There is an anti-virus program killing every computer virus. How to interpret this sentence? For every computer virus, there is an anti-virus program that kills it. • For every attack, I have a defense: • against MYDOOM, use Defender • against ILOVEYOU, use Norton • against BABLAS, use Zonealarm …  is expensive!
  • 15. Order of Quantifiers There is an anti-virus program killing every computer virus. There is one single anti-virus program that kills all computer viruses. How to interpret this sentence? I have one defense good against every attack. Example: P is CSE-antivirus, protects against ALL viruses That’s much better! Order of quantifiers is very important!
  • 16. Order of Quantifiers Let’s say we have an array A of size 6x6. 1 1 1 1 1 1 1 1 1 Then this table satisfies the statement.
  • 17. Order of Quantifiers Let’s say we have an array A of size 6x6. 1 1 1 1 1 1 1 1 1 But if the order of the quantifiers are changes, then this table no longer satisfies the new statement.
  • 18. Order of Quantifiers Let’s say we have an array A of size 6x6. 1 1 1 1 1 1 To satisfy the new statement, there must be a row with all ones.
  • 19. Questions Are these statements equivalent? Are these statements equivalent? Yes, in general, you can change the order of two “foralls”, and you can change the order of two “exists”.
  • 20. More Negations There is an anti-virus program killing every computer virus. What is the negation of the above sentence? For every program, there is some virus that it can not kill.
  • 21. Exercises 1. There is a smallest positive integer. 2. There is no smallest positive real number. In words, there is always a larger positive real number.
  • 22. Exercises 3. There are infinitely many prime numbers. In words, there exists a prime (first part) and there is no largest prime (second part, similar to the previous question). Formulating sentences using first order logic is useful in logic programming and database queries.
  • 23.  Quantifiers  Negation  Multiple quantifiers  Arguments of quantified statements
  • 24. True no matter what • the Domain is, • or the predicates are. ∀z [Q(z)  P(z)] → [∀x.Q(x)  ∀y.P(y)] Predicate Calculus Validity True no matter what the truth values of A and B are ( ) ( )A B B A→ ∨ → Propositional validity Predicate calculus validity That is, logically correct, independent of the specific content.
  • 25. Arguments with Quantified Statements Universal instantiation: Universal modus ponens: Universal modus tollens:
  • 26. Universal Generalization ( ) . ( ) A R c A x R x → → ∀ valid rule providing c is independent of A e.g. given any number c, 2c is an even number => for all x, 2x is an even number. Informally, if we could prove that R(c) is true for an arbitrary c (in a sense, c is a “variable”), then we could prove the for all statement. Remark: Universal generalization is often difficult to prove, we will introduce mathematical induction to prove the validity of for all statements.
  • 27. Proof: Give countermodel, where ∀z [Q(z)  P(z)] is true, but ∀x.Q(x)  ∀y.P(y) is false. In this example, let domain be integers, Q(z) be true if z is an even number, i.e. Q(z)=even(z) P(z) be true if z is an odd number, i.e. P(z)=odd(z) ∀z [Q(z)  P(z)] → [∀x.Q(x)  ∀y.P(y)] Valid Rule? Find a domain, and a predicate. Then ∀z [Q(z)  P(z)] is true, because every number is either even or odd. But ∀x.Q(x) is not true, since not every number is an even number. Similarly ∀y.P(y) is not true, and so ∀x.Q(x)  ∀y.P(y) is not true.
  • 28. Proof: Assume ∀z [Q(z)P(z)]. So Q(z)P(z) holds for all z in the domain D. Now let c be some element in the domain D. So Q(c)P(c) holds (by instantiation), and therefore Q(c) by itself holds. But c could have been any element of the domain D. So we conclude ∀x.Q(x). (by generalization) We conclude ∀y.P(y) similarly (by generalization). Therefore, ∀x.Q(x)  ∀y.P(y) QED. ∀z D [Q(z)  P(z)] → [∀x D Q(x)  ∀y D P(y)] Valid Rule?
  • 29. • Express (quantified) statements using logic formula • Use simple logic rules (e.g. DeMorgan, contrapositive, etc) • Fluent with arguments and logical equivalence Summary This finishes the introduction to logic, half of the first part. In the other half we will use logic to do mathematical proofs. At this point, you should be able to:
  • 30. (Optional) More About Logic Ideally, we can come up with a “perfect” logical system, which is consistent (not having contradictions) and is powerful (can derive everything that is true). But Gödel proved that there is no perfect logical system. This is called the Gödel’s incompleteness theorem. It is an important and surprising result in mathematics. The ideas in his proof are also influential in computer science, to prove that certain problem is not computable, e.g. it is impossible to write a program to check whether another program will loop forever on a particular input (i.e. a perfect debugger doesn’t exist).
  • 31. Applications of Logic (Optional) Logic programming Database Digital circuit solve problems by logic making queries, data mining