Professional Documents
Culture Documents
CH 01
CH 01
CH 01
Learning Objectives
Learning Objectives
Set-builder method
A = { x | x ∈ S, P(x) } or A = { x ∈ S | P(x) }
Example:
Subsets
Set X is a subset of set Y if every member of X is
also a member of Y.
Example:
Y Z, since a ∈ Y, but a ∉ Z
Cardinality of Sets
Let S be a finite set with n distinct elements,
where n ≥ 0. Then |S| = n , where the
cardinality (i.e., the size) of S is n
Example:
If P = {red, blue, yellow}, then |P| = 3
Singleton
A set with only one element is a singleton
Example:
H = { 4 }, |H| = 1, H is a singleton
Power Set
For any set X ,the power set of X ,written P(X),is
the set of all subsets of X
Example:
If X = {red, blue, yellow}, then P(X) = { ∅ , {red},
{blue}, {yellow}, {red,blue}, {red, yellow}, {blue,
yellow}, {red, blue, yellow} }
Barber’s Paradox
Union of Sets
Example:
If X = {1,2,3,4,5} and Y = {5,6,7,8,9}, then
X∪Y = {1,2,3,4,5,6,7,8,9}
Discrete Mathematical Structures: Theory and Applications 18
Intersection of Sets
Example:
If X = {1,2,3,4,5} and Y = {5,6,7,8,9}, then X ∩ Y = {5}
Disjoint Sets
Example:
If X = {1,2,3,4,} and Y = {6,7,8,9}, then X ∩ Y = ∅
Example:
• Example:
If X = {a,b,c,d} and Y =
{c,d,e,f}, then X – Y =
{a,b} and Y – X = {e,f}
Complement of Sets
Example:
If U = {a,b,c,d,e,f} and
X = {c,d,e,f}, then X’ =
{a,b}
Mathematical Logic
Propositional Logic
A statement, or a proposition, is a declarative
sentence that is either true or false, but not both
Lowercase letters denote propositions
Examples:
p: 2 is an even number (true)
q: 3 is an odd number (true)
r: A is a consonant (false)
The following are not propositions:
p: My cat is beautiful
q: Are you in charge?
Negation
The negation of p, written ∼p, is the statement
obtained by negating statement p
Truth values of p and ∼p are opposite
Symbol ~ is called “not” ~p is read as as “not p”
Example:
p: A is a consonant
~p: it is the case that A is not a consonant
Truth Table
Each row represents
a truth assignment for
propositions.
Implication
Let p and q be statements.The statement “if p
then q” is called an implication or condition.
The implication “if p then q” is written p → q
p → q is read:
“If p, then q”
“p is sufficient for q”
q if p
q whenever p
p implies q
Biconditional or Equivalence
Let p and q be statements. The statement “p
if and only if q” is called the biimplication or
biconditional of p and q
The biconditional “p if and only if q” is written
p↔q
p ↔ q is read:
“p if and only if q”
“p is necessary and sufficient for q”
“q if and only if p”
“p is equivalent to q”
Statement Formulas
Symbols p ,q ,r ,...,called propositional or
statement variables
Symbols ~, ∧, ∨, →,and ↔ are called logical
connectives
Definition of Statement Formulas:
1) A statement variable is a statement formula
2) If A and B are statement formulas, then the
expressions (~A ), (A ∧ B) , (A ∨ B ), (A →
B ) and (A ↔ B ) are statement formulas
Expressions are statement formulas that are
constructed only by using 1) and 2) above
Discrete Mathematical Structures: Theory and Applications 44
~ highest
∧ second highest
∨ third highest
→ fourth highest
↔ fifth highest
Tautology
A statement formula A is said to be a tautology if
the truth value of A is T for any assignment of the
truth values T and F to the statement variables
occurring in A
Contradiction
A statement formula A is said to be a
contradiction if the truth value of A is F for any
assignment of the truth values T and F to the
statement variables occurring in A
Example of Proof
Validity of Proofs
Proof: a proof of a theorem consists of a finite
sequence of logically valid statements ending in
a conclusion A1 , A2 , A3 , ..., An −1 , An
The final statement, An , is the conclusion, and
the statements A1 , A2 , A3 , ..., An −1 are the
premises of the argument.
A proof is logically valid if the statement formula,
i.e., A1 , A2 , A3 , ..., An−1 → An is a tautology.
Validity of Arguments
Valid Argument Forms
Hypothetical Syllogism
Dilemma
Example:
Q(x,y) : x > y, where the Domain is the set of integers
Q is a 2-place predicate
Q is T for Q(4,3) and Q is F for Q (3,4)
Universal Quantifiers
Existential Quantifiers
He loves everybody.
Examples of Quantifiers
Negation of Predicates
~ ∀x P( x) ≡ ∃x ~ P( x)
Example:
If P(x) is the statement “x has won a race” where the
domain of discourse is all runners, then the universal
quantification of P(x) is ∀x P ( x) , i.e., every runner has
won a race. The negation of this statement is “it is not the
case that every runner has won a race. Therefore there
exists at least one runner who has not won a race.
Therefore: ∃x ~ P ( x)
and so, ~ ∀x P ( x) ≡ ∃x ~ P ( x)
Negation of Predicates
~ ∀x P( x) ≡ ∃x ~ P( x)
~ ∃x P( x) ≡ ∀x ~ P( x)
Proof Techniques
Theorem
As Facts
As Implications
As Biimplications
Proof Techniques
Indirect Proof
The implication p → q is equivalent to the
implication (∼q → ∼p)
Therefore, in order to show that p → q is true,
one can also show that the implication
(∼q → ∼p) is true
To show that (∼q → ∼p) is true, assume that
the negation of q is true and prove that the
negation of p is true
Proof Techniques
Proof by Contradiction
Assume that the conclusion is not true and then
arrive at a contradiction
Example: Prove that there are infinitely many prime
numbers
Proof:
Assume there are not infinitely many prime numbers,
therefore they are listable, i.e. p1,p2,…,pn
Consider the number q = p1p2…pn+1. q is not
divisible by any of the listed primes
Therefore, q is a prime. However, it was not listed.
Contradiction! Therefore, there are infinitely many
primes
Discrete Mathematical Structures: Theory and Applications 69
Proof Techniques
Proof Techniques
Proof of Biimplications
To prove a theorem of the form ∀x (P(x) ↔
Q(x )), where D is the domain of the discourse,
consider an arbitrary but fixed element a from D.
For this a, prove that the biimplication P(a) ↔
Q(a) is true
The biimplication p ↔ q is equivalent to
(p → q) ∧ (q → p)
Prove that the implications p → q and q → p are
true
Assume that p is true and show that q is true
Assume that q is true and show that p is true
Discrete Mathematical Structures: Theory and Applications 71
Proof Techniques
Algorithms
Pseudocode Conventions
The symbol := is called the assignment operator
Example: The statement x := a is read as “assign the value a
to x” or “x gets the value a” or “copy the value of a into x”
x := a is also known as an assignment statement
Control Structures
One way-selection
if booleanExpression then statement
If booleanExpression evaluates to true, statement is
evaluated
Two way-selection
if booleanExpression then statement1
else statement2
If booleanExpression evaluates to true , statement1
executes,
otherwise statement2 executes
Discrete Mathematical Structures: Theory and Applications 74
Algorithms
Pseudocode Conventions
Control Structures
The while loop takes the form:
while booleanExpression do loopBody
The booleanExpression is evaluated. If it evaluates
to true, loopBody executes. Thereafter loopBody
continues to execute as long as booleanExpression
is true
The for loop takes the form:
for var := start to limit do loopBody
var is an integer variable. The variable var is set to
the value specified by start. If var limit, loopBody
≤
executes. After executing the loopBody , var is
incremented by 1. The statement continues to
execute until var > limit
Discrete Mathematical Structures: Theory and Applications 75
Algorithms
Pseudocode Conventions
Control Structures
Algorithms
Pseudocode Conventions
Block of Statement
To consider a set of statements a single statement, the
statements are written between the words begin and
end
begin
statement1
statement2
...
statementn;
end
Algorithms
Pseudocode Conventions
Return Statement
The return statement is used to return the value
computed by the algorithm and it takes the following
form:
return expression;
The value specified by expression is returned. In an
algorithm, the execution of a return statement also
terminates the algorithm
Read and Print Statements
read x;
Read the next value≤ and store it in the variable x
print x;
Output the value of x
Discrete Mathematical Structures: Theory and Applications 78
Algorithms
Pseudocode Conventions
Arrays (List)
A list is a set of elements of the same type
The length of the list is the number of elements in the list
L[1...n ]. L is an array of n components, indexed 1 to n . L[i ]
denotes the ith element of L
For data in tabular form, a two-dimensional array is used:
M[1...m,1...n ] M is a two-dimensional array of m rows
and n columns
The rows are indexed 1 to m and the columns are
indexed 1 to n
M[i,j] denotes the (i,j)th element of M, that is, the element
at the ith row and jth column position
Algorithms
Pseudocode Conventions
Subprograms (Procedures)
In a programming language,an algorithm is implemented in
the form of a subprogram, a.k.a. a subroutine or a module
Two types of subprograms
Functions
Returns a unique value
Procedure
Other types of subprograms
body of the function or procedure is enclosed between the
words begin and end
the execution of a return statement in a function terminates
the function
Algorithms
Pseudocode Conventions
Comments
In describing the steps of an algorithm, comments are
included wherever necessary to clarify the steps
Two types of comments: single-line and multi-line
Single-line comments start anywhere in the line
with the pair of symbols //
Multi-line comments are enclosed between the pair
of symbols /* and */
Specifies what the algorithm does, as well as the input
and output