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 (TT) or false (FF), but not both.     - Example 1: "Marikina is the Capital of the Philippines" (False); "1+2=31 + 2 = 3" (True).     - Non-Propositions: Questions ("What time is it?"), commands ("Read this carefully"), or sentences with variables ("x+1=2x + 1 = 2") unless values are assigned to the variables.
  • Propositional Variables: Conventional letters used are p,q,r,s,p, q, r, s, \dots.
  • 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\neg p): The statement "It is not the case that pp." The truth value is the opposite of pp.         - Example: If pp is "Michael’s PC runs Linux," ¬p\neg p is "Michael’s PC does not run Linux."     - Conjunction (pqp \wedge q): The statement "pp and qq." It is true only when both pp and qq are true; false otherwise.     - Disjunction (pqp \vee q): The statement "pp or qq." This is an inclusive or. It is false only when both pp and qq are false; true otherwise.     - Exclusive Or (pqp \oplus q): The statement "p or q but not bothp \text{ or } q \text{ but not both}." It is true when exactly one of pp and qq is true; false otherwise.     - Conditional Statement / Implication (pqp \rightarrow q): The statement "if pp, then qq." Here, pp is the hypothesis (antecedent/premise) and qq is the conclusion (consequence). It is false only when pp is true and qq is false.         - Terminology for pqp \rightarrow q: "pp is sufficient for qq," "qq is necessary for pp," "pp, only if qq," "qq unless ¬p\neg p."     - Biconditional Statement (pqp \leftrightarrow q): The statement "pp if and only if qq." True when pp and qq have the same truth values.         - Note: pqp \leftrightarrow q has the same truth value as (pq)(qp)(p \rightarrow q) \wedge (q \rightarrow p).
  • Precedence of Logical Operators:     1. Negation (¬\neg)     2. Conjunction (\wedge)     3. Disjunction (\vee)     4. Conditional (\rightarrow)     5. Biconditional (\leftrightarrow)

Logic and Bit Operations

  • Bit: A symbol with two possible values: 00 (False) and 11 (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 (\vee), AND (\wedge), and XOR (\oplus).
  • 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 011011011001\,1011\,0110 and 110001110111\,0001\,1101 is 101010101110\,1010\,1011.

Propositional Equivalences

  • Classification of Compound Propositions:     - Tautology: Always true (e.g., p¬pp \vee \neg p).     - Contradiction: Always false (e.g., p¬pp \wedge \neg p).     - Contingency: Neither a tautology nor a contradiction.
  • Logical Equivalence (\equiv or \Leftrightarrow): Propositions pp and qq are equivalent if pqp \leftrightarrow q is a tautology.
  • De Morgan’s Laws:     - ¬(pq)¬p¬q\neg(p \wedge q) \equiv \neg p \vee \neg q     - ¬(pq)¬p¬q\neg(p \vee q) \equiv \neg p \wedge \neg q
  • Other Key Equivalences:     - Double Negation Law: ¬(¬p)p\neg(\neg p) \equiv p     - Commutative Laws: pqqpp \vee q \equiv q \vee p; pqqpp \wedge q \equiv q \wedge p     - Distributive Laws: p(qr)(pq)(pr)p \vee (q \wedge r) \equiv (p \vee q) \wedge (p \vee r); p(qr)(pq)(pr)p \wedge (q \vee r) \equiv (p \wedge q) \vee (p \wedge r)     - Implication Equivalence: pq¬pqp \rightarrow q \equiv \neg p \vee q (Used in converting negated implications: ¬(pq)p¬q\neg(p \rightarrow q) \equiv p \wedge \neg q).

Predicate Logic and Quantifiers

  • Predicate Logic: Extends propositional logic to reason about properties of objects and relationships.
  • Predicates: Statements like "x>3x > 3". Here, xx is the subject and "is greater than 33" is the predicate (P(x)P(x)). Once a value is assigned to xx, P(x)P(x) becomes a proposition.     - n-ary Predicates: Involve multiple variables, e.g., R(x,y,z)R(x, y, z) for "x+y=zx + y = z".
  • Programming Application: Predicates serve as preconditions (valid input descriptions) and postconditions (conditions for output correctness).
  • Quantification:     - Universal Quantifier (\forall): The statement "P(x)P(x) for all values of xx in the domain." xP(x)\forall xP(x) is false if there is at least one counterexample.     - Existential Quantifier (\exists): The statement "There exists an element xx in the domain such that P(x)P(x) is true." xP(x)\exists xP(x) is false only if P(x)P(x) is false for every element in the domain.     - Uniqueness Quantifier (!\exists! or 1\exists_{1}): "There exists a unique xx such that P(x)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 (aAa \in A).
  • Representation:     - Roster Method: Listing elements within braces, e.g., {a,e,i,o,u}\{a, e, i, o, u\}.     - Set-Builder Notation: Defining by properties, e.g., {xZ+x is odd and x<10}\{x \in \mathbb{Z}^{+} \mid x \text{ is odd and } x < 10\}.
  • Common Sets:     - N={0,1,2,}\mathbb{N} = \{0, 1, 2, \dots\} (Natural numbers)     - Z={,1,0,1,}\mathbb{Z} = \{\dots, -1, 0, 1, \dots\} (Integers)     - Q={p/qp,qZ,q0}\mathbb{Q} = \{p/q \mid p, q \in \mathbb{Z}, q \neq 0\} (Rational numbers)     - R\mathbb{R} (Real numbers), C\mathbb{C} (Complex numbers)
  • Empty Set (\emptyset or {}\{\}): A set containing no elements.
  • Subsets (ABA \subseteq B): Every element of AA is also in BB.
  • Cardinality (S|S|): The number of distinct elements in a finite set.
  • Power Set (P(S)\mathcal{P}(S)): The set of all subsets of set SS. If S=n|S| = n, then P(S)=2n|\mathcal{P}(S)| = 2^{n}.
  • Set Operations:     - Union (ABA \cup B): Elements in either AA or BB or both.     - Intersection (ABA \cap B): Elements in both AA and BB. If AB=A \cap B = \emptyset, the sets are disjoint.     - Difference (ABA - B or ABA \setminus B): Elements in AA but not in BB. Note: AB=ABA - B = A \cap \overline{B}.     - Complement (A\overline{A}): Elements in the universal set UU that are not in AA.

Functions

  • Definition: A function f:ABf : A \rightarrow B assigns exactly one element of BB to each element of AA.     - Domain: Set AA.     - Codomain: Set BB.     - Range: The set of all images f(a)f(a).
  • Types of Functions:     - One-to-One / Injective: f(a)=f(b)f(a) = f(b) implies a=ba = b.     - Onto / Surjective: For every bBb \in B, there exists aAa \in A such that f(a)=bf(a) = b.     - One-to-One Correspondence / Bijective: Both injective and surjective.
  • Inverse Function (f1f^{-1}): Only possible if ff is bijective.
  • Composition (fgf \circ g): (fg)(a)=f(g(a))(f \circ g)(a) = f(g(a)). The range of gg must be a subset of the domain of ff.
  • 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\aleph_{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\mathbb{R}. This is proven using Cantor's diagonalization argument.

Relations

  • Properties of Relations (on set AA):     - Reflexive: (a,a)R(a, a) \in R for all aAa \in A.     - Symmetric: If (a,b)R(a, b) \in R, then (b,a)R(b, a) \in R.     - Antisymmetric: If (a,b)R(a, b) \in R and (b,a)R(b, a) \in R, then a=ba = b.     - Transitive: If (a,b)R(a, b) \in R and (b,c)R(b, c) \in R, then (a,c)R(a, c) \in R.
  • Equivalence Relation: Reflexive, symmetric, and transitive.
  • Partial Ordering / Poset (S,RS, R): Reflexive, antisymmetric, and transitive.     - Comparable: If aba \preceq b or bab \preceq 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 SS.     - Geometric Progression: a,ar,ar2,,arn,a, ar, ar^{2}, \dots, ar^{n}, \dots (common ratio rr).     - Arithmetic Progression: a,a+d,a+2d,,a+nd,a, a+d, a+2d, \dots, a+nd, \dots (common difference dd).
  • Recurrence Relations: Expressing ana_{n} in terms of previous terms (e.g., Fibonacci sequence: fn=fn1+fn2f_{n} = f_{n-1} + f_{n-2} with f0=0,f1=1f_{0}=0, f_{1}=1).
  • Summations: j=mnaj=am+am+1++an\sum_{j=m}^{n} a_{j} = a_{m} + a_{m+1} + \dots + a_{n}.

Number Theory

  • Divisibility: aba \mid b if there is an integer cc such that b=acb = ac (aa is a factor, bb is a multiple).
  • Division Algorithm: For integer aa and positive integer dd, there exist unique qq and rr such that a=dq+ra = dq + r with 0r<d0 \leq r < d.     - q=a div dq = a \text{ div } d; r=a mod dr = a \text{ mod } d.
  • Modular Arithmetic: ab(modm)a \equiv b \pmod{m} if m(ab)m \mid (a - b).
  • Base Expansions: Integers can be represented in base b>1b > 1. Common bases: Binary (base 2), Octal (base 8), Hexadecimal (base 16).
  • Primes: Integer p>1p > 1 whose only positive factors are 11 and pp.     - Fundamental Theorem of Arithmetic: Every integer >1>1 is uniquely expressed as a product of primes.     - Trial Division: Compound nn has a prime divisor n\leq \sqrt{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+tbgcd(a, b) = sa + tb for some integers s,ts, t.
  • Chinese Remainder Theorem: Solves systems of congruences with pairwise relatively prime moduli.
  • Fermat’s Little Theorem: If pp is prime and apa \nmid p, then ap11(modp)a^{p-1} \equiv 1 \pmod{p}.

Cryptography

  • Caesar Cipher: Shifts letters by 3 positions (f(p)=(p+3)(mod26)f(p) = (p + 3) \pmod{26}).
  • Cryptosystem: A five-tuple (P,C,K,E,D)(P, C, K, E, D) where PP=plaintext, CC=ciphertext, KK=keys, EE=encryption, DD=decryption.
  • RSA Cryptosystem: Public key system using large primes pp and qq. Modulus n=pqn = pq.     - Encryption: C=Me(modn)C = M^{e} \pmod{n}.     - Decryption: M=Cd(modn)M = C^{d} \pmod{n}, where dd is the inverse of electric exponent e(mod(p1)(q1))e \pmod{(p-1)(q-1)}.

Counting

  • Product Rule: If tasks have n1n_{1} and n2n_{2} ways respectively, total ways = n1×n2n_{1} \times n_{2}.
  • Sum Rule: If tasks are disjoint, total ways = n1+n2n_{1} + n_{2}.
  • Subtraction Rule (Inclusion-Exclusion): AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B|.
  • Permutations (P(n,r)P(n, r)): Ordered arrangements. P(n,r)=n!(nr)!P(n, r) = \frac{n!}{(n - r)!}.
  • Combinations (C(n,r)C(n, r)): Unordered selections. C(n,r)=n!r!(nr)!C(n, r) = \frac{n!}{r!(n - r)!}.

Graph Theory

  • Basic Definitions:     - Graph G=(V,E)G=(V, E) where VV=vertices, EE=edges.     - Adjacent: Vertices connected by an edge.     - Degree (deg(v)deg(v)): Number of edges incident with a vertex. Loops count twice.
  • Handshaking Theorem: 2m=vVdeg(v)2m = \sum_{v \in V} deg(v), where mm is the number of edges.
  • Directed Graphs:     - In-degree (deg(v)deg^{-}(v)): Edges ending at vv.     - Out-degree (deg+(v)deg^{+}(v)): Edges starting at vv.
  • Representations:     - Adjacency Matrix: n×nn \times n matrix where aij=1a_{ij}=1 if vertices are adjacent.     - Incidence Matrix: n×mn \times m matrix showing relationships between vertices and edges.