You are on page 1of 54

CSC331 Discrete Structures

and Logic
October, 2012
Topic A
Sets and Logic
Topic A Sets and Logic
Section 1.1 Sets
Section 1.2 Proposition
Section 1.3 Conditional Propositions and
Logical Equivalence
Section 1.4 Arguments and Rules of
Inference
Section 1.5 Quantifiers
Section 1.6 Nested Quantifiers
Section 1.1 Sets
Set = a collection of distinct unordered
objects
Members of a set are called elements
How to determine a set
Listing:
Example: A = {1,3,5,7}
Description
Example: B = {x | x = 2k + 1, 0 < k < 3}
Finite and infinite sets
Finite sets
Examples:
A = {1, 2, 3, 4}
B = {x | x is an integer, 1 < x < 4}

Infinite sets
Examples:
Z = {integers} = {, -3, -2, -1, 0, 1, 2, 3,}
S={x| x is a real number and 1 < x < 4} = [0, 4]

Some important sets
The empty set C has no elements.
Also called null set or void set.
Universal set: the set of all elements about
which we make assertions.
Examples:
U = {all natural numbers}
U = {all real numbers}
U = {x| x is a natural number and 1< x<10}
Some important sets
Two sets X and Y are equal and we write X = Y
if X and Y have the same elements.
X = Y if the following two conditions holds:
For every x, if x e X, then x e Y,
and
For every x, if x e Y, then x e X.
This is a great way to prove two sets are equal.
Cardinality
Cardinality of a set A (in symbols |A|) is the
number of elements in A
Examples:
If A = {1, 2, 3} then |A| = 3
If B = {x | x is a natural number and 1< x< 9}
then |B| = 9
Infinite cardinality
Countable (e.g., natural numbers, integers)
Uncountable (e.g., real numbers)
Subsets
X is a subset of Y if every element of
X is also contained in Y
(in symbols X _ Y)
Equality: X = Y if X _ Y and Y _ X

X is a proper subset of Y if X _ Y but
Y . X
Observation: C is a subset of every set
Power set
The power set of X is the set of all subsets of X,
in symbols P(X),
i.e. P(X)= {A | A _ X}
Example: if X = {1, 2, 3},
then P(X) = {C, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}}

Theorem 2.1.4: If |X| = n, then |P(X)| = 2
n
.

Set operations:
Union and Intersection
Given two sets X and Y
The union of X and Y is defined as the set
X Y = { x | x e X or x e Y}

The intersection of X and Y is defined as the set
X Y = { x | x e X and x e Y}
Two sets X and Y are disjoint if X Y = C
Complement and Difference
The difference of two sets
X Y = { x | x e X and x e Y}
The difference is also called the relative complement
of Y in X
Symmetric difference
X Y = (X Y) (Y X)
The complement of a set A contained in a
universal set U is the set A
c
= U A
In symbols A
c
= U - A

Venn diagrams
A Venn diagram provides a graphic view of
sets
Set union, intersection, difference,
symmetric difference and complements can
be identified


Properties of set operations (1)
Theorem 2.1.10: Let U be a universal set, and
A, B and C subsets of U. The following
properties hold:
a) Associativity: (A B) C = A (B C)
(A B) C = A (B C)
b) Commutativity: A B = B A
A B = B A

Properties of set operations (2)
c) Distributive laws:
A(BC) = (AB)(AC)
A(BC) = (AB)(AC)
d) Identity laws:
AU=A AC = A
e) Complement laws:
AA
c
= U AA
c
= C


Correction!!!!!
It was incorrectly reversed in
previous version
Properties of set operations (3)
f) Idempotent laws:
AA = A AA = A
g) Bound laws:
AU = U AC = C
h) Absorption laws:
A(AB) = A A(AB) = A
Properties of set operations (4)
i) Involution law: (A
c
)
c
= A

j) 0/1 laws: C
c
= U U
c
= C
k) De Morgans laws for sets:
(AB)
c
= A
c
B
c

(AB)
c
= A
c
B
c

Union and intersection of
a family S of sets
The union of an arbitrary family S of sets is
defined to be those elements x belonging to
at least one set X in S.
S = {x | x e X for some X e S}
The intersection of an arbitrary family S of
sets is defined to be those elements x
belonging to every set X in S
S = {x | x e X for all X e S}



Union and intersection of
a family S of sets (2)
Partition
The partition of a set X divides X into non-
overlapping subsets.
More formally, a collection S of nonempty
subsets of X is said to be a partition of set X if
every element in X belongs to exactly one
member of S
If S is a partition of X
S is pair-wise disjoint and
S = X

Logic
Logic = the study of correct reasoning
Use of logic
In mathematics:
to prove theorems
In computer science:
to prove that programs do what they are
supposed to do
Section 1.2 Propositions


A proposition is a statement or sentence
that can be determined to be either true or
false.
Examples:
John is a programmer" is a proposition
I wish I were wise is not a proposition


Truth table of conjunction



The truth values of compound propositions
can be described by truth tables.
Truth table of conjunction






p ^ q is true only when both p and q are true.
p q p ^ q
T T T
T F F
F T F
F F F
Example
Let p = Tigers are wild animals
Let q = Chicago is the capital of Illinois
p ^ q = "Tigers are wild animals and
Chicago is the capital of Illinois"
p ^ q is false. Why?

Truth table of disjunction
The truth table of (inclusive) disjunction is




p v q is false only when both p and q are false
Example: p = "John is a programmer", q = "Mary is a lawyer"
p v q = "John is a programmer or Mary is a lawyer"
p q p v q
T T T
T F T
F T T
F F F
Negation
Negation of p: in symbols ~p





~p is false when p is true, ~p is true when p is
false
Example: p = "John is a programmer"
~p = "It is not true that John is a programmer"

p ~p
T F
F T
More compound statements

Let p, q, r be simple statements
We can form other compound statements,
such as
(pvq)^r
pv(q^r)
(~p)v(~q)
(pvq)^(~r)
and many others
Example: truth table of (pvq)^r
p q r (p v q) ^ r
T T T
T T F
T F T
T F F
F T T
F T F
F F T
F F F
Section 1.3 Conditional propositions
and logical equivalence

A conditional proposition is of the form
If p then q
In symbols: p q
Example:
p = " John is a programmer"
q = " Mary is a lawyer "
p q = If John is a programmer then Mary is
a lawyer"

Truth table of p q






p q is true when both p and q are true
or when p is false (true by default or vacuously true)

p q p q
T T T
T F F
F T T
F F T
Hypothesis and conclusion

In a conditional proposition p q,
p is called the antecedent or hypothesis
q is called the consequent or conclusion
If "p then q" is considered logically the
same as "p only if q"
Necessary and sufficient

A necessary condition is expressed by the
conclusion.
A sufficient condition is expressed by the
hypothesis.
Example:
If John is a programmer then Mary is a lawyer"
Necessary condition: Mary is a lawyer
Sufficient condition: John is a programmer

Logical equivalence
Two propositions are said to be logically
equivalent if their truth tables are identical.






Example: ~p v q is logically equivalent to p q
p q ~p v q p q
T T T T
T F F F
F T T T
F F T T
Converse
The converse of p q is q p






These two propositions
are not logically equivalent
p q p q q p
T T T T
T F F T
F T T F
F F T T
Contrapositive
The contrapositive (or transposition) of the
proposition p q is ~q ~p.






They are logically equivalent.

p q p q ~q ~p
T T T T
T F F F
F T T T
F F T T
Biconditional proposition
The biconditional propersition p if and only if q
is defined in symbols as p q






p q is logically equivalent to (p q)^(q p)


p q p q (p q) ^ (q p)
T T T T
T F F F
F T F F
F F T T
De Morgans laws for logic

The following pairs of propositions are
logically equivalent:

~ (p v q) and (~p)^(~q)
~ (p ^ q) and (~p) v (~q)

Section 1.4 Arguments and Rules
of Inference
Deductive reasoning: the process of reaching a
conclusion q from a sequence of propositions p
1
,
p
2
, , p
n
.
A (deductive) argument is a sequence of
propositions written as
The symbol is read therefore.
The propositions p
1
, p
2
, , p
n
are called
premises or hypothesis.
The proposition q that is logically obtained
through the process is called the conclusion.
Rules of inference (1)
1. Law of detachment or
modus ponens
p q
p
Therefore, q

2. Modus tollens
p q
~q
Therefore, ~p
Rules of inference (2)
3. Rule of Addition
p
Therefore, p v q

4. Rule of simplification
p ^ q
Therefore, p


5. Rule of conjunction
p
q
Therefore, p ^ q


Rules of inference (3)



6. Rule of hypothetical syllogism
p q
q r
Therefore, p r

7. Rule of disjunctive syllogism
p v q
~p
Therefore, q

Section 1.5 Quantifiers
A propositional function P(x) is a statement
involving a variable x
For example:
P(x): 2x is an even integer
x is an element of a set D
For example, x is an element of the set of integers
D is called the domain of P(x)
Domain of a propositional function
In the propositional function
P(x): 2x is an even integer,
the domain D of P(x) must be defined, for
instance D = {integers}.
D is the set where the x's come from.
For every and for some
Most statements in mathematics and
computer science use terms such as for
every and for some.
For example:
For every triangle T, the sum of the angles of T
is 180 degrees.
For every integer n, n is less than p, for some
prime number p.

Universal quantifier

One can write P(x) for every x in a domain D
In symbols: x P(x)
is called the universal quantifier
Truth of as propositional function

The statement x P(x) is
True if P(x) is true for every x e D
False if P(x) is not true for some x e D
Example: Let P(n) be the propositional
function n
2
+ 2n is an odd integer
n e D = {all integers}
P(n) is true only when n is an odd integer,
false if n is an even integer.

Existential quantifier

For some x e D, P(x) is true if there exists
an element x in the domain D for which P(x) is
true. In symbols: -x, P(x)

The symbol - is called the existential
quantifier.
Counterexample
The universal statement x P(x) is false if
-x e D such that P(x) is false.

The value x that makes P(x) false is called a
counterexample to the statement x P(x).
Example: P(x) = "every x is a prime number", for
every integer x.
But if x = 4 (an integer) this x is not a primer
number. Then 4 is a counterexample to P(x)
being true.
Generalized De Morgans
laws for Logic
If P(x) is a propositional function, then each
pair of propositions in a) and b) below have
the same truth values:
a) ~(x P(x)) and -x: ~P(x)
"It is not true that for every x, P(x) holds" is equivalent
to "There exists an x for which P(x) is not true"
b) ~(-x P(x)) and x: ~P(x)
"It is not true that there exists an x for which P(x) is
true" is equivalent to "For all x, P(x) is not true"
Summary of propositional logic
In order to prove the
universally quantified
statement x P(x) is
true
It is not enough to
show P(x) true for
some x e D
You must show P(x) is
true for every x e D

In order to prove the
universally quantified
statement x P(x) is
false
It is enough to exhibit
some x e D for which
P(x) is false
This x is called the
counterexample to
the statement x P(x)
is true
Rules of inference for
quantified statements
1. Universal instantiation
xeD, P(x)
d e D
Therefore P(d)
2. Universal generalization
P(d) for any d e D
Therefore x, P(x)
3. Existential instantiation
- x e D, P(x)
Therefore P(d) for some
d eD
4. Existential generalization
P(d) for some d eD
Therefore - x, P(x)

Section 1.6 Nested Quantifiers
By definition, the statement xy P(x, y),
with domain of discourse XY, is true if, for
every x e X and every y e Y, P(x, y) is true.
The statement xy P(x, y) is false if there is
at least one x e X and at least one y e Y
such that P(x, y) is false.
x-y P(x, y)
By definition, the statement x-y P(x, y), with
domain of discourse XY, is true if, for every
x e X, there is at least one y e Y for which
P(x, y) is true. The statement x-y P(x, y) is
false if there is at least one x e X such that
P(x, y) is false for every y e Y.
-xy P(x, y)
By definition, the statement -xy P(x, y), with
domain of discourse XY, is true if there is at
least one x e X such that P(x, y) is true for
every one y e Y. The statement -xy P(x, y)
is false if, for every x e X, there is at least
one y e Y such that P(x, y) is false.
-x-y P(x, y)
By definition, the statement -x-y P(x, y), with
domain of discourse XY, is true if there is at
least one x e X and at least one y e Y such
that P(x, y) is true. The statement -x-y P(x,
y) is false if, for every x e X and for every y e
Y, P(x, y) is false.

You might also like