mt263f-11 discrete structures li tak sing( 李德成 ) [email protected] room a0936 27686816
TRANSCRIPT
mt263f-1 2
Textbook: Discrete Structures, Logics, and Computability by James L. Hein (2nd Edition)
On Fridays, the second hour will be tutorial and tutorial worksheets will be distributed. They will not be assessed.
Test: Two Tests
Examination: 3 hr examination in late April to mid May
Course result: Test(30%), Examination(70%)
You must have at least 40 marks in both the total score.
mt263f-1 3
Syllabus
Data types, functions, and data structures;Formal logic, recursion, proofs;Algorithms and analysis of algorithms;Formal languages, Turing machines.
mt263f-1 4
Web site
You can find online materials at:http://plbpc001.ouhk.edu.hk/~comps263f
mt263f-1 5
Elementary Notions and Notations
This is related to chapter one of the text book
Logical Statements – statements that can either be true or false.
For example, I am an OUHK student.
mt263f-1 6
Negation
If S represents a logical statement, then negation of S represents the statement “not S”.
If S is: I am a OUHK student, then “not S” is: I am not a OUHK student.
mt263f-1 7
Truth table
A truth table list out all the possible values of different logical statements in different scenarios. So if we list S and “not S” in a true table, we would have:
S Not S
True false
False true
mt263f-1 8
Conjunction
The conjunction of A and B is the statement “A and B”
A B A and B
True True True
True False False
False True False
False False False
mt263f-1 9
Disjunction
The disjunction of A and B is “A or B”.
A B A or B
True True True
True False True
False True True
False False False
mt263f-1 10
Comparison of two logical statements
Two logical statements are equal if and only if they have the same values as listed in a true table.
mt263f-1 11
“not (A and B)” and “(not A) or (not B)”
A B A and B Not (A and B)
T T T F
T F F T
F T F T
F F F T
A B Not A Not B (Not A) or (not B)
T T F F F
T F F T T
F T T F T
F F T T T
This is also known as DeMorgan’s Thereom
mt263f-1 12
Other equivalent logical statements
A and B = B and A (commutative)A or B = B or A (commutative)A and (B and C) = (A and B) and C
(associative)A or (B or C) = (A or B) or C (associative)A and (B or C) = (A and B) or (A and C)
(distributive)
mt263f-1 13
A or (B and C) = (A or B) and (A or C) (distributive)
not (A and B) = (not A) or (not B) (DeMorgan’s theorem)
not (A or B) = (not A) and (not B) (DeMorgan’s theorem)
true and A = Afalse and A = false
mt263f-1 14
true or A = truefalse or A = Anot (not A) = AA and (A or B) = A (absorption)A or (A and B) = A (absorption)
mt263f-1 15
Conditional statements
If A then B. If 3=3 then 2=2 (true) If 3=3 then 2=1 (false) If 3=2 then 2=2 (true) If 3=2 then 2=1 (true)
A B If A then B
True True True
True False False
False True True
False False True
mt263f-1 16
if and only if
“A if and only if B” is actually “if A then B” and “if B then A”. “if and only if” is often written as iff
A B if A then B if B then A A iff B
T T T T T
T F F T F
F T T F F
F F T T T
“A iff B” is true only if both A or B have the same value. A iff B if A is equivalent to B
mt263f-1 17
“If A then B” and “If not B then not A”
A B Not A Not B If not B then not A
T T F F T
T F F T F
F T T F T
F F T T T
So we can see that “if A then B” and “if not B then not A” are equal logical statements.
mt263f-1 18
•So the following statements are equivalent:
•If the room is available, then we can take it.
•If we cannot take the room, then it is not available.
mt263f-1 19
Other equivalent logical statements
Not (A or B) (not A) and (not B)
A and (B or C) (A and B) or (A and C)
A or (B and C) (A or B) and (A or C)
If A then B (not A) or B
Not (if A then B) A and (not B)
mt263f-1 20
Proof techniques
Proof by Exhaustive CheckingThis means that you check every possible case
to see that the statement is true.This is only possible if the number of cases is
finite.
mt263f-1 21
For example, we want to prove the statement:All integers between 10 and 15 exclusive are not square of another integer.Proof: The numbers between 10 and 15 exclusive are 11, 12, 13, 14. We can then check each of these numbers and find that
741.314
605.313
464.312
316.311
Therefore, we have proved the statement
mt263f-1 22
Conditional Proof
Many statements that we want to proof are in the form “if A then B”. We should start the argument from A and then we should arrive at B.
mt263f-1 23
Prove the statement: if n is an odd integer, then n2 is also an odd integer.
Proof: n is an odd integer. Let n=2k+1 where k is an integer. Therefore, n2=4k2+4k+1=2(k2+2k)+1Now, 2(k2+2k) is an even number, therefore 2(k2+2)+1 is an odd number. Therefore n2 is an odd number.
There are more examples in the textbook.
mt263f-1 24
Set
A set is a collection of things called its elements, members or objects. If S is a set and x is an element in S, then we write
xSIf x is not an element in S, then we write
xSEvery element in a set must be distinct. We are not interested in the order of its
elements.
mt263f-1 25
Describing Sets
List out the elements:A={a,b,c}B={0,1,....,100}C={0,1,1,2} : this is not a set as it has two elements that are equal to 1.
Empty set:{},
mt263f-1 26
Equality of sets
Two sets are equal if they have the same elements.
{1,2,3}={3,2,1}A = B iff (xA iff xB)One consequence is that all empty sets
are equal because they all contain no elements.
mt263f-1 27
Finite and infinite sets
Finite sets are sets that contain finite number of elements. For example A={1,2,3}
Infinite sets are sets with in infinite number of elements. For example: N={0,1,2,3,...}, Z={....-2,-1,0,1,2,3...}
mt263f-1 28
Describing sets by properties
S={x| x has property P}A={x| x is an even number}R={x| x is a real number}
mt263f-1 29
Subsets
If every element of A can be found in B, then A is a subset of B, and is written as:AB
If A is not a subset of B, we write:
ABVenn diagram is a graphical
representation of sets. The following Venn diagram represents AB.
mt263f-1 30
A
B
A
mt263f-1 31
•Consequence: if A is a set, then AA.•Proof: if A is a set, then every element in A is in A, therefore AA.Consequence: if A is a set, then A.•Proof: the condition of A is that every element of should be in A. The other way to put it is: you cannot find any element that is in but not in A. Now, this statement is true because you cannot find any element in .
mt263f-1 32
ExampleProve that AB where A={x|x>4}, B={x|x2>1}For every xA,
x>4x2>16x2>1xB
So every x in A is also in B, so AB
mt263f-1 33
Power set
A power set of S is the set that contains all the subsets of S. The power set is denoted as power(S).
If S={a,b,c}, thenpower(S)={,{a},{b},{c},{a,b},{b,c},{c,a}, {a,b,c}}
If S is a set with n elements, then power(S) is a set with 2n elements.
mt263f-1 34
Equality of sets
A=B means AB and BA
mt263f-1 35
Union
The union of two sets A and B is the set of all the elements that are either in A or in B.
It is denoted as AB.AB={x| xA or xB}The following figure represents AB.
mt263f-1 36
A B
mt263f-1 37
Properties of Union
A=AAB=BA (commutative)A(BC)=(AB) C (associative)AA=AAB if and only if AB=B.
Proof of A=A Obviously, A ANow, we want to prove that A A.For every x A x A or x x A or falsex ATherefore, A ATherefore A=A
mt263f-1 38
Proof of AB if and only if AB=B
If AB, xAx BNow, BAB, we want to prove that
ABB.x AB
x A or x B x B or x B (since xAx B) x B
Therefore ABBTherefore AB=B
mt263f-1 39
Proof of AB if and only if AB=B (Cont.)Assume AB=B xA
xA or xB xAB xB (since AB=B )
Therefore AB
mt263f-1 40
mt263f-1 41
Intersection of sets
The intersection of two sets A and B is the set of all elements that are in both A and B.
It is denoted as AB.A B={x| xA and xB}The following figure represents A B.
mt263f-1 42
A B
mt263f-1 43
Properties of Intersection
A=AB=BA (commutative)A(BC)=(AB) C (associative)AA=AAB if and only if AB=A
Proof of A=
Obviously, A.Now, we just have to prove that A.x A
x A and x x A and falsefalse x
Therefore, A Therefore A=
mt263f-1 44
Proof of AB if and only if AB=A
Assume that AB, we want to prove that AB=A.
Obviously, ABAxA
xA and xB (since AB)xAB
Therefore AB=A
mt263f-1 45
Proof of AB if and only if AB=A(cont.)Assume that AB=AxA
xAB (since AB=A) xA and xB xB
Therefore AB
mt263f-1 46
mt263f-1 47
Difference of sets
If A and B are sets, then the different A-B is the set of elements in A that are not in B.
A-B={x| xA and xB}
mt263f-1 48
A B
mt263f-1 49
Symmetric Difference of Sets
The symmetric difference of sets A and B is the set AB of elements that are either in A or in B but not both.
AB={x| (xA or xB) and not (xA and xB) }
mt263f-1 50
A B
mt263f-1 51
Complement of a Set
The complement of A is the set that contain all elements except those in A.
A’={x| xA}
mt263f-1 52
Combining properties
A(BC)=(AB)(AC) (distributive)A(BC)=(AB)(AC) (distributive)A(AB)=A (absorption)A(AB)=A (absorption)(A’)’=A(AB)’=A’B’ (DeMorgan’s theorem)