0% found this document useful (0 votes)
19 views

Module 1 Logic

Discrete mathematics slides

Uploaded by

ccchengchuuu
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)
19 views

Module 1 Logic

Discrete mathematics slides

Uploaded by

ccchengchuuu
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/ 72

Module #1 - Logic

Module #1:
Foundations of Logic
Rosen 6th ed., §§1.1-1.4
~74 slides, ~4-6 lectures

2024/10/9 1
Module #1 - Logic
Module #1: Foundations of Logic
(§§1.1-1.3, ~3 lectures)
Mathematical Logic is a tool for working with
complicated compound statements. It
includes:
 A language for expressing them.
 A concise notation for writing them.
 A methodology for objectively reasoning
about their truth or falsity.
 It is the foundation for expressing
formal proofs in all branches of
mathematics.

2024/10/9 2
Module #1 - Logic

Foundations of Logic: Overview


 Propositional logic (§1.1-1.2):
– Basic definitions. (§1.1)
– Equivalence rules & derivations. (§1.2)
 Predicate logic (§1.3-1.4)
– Predicates.
– Quantified predicate expressions.
– Equivalences & derivations.

2024/10/9 3
Module #1 - Logic Topic #1 – Propositional Logic

Propositional Logic (§1.1)


Propositional Logic is the logic of compound
statements built from simpler statements
using so-called Boolean connectives.
Some applications in computer science:
 Design of digital electronic circuits.

 Expressing conditions in programs.

 Queries to databases & search engines.

2024/10/9 4
Module #1 - Logic Topic #1 – Propositional Logic

Definition of a Proposition
A proposition (p, q, r, …) is simply a
statement (i.e., a declarative sentence)
with a definite meaning, having a truth
value that’s either true (T) or false (F)
(never both, neither, or somewhere in
between).
(However, you might not know the actual
truth value, and it might be situation-
dependent.)
[Later we will study probability theory, in which we
assign degrees of certainty to propositions. But
for now: think True/False only!]
2024/10/9 5
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Operators / Connectives
An operator or connective combines
one or more operand expressions
into a larger expression. (E.g., “+”
in numeric exprs.)
Unary operators take 1 operand
(e.g., −3); binary operators take 2
operands (eg 3  4).
Propositional or Boolean operators
operate on propositions or truth
values instead of on numbers.
2024/10/9 6
Module #1 - Logic
Some Popular Boolean
Operators

Formal Name Nickname Arity Symbol

Negation operator NOT Unary ¬

Conjunction operator AND Binary 

Disjunction operator OR Binary 

Exclusive-OR operator XOR Binary 

Implication operator IMPLIES Binary 

Biconditional operator IFF Binary ↔

2024/10/9 7
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

The Negation Operator


The unary negation operator “¬” (NOT)
transforms a prop. into its logical
negation.
E.g. If p = “I have brown hair.”
then ¬p = “I do not have brown
hair.” p p
Truth table
T :≡ True; F :≡ for
False NOT: T F
“:≡” means “is defined as” F T
Operand Result
2024/10/9
column column 8
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

The Conjunction Operator


The binary conjunction operator “”
(AND) combines two propositions to
form their logical conjunction.

E.g. If p=“I will have salad for lunch.”
ND

and q=“I will have steak for dinner.”,


then pq=“I will have salad for lunch
and
I will have steak for dinner.”
Remember: “” points up like an “A”, and it means “ND”
2024/10/9 9
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Conjunction Truth Table


 Note that a Operand columns
conjunction p q pq
p1  p2  …  p n
F F F
of n propositions
will have 2 rows
n F T F
in its truth table. T F F
T T T
 Also: ¬ and  operations together are
suffi-cient to express any Boolean
truth table!
2024/10/9 10
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

The Disjunction Operator


The binary disjunction operator “”
(OR) combines two propositions to
form their logical disjunction.
p=“My car has a bad engine.”
q=“My car has a bad carburetor.”
pq=“Either my car has a bad engine,
or
my car has a bad carburetor.”
After the downward-
pointing “axe” of “”
splits the wood, you
Meaning is like “and/or” in English. can take 1 piece OR the
other, or both.
2024/10/9 11
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Disjunction Truth Table

 Note that pq means p q


pq
that p is true, or q is
true, or both are true! F F F
Note
F T T difference
 So, this operation is
T
also called inclusive or,
F T from AND

because it includes the T T T


possibility that both p and q are
true.
 “¬” and “” together are also
2024/10/9 12
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Nested Propositional Expressions


 Use parentheses to group sub-
expressions:
“I just saw my old friend, and either
he’s grown or I’ve shrunk.” = f  (g  s)
– (f  g)  s would mean something
different
– fgs would be ambiguous
 By convention, “¬” takes precedence
over both “” and “”.
– ¬s  f means (¬s)  f , not ¬
(s  f)
2024/10/9 13
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

A Simple Exercise
Let p=“It rained last night”,
q=“The sprinklers came on last
night,”
r=“The lawn was wet this morning.”
Translate each of the following into
English: “It didn’t rain last night.”
“The lawn was wet this morning, and
¬p =it didn’t rain last night.”
r  ¬p = “Either the lawn wasn’t wet this
morning, or it rained last night, or
¬ r  p  q = the sprinklers came on last night.”
2024/10/9 14
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

The Exclusive Or Operator


The binary exclusive-or operator “”
(XOR) combines two propositions to
form their logical “exclusive or”
(exjunction?).
p = “I will earn an A in this course,”
q = “I will drop this course,”
p  q = “I will either earn an A for this
course, or I will drop it (but not
both!)”
2024/10/9 15
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Exclusive-Or Truth Table


 Note that pq means
that p is true, or q is
true, but not both! p q pq
 This operation is
F F F
called exclusive or, F T T
because it excludes the T F T
possibility that both p and
T Tq are
F Note
difference
true. from OR.

 “¬” and “” together are not


universal.
2024/10/9 16
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Natural Language is Ambiguous


Note that English “or” can be ambiguous
regarding the “both” case!
“Pat is a singer or
Pat is a writer.” - p q p "or" q
“Pat is a man or F F F
Pat is a woman.”- F T T
Need context to disambiguateT Fthe T
meaning!  T T ?
For this class, assume “or” means
inclusive.

2024/10/9 17
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

The Implication Operator


antecedent consequent
The implication p  q states that p implies q.
I.e., If p is true, then q is true; but if p is
not true, then q could be either true or
false.
E.g., let p = “You study hard.”
q = “You will get a good grade.”
p  q = “If you study hard, then you will
get a good grade.” (else, it could go either
way)

2024/10/9 18
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Implication Truth Table


p  q is false only when
p is true but q is not true.
p q pq
p  q does not say F F T
that p causes q! F T T The
p  q does not requireT F F only
False
that p or q are ever true!T T T case!
 E.g. “(1=0)  pigs can fly” is TRUE!

2024/10/9 19
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

English Phrases Meaning p  q


 “p implies q”  “p only if q”
– Ex: no class tomorrow only if
 “if p, then q”
the typhoon alarm.
 “if p, q”
 “p is sufficient for q”
 “when p, q”
 “q is necessary for
 “whenever p, q” p”
 “q if p”  “q follows from p”
 “q when p”  “q is implied by p”
 “q whenever p” We will see some equivalent
logic expressions later.

2024/10/9 20
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Converse, Inverse, Contrapositive


Some terminology, for an implication p
 q:
 Its converse is: q  p.

 Its inverse is: ¬p  ¬q.


 Its contrapositive: ¬q  ¬ p.
 One of these three has the same
meaning (same truth table) as p  q.
Can you figure out which?
2024/10/9 21
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

How do we know for sure?


Proving the equivalence of p  q and
its contrapositive using truth tables:

p q q p pq q p
F F T T T T
F T F T T T
T F T F F F
T T F F T T

2024/10/9 22
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

The biconditional operator


The biconditional p  q states that p is true
if and only if (IFF) q is true.
p = “Bush wins the 2004 election.”
q = “Bush will be president for all of 2005.”
p  q = “If, and only if, Bush wins the 2004
election, Bush will be president for all of
2005.”

2024/10/9 23
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Biconditional Truth Table


p  q means that p and q
have the same truth value. p qpq
 Note this truth table is the
F F T
exact opposite of ’s!
F T F
– p  q means ¬(p  q)
T F F
 p  q does not imply
T T T
p and q are true, or cause each other.

2024/10/9 24
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Boolean Operations Summary

 We have seen 1 unary operator


(out of the 4 possible) and 5
binary operators (out of the 16
possible).
p q p pq Their
pqtruth
pq tables are
pq pq
below.
F F T F F F T T
F T T F T T T F
T F F F T T F F
T T F T T F T T
2024/10/9 25
Module #1 - Logic Topic #1.0 – Propositional Logic: Operators

Some Alternative Notations

Name: not and or xor implies iff


Propositional logic:      
Boolean algebra: p pq + 
C/C++/Java (wordwise): ! && || != ==
C/C++/Java (bitwise): ~ & | ^
Logic gates:

2024/10/9 26
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences

Propositional Equivalence (§1.2)


Two syntactically (i.e., textually)
different compound propositions may
be the semantically identical (i.e.,
have the same meaning). We call
them equivalent. Learn:
 Various equivalence rules or laws.

 How to prove equivalences using


symbolic derivations.

2024/10/9 27
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences

Tautologies and Contradictions


A tautology is a compound proposition
that is true no matter what the truth
values of its atomic propositions are!
Ex. p  p [What is its truth table?]
A contradiction is a compound
proposition that is false no matter
what! Ex. p  p [Truth table?]
Other compound props. are
contingencies.

2024/10/9 28
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences

Logical Equivalence
Compound proposition p is logically
equivalent to compound proposition
q, written pq, IFF the compound
proposition pq is a tautology.
Compound propositions p and q are
logically equivalent to each other IFF
p and q contain the same truth
values as each other in all rows of
their truth tables.
2024/10/9 29
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences
Proving Equivalence
via Truth Tables
Ex. Prove that pq  (p  q).

p q pq p q p  q (p  q)


F F F T T T F
F T T T F F T
T F T F T F T
T T T F F F T

2024/10/9 30
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences

Equivalence Laws
 These are similar to the arithmetic
identities you may have learned in
algebra, but for propositional
equivalences instead.
 They provide a pattern or template
that can be used to match all or part
of a much more complicated
proposition and to find an
equivalence for it.
2024/10/9 31
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences

Equivalence Laws - Examples


 Identity: pT  p pF  p
 Domination: pT  T pF  F
 Idempotent: pp  p pp  p
 Double negation: p  p
 Commutative: pq  qp pq  qp
 Associative: (pq)r  p(qr)
(pq)r  p(qr)

2024/10/9 32
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences

More Equivalence Laws


 Distributive: p(qr)  (pq)(pr)
p(qr)  (pq)(pr)
 De Morgan’s:
(pq)  p  q
(pq)  p  q
 Trivial tautology/contradiction:
p  p  T p  p  F

2024/10/9 33
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences
Defining Operators via
Equivalences
Using equivalences, we can define
operators in terms of other operators.
 Exclusive or: pq  (pq)(pq)
pq 
(pq)(qp)
 Implies: pq  p  q
 Biconditional: pq  (pq)  (qp)
pq  (pq)

2024/10/9 34
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences

An Example Problem
 Check using a symbolic derivation whether
(p  q)  (p  r)  p  q  r.
(p  q)  (p  r) 
[Expand definition of ] (p  q)  (p  r)
[Defn. of ]  (p  q)  ((p  r)  (p
 r))
[DeMorgan’s Law]
 (p  q)  ((p  r)  (p 
r))
 [associative law] cont.
2024/10/9 35
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences

Example Continued...
(p  q)  ((p  r)  (p  r))  [ commutes]
 (q  p)  ((p  r)  (p  r)) [ associative]
 q  (p  ((p  r)  (p  r))) [distrib.  over ]
 q  (((p  (p  r))  (p  (p  r)))
[assoc.]  q  (((p  p)  r)  (p  (p  r)))
[trivail taut.]  q  ((T  r)  (p  (p  r)))
[domination]  q  (T  (p  (p  r)))
[identity]  q  (p  (p  r))  cont.

2024/10/9 36
Module #1 - Logic Topic #1.1 – Propositional Logic: Equivalences

End of Long Example


q  (p  (p  r))
[DeMorgan’s]  q  (p  (p  r))
[Assoc.]  q  ((p  p)  r)
[Idempotent]  q  (p  r)
[Assoc.]  (q  p)  r
[Commut.]  p  q  r
Q.E.D. (quod erat demonstrandum)

(Which was to be shown.)


2024/10/9 37
Module #1 - Logic Topic #3 – Predicate Logic

Predicate Logic (§1.3)


 Predicate logic is an extension of
propositional logic that permits
concisely reasoning about whole classes
of entities.
 Propositional logic (recall) treats simple
propositions (sentences) as atomic
entities.
 In contrast, predicate logic
distinguishes the subject of a sentence
from its predicate.
– Remember these English grammar
2024/10/9
terms? 38
Module #1 - Logic Topic #3 – Predicate Logic

Applications of Predicate Logic


It is the formal notation for writing
perfectly clear, concise, and
unambiguous mathematical
definitions, axioms, and theorems
(more on these in chapter 3) for any
branch of mathematics.
Predicate logic with function symbols, the “=”
operator, and a few proof-building rules is
sufficient for defining any conceivable
mathematical system, and for proving anything
that can be proved within that system!
2024/10/9 39
Module #1 - Logic Topic #3 – Predicate Logic

Other Applications
 Predicate logic is the foundation of the
field of mathematical logic, which
culminated in Gödel’s incompleteness
theorem, which revealed the ultimate
limits of mathematical thought:
– Given any finitely describable, consistent
proof procedure, there will still be some
true statements that can never be proven
by that procedure.
 I.e.,we can’t discover all
mathematical truths, unless we
sometimes resort to making guesses.
2024/10/9 40
Module #1 - Logic Topic #3 – Predicate Logic

Practical Applications
 Basis for clearly expressed formal
specifications for any complex
system.
 Basis for automatic theorem provers
and many other Artificial Intelligence
systems.
 Supported by some of the more
sophisticated database query engines
and container class libraries
(these are types of programming
tools).
2024/10/9 41
Module #1 - Logic
Deductive Database
example tables
PART_COST ASSEMBLY
BASIC_PART SUPPLIER COST TIME PART SUBPART QTY
top_tube cinelli 20.00 14
top_tube columbus 15.00 6 bike frame 1
down_tube columbus 10.00 6 bike wheel 2
head_tube cinelli 20.00 14 frame top_tube 1
head_tube columbus 15.00 6 frame down_tube 1
seat_mast cinelli 20.00 6 frame head_tube 1
seat_mast cinelli 15.00 14
seat_stay cinelli 15.00 14 frame seat_mast 1
seat_stay columbus 10.00 6 frame seat_stay 2
chain_stay columbus 10.00 6 frame chain_stay 2
fork cinelli 40.00 14 frame fork 1
fork columbus 30.00 6 wheel spoke 36
spoke campagnolo 0.60 15
nipple mavic 0.10 3
wheel nipple 36
hub campagnolo 31.00 5 wheel rim 1
hub suntour 18.00 14 wheel hub 1
rim mavic 50.00 3 wheel tire 1
rim araya 7.00 1

2024/10/9 42
Module #1 - Logic

Example
 Try writing a program for the following
query: Find the maximum time required
for basic subparts of the given assembly
(assuming each basic subpart is delivered
by fastest provider)?

 Predicate of our goal:


– howsoon(…)
– See the following program.

2024/10/9 43
Module #1 - Logic

Example
 All subparts: a transitive-closure query
all_subparts(Part,Sub) 
assembly(Part, Sub, _).
all_subparts(Part, Sub2) 
all_subparts(Part, Sub1),
assembly(Sub1, Sub2, _ ).
 For each part, basic or otherwise, find its basic subparts. A
basic part is a subpart of itself :
basic_subparts(BasicP, BasicP) 
part_cost(BasicP,_ , _, _).
basic_subparts(Prt, BasicP) 
assembly(Prt, SubP, _),
basic_subparts(SubP, BasicP).

2024/10/9 44
Module #1 - Logic

Example
 For each basic part find the least
time needed for delivery
fastest(Part, Time) 
part_cost(Part, Sup1,Cost,Time),
faster(Part, Time).
faster(Part, Time) 
part_cost(Part, Sup2, Cost, Time),
part_cost(Part,Sup1,Cost,Time1),
Time1<Time.

2024/10/9 45
Module #1 - Logic

Example
 Times required for basic subparts of the given assembly
timeForbasic(AssPart, BasicSub, Time) 
basic_subparts(AssPart,BasicSub),
fastest(BasicSub, Time).
 The maximum time required for basic subparts of the given
assembly
howsoon(AssPart, Time) 
timeForbasic(AssPart, _, Time),
slower(AssPart, Time).
slower(Part, Time) 
timeForbasic(Part, _(basic1) , Time),
timeForbasic(Part, _(basic2) , Time1),
Time1 > Time.
Note: to compute howsoon you must first compute larger
completely.

2024/10/9 46
Module #1 - Logic Topic #3 – Predicate Logic

Subjects and Predicates


 In the sentence “The dog is sleeping”:
– The phrase “the dog” denotes the subject -
the object or entity that the sentence is about.
– The phrase “is sleeping” denotes the predicate-
a property that is true of the subject.

 In predicate logic, a predicate is modeled as a


function P(·) from objects to propositions.
– P(x) = “x is sleeping” (where x is any object).

2024/10/9 47
Module #1 - Logic Topic #3 – Predicate Logic

More About Predicates


 Convention: Lowercase variables x, y, z...
denote objects/entities; uppercase
variables P, Q, R… denote propositional
functions (predicates).
 Keep in mind that the result of applying a
predicate P to an object x is the
proposition P(x). But the predicate P
itself (e.g. P=“is sleeping”) is not a
proposition (not a complete sentence).
– E.g. if P(x) = “x is a prime number”,
P(3) is the proposition “3 is a prime number.”
2024/10/9 48
Module #1 - Logic Topic #3 – Predicate Logic

Propositional Functions
 Predicate logic generalizes the
grammatical notion of a predicate to
also include propositional functions of
any number of arguments, each of
which may take any grammatical
role that a noun can take.
– E.g. let P(x,y,z) = “x gave y the grade
z”, then if
x=“Mike”, y=“Mary”, z=“A”, then P(x,y,z)
= “Mike gave Mary the grade A.”
2024/10/9 49
Module #1 - Logic Topic #3 – Predicate Logic

Universes of Discourse (U.D.s)


 The power of distinguishing objects
from predicates is that it lets you state
things about many objects at once.
 E.g., let P(x)=“x+1>x”. We can then
say,
“For any number x, P(x) is true” instead
of
(0+1>0)  (1+1>1)  (2+1>2)  ...
 The collection of values that a variable
x can take is called x’s universe of
discourse.
2024/10/9 50
Module #1 - Logic Topic #3 – Predicate Logic

Quantifier Expressions
 Quantifiers provide a notation that allows us to
quantify (count) how many objects in the univ.
of disc. satisfy a given predicate.

 “” is the FORLL or universal quantifier.


x P(x) means for all x in the u.d., P holds.

 “” is the XISTS or existential quantifier.


x P(x) means there exists an x in the u.d.
(that is, 1 or more) such that P(x) is true.

2024/10/9 51
Module #1 - Logic Topic #3 – Predicate Logic

The Universal Quantifier 


 Example:
Let the u.d. of x be parking spaces at
UF.
Let P(x) be the predicate “x is full.”
Then the universal quantification of
P(x), x P(x), is the proposition:
– “All parking spaces at UF are full.”
– i.e., “Every parking space at UF is full.”
– i.e., “For each parking space at UF, that space is
full.”
2024/10/9 52
Module #1 - Logic Topic #3 – Predicate Logic

The Existential Quantifier 


 Example:
Let the u.d. of x be parking spaces at
UF.
Let P(x) be the predicate “x is full.”
Then the existential quantification of
P(x), x P(x), is the proposition:
– “Some parking space at UF is full.”
– “There is a parking space at UF that is
full.”
– “At least one parking space at UF is full.”
2024/10/9 53
Module #1 - Logic Topic #3 – Predicate Logic

Free and Bound Variables


 An expression like P(x) is said to
have a free variable x (meaning, x is
undefined).
 A quantifier (either  or ) operates
on an expression having one or more
free variables, and binds one or
more of those variables, to produce
an expression having one or more
bound variables.
2024/10/9 54
Module #1 - Logic Topic #3 – Predicate Logic

Example of Binding
 P(x,y) has 2 free variables, x and y.
 x P(x,y) has 1 free variable, and one
bound variable. [Which is which?]
 “P(x), where x=3” is another way to bind
x.
 An expression with zero free variables is a
bona-fide (actual) proposition.
 An expression with one or more free
variables is still only a predicate: x P(x,y)

2024/10/9 55
Module #1 - Logic Topic #3 – Predicate Logic

Nesting of Quantifiers
Example: Let the u.d. of x & y be people.
Let L(x,y)=“x likes y” (a predicate w. 2 f.v.’s)
Then y L(x,y) = “There is someone whom x
likes.” (A predicate w. 1 free variable, x)
Then x (y L(x,y)) =
“Everyone has someone whom they like.”
(A __________ with ___ free variables.)

2024/10/9 56
Module #1 - Logic
Review: Propositional Logic
(§§1.1-1.2)
 Atomic propositions: p, q, r, …
 Boolean operators:      

 Compound propositions: s  (p  q)


r
 Equivalences: pq  (p  q)

 Proving equivalences using:


– Truth tables.
– Symbolic derivations. p  q  r …

2024/10/9 57
Module #1 - Logic Topic #3 – Predicate Logic

Quantifier Exercise
If R(x,y)=“x relies upon y,” express
the following in unambiguous English:
x(y R(x,y))= Everyone has someone to rely on.
y(x R(x,y))= There’s a poor overburdened soul whom
x(y R(x,y))= everyone relies upon (including himself)!
There’s some needy person who relies
y(x R(x,y))=upon everybody (including himself).
x(y R(x,y))=Everyone has someone who relies upon them.
Everyone relies upon everybody,
(including themselves)!
2024/10/9 58
Module #1 - Logic Topic #3 – Predicate Logic

Natural language is ambiguous!


 “Everybody likes somebody.”
– For everybody, there is somebody they
like,
 x y Likes(x,y) [Probably more likely.]
– or, there is somebody (a popular person)
whom everyone likes?
 y x Likes(x,y)
 “Somebody likes everybody.”
– Same problem: Depends on context,
emphasis.
2024/10/9 59
Module #1 - Logic Topic #3 – Predicate Logic
More to Know About Binding
 x x P(x) - x is not a free variable
in
x P(x), therefore the x binding
isn’t used.
 (x P(x))  Q(x) - The variable x is
outside of the scope of the x
quantifier, and is therefore free. Not
a proposition!
 (x P(x))  (x Q(x)) – This is legal,
because there are 2 different x’s!
2024/10/9 60
Module #1 - Logic Topic #3 – Predicate Logic

Quantifier Equivalence Laws


 Definitionsof quantifiers: If
u.d.=a,b,c,…
x P(x)  P(a)  P(b)  P(c)  …
x P(x)  P(a)  P(b)  P(c)  …
 From those, we can prove the laws:
x P(x)  x P(x)
x P(x)  x P(x)
 Which propositional equivalence
laws can be used to prove this?
2024/10/9 61
Module #1 - Logic Topic #3 – Predicate Logic
More Equivalence Laws
 x y P(x,y)  y x P(x,y)
x y P(x,y)  y x P(x,y)
 x (P(x)  Q(x))  (x P(x))  (x
Q(x))
x (P(x)  Q(x))  (x P(x))  (x
Q(x))
 Exercise:
See if you can prove these
yourself.
– What propositional equivalences did you
use?
2024/10/9 62
Module #1 - Logic Topic #3 – Predicate Logic

More Notational Conventions


 Quantifiers bind as loosely as needed:
parenthesize x P(x)  Q(x)
 Consecutive quantifiers of the same
(
type can be combined: x )y z P(x,y,z)

x,y,z P(x,y,z) or even xyz P(x,y,z)
 All quantified expressions can be
reduced
to the canonical alternating form
x1x2x3x4… P(x1, x2, x3, x4, …)

2024/10/9 63
Module #1 - Logic Topic #3 – Predicate Logic
Defining New Quantifiers
As per their name, quantifiers can be
used to express that a predicate is true
of any given quantity (number) of
objects.
Define !x P(x) to mean “P(x) is true of
exactly one x in the universe of
discourse.”
!x P(x)  x (P(x)  y (P(y)  y x))
“There is an x such that P(x), where
there is no y such that P(y) and y is
other than x.”
2024/10/9 64
Module #1 - Logic Topic #3 – Predicate Logic
Some Number Theory
Examples
 Let u.d. = the natural numbers 0, 1, 2, …
 “A number x is even, E(x), if and only if it
is equal to 2 times some other number.”
x (E(x)  (y x=2y))
 “A number is prime, P(x), iff it’s greater
than 1 and it isn’t the product of two non-
unity numbers.”
x (P(x)  (x>1  yz x=yz  y1 
z1))

2024/10/9 65
Module #1 - Logic

Goldbach’s Conjecture (unproven)


Using E(x) and P(x) from previous
slide,
E(x>2): P(p),P(q): p+q = x
or, with more explicit notation:
x [x>2  E(x)] →
p q P(p)  P(q)  p+q = x.
“Every even number greater than 2
is the sum of two primes.”
2024/10/9 66
Module #1 - Logic Topic #3 – Predicate Logic

Calculus Example

 One way of precisely defining the


calculus concept of a limit, using

lim f ( x)  L 
quantifiers:

x a

   0 :   0 : x : 
 
 | x  a |    | f ( x)  L |  
2024/10/9 67
Module #1 - Logic Topic #3 – Predicate Logic

Deduction Example
 Definitions:
s :≡ Socrates (ancient Greek
philosopher);
H(x) :≡ “x is human”;
M(x) :≡ “x is mortal”.
 Premises:
H(s) Socrates is
human. x H(x)M(x) All
humans are mortal.
2024/10/9 68
Module #1 - Logic Topic #3 – Predicate Logic

Deduction Example Continued


Some valid conclusions you can draw:
H(s)M(s) [Instantiate universal.] If
Socrates is human

then he is mortal.
H(s)  M(s) Socrates is inhuman
or mortal.
H(s)  (H(s)  M(s))
Socrates is human, and also either inhuman
or mortal.
(H(s)  H(s))  (H(s)  M(s)) [Apply
distributive law.]
F  (H(s)  M(s)) [Trivial
contradiction.]
2024/10/9 69
Module #1 - Logic Topic #3 – Predicate Logic

Another Example
 Definitions: H(x) :≡ “x is human”;
M(x) :≡ “x is mortal”; G(x) :≡ “x is a
god”
 Premises:
– x H(x)  M(x) (“Humans are mortal”)
and
– x G(x)  M(x) (“Gods are immortal”).
 Show that x (H(x)  G(x))
(“No human is a god.”)
2024/10/9 70
Module #1 - Logic Topic #3 – Predicate Logic

The Derivation
 x H(x)M(x) and x G(x)M(x).
 x M(x)H(x) [Contrapositive.]
 x [G(x)M(x)]  [M(x)H(x)]

 x G(x)H(x) [Transitivity of .]


 x G(x)  H(x) [Definition of .]
 x (G(x)  H(x)) [DeMorgan’s law.]
 x G(x)  H(x) [An equivalence
law.]

2024/10/9 71
Module #1 - Logic
Example from Singapore elementary
school …
 Albert and Bernard want to know Cheryl’s birthday. She gives
them 10 possible dates.
– May 15, May 16, May 19
– June 17, June 18
– July 14, July 16
– August 14, August 15, August 17
Cheryl then tells Albert and Bernard separately the month and the
day of her birthday respectively.
Albert: I don’t know when Cheryl’s birthday is, but I know that
Bernard does not know too.
Bernard: At first I don’t know when Cheryl’s birthday is, but I know
now.
Albert: Then I also know when is her birthday.

So when is Cheryl’s birthday?


2024/10/9 72

You might also like