0% found this document useful (0 votes)
29 views82 pages

CS101 - Chapter2 Dicrete Math

The document discusses logic and propositions. It defines logic, truth values, propositional logic, and logical operators such as negation, conjunction, disjunction, and conditional statements. Examples are provided to illustrate each concept.

Uploaded by

Althea Ponce
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views82 pages

CS101 - Chapter2 Dicrete Math

The document discusses logic and propositions. It defines logic, truth values, propositional logic, and logical operators such as negation, conjunction, disjunction, and conditional statements. Examples are provided to illustrate each concept.

Uploaded by

Althea Ponce
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 82

Logic

study of reasoning
specifically concerned with whether reasoning is
correct
focuses on the relationship among statements
as opposed to the content of any particular
statement.
example:
All mathematicians wear sandals.
Anyone who wears sandals is an algebraist.
Therefore, all mathematicians are algebraists.

Technically, logic is of no help in determining whether any of


these statements is true; however, if the first two statements
are true, logic assures us that the last statement is also true.
Logical methods

used in mathematics to prove theorems

used in computer science to prove that
programs do what they are alleged to do.
Truth value of a statement
The only positive integers that divide 7 are 1 and
7 itself. True
Gloria Macapagal Arroyo is the 14th president of
the Philippines as she won in the 1998
presidential elections. False
For every positive integer n, there is a prime
number larger than n. True
Earth is the only planet in the universe that has
life. Truth value unknown at this time
Buy two tickets to the rock concert for Friday. No
There is nothing on the television. truth
value
ambiguous
Proposition
a sentence that is either true or false, but not
both
typically expressed as a declarative sentence

Atomic Propositions
propositions in which each one is an atomic
entity
truth or falsity is independent of any other
propositions.
Representation of proposition
we will use lowercase letters, such as p, q, and
r, so that the notation
p: 1 + 1 = 3
defines p to be the proposition 1 + 1 = 3.
Propositional Logic
there are two possible truth values that can be
associated with atomic propositions
every proposition may be associated with only
one of the truth values of true and false, at any
given time
sometimes determining the truth or falsity of a
given proposition may not be possible but we
know it must be true or false
a proposition can never be both true and false at
the same time although the truth value of a
given proposition may change according to
when it is stated.
Examples of Propositions
p: 1 + 1 = 2
q: Today is Tuesday.
r: Jack likes Jill.
s: Cedric is happy.
Three-valued Logic
a proposition may have a third truth value of
undefined
it is quite difficult to attach a truth value to some
propositions, thus, the undefined truth value for
propositions in this field is accepted

However, in our study of discrete mathematics,


we will tackle only two-valued propositions, and
so we may conclude that a proposition is either
true or false, we just have no means of
determining precisely which.
Propositions
basic building blocks of any theory of logic
just as natural numbers can be combined
via addition or multiplication to form
mathematical terms, so do atomic
propositions via a variety of propositional
logic operators to form compound
propositions.
Compound Proposition
a single proposition that results from the
combination of atomic propositions

example of atomic propositions:


 It is raining.
 I will take my umbrella.

example of compound propositions:


 It is raining and I will take my umbrella.
 It is not raining and I will not take my umbrella.
Negation
Definition. The negation of p, denoted ~p or p ,
is the proposition
not p.
Examples:
p: Eric is a vegetarian.
q: Today is Wednesday.
~p: Eric is not a vegetarian.
~q: Today is not Wednesday.
Law 2.1 (Properties of Negation)
1. (~ true )  false
(~ false)  true
2. For any proposition p, the negation of the
negation of p is p itself. That is,
(~ ~ p)  p

Negation is a unary logic operator because it


takes in only one argument, that is, it operates
only on one proposition – the proposition to be
negated
Truth Table
provides a means of representing the truth or
falsity of logical statements
the possible values of all atomic propositions
contained in the proposition are listed, T for true
and F for false, and the truth value of the overall
proposition can thus be calculated for each
possible combination
Truth Table for Negation

p ~p
T F
F T
Conjunction
Definition. Let p and q be propositions.
The conjunction of p and q, denoted p  q,
is the proposition
p and q.
Remark: The proposition p  q can also
be read as “p conjoined with q”.
Example:
Given: p: 0 < 1
q: 1 < 2
p  q: (0 < 1)  (1 < 2).
Truth Table for Conjunction
p q pq

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

Notice that the conjuction p  q is true provided that p


and q are both true; p  q is false otherwise.
Example of Conjunction
p: Eric is a vegetarian.
q: Eric eats hamburger.

if p is false, and q is true, then the conjunction


p  q: Eric is a vegetarian and Eric eats hamburger
is false.
on the other hand, if Eric is indeed a vegetarian, so
that p is true and q is false, then we obtain the
same truth value of false for the conjunction p  q.
Properties of Conjunction
For any propositions p, q and r,
1. Conjunction is idempotent, that is,
(p  p)  p
2. (p  true)  p
3. (p  false)  false
4. (p  ~ p)  false
5. Conjunction is commutative, that is,
(p  q)  (q  p)
6. Conjunction is associative, that is,
p  (q  r)  (p  q)  r
Truth table for p  (~ q)

p q ~q p ~ q

T T F F

T F T T

F T F F

F F T F
Disjunction
Definition. The disjunction of p and q, denoted p
 q, is the proposition
p or q

Remark: The proposition p  q can also be read


as “p disjoined with q”.
Note: Here, the or in the disjunction p  q is used
in the inclusive sense; that is, p  q is
considered to be true if either p or q or both are
true, and p  q is false only if both p and q are
false. There is also an exclusive-or in which p
exor q is true if either p or q, but not both, is true.
Truth Table for Disjunction
p q p q

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

Notice that the conjuction p  q is true provided that p


and q are both true; p  q is false otherwise.
Example of Disjunction

p: A decade is 10 years
q: A year is always 365 days
p  q: A decade is 10 years or a year is always
365 days

since p is true and q is false, then the disjunction


p  q is true
Example of Disjunction

p: 23 = 6
q: 4 x 8 = 48
p  q: 23 = 6 or 4 x 8 = 48

since p is false and q is false, then the disjunction


p  q is false
Example of Disjunction
Let p: Blaise Pascal invented several calculating
machines
q: The first all-electronic digital computer was
constructed in the twentieth century,
r:  was calculated to 1,000,000 decimal
digits in 1954.

Represent the proposition below symbolically and


determine whether it is true or false.
Either Blaise Pascal invented several calculating
machines and it is not the case that the first all-electronic
digital computer was constructed in the twentieth century;
or  was calculated to 1,000,000 decimal digits in 1954,
Example of Disjunction
Either Blaise Pascal invented several calculating
machines and it is not the case that the first all-
electronic digital computer was constructed in
the twentieth century; or  was calculated to
1,000,000 decimal digits in 1954,

FF
Symbolic representation: Truth value:
(p  (~q))  r ( p  q )  r  (T  T )  F
 (T  F )  F
FF
F
Properties of Disjunction
For any propositions p, q and r,

1. Disjunction is idempotent, that is,


(p  p)  p
2. (p  false)  p
3. (p  true)  true
4. Disjunction is commutative, that is,
(p  q)  (q  p)
5. Disjunction is associative, that is,
p  (q  r)  (p  q)  r
Properties of Disjunction
For any propositions p, q and r,
6. For any proposition p
(~p  p)  true
7. Disjunction distributes through conjunction,
that is, for any propositions p, q and r,
p  (q  r)  (p  q)  (p  r)
(p  q)  r  (p  r)  (q  r)
8. Conjunction distributes through disjunction,
that is, for any propositions p, q and r,
p  (q  r)  (p  q)  (p  r)
(p  q)  r  (p  r)  (q  r)
Exercise
Show that indeed disjunction
distributes through conjunction, that
is, for any propositions p, q and r,

p  (q  r)  (p  q)  (p  r)
(p  q)  r  (p  r)  (q  r)
Truth table for p  (q  r)
p q r q  r p  (q  r) pq pr (p  q) 
(p  r)
T T T T T T T T
T T F F T T T T
T F T F T T T T
T F F F T T T T
F T T T T T T T
F T F F F T F F
F F T F F F T F
F F F F F F F F
Conditional Propositions
Definition. If p and q are propositions,
the compound proposition
if p then q
is called a conditional proposition and is
denoted pq
Remark: The  operator is called the
implication operator and the proposition
p is called the hypothesis (or antecedent)
and the proposition q is called the
conclusion (or consequent).
Example of a conditional proposition
If the Mathematics Department gets an
additional budget, then it will hire one new
faculty member.
p: If the Mathematics Department gets an
additional budget
q: It will hire one new faculty member
p q:
If the Mathematics Department gets an
additional budget, then it will hire one new
faculty member.
Other Forms of pq
Mary will be a good student if she studies
hard.
John may take calculus only if he has
sophomore, junior, senior standing.
When you sing, my ears hurt.
A necessary condition for the Cubs to
win the World Series is that they sign a
right-handed relief pitcher.
A sufficient condition for Ralph to visit
California is that he goes to Disneyland.
Other Forms of pq
The hypothesis is the clause following if
The only if clause is the conclusion; that is, if p then
q is considered logically the same as p only if q
The “if p then q” formulation emphasizes the
hypothesis, whereas the “p only if q” formulation
emphasizes the conclusion; the difference is only
the style.
When means the same as if
The conclusion expresses a necessary condition
The hypothesis expresses a sufficient condition
Other Forms of pq
Mary will be a good student if she studies hard.
 If Mary studies hard, then she will be a good
student.
John may take calculus only if he has
sophomore, junior, senior standing.
 If John takes calculus then he has sophomore,
junior, or senior standing.

When you sing, my ears hurt.


 If you sing, then my ears hurt.
Other Forms of pq
A necessary condition for the Cubs to win the
World Series is that they sign a right-handed
relief pitcher.
 If the Cubs win the World Series, then they sign
a right-handed relief pitcher.

A sufficient condition for Ralph to visit California


is that he goes to Disneyland.
 If Ralph goes to Disneyland, then he visits
California.
Truth Table for p  q
p q pq

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

Note that the truth table for a conditional position shows a


truth value of false only when the hypothesis is true and the
conclusion is false. At all other cases, the statement is true.
Example of a conditional proposition
If the Mathematics Department gets an
additional budget, then it will hire one new
faculty member.
The statement is really of interest only
when the hypothesis is true
If it is true that the Mathematics
Department gets an additional budget,
and it is also true that the Department
hires one new faculty member, then we
would regard the statement as true
Example of a conditional proposition
However, if it is true that the
Mathematics Department gets an
additional budget but it is false that
this department hires one new faculty
member, we would regard the
statement as false.
Example of a conditional proposition
If the Mathematics Department gets an
additional budget, then it will hire one new
faculty member.
In general, when the hypothesis p is true,
the conditional proposition is true if q is
true, and false if q is false.
If the hypothesis p is false, the only
intuitively clear point is that the truth value
of the conditional statement should not
hinge on the conclusion’s truth value.
Example of a conditional proposition
If the Mathematics Department gets an
additional budget, then it will hire one new
faculty member.
We would not consider the above
statement to be false simply because the
Mathematics Department did not get an
additional budget.
Nonetheless, the conditional proposition,
like any other proposition, must have a
truth value, even if the hypothesis is false.
The standard definition declares to be
true if p is false.
Example of a conditional proposition

p: 1 > 2
q: 4 < 8

pq is true

q p is false
Example of a conditional proposition
Given: p – true, q – false, r – true
Find the truth values of the following
propositions:
( p  q)  r
( p  q)  r
p  (q  r )
p  (q  r )
Relationship of propositions
In ordinary language, the hypothesis and
conclusion in a conditional proposition
are normally related, but in logic, the
hypothesis and conclusion in a
conditional proposition are not required
to refer to the same subject matter.

For example, in logic, we permit


propositions such as:
If 5 < 3, then Nelson Rockefeller was the
president of the United States.
Relationship of propositions
Logic is concerned with the form of
propositions and the relation of
propositions to each other and not with the
subject matter itself.

In fact, the given statement in the previous


slide is true since the hypothesis is false.

Notice that a true conditional proposition is


different from a conditional proposition
with a true conclusion.
Converse of a proposition
Recall:
p: 1 > 2 pq is true
q: 4 < 8 q p is false
The above example shows that the proposition can be
true while the proposition q p
is false.
We call the proposition
proposition
q p the converse of the
p  .q
Hence, a conditional proposition can be true while its
converse is false.
This shows that implication, unlike other propositional logical
operators, is not commutative. Furthermore, it not idempotent
and associative.
Example of a conditional proposition
Given the conditional proposition
If 1 < 2, then 3 < 6.
Write the proposition symbolically.
Write the converse of this statement
symbolically and in words. Also, find
the truth value of the conditional
proposition and its converse.
Example of a conditional proposition
Solution:
Let p: 1 < 2, q: 3 < 6.
The given statement may be written
symbolically as p  q
Since p and q are both true, this statement is
true.
The converse may be written symbolically as q  p
and in words as
If 3 < 6, then 1 < 2.
Since p and q are both true, the converse is
true.
Logical Equivalence
Definition. If p and q are propositions, the
compound proposition
p if and only if q
is called a biconditional proposition and is
denoted
pq
Remarks:
 The  operator is called the equivalence operator.
 An alternative way to state “p if and only if q” is “p is
a necessary and sufficient condition for q.”
 “p if and only if q” can also be written as “p iff q.”
Truth Table for Logical Equivalence

p q pq

T T T

T F F

F T F
F F T
Example of logical equivalence
p: 1 < 5
q: 2 < 6

p  q is true since both p and q are


true

An alternative way to state this statement is:


A necessary and sufficient condition for
1 < 5 is that 2 < 6.
Property of Logical Equivalence
(Law 2.4) For any propositions p and q,
(p  q)  ((~ p)  q).
Example:
p: It will rain this afternoon.
q: The Garcias will stay in.
p  q: If it rains this afternoon, then the Garcias
will stay in
(~ p)  q: Either it will not rain this afternoon or
the Garcias will stay in.
(p  q)  ((~ p)  q)
Logically Equivalent Compound
Propositions

Definition. Suppose that the compound


propositions P and Q are made up of the
propositions p1, . . . , pn. We say that P and
Q are logically equivalent and write
P Q
provided that given any truth values of
p1,..., pn, either P and Q are both true or P
and Q are both false.
De Morgan’s Laws (Law 2.5)

For any propositions p and q,


~ (p  q)  ((~ p)  (~ q))
~ (p  q)  ((~ p)  (~ q)).
These laws can also written as follows:

p  q  p  q,
pq  pq
Proof of De Morgan’s Law (i)

p q pq
T T F F
T F F F
F T F F
F F T T
pq  pq
pq pq

p q p q pq
pq pq

T T F F
T F T T
F T F F
F F F F
( p  q )  ( p  q )  (q  p )

( p  q) 
  q  p
pq pq

p q p q p q
p  q p  q(q  p )
pq pq
pq
q p
pq

T T T T T T
T F F F T F
F T F T F F
F F T T T T
Properties of Equivalence (Law 2.6)

1. Equivalence is associative, that is, for any


propositions p, q and r,
p  (q  r)  (p  q)  r
2. Equivalence is commutative, that is, for any
propositions p and q,
(p  q)  (q  p)
3. Any proposition is equivalent to itself, that is, for
any proposition p
(p  p)  true
Properties of Equivalence (Law 2.6)

4. No proposition is equivalent to its negation, that


is, for any proposition p
(p  (~p))  false
5. To say that one proposition p is equivalent to
another proposition q, is the same as saying p
implies q, and q implies p. That is, for any
propositions p and q,
p  q  (p q)  (q  p).
Contrapositive
Definition. The contrapositive (or transposition)
of the conditional proposition p  q is the
proposition q  p
Remarks:
1. Notice the difference between the contrapositive
and the converse. The converse of a conditional
proposition merely reverses the roles of p and q,
whereas the contrapositive reverses the roles of
p and q and negates each of them.
2. The contrapositive is an alternative, logically
equivalent form of the conditional proposition.
An Example of contrapositive
Write the proposition
If 1 < 4, then 5 > 8
symbolically and write the converse and the contrapositive
both symbolically and in words. Find the truth value of each
proposition.
Answer:
Let p: 1 < 4 q: 5 > 8,
then the given proposition may be written symbolically as
p → q.
The converse is q → p or in words If 5 > 8, then 1 < 4.
The contrapositive is ~ q → ~p or in words,
If 5 is not greater than 8, then 1 is not less than 4.
We see that p → q is false, q → p is true,
and ~ q → ~p is false.
A theorem on contrapositive
The conditional proposition p → q and its
contrapositive ~p → ~q are logically equivalent.
Proof:

p q p→q ~q → ~p
T T T T
T F F F
F T T T
F F T T
Hierarchy of Logical Operators

1. negation (~) has the highest priority


2. conjunction ()
3. disjunction ()
4. implication ()
5. logical equivalence ()
Hierarchy of Logical Operators:
An Example

The proposition ~ p  q means (~ p)  q


rather than ~ (p  q).
The proposition p  q  r means
( p  q)  r rather than p  (q r).
Tautology

Definition. A proposition which is


always logically equivalent to
true, no matter what the values
of its constituent atomic
propositions are, is called a
tautology.
Tautology
Remark:
An easy method of determining
whether or not a proposition is a
tautology is to substitute truth values
for the atomic propositions. If the
truth value of the proposition is true for
all combinations of values attributed to
the atomic propositions, then, we may
conclude that it is a tautology.
Examples of Tautology

p~p
pp
(p  q)  (p  ~q)  (~p  q) 
(~p  ~q)
Is (p  ~ p)  q a tautology?

Answer:
From the previous slide, we
have seen that p  ~ p is a
tautology. If q is false, then
(p  ~ p)  q is false. Hence
(p  ~ p)  q is not a
tautology.
Contradiction
Definition. A proposition which is
always false is called a contradiction.
Example:
The proposition ~ (p  p) is a
contradiction. If p is true, then the
overall proposition is false, whereas if
p is false the overall proposition is also
false.
Contingency

Definition.
If a proposition is neither a
tautology nor a contradiction,
then it is called a contingency.
Contingency
Example:
Consider the proposition p  q.
If p is true and q is false, then
the implication is false,
whereas if p and q are both
true the implication is true.
Hence, the implication p  q is
a contingency.
Equational Reasoning

We can determine the truth or


falsity of propositions by
substituting one logically
equivalent proposition for
another.
Equational Reasoning

When conducting this process,


we have to strictly apply the
laws of propositional logic at
each step.
This method of analysis is called
Equational Reasoning.
Equational Reasoning:
An Example

Problem: Prove that p  p is


equivalent to true using the laws
of propositional logic.
Proof:
pp
 ~p  p [Law 2.4]
 true [Law 2.3.6]
Equational Reasoning:
An Example

Problem: Prove that p  (p q) is logically


equivalent to (p q).
Proof:
p  (p q)
 ~p  (p q) [Law 2.4]
 ~p  (~p  q) [Law 2.4]
 ( ~p  ~p)  q [Law
[ 2.3.5 )]
 ~p  q [Law 2.3.1 (Idemp of V]
 (p q) [Law 2.4]
Equational Reasoning:
An Example
Problem: Using equational reasoning, find
the truth value of the proposition
(p  q)  (~p  ~q).

Solution:
(p  q)  (~p  ~q)
 (p  q)  ~(p  q) [De Morgan’s Law]
 false [Law 2.6.4
(No prop. is equiv. to its negation)]

You might also like