Discrete Mathematics (H) Midterm Review Note
Published:
1 Logic
1.1 Propositional Logic
1.1.1 Propositions
A proposition is a declarative sentence that is either true or false, but not both. For example, “SUSTech is in Shenzhen” is a proposition, while “No parking on campus” is not a proposition.
1.1.2 Logical Connectives
There are six logical connectives in propositional logic, which are negation(), conjunction(), disjunction(), exclusive or(), implication(), and biconditional().
For implication , we call the hypothesis and the conclusion.
The converse of is . The inverse of is . The contrapositive of is .
1.1.3 Tautologies and Contradictions
A tautology is a proposition that is always true, regardless of the truth values of its individual components. A contradiction is a proposition that is always false. A contingency is a proposition that is neither a tautology nor a contradiction.
1.1.4 Logical Equivalences
Two propositions are logically equivalent if they have the same truth values for all possible combinations of truth values of their component propositions.
The propositions and are logically equivalent if and only if is a tautology, denoted by or .
1.1.5 Important Logical Equivalences
- •
Identity laws
- •
Domination laws
- •
Idempotent laws
- •
Double negation laws
- •
Commutative laws
- •
Associative laws
- •
Distributive laws
- •
De Morgan’s laws
- •
Absorption laws
- •
Negation laws
- •
Useful law
1.2 Predicate Logic
1.2.1 Predicates and Quantifiers
A constant models a specific object. A variable represents objects of specific type. A predicate represents properties or relations among objects.
However, a predicate is not a proposition, because it is not a declarative sentence. It becomes a proposition when the variable is assigned a value. Additionally, the universal quantification and existential quantification of a predicate is a proposition. For example, is not a proposition, while and are propositions.
The universe(domain) of a predicate is the set of all objects that can be substituted for the variables in a predicate. The truth set of a predicate is the set of objects in the universe that can be substituted for in to make the resulting proposition true.
The truth values of and depend on both the universe and the predicate .
1.2.2 Precedence of Quantifiers
The quantifiers and have higher precedence than all the logical operators. For example, means , not .
1.2.3 Translation with Quantifiers
Universal quantification
Sentence: All SUSTech students are smart.
Universe: all students
Translation:
Typical error: , which means all students are at SUSTech and smart.
Existential quantification
Sentence: Some SUSTech students are smart.
Universe: all students
Translation:
Typical error: , this is true if there is anyone who is not at SUSTech.
1.2.4 Nested Quantifiers
The order of nested quantifiers is important. For example, let denotes “ loves ”, then means “Everyone loves someone”, while means “There is someone whom everyone loves”.
However, the order of nested quantifiers does not matter if quantifiers are of the same type.
1.2.5 Negating Quantifiers
- •
- •
- •
2 Mathematical Proofs
2.1 Theorems and Proofs
2.1.1 Definitions
An axiom or postulate is a statement or proposition that is regarded as being established, accepted, or self-evidently true. A theorem is a statement or proposition that can be proved to be true. A lemma is a statement that can be proved to be true, and is used in proving a theorem.
In formal proofs, steps follow logically from the set of premises, axioms, lemmas, and other previously proved theorems.
2.1.2 Rules of inference
- •
Modus Ponens:
- •
Modus Tollens:
- •
Hypothetical Syllogism:
- •
Disjunctive Syllogism:
- •
Addition:
- •
Simplification:
- •
Conjunction:
- •
Resolution:
- •
Universal instantiation:
- •
Universal generalization:
- •
Existential instantiation:
- •
Existential generalization:
2.1.3 Methods of Proof
To proof :
- •
Direct proof: Show that if is true then follows.
- •
Proof by contrapositive: Show that .
- •
Proof by contradiction: Show that contradicts the assumptions.
- •
Proof by cases: Give proofs for all possible cases.
- •
Proof of equivalence : Prove and .
3 Sets and Functions
3.1 Sets
3.1.1 Definitions
A set is an unordered collection of objects, called elements or members of the set. We can represent a set by listing its elements between braces, or defining a property that its elements satisfy.
3.1.2 Important Sets
- •
is the set of natural numbers.
- •
is the set of integers. is the set of positive integers.
- •
is the set of rational numbers.
- •
is the set of real numbers.
- •
is the set of complex numbers.
- •
is the set of all objects under consideration.
- •
is the empty set. Note:
- •
is the power set of , which is the set of all subsets of .
- •
Disjoint sets and are sets that have no elements in common, i.e., .
3.1.3 Set Operations
- •
Union:
- •
Intersection:
- •
Difference:
- •
Complement:
- •
Cartesian product:
3.1.4 Cardinality
The cardinality of a set , denoted by , is the number of distinct elements in the set. The sets and have the same cardinality if there is a one-to-one correspondence between them. If there is a one-to-one function from to , the cardinality of is less than or equal to the cardinality of , denoted by .
A set that is either finite or has the same cardinality as the set of positive integers is called countable. A set that is not countable is called uncountable.
Here are some examples of countable and uncountable sets:
- •
Countable Sets: , the set of finite strings over a finite alphabet
- •
Uncountable Sets: ,
The subset of a countable set is still countable.
To prove a set is countable, we can use Schröder-Bernstein theorem. If there are one-to-one functions and , then there is a one-to-one correspondence between and , and .
To prove a set is uncountable, we can use Cantor’s diagonalization method. Assume that is countable, then we can list all elements of in a table. Then we can construct a new element that is not in the table, which contradicts the assumption that is countable.
For power set, we have the following formula:
For union and intersection, we have the following formulas:
For Cartesian product, we have the following formula:
Note: and
3.1.5 Computable vs. Uncomputable
We say a function is computable if there is an algorithm that can compute the function’s value for any input in a finite amount of time.
There are functions that are not computable. This is true because the set of computer programs is countable, while the set of functions from to the set is uncountable. (Cantor’s diagonalization method)
3.1.6 Cantor’s Theorem
For any set , .
This is obviously true for finite sets, because . (Note that )
For infinite sets, we can prove this by contradiction. Assume that , then there is a one-to-one correspondence between and . Let be a function from to , then we can construct a set . Since is a one-to-one correspondence, there must be an element such that . However, implies , which is a contradiction.
To build a one-to-one function from to is trivial, because we can just map each subset of to its smallest element.
Hence, we know that and . Therefore, .
3.1.7 Set Identities
- •
Identity laws
- •
Domination laws
- •
Idempotent laws
- •
Complementation laws
- •
Commutative laws
- •
Associative laws
- •
Distributive laws
- •
De Morgan’s laws
- •
Absorption laws
- •
Complement laws
3.2 Tuples
An ordered -tuple is a sequence of elements, where is a positive integer.
3.3 Functions
3.3.1 Definitions
Let and be sets. A function from to , denoted by , is an assignment of exactly one element of to each element of .
We represent a function by a formula or explicitly state the assignments between elements of and . For example, let and , then can be represented by .
Let be a function. We say that is the domain of and is the codomain of . If , is the image of under , and is a preimage of . The range of is the set of all images of elements of , denoted by .
3.3.2 Injective, Surjective, and Bijective Functions
A function is injective (one-to-one) if and only if implies for all . A function is surjective (onto) if and only if . A function is bijective (one-to-one correspond) if and only if is both injective and surjective.
The inverse of a function, denoted by , is only defined for bijective functions.
3.3.3 Sequences
A sequence is a function from a subset of integers (typically or ) to a set . We use the notation to denote the image of under the function, and we call the th term of the sequence.
4 Complexity of Algorithms
4.1 Big- Notation
We say that (reads as “ is big- of ”) if there are positive constants and such that for all .
Important big- estimation:
- •
- •
(Actually we can prove )
- •
for any
- •
for any and
Similarly, we can define big- and big-.
4.2 Algorithms
An algorithm is a finite set of precise instructions for performing a computation or for solving a problem. A computational problem is a specification of the desired input-output relationship. An instance of a computational problem is a specific input. A correct algorithm halts with the correct output for every instance of the problem, and we can say that the algorithm solves the problem.
4.2.1 Time and Space Complexity
The time complexity of an algorithm is the number of machine operations it performs on an instance. The space complexity of an algorithm is the number of cells of memory it uses on an instance.
4.2.2 Input Size
The input size is the number of bits needed to represent the input. For an integer , the input size actually is (or just ). Therefore, an algorithm that runs in seems to be linear and efficient, but it is actually exponential ().
We say two positive functions and are of the same type if and only If
for all large and some positive constants .
Therefore, all polynomial functions are of the same type, and all exponential functions are of the same type. But polynomial functions are not of the same type as exponential functions.
4.2.3 Decision Problems and Optimization Problems
A decision problem is a question that has two possible answers: yes or no. An optimization problem is a question that requires an answer that is an optimal configuration.
If is a decision problem and is the input, we often write to mean that the answer to the decision problem is yes, and to mean that the answer is no.
An optimization problem usually has a corresponding decision problem.
4.2.4 Complexity Classes
We divide the set of all decision problems into three complexity classes.
A problem is solvable (tractable) in polynomial time if there is an algorithm that solves the problem and the number of steps required by the algorithm on any instance of size is for some constant .
The class is the set of all decision problems that are solvable in polynomial time. The class is the set of all decision problems for which there exists a certificate for each yes-input that can be verified in polynomial time.
4.2.5 NP Completeness
Reduction is a relationship between two problems. We say can be reduced to if every instance of can be transformed into an instance of such that the answer to the transformed instance is yes if and only if the answer to the original instance is yes.
A polynomial-time reduction from to is a reduction that can be performed in polynomial time, denoted by . Intuitively, this means is no harder than .
A problem is NP-complete if and only if
- •
- •
Every problem ,
Therefore, if we can find a polynomial-time algorithm for an NP-complete problem, then we can solve all NP problems in polynomial time.
5 Number Theory
5.1 Divisibility and Modular Arithmetic
5.1.1 Divisibility
Let be integers. Then the following holds:
- •
If and , then and .
- •
If , then .
- •
If and , then .
- •
Corollary: If are integers, where , such that and , then for any integers and .
5.1.2 Modular Arithmetic
Let be integers, where . We say that is congruent to modulo , denoted by , if and only if . This is called congruence and is called the modulus.
The following properties hold:
- •
If and , then .
- •
If and , then .
- •
Corollary: , and .
5.2 Prime
An integer is prime if and only if its only positive divisors are 1 and . An integer is composite if and only if it is not prime.
The fundamental theorem of arithmetic states that every integer greater than 1 is either prime or can be written as a unique product of prime numbers.
GCD of two integers and , denoted by , is the largest integer that divides both and . If we factorize and into prime numbers, then , where and are the exponents of in the factorization of and . Two integers are relatively prime if and only if their GCD is 1.
Similarly, we can define LCM of two integers and , denoted by , is the smallest positive integer that is divisible by both and .
5.3 Eculidean Algorithm
The Eculidean algorithm is an efficient method for computing the GCD of two integers. It can solve the problem in time, where is the smaller of the two integers.
The central idea is that if , then . Here is the proof: If is a common divisor of and , we can write and . By the corollary, we know that , which implies . Therefore, is a common divisor of and .
For example, to compute :
Therefore, .
5.4 Bezout’s Theorem
Let and be integers, not both zero. Then there exist integers and such that .
We can use the extended Eculidean algorithm to find and .
For example, since , we can find and such that , with the following steps:
Firstly, we use the Eculidean algorithm to find the GCD of 503 and 286:
Then, we can find and :
Therefore, and .
The corollaries of Bezout’s theorem are:
- •
If and , then .
- •
If is a prime and , then for some .
- •
If and , then .
The proof of the first corollary is as follows: Since , we can find and such that . Then . Since , we know that . Therefore, .
5.5 Linear Congruence
A linear congruence is an equation of the form , where are integers and .
5.5.1 Modular Inverse
Let and be integers, where . If there exists an integer such that , then is called the modular inverse of modulo .
If and are relatively prime, then has a modular inverse modulo . Furthermore, the modular inverse of modulo is unique modulo .
We can use the extended Eculidean algorithm to find the modular inverse of modulo .
5.5.2 Chinese Remainder Theorem
Let be positive integers that are pairwise relatively prime, and let be any integers. Then the system of linear congruences:
has a solution, and any two solutions are congruent modulo .
Let . Then the solution is , where is the modular inverse of modulo .
For example, to solve the system of linear congruences:
We can find , , and . Therefore, is a solution.
5.6 Fermat’s Little Theorem
Let be a prime and be an integer such that . Then .
5.7 Euler’s Theorem
Euler’s function is the number of positive integers less than or equal to that are relatively prime to . The function has the following properties:
- •
If is prime, then .
- •
If is prime and , then .
- •
If and are relatively prime, then .
Euler’s theorem states that if is a positive integer and is an integer such that and are relatively prime, then .
It is worth noting that might not be the smallest positive integer such that .
5.8 Primitive Roots
A primitive root modulo a prime is an integer such that every nonzero integer modulo is congruent to a power of modulo .
6 Groups, Rings, and Fields
6.1 Groups
A group is a set together with a binary operation on such that the following axioms hold:
- •
Closure: For all , .
- •
Associativity: For all , .
- •
Identity: There exists a unique element such that for all , .
- •
Inverse: For each , there exists an element such that .
6.1.1 Permutation Groups
A permutation group is a group whose elements are permutations of a given set and whose operation is composition of permutations in . Let denotes a sequence of elements, and denotes the set of all permutations of . Then for any two elements and , is also a permutation of .
For example, , and . If and , then . The operation is .
Therefore, is a group.
6.1.2 Abeilian Groups
A group is abeilian if and only if for all , .
6.2 Rings
If is an abeilian group, we define a second binary operation on such that the following axioms hold:
- •
Closure: For all , .
- •
Associativity: For all , .
- •
Distributivity: For all , and .
6.2.1 Commutative Ring
A ring is commutative if and only if for all , .
6.2.2 Integral Domain
A commutative ring is an integral domain if the following axiom holds:
- •
Identity: There exists a unique element such that for all , .
- •
Nonzero product: For all , if , then or .
6.3 Fields
A commutative ring is a field if the following axiom holds:
- •
Inverse: For each , there exists an element such that .
6.4 Other Facts
- •
, the set of integers modulo , is a commutative ring.
- •
is a group but not an abeilian group. (The set of all invertible matrices)
- •
is a ring but not a commutative ring.
- •
is a commutative ring but not an integral domain.
- •
is an integral domain but not a field.
7 Cryptography
7.1 Public Key Cryptography
7.1.1 RSA Cryptosystem
The RSA public key cryptosystem works as follows:
- 1.
Choose two large primes and .
- 2.
Compute and .
- 3.
Choose such that and .
- 4.
Compute such that .
- 5.
Publish the public key and keep the private key secret.
To encrypt a message , compute . To decrypt a ciphertext , compute .
The correctness of the algorithm is as follows:
To leave a RSA signature, compute . To verify a RSA signature, compute .( and are interchangeable)
7.1.2 El Gamal Cryptosystem
The El Gamal public key cryptosystem works as follows:
- 1.
Choose a large prime and a primitive root modulo .
- 2.
Choose such that .
- 3.
Compute .
- 4.
Publish the public key and keep the private key secret.
To encrypt a message , choose such that and , then compute and . To decrypt a ciphertext , compute .
The correctness of the algorithm is as follows:
7.2 Diffie-Hellman Key Exchange
The Diffie-Hellman key exchange works as follows:
- 1.
Choose a large prime and a primitive root modulo .
- 2.
Alice chooses such that and sends to Bob.
- 3.
Bob chooses such that and sends to Alice.
- 4.
Alice computes .
- 5.
Bob computes .
- 6.
Now Alice and Bob share the secret key .
8 Mathematical Induction
8.1 Proof by Smallest Counterexample
To prove a statement for all , we can use proof by smallest counterexample. We assume that is false for some . Then there must be a smallest integer such that is false. Since is true, . Then we use the fact that the for all is true to show that is true, which is a contradiction.
8.2 Direct Proof
8.2.1 Weak Principle of Mathematical Induction
If the statement is true, and the statement is true for all integers , then the statement is true for all integers .
We call the basis step (inductive hypothesis) and the inductive step (inductive conclusion).
8.2.2 Strong Principle of Mathematical Induction
If the statement is true, and the statement is true for all integers , then the statement is true for all integers .
We can see that the weak form is a special case of the strong form, and the strong form can be derived from the weak form.