Comprehensive Study Guide for Discrete Structure 1
Introduction to Discrete Structures
Foundations: Both mathematics and computer science are based on logic as a tool to establish truth through various techniques of proof. Discrete Structure 1 (COMP 20043) introduces mathematical concepts essential for high-level computer science courses.
Course Topics:
- Propositional and predicate logic.
- Proof techniques.
- Set theory.
- Functions and relations.
- Number theory.
- Elementary combinatorics and counting methods.
- Graph theory.
Chapter 1: Propositional Logic
The Rule of Logic: Logic provides precise meaning to mathematical statements and distinguishes valid from invalid arguments. It is used in computer circuit design, program construction, and verification.
Definition of Proposition: A proposition is a declarative sentence (declares a fact) that is either true (T) or false (F), but not both.
- Example 1: "Marikina is the Capital of the Philippines" (False); "1+2=3" (True).
- Non-Propositions: Questions ("What time is it?"), commands ("Read this carefully"), or sentences with variables ("x+1=2") unless values are assigned to the variables.
Propositional Variables: Conventional letters used are p,q,r,s,….
History: Developed by Aristotle 2300 years ago. The three laws of Aristotelian logic are:
- Law of Identity: "A statement is itself."
- Law of Excluded Middle: "A statement is either true or false but not both."
- Law of Non-Contradiction: "No statement is both true and false."
Logical Operators:
- Negation (¬p): The statement "It is not the case that p." The truth value is the opposite of p.
- Example: If p is "Michael’s PC runs Linux," ¬p is "Michael’s PC does not run Linux."
- Conjunction (p∧q): The statement "p and q." It is true only when both p and q are true; false otherwise.
- Disjunction (p∨q): The statement "p or q." This is an inclusive or. It is false only when both p and q are false; true otherwise.
- Exclusive Or (p⊕q): The statement "p or q but not both." It is true when exactly one of p and q is true; false otherwise.
- Conditional Statement / Implication (p→q): The statement "if p, then q." Here, p is the hypothesis (antecedent/premise) and q is the conclusion (consequence). It is false only when p is true and q is false.
- Terminology for p→q: "p is sufficient for q," "q is necessary for p," "p, only if q," "q unless ¬p."
- Biconditional Statement (p↔q): The statement "p if and only if q." True when p and q have the same truth values.
- Note:p↔q has the same truth value as (p→q)∧(q→p).
Bit: A symbol with two possible values: 0 (False) and 1 (True). The term "bit" was introduced by John Tukey in 1946.
Boolean Variable: A variable whose value is either true or false.
Bit Operations: Correspond to logical operators. OR (∨), AND (∧), and XOR (⊕).
Bit String: A sequence of zero or more bits. The length is the number of bits in the string.
- Bitwise OR, AND, XOR: Applied to strings of the same length by operating on corresponding bits.
- Example: Bitwise XOR of 0110110110 and 1100011101 is 1010101011.
Propositional Equivalences
Classification of Compound Propositions:
- Tautology: Always true (e.g., p∨¬p).
- Contradiction: Always false (e.g., p∧¬p).
- Contingency: Neither a tautology nor a contradiction.
Logical Equivalence (≡ or ⇔): Propositions p and q are equivalent if p↔q is a tautology.
Predicate Logic: Extends propositional logic to reason about properties of objects and relationships.
Predicates: Statements like "x>3". Here, x is the subject and "is greater than 3" is the predicate (P(x)). Once a value is assigned to x, P(x) becomes a proposition.
- n-ary Predicates: Involve multiple variables, e.g., R(x,y,z) for "x+y=z".
Programming Application: Predicates serve as preconditions (valid input descriptions) and postconditions (conditions for output correctness).
Quantification:
- Universal Quantifier (∀): The statement "P(x) for all values of x in the domain." ∀xP(x) is false if there is at least one counterexample.
- Existential Quantifier (∃): The statement "There exists an element x in the domain such that P(x) is true." ∃xP(x) is false only if P(x) is false for every element in the domain.
- Uniqueness Quantifier (∃! or ∃1): "There exists a unique x such that P(x)."
Binding Variables:
- Bound Variable: A variable to which a quantifier is applied.
- Free Variable: An occurrence of a variable not bound by a quantifier.
- Scope: The part of the logical expression to which the quantifier applies.
Sets and Set Operations
Set: An unordered collection of objects called elements (a∈A).
Representation:
- Roster Method: Listing elements within braces, e.g., {a,e,i,o,u}.
- Set-Builder Notation: Defining by properties, e.g., {x∈Z+∣x is odd and x<10}.
Common Sets:
- N={0,1,2,…} (Natural numbers)
- Z={…,−1,0,1,…} (Integers)
- Q={p/q∣p,q∈Z,q=0} (Rational numbers)
- R (Real numbers), C (Complex numbers)
Empty Set (∅ or {}): A set containing no elements.
Subsets (A⊆B): Every element of A is also in B.
Cardinality (∣S∣): The number of distinct elements in a finite set.
Power Set (P(S)): The set of all subsets of set S. If ∣S∣=n, then ∣P(S)∣=2n.
Set Operations:
- Union (A∪B): Elements in either A or B or both.
- Intersection (A∩B): Elements in both A and B. If A∩B=∅, the sets are disjoint.
- Difference (A−B or A∖B): Elements in A but not in B. Note: A−B=A∩B.
- Complement (A): Elements in the universal set U that are not in A.
Functions
Definition: A function f:A→B assigns exactly one element of B to each element of A.
- Domain: Set A.
- Codomain: Set B.
- Range: The set of all images f(a).
Types of Functions:
- One-to-One / Injective:f(a)=f(b) implies a=b.
- Onto / Surjective: For every b∈B, there exists a∈A such that f(a)=b.
- One-to-One Correspondence / Bijective: Both injective and surjective.
Inverse Function (f−1): Only possible if f is bijective.
Composition (f∘g):(f∘g)(a)=f(g(a)). The range of g must be a subset of the domain of f.
Partial Function: Assignment for a subset of the domain. If it covers the whole domain, it is a total function.
Cardinality of Sets (Extended)
Countable Sets: Sets that are finite or have the same cardinality as positive integers (ℵ0 or aleph null).
- Example: The set of all integers is countable.
Uncountable Sets: Sets that cannot be listed, such as the set of real numbers R. This is proven using Cantor's diagonalization argument.
Relations
Properties of Relations (on set A):
- Reflexive:(a,a)∈R for all a∈A.
- Symmetric: If (a,b)∈R, then (b,a)∈R.
- Antisymmetric: If (a,b)∈R and (b,a)∈R, then a=b.
- Transitive: If (a,b)∈R and (b,c)∈R, then (a,c)∈R.
Equivalence Relation: Reflexive, symmetric, and transitive.
Partial Ordering / Poset (S,R): Reflexive, antisymmetric, and transitive.
- Comparable: If a⪯b or b⪯a.
- Total Order: Every pair of elements is comparable (also called a chain).
- Well-Ordered Set: A total order where every non-empty subset has a least element.
Sequences and Summations
Sequence: A function from a subset of integers to a set S.
- Geometric Progression:a,ar,ar2,…,arn,… (common ratio r).
- Arithmetic Progression:a,a+d,a+2d,…,a+nd,… (common difference d).
Recurrence Relations: Expressing an in terms of previous terms (e.g., Fibonacci sequence: fn=fn−1+fn−2 with f0=0,f1=1).
Summations:∑j=mnaj=am+am+1+⋯+an.
Number Theory
Divisibility:a∣b if there is an integer c such that b=ac (a is a factor, b is a multiple).
Division Algorithm: For integer a and positive integer d, there exist unique q and r such that a=dq+r with 0≤r<d.
- q=a div d; r=a mod d.
Modular Arithmetic:a≡b(modm) if m∣(a−b).
Base Expansions: Integers can be represented in base b>1. Common bases: Binary (base 2), Octal (base 8), Hexadecimal (base 16).
Primes: Integer p>1 whose only positive factors are 1 and p.
- Fundamental Theorem of Arithmetic: Every integer >1 is uniquely expressed as a product of primes.
- Trial Division: Compound n has a prime divisor ≤n.
GCD and LCM:
- Greatest Common Divisor (GCD): Largest shared divisor.
- Euclidean Algorithm: Method for finding GCD using successive applications of the division algorithm.
- Bézout’s Theorem:gcd(a,b)=sa+tb for some integers s,t.
Chinese Remainder Theorem: Solves systems of congruences with pairwise relatively prime moduli.
Fermat’s Little Theorem: If p is prime and a∤p, then ap−1≡1(modp).
Cryptography
Caesar Cipher: Shifts letters by 3 positions (f(p)=(p+3)(mod26)).
Cryptosystem: A five-tuple (P,C,K,E,D) where P=plaintext, C=ciphertext, K=keys, E=encryption, D=decryption.
RSA Cryptosystem: Public key system using large primes p and q. Modulus n=pq.
- Encryption:C=Me(modn).
- Decryption:M=Cd(modn), where d is the inverse of electric exponent e(mod(p−1)(q−1)).
Counting
Product Rule: If tasks have n1 and n2 ways respectively, total ways = n1×n2.
Sum Rule: If tasks are disjoint, total ways = n1+n2.
Basic Definitions:
- Graph G=(V,E) where V=vertices, E=edges.
- Adjacent: Vertices connected by an edge.
- Degree (deg(v)): Number of edges incident with a vertex. Loops count twice.
Handshaking Theorem:2m=∑v∈Vdeg(v), where m is the number of edges.
Directed Graphs:
- In-degree (deg−(v)): Edges ending at v.
- Out-degree (deg+(v)): Edges starting at v.
Representations:
- Adjacency Matrix:n×n matrix where aij=1 if vertices are adjacent.
- Incidence Matrix:n×m matrix showing relationships between vertices and edges.