Packet 2

advertisement
CSC 224/226 Notes Packet #2: Set Theory & Predicate Calculus
Barnes
Packet #2: Set Theory & Predicate
Calculus
Applied Discrete Mathematics
Table of Contents
Full Adder Information
Page 1
Predicate Calculus Information
First Hour Exam Study Sheet
Some First Hour Exam review material
Set Theory Information
Arithmetic Proofs Information
Pages 2-9
Page 10
Pages 11-16
Pages 17-26
Page 27
CSC 224/226 Notes Packet #2: Set Theory & Predicate Calculus
Barnes
Design of Full Adder
A full binary adder has 3 inputs
1. bit A (X)
2. bit B (Y)
3. carry in (C)
and 2 outputs
1. bit out (S)
2. carry to next digit (Cout )
Start by making truth table assuming all inputs and specifying all outputs.
X
Inputs
Y
C
Outputs
S
Cout
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
1
1
0
1
0
0
0
0
1
0
1
1
1
1
1
0
1
0
1
1
1
then write "and" condition for all "1" outputs then "or" all "and" conditions.
S = X'Y'C + X'YC' + XY'C' + XYC
Cout = X'YC + XY'C + XYC' + XYC
then simplify.
1
Predicate Calculus Outline
I.
Predicates - binding of variables to form propositions.
II.
General Quantifiers
A.  - Universal - means "for all"
B.  - Existential - means "there exists"
C.
D.
III.
Combinations of two variables using quantifiers
Distribution of negation using De Morgan's rules
Compound propositions of a single variable and proving set
theory problems (next topic that will be covered)
2
Predicate - function which becomes a proposition when the variables
are assigned values from an appropriate Universe of Discourse (U).
QUANTIFIERS
P(x): x2 > x
But these are:
(not a proposition)
- For all x in , x2 > x
- For some x in , x2 > x
- There exists x in  for which x2 > x
Predicates
1.
2.
3.
P(x): x2 > x
Choose value for x from .
P(5): 52 > 5
pin variable at 5
P(x) is not a proposition
P(x): x  x = x
P(x) is not a proposition
Choose value for x from P({0,1}).
P(0): 0  0 = 0 pin variable at 0
P(0) is a proposition
Q(x,y): (x < y)  (x2 < y2 )
Choose x,y from .
Q(-3,2): (-3 < 2)  ((-3)2 < 22 )
P(5) is a proposition
Q(x,y) is not a proposition
Q(-3,2) is a proposition
From predicates (P(x), Q(x)) one can form compound predicates:
¬P(x)
(P(x)  Q(x))
(P(x)  Q(x))
(P(x)  Q(x))
(P(x)  Q(x))
x P(x)
x Q(x)
Example:
[ x (P(x)  Q(x))  ( x P(x) x Q(x))]
3
Propositional Logic Equivalences and Implications Still Hold
Example:
( x P(x)  x Q(x))  ( ¬(x P(x))  x Q(x))
(implication equivalence)
Example:
x (P(x)  Q(x))  x P(x) x Q(x)
(modus ponens implication)
Also Have New Relationships:
De Morgan's Rules in Predicate Calculus
¬(x P(x))  x (¬P(x))
¬(x P(x))
P(x)

¬P(x)
x (¬P(x))
1
at least one
P(x) false
1
(at least
one true)
1
0
all P(x) true
1
(all false)
0
¬(x P(x))  x (¬P(x))
P(x)
¬(x P(x))  x (¬P(x)) ¬P(x)
all false
1
1
1
(all true)
at least
0
1
0
(at least
one true
one false)
4
Predicate Calculus Truth Table Example 1:
x P(x) x Q(x) x [P(x)  Q(x)]
We have two propositions on the left side which form the compound
proposition [x P(x) x Q(x)]. We must consider all combinations of the truth
values:
x P(x)
x Q(x)
x P(x) x Q(x)
x [P(x)  Q(x)]
0
0
0
1
0
0
Row 1
Row 2
1
1
0
1
0
1
Row 3
Row 4
Row 1:
x P(x) = 0  P(x) has at least one 0 (false for some value of x)
x Q(x) = 0  Q(x) has at least one 0
Therefore, P(x)  Q(x) has at least one 0
Therefore, x(P(x)  Q(x)) = 0
Row 2:
x P(x) = 0  P(x) has at least one 0
x Q(x) = 1  Q(x) = 1 for all x
P(x) Q(x) = 0 since P(x) = 0 for some x
Therefore, x(P(x)  Q(x)) = 0
Row 3:
Row 4:
x P(x) = 1
x Q(x) = 0
Work same way and show Case 3 = 0
x P(x) = 1
x Q(x) = 1
Work same way and show Case 4 = 1
x P(x) x Q(x) x [P(x)  Q(x)] is the same on both sides of the truth
table and therefore the statement is true.
5
Predicate Calculus Conversion Example:
We can prove that: x P(x) x Q(x) x [P(x) Q(x)] from our previous
statement without using truth tables:
Start:
x P(x) x Q(x) x [P(x)  Q(x)]
negate both sides
¬[x P(x) x Q(x)] ¬[x [P(x)  Q(x)]]
x [¬P(x)] x [¬Q(x)] x [¬P(x) ¬Q(x)]
substitute ¬P(x) = A(x)
¬Q(x) = B(x)
x [A(x)] x [B(x)] x [A(x) B(x)]
Predicate Calculus Truth Table Example 2:
Is x P(x)x Q(x) x [P(x)  Q(x)] true?
x P(x)
x Q(x)
x P(x) x Q(x)
0
0
0
1
0
1
Row 1: Can be true for
some P(x)  Q(x) and
1
1
0
1
1
1
therefore not logically
equivalent. (See example
below.)
Row 1:
x [P(x)  Q(x)]
x P(x) = 0  P(x) has at least one 0
x Q(x) = 0  Q(x) has at least one 0
Does P(x)  Q(x) always have at least one "0" for any P(x)
and Q(x)?
x P(x) x Q(x) P(x)
Q(x) P(x) Q(x)
x [P(x)  Q(x)]
0
0
1
0
1
1
0
0
0
1
1
1
6
Predicate Calculus Truth Table Example 3 (Independent Variables):
x P(x) y Q(y) x y [P(x)  Q(y)]
We have two propositions on the left side which form the compound proposition
x y [P(x)  Q(y)].We must consider all combinations of the truth values:
x P(x)
y Q(y)
x P(x) y Q(y)
x y [P(x) Q(y)]
0
0
1
0
1
0
0
1
1
Row 1
Row 2
Row 3
1
1
1
Row 4
Row 1:
y Q(y) = 0  Q(y)=0 for all y values
Therefore, sub in Q(y)=0 to get x y [P(x) 0 ] = x y P(x) = x P(x)
Therefore, since x P(x) is false, then x y [P(x) Q(y)] = 0
Row 2:
y Q(y) = 1  Q(c)=1 for some c
Therefore, sub in Q(y)=1 to get x y [P(x) 1 ] = x y 1 = 1
Therefore, x y [P(x) Q(y)] = 1
Row 1:
y Q(y) = 0  Q(y)=0 for all y values
Therefore, sub in Q(y)=0 to get x y [P(x) 0 ] = x y P(x) = x P(x)
Therefore, since x P(x) is true, then x y [P(x) Q(y)] = 1
Row 2:
y Q(y) = 1  Q(c)=1 for some c
Therefore, sub in Q(y)=1 to get x y [P(x) 1 ] = x y 1 = 1
Therefore, x y [P(x) Q(y)] = 1
x P(x) y Q(y) x y [P(x)  Q(y)] is the same on both sides of the truth
table and therefore the statement is true. In this case, the variables in each
predicate are independent, so the order of the quantifiers DOES NOT MATTER.
7
Example: Definition of Continuity
A function of f is continuous on the real numbers if and only if
 [( > 0) (( > 0) xy [x - y < f(x) - f(y)< ])]
Universe of Discourse = 
One can negate an expression. For example, consider the expression
x [P(x)  y Q(y)], negating gives the following:
¬ x [P(x)  y Q(y)]
x ¬ [P(x) y Q(y)]
x ¬ [¬P(x) y Q(y)]
x [P(x)  ¬(y Q(y))]
x [P(x)y ¬(Q(y))]
**Recommended: Negate the definition of continuity: i.e., f is not
continuous on  …
8
Given the following predicates, evaluate the propositions generated
by using the indicated quantifiers with those predicates.
P(x,y) x  {0,1}, y  {0,1}
Quantifiers
P(x,y) x , y 
x2 + y = y2 + 2x
xy = yx
0 (x = 1 and y = 2 is false)
0 (x = 1 and y = 0 is false)
xy = yx
1 (x = 0 and y = 0 is true)
1 (x = 0 and y = 0 is true)
xy
1
0: (2x - x2 ) < 4 , for x = 1 is imag
1: y = 1
yx
See ** below.
0
1: y = 1
1: y - y2 < 1, is real for all y
See * below.
0
yx
xy

*yx Case: x2 + y = y2 + 2x
x2 - 2x - (y2 - y) = 0
x=
xy
2
4 + 4(y2 - y)
2
1: x = 0
1: x = 0
**: xy Case: x2 + y = y2 + 2x
y2 - y - (x2 - 2x) = 0
y=
1
1 + 4(x2 - 2x)
2
(4 + 4(y2 - y)) > 0
4(y2 - y) > -4
(1 + 4(x2 - 2x)) > 0
4(x2 - 2x) > -1
y2 - y > -1
1
x2 - 2x > -4
y - y2 < 1
1
2x - x2 < 4
is true for all values
is false when x = 1
of y
9
First Hour Exam Study Sheet
I.
Truth tables
Be able to prove a logical equivalence or implication with a truth table.
II.
General knowledge
Be familiar with:
DeMorgan's laws that relate  to 
modus ponens,
modus tollens,
contrapositive,
implication laws relating  to  and 
transitivity laws,
constructive and destructive dilemmas for combining
multiple implications,
etc.
III.
Understand a direct proof as well as an indirect proof such as
contradiction
IV.
Be able to follow and give reasons for each step in a propositional
calculus proof
V.
Be able to test if a proposition is true by use of a truth table and give
formal proof if true or counter example if false
VI.
Be able to prove a proposition by contradiction
proof by
VII. Logic circuits
A. Be able to produce logic statements from a logic circuit
B. Be able to change the form of the logic statement by use
of logical equivalences
C. Be able to produce a logic circuit from the logic
statement
D. Know the symbols for and's, or's, nand's, nor's, etc.
VIII. Predicate Calculus
A. Know quantifiers, FOR ALL and THERE EXISTS
B. Be able to apply DeMorgan’s and other logical equivalence rules to
predicate calculus statements
C. Be able to prove logical impications and logical equivalences in
predicate calculus using truth tables
D. Be able to write predicate calculus statements in English and convert
English statements to predicate calculus.
10
Some First Hour Exam Review Material
These proofs are intended as extra practice problems for the first hour exam.
They do not have to be turned in and will not be collected. However, they are
recommended, since the same types of problems will be encountered on the
exam. A solution for each problem is attached. Reminder: There are a variety
of solutions for each problem, so your solution may or may not match the
solution given. Do a direct and indirect proof for each.
1.
Given:
p  (q  r)
Prove:
sr
(p  ¬s)
q
2.
Given:
pq
rs
(q  s)  ¬t
Prove:
t  (¬p  ¬r)
3.
Given:
p  (q  r)
qs
Prove:
p  (r  s)
11
Solutions
1.
Direct Proof:
Statement
1. p  (q  r)
2. (p  ¬s)
Given
Given
3.
4.
q
¬p  ¬s
Given
2; Implication (rule 10a)
5.
6.
7.
8.
9.
10.
11.
sp
s  (q  r)
s  (¬q  r)
(¬s  (¬q  r))
((¬s  r)  ¬q)
(¬s  r)
sr
4; Contrapositive (rule 9)
1,5; Hypothetical Syllogism (rule 24)
6; Implication (rule 10a)
7; Implication (rule 10a)
8; Associate (rule 3a)
3,9; Disjunctive Syllogism (rule 21)
10; Implication (rule 10a)
Reason
Indirect Proof:
Statement
1. p  (q  r)
2. (p ¬s)
Given
Given
3.
4.
5.
6.
7.
Given
Negation of Conclusion
4; Implication (rule 10b)
2; Implication (rule 10a)
6; Contrapositive (rule 9)
q
¬(s  r)
(s  ¬r)
¬p  ¬s
sp
Reason
8. s
9. p
10. q  r
5; Simplification (rule 17)
7,8; Modus Ponens (rule 19)
1,9; Modus Ponens (rule 19)
11. ¬r
12. ¬q
13. (¬q  q)
5; Simplification (rule 17)
10,11; Modus Tollens (rule 20)
3,12; Conjunction (rule 34)
14. Contradiction
13; Rule 7b
12
2.
Direct Proof:
Statement
1. p  q
2. r  s
3. (q  s)  ¬t
4. (p  r)  (q  s)
5. (p  r)  ¬t
6. t  ¬(p  r)
Given
Given
Given
1,2; Constructive Dilemmas (rule 26a)
3,4; Hypothetical Syllogism (rule 24)
5; Contrapositive (rule 9)
7.
6; DeMorgan (rule 8a)
t  (¬p  ¬r)
Reason
Indirect Proof:
Statement
1. p  q
2. r  s
3. (q  s)  ¬t
4. ¬[t  (¬p  ¬r)]
5. ¬[t  ¬(p  r)]
6. (t  (p  r))
Given
Given
Given
Negation of Conclusion
4; DeMorgan (rule 8a)
5; Implication (rule 10b)
7.
8.
9.
10.
6; Simplification (rule 17)
6; Simplification (rule 17)
1,2; Constructive Dilemmas (rule 26a)
8,9; Modus Ponens (rule 19)
t
(p  r)
(p  r)  (q  s)
(q  s)
Reason
11. ¬t
12. (t  ¬t)
3,10; Modus Ponens (rule 19)
7,11; Conjunction (rule 34)
13. Contradiction
12; Rule 7b
13
3.
Direct Proof:
Statement
1. p  (q  r)
2. q  s
3. (q  r)  (s  r)
4. p  (s  r)
5. p  (r  s)
Reason
Given
Given
2; Rule 25a
1,3; Hypothetical Syllogism (rule 24)
4; Commutative (rule 2a)
Indirect Proof:
Statement
1. p  (q  r)
2. q  s
3. ¬(p  (r  s))
4. (p  ¬(r  s))
Given
Given
Negation of Conclusion
3; Implication (rule 10b)
5.
6.
7.
p
¬(r  s)
(¬r  ¬s)
4; Simplification (rule 17)
4; Simplification (rule 17)
6; DeMorgan (rule 8a)
8.
¬r
7; Simplification (rule 17)
9.
10.
11.
12.
¬s
¬q
(¬q  ¬r)
¬(q  r)
7; Simplification (rule 17)
2,9; Modus Tollens (rule 20)
8,10; Conjunction (rule 34)
11; DeMorgan (rule 8a)
Reason
13. ¬p
14. (¬p  p)
1,12; Modus Tollens (rule 20)
5,13; Conjunction (rule 34)
15. Contradiction
14; Rule 7b
14
More First Hour Exam Review Material
These proofs are intended as extra practice problems for the first hour exam. They do
not have to be turned in and will not be collected. However, they are recommended,
since the same types of problems will be encountered on the exam. A solution for each
problem is attached. Reminder: There are a variety of solutions for each problem, so
your solution may or may not match the solution given. Do a direct proof for each.
1.
Given:
p q
rs
Prove:
qs
rp
2.
Given:
pq
rs
q s
Prove:
 (p  r)
3.
Given:
p s
q p
q
Prove:
s
4.
Use the contrapositive and DeMorgan’s laws on the right side of the following:
[(p  q)  (r  s)]  [(p  r)  (q  s)] (Note: This is the Constructive Dilemma)
to obtain the following:
[(p  q) (r  s)] [(q  s)  (p  r)] (Note: This is Destructive Dilemma).
5.
Use the implication rule on the left side of the following:
[(p  q)  q ]p (Note: This is Modus Tollens)
to obtain the following:
[(p  q)  q]  p (Note: This is Disjunctive Syllogism).
15
Solutions
1.
1.
2.
3.
4.
5.
6.
Statement
pq
rs
r  p
(p  r)  (q  s)
pr
qs
Reason
Given
Given
Given
1,2; Constructive Dilemmas (rule 26a)
3; Commutative Laws (rule 2a)
4,5; Modus Ponens (rule 19)
2.
1.
2.
3.
4.
5.
6.
Statement
pq
rs
q  s
 (q  s)
(p  r)  (q  s)
 (p  r)
Reason
Given
Given
Given
3; DeMorgan’s Laws (rule 8b)
1,2; Constructive Dilemmas (rule 26b)
4,5; Modus Tollens (rule 20)
3.
1.
2.
3.
4.
5.
Statement
ps
qp
q
p
s
Reason
Given
Given
Given
2,3; Disjunctive Syllogism (rule 21)
1,4; Modus Ponens (rule 19)
----------------------------------------------------------------------------------------------------------4. [(p  q)  (r  s)]  [(p  r)  (q s)]
5.
[(p  q)  (r  s)]  [ (q s)   (p  r)]
[(p  q)  (r  s)]  [(q  s)  (p  r)]
Contrapositive
DeMorgan’s
[(p  q)  q]  p
[(p  q)  q]  p
Implication
16
Set Theory Outline
I.
Definitions
II.
Operations
III.
Use of Venn Diagrams
IV.
Set Proofs using Set Theory and Predicate Calculus
17
Sets
Use capital letters such as A, B, C for set designation.
Use small letters such as a, b, c for elements of a set.
A = {a,b,c}
{elements}
 = is element of
aA
A represents cardinality (number of elements) of a set.
A = {a,b,c} = 3
Sets can be represented by a general description.
B = {n  n  P}
The elements of B are n such that n is an element of P.
There are some special representations:
[a,b] = {x  a  x  b}
[a,b) = {x : a  x < b}
(a,b] = {x : a < x  b}
(a,b) = {x: a < x < b}
Note:
[1,2]
(1,2)
{1,2}
infinite number of elements
infinite number of elements
two elements
 (also written { }) is the symbol for the empty set (the set with no
elements).
Elements of a set can be sets:
A = {1,2,3}
B = {a,b,c,d}
C = {A,B}
A = 3
B = 4
C = 2
18
Note:
 = 0
However
{} = 1
P(A) is the power set of A. The power set is the set of elements
which are all possible subsets of A. For any set A,  A. (The empty set is a
subset of all sets.)
Examples:
A = {0,1}
Subsets of A: , {0}, {1}, {0,1}
P(A) = {,{0},{1},{0,1}}
A = {a,b,c}
Subsets of A: , {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}
P(A) = {,{a},{b},{c},{a,b},{a,c},{b,c},{a,b,c}}
Suppose
A=
P(A) = {}
A = {a,b}
P(A) = {,{a},{b},{a,b}}
A = 0
{} = 1
A = 2
P(A) = 4
A = 3
P(A) = 8
A = n
P(A) = 2n
prove by induction
A=
P(A) = 1
A = 0
20 = 1
true for zero
A = n + 1
A = {e1 ,e2 ,…,en ,en+1 }
P(A) = P(A/{e n1 }) + P[(A/{en+1 }) {en+1 }]
P(A)
2  2n
= 2n + 2n
= 2n+1
19
Set Operations
Let:
A = {1,2,5,7,9}
B = {1,5,6,8}
 = union of sets
A  B = {x  x  A or x  B}
A  B = {1,2,5,6,7,8,9}
 = intersection of sets
A  B = {x  x A and x  B}
A  B = {1,5}
\ or - = difference (relative complement) of sets
A/B = {x  x  A and x  B}
Also written as (A  Bc ) or (A - B)
A/B = {2,7,9}
B/A = {6,8}
 = symmetric difference (xor) of sets
A  B = {x  (x  (A  B)) and (x  (A  B))}
Also written as (A/B  B/A)
A  B = {2,6,7,8,9}
= subset of a set
A B = {x  if x  A then x B}
= proper subset of a set
A B = {x  if x  A then x  B, but not for all x  B}
Also written as (A ≠ B)
U = universal set being considered
i. e.: , etc.
c = absolute complement of a set
Ac = {x  x  A}
Also written as (U/A)
20
Laws of Algebra of Sets
1.
Commutative Laws
a.
A B = B  A
b.
AB=BA
2.
Associative Laws
a.
(A  B)  C = A  (B  C)
b.
(A  B)  C = A  (B  C)
3.
Distributive Laws
a.
A  (B  C) = (A  B)  (A  C)
b.
A  (B  C) = (A B)  (A  C)
4.
Idempotent Laws
a.
AA=A
b.
AA=A
5.
Identity Laws
a.
A  = A
b.
A  = 
c.
d.
AU=U
AU=A
6.
Double Complementation
(Ac )c = A
7.
a.
b.
8.
a.
b.
9.
A  Ac = U
A  Ac =
Uc = 
c = U
De Morgan Laws
a.
(A  B)c = Ac  Bc
b.
(A  B)c = Ac  Bc
21
Venn Diagrams
Union - A  B
Intersection - A  B
Relative Complement - A/B
Symmetric Difference - A  B
22
Absolute Complement - Ac
Examples:
1.
Show (A-B)-C ≠ A-(B-C)
Let A = {1,2} B = {1,3} C = {2,3}
Then (A-B)-C = {2}-{2,3} = ,
but A-(B-C) = {1,2}-{1} = {2}
2.
Show (A-B)-C
(A-B)-C
A-(B-C)
A-(B-C)
23
Examples involving the empty set:
{n  2 < n < 3} = 
{r Qr2 = 2} = 
{x  x2 < 0} = 
Illustration of the Distributive Laws:
A  (B  C) = (A  B)  (A  C)


Consider De Morgan's Laws:
(A  B)c = Ac  Bc
(A  B)c
Ac  Bc
24
Computer Representation of Subsets of a Small Set S
3-bit binary numbers
a
b
c
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
S = {a,b,c}
Elements of P(S)

{c}
{b}
{b,c}
{a}
{a,c}
{a,b}
{a,b,c}
If S = k then P(S) = 2k .
Cardinality - size of set
finite - if number of elements is n for some n .
infinite- otherwise
Set
{a,b,c}
{2,4,…,12}
{x  x2 + 1 = 0}
Cardinality
3
6
{2x + 1 x P}
infinite
[0,1)
, Q, Z, P, C
infinite
infinite
0
25
Examples
1.
2.
3.
4.
5.
6.
7.
8.
Q  = Q
-Q = Irrationals
-P = {0}
Z  P = {0,-1,-2,-3,…}
 P = 
(0,1)  Z = 
(0,1)  [1,2] = (0,2]
(0,1)  (1,2) = 
True or False?
1.
[(A  B)  (B
C)] (A  C)
True: B = {A,…}
2.
[(A  B)  (B
C
C)]  (A
C)
False: Counter-example:
A = {1}, B = {{1},2}, C = {{1},2,3}
3.
[(A  B)  (B  C)]  (A
C)
False: Counter-example:
A = {1}, B = {{1},2}, C = {{{1},2},3}
26
Arithmetic Proofs Information
N = Natural numbers
0,1,2,3,...
P = Positive integers
1,2,3,...
Z = all integers
...-3,-2,-1,0,1,2,3,...
Q = all rational numbers (ratio of two integers m/n)
R = all real numbers
1.)
We will deal most often with integers
A.
Integers are closed under
1.
addition
2.
multiplication
Integers closed under an operation means that if you start with integers
and perform these operations, you will end up with an integer.
2+3=5
all integers
4 * 7 = 28 all integers
9
4
= (2.25) 9 and 4 are integers
but (2.25) is not an integer.
Therefore, integers are not closed under division
B.
Other properties we will assume:
1.
Normal arithmetic rules apply:
a.
2+3=5
b.
4 * 7 = 28
2.
c.
12/3 = 4, etc.
Properties of numbers
a.
x even  x = 2n (where n is an integer)
b.
x is odd  x = 2n + 1 (where n is an integer)
c.
d.
x is rational  x = m/n where m and n are integers
x is prime  x > 1 (and cannot be factored except by 1
and x)
e.
x is an integer  x is prime or a product of primes
f.
g.
if "a" and "b" are integers; there exist two integers "q"
and "r" such that: a = q*b + r where 0  r < b.
xy = 0  x = 0, y = 0, or both x and y = 0
27
28
Download