Discrete Mathematics
Complete Notes
Logic ยท Sets ยท Graph Theory ยท Combinatorics ยท Proofs โ All in Easy English
๐ Table of Contents โ 14 Units
Introduction to Discrete Mathematics
What is Discrete Math and why do we study it?
What is Discrete Mathematics?
Discrete Mathematics is the study of mathematical structures that are fundamentally discrete (separate, distinct) rather than continuous. It deals with objects that can only take specific, separated values.
Discrete vs Continuous Mathematics
| Feature | Discrete Mathematics | Continuous Mathematics |
|---|---|---|
| Values | Separate, distinct, countable | Unbroken, smooth range |
| Examples | Integers: 1, 2, 3, 4... | Real numbers: 1.5, 2.73, ฯ |
| Graph Type | Points, nodes, discrete steps | Smooth curves, flowing lines |
| Operations | Counting, listing, logical operations | Calculus, limits, derivatives |
| Used In | Computer Science, algorithms, cryptography | Physics, engineering, calculus |
Why is Discrete Math Important for Computer Science?
- Algorithm Design โ Understanding complexity and efficiency
- Data Structures โ Trees, graphs, and networks
- Logic & Proofs โ Foundation of program correctness
- Cryptography โ Number theory and security
- Database Theory โ Relations and set operations
- Artificial Intelligence โ Logic, probability, graph search
- Networking โ Graph theory for network topology
Main Topics in Discrete Mathematics
Propositional Logic
Statements, truth values, and logical operators.
What is a Proposition?
A proposition (or statement) is a declarative sentence that is either true (T) or false (F), but not both. The truth value is either 1 (true) or 0 (false).
Examples of Propositions
| Statement | Proposition? | Reason |
|---|---|---|
| "2 + 2 = 4" | โ Yes | Clearly true |
| "Paris is the capital of France" | โ Yes | True statement |
| "x + 5 = 10" | โ No | Depends on value of x |
| "Close the door!" | โ No | Command, not a statement |
| "What time is it?" | โ No | Question, not a statement |
| "This sentence is false" | โ No | Paradox โ neither true nor false |
Logical Operators (Connectives)
| Operator | Symbol | Name | Meaning |
|---|---|---|---|
| NOT | ยฌ or ~ | Negation | Opposite truth value |
| AND | โง | Conjunction | Both must be true |
| OR | โจ | Disjunction | At least one must be true |
| IF-THEN | โ | Implication | If p then q |
| IF AND ONLY IF | โ | Biconditional | Both have same truth value |
Truth Tables
1. Negation (NOT)
| p | ยฌp |
|---|---|
| T | F |
| F | T |
2. Conjunction (AND)
| p | q | p โง q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | F |
3. Disjunction (OR)
| p | q | p โจ q |
|---|---|---|
| T | T | T |
| T | F | T |
| F | T | T |
| F | F | F |
4. Implication (IF-THEN)
p โ q means "if p then q". It's false only when p is true and q is false.
| p | q | p โ q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | T |
| F | F | T |
5. Biconditional (IF AND ONLY IF)
p โ q is true when both have the same truth value.
| p | q | p โ q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | T |
Predicate Logic & Quantifiers
Variables, predicates, and universal/existential quantifiers.
What is Predicate Logic?
Predicate logic (also called first-order logic) extends propositional logic by dealing with statements that contain variables. A predicate is a statement whose truth value depends on one or more variables.
Predicates vs Propositions
| Type | Example | Explanation |
|---|---|---|
| Proposition | "5 is odd" | Fixed truth value (True) |
| Predicate | "x is odd" | Truth depends on x |
| Predicate | P(x): "x > 10" | True if x > 10, false otherwise |
| Predicate | Q(x,y): "x + y = 10" | Depends on both x and y |
Quantifiers
Quantifiers allow us to make statements about "all" or "some" elements in a domain.
1. Universal Quantifier (โ)
Symbol: โ (for all, for every)
Meaning: โx P(x) means "P(x) is true for ALL values of x in the domain"
Example: โx (xยฒ โฅ 0) means "For all real numbers x, xยฒ is non-negative" This is TRUE for all real numbers. โx (x > 5) means "For all x, x is greater than 5" This is FALSE (not all numbers are > 5).
2. Existential Quantifier (โ)
Symbol: โ (there exists, for some)
Meaning: โx P(x) means "P(x) is true for AT LEAST ONE value of x"
Example: โx (xยฒ = 16) means "There exists an x such that xยฒ = 16" This is TRUE (x = 4 or x = -4). โx (xยฒ = -1) means "There exists a real x such that xยฒ = -1" This is FALSE for real numbers.
Negation of Quantifiers
| Statement | Negation | Explanation |
|---|---|---|
| โx P(x) | โx ยฌP(x) | "Not all" means "at least one is not" |
| โx P(x) | โx ยฌP(x) | "None exists" means "all are not" |
Multiple Quantifiers
Order matters when using multiple quantifiers!
โx โy (x + y = 0) "For every x, there exists a y such that x + y = 0" TRUE (for any x, we can choose y = -x) โy โx (x + y = 0) "There exists a y such that for all x, x + y = 0" FALSE (no single y works for ALL x)
Translating English to Logic
| English Statement | Logical Form |
|---|---|
| All students passed | โx (Student(x) โ Passed(x)) |
| Some student failed | โx (Student(x) โง Failed(x)) |
| No student cheated | ยฌโx (Student(x) โง Cheated(x)) |
| Not all birds can fly | ยฌโx (Bird(x) โ CanFly(x)) |
Sets & Set Operations
Collections of objects and operations on them.
What is a Set?
A set is a well-defined collection of distinct objects, called elements or members. Sets are usually denoted by capital letters (A, B, C) and elements by lowercase letters.
A = {1, 2, 3, 4, 5}
B = {red, blue, green}
C = {x | x is an even number} โ set-builder notation
โ means "is an element of"
โ means "is not an element of"
3 โ A (3 is in A)
6 โ A (6 is not in A)Types of Sets
| Type | Definition | Example |
|---|---|---|
| Finite Set | Has limited number of elements | A = {1, 2, 3} |
| Infinite Set | Has unlimited elements | โ = {1, 2, 3, ...} |
| Empty Set | Contains no elements | โ or { } |
| Singleton Set | Contains exactly one element | {5} |
| Universal Set | Contains all elements under consideration | U |
| Subset | All elements of A are in B | A โ B |
| Proper Subset | A โ B but A โ B | A โ B |
Set Operations
1. Union (โช)
A โช B contains all elements that are in A OR in B (or in both).
A = {1, 2, 3}
B = {3, 4, 5}
A โช B = {1, 2, 3, 4, 5}2. Intersection (โฉ)
A โฉ B contains only elements that are in BOTH A AND B.
A = {1, 2, 3}
B = {3, 4, 5}
A โฉ B = {3}3. Difference (โ)
A โ B contains elements in A but NOT in B.
A = {1, 2, 3}
B = {3, 4, 5}
A โ B = {1, 2}4. Complement (A' or ฤ)
A' contains all elements in the universal set U that are NOT in A.
U = {1, 2, 3, 4, 5, 6}
A = {1, 2, 3}
A' = {4, 5, 6}5. Cartesian Product (ร)
A ร B is the set of all ordered pairs (a, b) where a โ A and b โ B.
A = {1, 2}
B = {x, y}
A ร B = {(1,x), (1,y), (2,x), (2,y)}
|A ร B| = |A| ร |B| = 2 ร 2 = 4Set Identities (Laws)
| Law | Union Form | Intersection Form |
|---|---|---|
| Identity | A โช โ = A | A โฉ U = A |
| Domination | A โช U = U | A โฉ โ = โ |
| Idempotent | A โช A = A | A โฉ A = A |
| Complement | A โช A' = U | A โฉ A' = โ |
| Commutative | A โช B = B โช A | A โฉ B = B โฉ A |
| Associative | (AโชB)โชC = Aโช(BโชC) | (AโฉB)โฉC = Aโฉ(BโฉC) |
| Distributive | Aโช(BโฉC) = (AโชB)โฉ(AโชC) | Aโฉ(BโชC) = (AโฉB)โช(AโฉC) |
De Morgan's Laws for Sets
(A โช B)' = A' โฉ B' (A โฉ B)' = A' โช B' "The complement of a union is the intersection of complements" "The complement of an intersection is the union of complements"
Relations & Functions
Mappings between sets and their properties.
What is a Relation?
A relation R from set A to set B is a subset of the Cartesian product A ร B. It shows how elements of A are related to elements of B.
A = {1, 2, 3}
B = {4, 5}
R = {(1,4), (2,5), (3,4)} โ relation from A to B
We write: 1 R 4 (1 is related to 4)Types of Relations
For a relation R on a set A (from A to A):
| Property | Definition | Example |
|---|---|---|
| Reflexive | Every element relates to itself: โx (x R x) | โค (every number โค itself) |
| Symmetric | If x R y then y R x | = (if x = y then y = x) |
| Antisymmetric | If x R y and y R x, then x = y | โค (if xโคy and yโคx, then x=y) |
| Transitive | If x R y and y R z, then x R z | < (if x |
Equivalence Relation
A relation that is reflexive, symmetric, and transitive is called an equivalence relation.
Example: "=" (equality) is an equivalence relation - Reflexive: x = x - Symmetric: if x = y, then y = x - Transitive: if x = y and y = z, then x = z
What is a Function?
A function f from A to B (written f: A โ B) is a special relation where every element in A is related to EXACTLY ONE element in B.
f: A โ B A is the domain B is the codomain The set of actual output values is the range Example: f(x) = xยฒ Domain: โ (all real numbers) Codomain: โ Range: [0, โ) (non-negative reals only)
Types of Functions
| Type | Definition | Diagram |
|---|---|---|
| One-to-One (Injective) | Different inputs โ different outputs If f(xโ) = f(xโ), then xโ = xโ | Each output has at most one input |
| Onto (Surjective) | Every element in codomain is an output Range = Codomain | Every output is used |
| Bijective | Both one-to-one AND onto | Perfect pairing โ each input has exactly one output, and vice versa |
Function Examples
One-to-One but NOT Onto: f: โ โ โ, f(x) = 2x One-to-one: different x โ different 2x Not onto: odd numbers never appear as outputs Onto but NOT One-to-One: f: โ โ โ, f(x) = xยฒ Onto [0,โ): all non-negative numbers are outputs Not one-to-one: f(2) = f(-2) = 4 Bijective: f: โ โ โ, f(x) = x + 5 One-to-one: different x โ different x+5 Onto: every real number y = x+5 for some x
Composition of Functions
If f: A โ B and g: B โ C, then (g โ f): A โ C is defined as (g โ f)(x) = g(f(x))
f(x) = x + 3 g(x) = 2x (g โ f)(x) = g(f(x)) = g(x+3) = 2(x+3) = 2x + 6 (f โ g)(x) = f(g(x)) = f(2x) = 2x + 3 Note: g โ f โ f โ g (order matters!)
Mathematical Induction
Proving statements for all natural numbers โ the domino effect.
What is Mathematical Induction?
Mathematical induction is a proof technique used to prove statements about all natural numbers (or integers). Think of it like dominoes โ if the first falls and each domino knocks down the next, all dominoes will fall!
Principle of Mathematical Induction
To prove a statement P(n) is true for all n โฅ 1:
- Step 1 (Base Case): Prove P(1) is true
- Step 2 (Inductive Hypothesis): Assume P(k) is true for some arbitrary k โฅ 1
- Step 3 (Inductive Step): Using the assumption, prove P(k+1) is true
- Conclusion: By induction, P(n) is true for all n โฅ 1
Example 1: Sum of First n Natural Numbers
Prove: 1 + 2 + 3 + ... + n = n(n+1)/2
Step 1: Base Case (n=1) Left side: 1 Right side: 1(1+1)/2 = 1 โ True for n=1 Step 2: Inductive Hypothesis Assume true for n=k: 1 + 2 + 3 + ... + k = k(k+1)/2 Step 3: Inductive Step (prove for n=k+1) Need to show: 1 + 2 + ... + k + (k+1) = (k+1)(k+2)/2 Left side: = [1 + 2 + ... + k] + (k+1) = k(k+1)/2 + (k+1) [using hypothesis] = k(k+1)/2 + 2(k+1)/2 = [k(k+1) + 2(k+1)]/2 = (k+1)(k+2)/2 [factoring] = Right side โ Conclusion: By induction, formula is true for all n โฅ 1.
Example 2: Power Inequality
Prove: 2โฟ > n for all n โฅ 1
Base Case (n=1):
2ยน = 2 > 1 โ
Inductive Hypothesis:
Assume 2^k > k for some k โฅ 1
Inductive Step (prove 2^(k+1) > k+1):
2^(k+1) = 2 ยท 2^k
> 2 ยท k [using hypothesis: 2^k > k]
= k + k
โฅ k + 1 [since k โฅ 1]
โด 2^(k+1) > k+1 โ
Conclusion: By induction, 2โฟ > n for all n โฅ 1.Strong Induction
In strong induction, we assume P(1), P(2), ..., P(k) are ALL true (not just P(k)), then prove P(k+1).
Regular Induction: Assume P(k) โ Prove P(k+1) Strong Induction: Assume P(1)โงP(2)โง...โงP(k) โ Prove P(k+1) Use strong induction when proving P(k+1) requires information from multiple previous cases.
Common Mistakes in Induction
- Forgetting Base Case โ Always prove for n=1 (or starting value)
- Not Using Hypothesis โ Must explicitly use P(k) assumption in step 3
- Proving Wrong Direction โ Must prove P(k) โ P(k+1), not the reverse
- Circular Reasoning โ Don't assume what you're trying to prove
Combinatorics โ Counting Techniques
Permutations, combinations, and the art of counting.
What is Combinatorics?
Combinatorics is the branch of mathematics concerned with counting, arranging, and combining objects. It answers questions like "How many ways can we arrange these items?" or "How many subsets can we choose?"
Fundamental Counting Principles
1. Addition Principle (OR)
If task A can be done in m ways and task B can be done in n ways, and they CANNOT be done together, then either A OR B can be done in m + n ways.
Example: Travel from City X to City Y - By train: 3 routes - By bus: 5 routes Total ways = 3 + 5 = 8 ways
2. Multiplication Principle (AND)
If task A can be done in m ways and task B can be done in n ways, and both must be done, then A AND B can be done in m ร n ways.
Example: Password with 1 letter + 1 digit - Letters: 26 ways - Digits: 10 ways Total passwords = 26 ร 10 = 260
Permutations (Order Matters)
A permutation is an arrangement of objects where ORDER matters.
Permutation of n Objects
Number of ways to arrange n distinct objects = n! (n factorial)
n! = n ร (n-1) ร (n-2) ร ... ร 2 ร 1 Example: Arrange 4 books on a shelf 4! = 4 ร 3 ร 2 ร 1 = 24 ways
Permutation of r Objects from n
P(n, r) or nPr = number of ways to arrange r objects chosen from n objects
P(n, r) = n!/(n-r)! Example: Choose and arrange 3 winners from 10 contestants P(10, 3) = 10!/(10-3)! = 10!/7! = 10ร9ร8 = 720 ways
Combinations (Order Doesn't Matter)
A combination is a selection of objects where ORDER does NOT matter.
C(n, r) or nCr = n!/[r!(n-r)!]
Also written as (n choose r) or โฟCแตฃ
Example: Choose 3 students from 10 for a committee
C(10, 3) = 10!/[3!(10-3)!]
= 10!/(3!ร7!)
= (10ร9ร8)/(3ร2ร1)
= 120 waysPermutation vs Combination
| Feature | Permutation | Combination |
|---|---|---|
| Order | Matters | Does NOT matter |
| Formula | P(n,r) = n!/(n-r)! | C(n,r) = n!/[r!(n-r)!] |
| Example | PIN code 1234 โ 4321 | Team {A,B,C} = {C,B,A} |
| Result | Always larger | Always smaller |
| Relationship | P(n,r) = r! ร C(n,r) | |
Special Cases
C(n, 0) = 1 (one way to choose nothing) C(n, n) = 1 (one way to choose everything) C(n, r) = C(n, n-r) (symmetry property) Example: C(10, 3) = C(10, 7) = 120
Permutations with Repetition
When objects are not all distinct:
n!/(nโ! ร nโ! ร ... ร nโ!) where nโ, nโ, ..., nโ are counts of repeated objects Example: Arrange letters in "MISSISSIPPI" Total letters = 11 M:1, I:4, S:4, P:2 Arrangements = 11!/(1!ร4!ร4!ร2!) = 34,650
Common Problem Types
| Question Type | Use |
|---|---|
| Arrange/Order items | Permutation |
| Select/Choose items (no order) | Combination |
| Form teams/committees | Combination |
| Assign ranks/positions | Permutation |
| Passwords/PINs | Permutation with repetition allowed |
Discrete Probability
Calculating chances and likelihood of events.
What is Probability?
Probability measures how likely an event is to occur. It's a number between 0 (impossible) and 1 (certain).
P(Event) = (Number of favorable outcomes) / (Total number of possible outcomes) P(E) โ [0, 1] P(certain event) = 1 P(impossible event) = 0
Basic Probability Example
Rolling a fair die (6 faces: 1,2,3,4,5,6): P(getting 4) = 1/6 P(getting even) = 3/6 = 1/2 (faces: 2,4,6) P(getting โค 6) = 6/6 = 1 (certain) P(getting 7) = 0/6 = 0 (impossible)
Complement Rule
The probability that an event does NOT occur:
P(not E) = 1 โ P(E) or P(E') = 1 โ P(E) Example: P(not getting 4) = 1 โ 1/6 = 5/6
Addition Rule (OR)
For mutually exclusive events (cannot happen together):
P(A or B) = P(A โช B) = P(A) + P(B)
Example: Drawing a card
P(Ace or King) = P(Ace) + P(King)
= 4/52 + 4/52 = 8/52 = 2/13For non-mutually exclusive events (can happen together):
P(A or B) = P(A) + P(B) โ P(A and B)
Example: Drawing a card
P(Heart or King) = P(Heart) + P(King) โ P(King of Hearts)
= 13/52 + 4/52 โ 1/52
= 16/52 = 4/13Multiplication Rule (AND)
For independent events (one doesn't affect the other):
P(A and B) = P(A โฉ B) = P(A) ร P(B)
Example: Flipping two coins
P(both heads) = P(H on first) ร P(H on second)
= 1/2 ร 1/2 = 1/4Conditional Probability
Probability of A given that B has occurred:
P(A|B) = P(A โฉ B) / P(B) Example: Two dice rolled, sum is 8 P(first die is 3 | sum is 8) Outcomes where sum = 8: (2,6),(3,5),(4,4),(5,3),(6,2) = 5 outcomes Outcomes where first = 3 and sum = 8: (3,5) = 1 outcome P(first=3 | sum=8) = 1/5
Independent vs Dependent Events
| Type | Definition | Example |
|---|---|---|
| Independent | One event doesn't affect the other P(A|B) = P(A) | Flipping two coins |
| Dependent | One event affects the other P(A|B) โ P(A) | Drawing cards without replacement |
Expected Value
The average outcome if an experiment is repeated many times:
E(X) = ฮฃ [x ร P(x)]
Example: Rolling a die
E(X) = 1ร(1/6) + 2ร(1/6) + 3ร(1/6) + 4ร(1/6) + 5ร(1/6) + 6ร(1/6)
= (1+2+3+4+5+6)/6
= 21/6 = 3.5Graph Theory Basics
Vertices, edges, and network connections.
What is a Graph?
A graph G = (V, E) is a collection of vertices (nodes) V and edges (connections) E that connect pairs of vertices. Graphs model relationships and networks.
Graph Terminology
| Term | Definition |
|---|---|
| Vertex (Node) | A point in the graph |
| Edge (Link) | Connection between two vertices |
| Adjacent Vertices | Two vertices connected by an edge |
| Degree | Number of edges connected to a vertex |
| Path | Sequence of vertices connected by edges |
| Cycle | Path that starts and ends at the same vertex |
| Connected Graph | There's a path between every pair of vertices |
Types of Graphs
| Type | Description | Example |
|---|---|---|
| Undirected Graph | Edges have no direction (bidirectional) | Friendship network |
| Directed Graph (Digraph) | Edges have direction (arrows) | Twitter followers |
| Weighted Graph | Edges have associated weights/costs | Road network with distances |
| Simple Graph | No loops, no multiple edges | Most common type |
| Complete Graph Kn | Every vertex connected to every other | Kโ has 6 edges |
| Bipartite Graph | Vertices split into two sets, edges only between sets | Students-Courses matching |
Degree of a Vertex
The degree of a vertex is the number of edges connected to it.
In undirected graph: deg(v) = number of edges at vertex v In directed graph: in-degree = number of edges coming IN out-degree = number of edges going OUT
Handshaking Lemma
The sum of all vertex degrees equals twice the number of edges:
ฮฃ deg(v) = 2|E| Why? Each edge contributes 1 to the degree of TWO vertices. Corollary: In any graph, the number of vertices with odd degree is EVEN.
Paths and Cycles
- Path: Sequence of vertices where each adjacent pair is connected by an edge
- Simple Path: No vertex is repeated
- Cycle: Path that starts and ends at the same vertex
- Simple Cycle: Cycle with no repeated vertices (except first/last)
Euler and Hamilton Paths
| Type | Definition | Exists When |
|---|---|---|
| Euler Path | Path that visits every EDGE exactly once | 0 or 2 vertices of odd degree |
| Euler Circuit | Euler path that starts/ends at same vertex | All vertices have even degree |
| Hamilton Path | Path that visits every VERTEX exactly once | No simple rule (NP-complete) |
| Hamilton Circuit | Hamilton path that starts/ends at same vertex | No simple rule |
Graph Representation
1. Adjacency Matrix
A matrix where entry (i,j) = 1 if edge exists between vertex i and j, otherwise 0.
Graph: A-B, B-C, A-C
A B C
A [ 0 1 1 ]
B [ 1 0 1 ]
C [ 1 1 0 ]2. Adjacency List
For each vertex, list its adjacent vertices.
A: [B, C] B: [A, C] C: [A, B]
Trees
Special graphs โ hierarchical structures without cycles.
What is a Tree?
A tree is a connected graph with NO cycles. It's the most fundamental hierarchical structure in computer science.
Properties of Trees
- A tree with n vertices has exactly n โ 1 edges
- There is exactly one path between any two vertices
- Removing any edge disconnects the tree
- Adding any edge creates exactly one cycle
- A tree is a minimally connected graph
Tree Terminology
| Term | Definition |
|---|---|
| Root | The topmost vertex (in rooted trees) |
| Parent | Vertex directly above another |
| Child | Vertex directly below another |
| Leaf (Terminal) | Vertex with no children |
| Internal Vertex | Vertex with at least one child |
| Sibling | Vertices with the same parent |
| Ancestor | Any vertex on path from root to this vertex |
| Descendant | Any vertex in subtree rooted at this vertex |
| Level | Distance from root (root is level 0) |
| Height | Maximum level in the tree |
Types of Trees
| Type | Description |
|---|---|
| Binary Tree | Each vertex has at most 2 children (left and right) |
| Full Binary Tree | Every vertex has 0 or 2 children |
| Complete Binary Tree | All levels filled except possibly the last, filled left to right |
| Perfect Binary Tree | All internal vertices have 2 children, all leaves at same level |
| Binary Search Tree (BST) | Left child < parent < right child |
| Spanning Tree | Subgraph that includes all vertices and is a tree |
Binary Tree Properties
For a binary tree with n vertices: - Maximum number of vertices at level i = 2^i - Maximum vertices in tree of height h = 2^(h+1) โ 1 - Minimum height for n vertices = โlogโ(n+1)โ โ 1 For a perfect binary tree: - Height h โ vertices = 2^(h+1) โ 1 - Height h โ leaves = 2^h
Tree Traversal Methods
Ways to visit all vertices in a tree:
| Method | Order | Use Case |
|---|---|---|
| Preorder | Root โ Left โ Right | Copy a tree, prefix expression |
| Inorder | Left โ Root โ Right | BST gives sorted order |
| Postorder | Left โ Right โ Root | Delete a tree, postfix expression |
| Level-order (BFS) | Level by level, left to right | Shortest path, level-wise processing |
Spanning Trees
A spanning tree of a connected graph G is a subgraph that:
- Includes all vertices of G
- Is a tree (connected, no cycles)
- Has exactly n โ 1 edges (where n = number of vertices)
Minimum Spanning Tree (MST)
For a weighted graph, the MST is the spanning tree with minimum total edge weight.
Algorithms to find MST: 1. Kruskal's Algorithm โ Sort edges, add smallest without creating cycle 2. Prim's Algorithm โ Start from a vertex, grow tree by adding cheapest edge
Boolean Algebra
Mathematical foundation of digital logic and computer circuits.
What is Boolean Algebra?
Boolean algebra is a branch of mathematics that deals with variables that have only two possible values: true (1) or false (0). It's the mathematical foundation of digital electronics and computer logic.
Boolean Operations
| Operation | Symbol | Name | Result |
|---|---|---|---|
| AND | ยท or โง | Conjunction | 1 only if both are 1 |
| OR | + or โจ | Disjunction | 1 if at least one is 1 |
| NOT | ' or ยฌ | Negation | Flips the value |
Boolean Algebra Laws
| Law | AND Form | OR Form |
|---|---|---|
| Identity | x ยท 1 = x | x + 0 = x |
| Null/Domination | x ยท 0 = 0 | x + 1 = 1 |
| Idempotent | x ยท x = x | x + x = x |
| Complement | x ยท x' = 0 | x + x' = 1 |
| Involution | (x')' = x | |
| Commutative | x ยท y = y ยท x | x + y = y + x |
| Associative | (xยทy)ยทz = xยท(yยทz) | (x+y)+z = x+(y+z) |
| Distributive | xยท(y+z) = xยทy + xยทz | x+(yยทz) = (x+y)ยท(x+z) |
| Absorption | xยท(x+y) = x | x + xยทy = x |
De Morgan's Laws
(x ยท y)' = x' + y' (x + y)' = x' ยท y' In words: "The complement of AND is OR of complements" "The complement of OR is AND of complements"
Simplification Example
Simplify: F = xยทy + xยทy' Step 1: Factor out x F = xยท(y + y') Step 2: Apply complement law: y + y' = 1 F = xยท1 Step 3: Apply identity law: xยท1 = x F = x Result: The expression simplifies to just x!
Boolean Functions
A Boolean function maps Boolean inputs to a Boolean output:
f(x, y, z) = xยทy' + x'ยทz Truth table: x y z | f 0 0 0 | 0 0 0 1 | 1 0 1 0 | 0 0 1 1 | 1 1 0 0 | 1 1 0 1 | 1 1 1 0 | 0 1 1 1 | 0
Canonical Forms
| Form | Description | Example |
|---|---|---|
| Sum of Products (SOP) | OR of AND terms (minterms) | x'y + xy' |
| Product of Sums (POS) | AND of OR terms (maxterms) | (x+y)ยท(x'+y') |
Recurrence Relations
Sequences defined recursively โ solving recursive formulas.
What is a Recurrence Relation?
A recurrence relation is an equation that defines a sequence based on previous terms. Each term is expressed as a function of earlier terms.
Components of a Recurrence Relation
- Recurrence equation: The recursive formula
- Initial conditions: Base case values
Example: a_n = 2ยทa_(n-1) + 3 with a_0 = 1 a_0 = 1 (initial condition) a_1 = 2ยท1 + 3 = 5 a_2 = 2ยท5 + 3 = 13 a_3 = 2ยท13 + 3 = 29 ...
Types of Recurrence Relations
| Type | Form | Example |
|---|---|---|
| Linear Homogeneous | a_n = cโยทa_(n-1) + cโยทa_(n-2) | a_n = 3a_(n-1) โ 2a_(n-2) |
| Linear Non-Homogeneous | a_n = cโยทa_(n-1) + f(n) | a_n = 2a_(n-1) + n |
| First-Order | Depends on one previous term | a_n = 2a_(n-1) + 1 |
| Second-Order | Depends on two previous terms | a_n = a_(n-1) + a_(n-2) |
Solving Linear Homogeneous Recurrence Relations
For: a_n = cโยทa_(n-1) + cโยทa_(n-2)
Step 1: Form characteristic equation: rยฒ = cโยทr + cโ
Step 2: Solve for roots rโ, rโ
Step 3: General solution depends on roots:
- Two distinct roots: a_n = Aยทrโโฟ + Bยทrโโฟ
- One repeated root r: a_n = (A + Bยทn)ยทrโฟ
Step 4: Use initial conditions to find A and B
Example: Solve a_n = 5a_(n-1) โ 6a_(n-2), a_0=1, a_1=4
Step 1: Characteristic equation
rยฒ = 5r โ 6
rยฒ โ 5r + 6 = 0
(r โ 2)(r โ 3) = 0
rโ = 2, rโ = 3
Step 2: General solution (two distinct roots)
a_n = Aยท2โฟ + Bยท3โฟ
Step 3: Apply initial conditions
a_0 = 1: Aยท2โฐ + Bยท3โฐ = 1 โ A + B = 1
a_1 = 4: Aยท2ยน + Bยท3ยน = 4 โ 2A + 3B = 4
Solve system:
From first: B = 1 โ A
Substitute: 2A + 3(1โA) = 4
2A + 3 โ 3A = 4
โA = 1
A = โ1, B = 2
Step 4: Final solution
a_n = โ1ยท2โฟ + 2ยท3โฟ = 2ยท3โฟ โ 2โฟ
Verify: a_0 = 2ยท1 โ 1 = 1 โ
a_1 = 2ยท3 โ 2 = 4 โFamous Recurrence Relations
| Sequence | Recurrence | Initial | Closed Form |
|---|---|---|---|
| Fibonacci | F_n = F_(n-1) + F_(n-2) | F_0=0, F_1=1 | F_n = (ฯโฟ โ ฯโฟ)/โ5 |
| Geometric | a_n = rยทa_(n-1) | a_0 = a | a_n = aยทrโฟ |
| Arithmetic | a_n = a_(n-1) + d | a_0 = a | a_n = a + nยทd |
| Tower of Hanoi | T_n = 2T_(n-1) + 1 | T_1 = 1 | T_n = 2โฟ โ 1 |
Counting Principles & Pigeonhole Principle
Advanced counting techniques and a powerful proof tool.
Inclusion-Exclusion Principle
For counting elements in unions of sets, avoiding double-counting:
For two sets:
|A โช B| = |A| + |B| โ |A โฉ B|
For three sets:
|A โช B โช C| = |A| + |B| + |C|
โ |A โฉ B| โ |A โฉ C| โ |B โฉ C|
+ |A โฉ B โฉ C|
Pattern: Add individual, subtract pairs, add triples...Example: Inclusion-Exclusion
In a class of 50 students:
- 30 study Math
- 25 study Physics
- 10 study both
How many study at least one subject?
|M โช P| = |M| + |P| โ |M โฉ P|
= 30 + 25 โ 10
= 45 studentsPigeonhole Principle
Simple version: If n+1 objects are placed into n boxes, then at least one box contains more than one object.
Generalized Pigeonhole Principle
If n objects are placed into k boxes, then at least one box contains at least โn/kโ objects.
โ โ is the ceiling function (rounds up) Example: 50 students, 7 days of the week At least one day has: โ50/7โ = โ7.14โ = 8 students born on it
Pigeonhole Principle Examples
Example 1: Handshakes
In any group of 6 people, either:
- 3 people mutually know each other, OR
- 3 people are mutual strangers
Example 2: Socks
You have 10 black socks and 10 white socks in a drawer.
How many must you grab (in the dark) to guarantee a matching pair?
Answer: 3 socks
(2 colors = 2 boxes, so 3rd sock must match one)
Example 3: Integers
Among any 5 integers, at least two have the same remainder
when divided by 4.
Proof: 4 possible remainders (0,1,2,3) = 4 boxes
5 integers = 5 objects
By pigeonhole: โ5/4โ = 2 must have same remainderCounting with Restrictions
1. Arrangements with Restrictions
Problem: Arrange 5 people in a row where 2 specific people must sit together. Solution: Treat the 2 as one unit - Units to arrange: 4 (the pair + 3 others) = 4! ways - Ways to arrange the pair internally = 2! ways - Total = 4! ร 2! = 24 ร 2 = 48 ways
2. Distributing Objects into Boxes
| Objects | Boxes | Formula |
|---|---|---|
| Distinct | Distinct | k^n (each object has k choices) |
| Identical | Distinct | C(n+k-1, k-1) = stars and bars |
| Distinct | Identical | Stirling numbers (complex) |
| Identical | Identical | Integer partitions |
Stars and Bars Method
Distributing n identical objects into k distinct boxes:
Number of ways = C(n + k โ 1, k โ 1) Example: Distribute 5 identical candies among 3 children C(5 + 3 โ 1, 3 โ 1) = C(7, 2) = 21 ways Visual: โ โ โ โ โ with 2 bars | to separate: โ โ |โ |โ โ means child1 gets 2, child2 gets 1, child3 gets 2
Proof Techniques
Methods to prove mathematical statements โ the foundation of rigorous thinking.
What is a Mathematical Proof?
A proof is a logical argument that establishes the truth of a mathematical statement beyond any doubt. It uses axioms, definitions, and previously proven results.
Types of Proof Techniques
1. Direct Proof
Start with assumptions (hypothesis), use logical steps, arrive at conclusion.
Structure: Assume P is true โ ... logical steps ... โ Therefore Q is true
Example: Prove that if n is even, then nยฒ is even. Proof: Assume n is even. Then n = 2k for some integer k (definition of even) nยฒ = (2k)ยฒ = 4kยฒ = 2(2kยฒ) Since 2kยฒ is an integer, nยฒ = 2m where m = 2kยฒ Therefore nยฒ is even. โ
2. Proof by Contrapositive
To prove P โ Q, instead prove ยฌQ โ ยฌP (contrapositive is logically equivalent)
Example: Prove if nยฒ is odd, then n is odd. Instead, prove: if n is even, then nยฒ is even (contrapositive of original statement) Assume n is even. n = 2k nยฒ = 4kยฒ = 2(2kยฒ) โ even Therefore, if n is even, nยฒ is even. By contrapositive: if nยฒ is odd, then n is odd. โ
3. Proof by Contradiction
Assume the statement is FALSE, derive a contradiction, conclude it must be TRUE.
Structure: Assume ยฌP โ ... โ Contradiction! โ Therefore P must be true
Example: Prove โ2 is irrational. Proof by contradiction: Assume โ2 is rational. Then โ2 = p/q where p,q are integers, qโ 0, in lowest terms โ2 = p/q 2 = pยฒ/qยฒ pยฒ = 2qยฒ โ pยฒ is even, so p is even Let p = 2k (2k)ยฒ = 2qยฒ 4kยฒ = 2qยฒ qยฒ = 2kยฒ โ qยฒ is even, so q is even But p and q are both even, contradicting "lowest terms"! Therefore โ2 must be irrational. โ
4. Proof by Cases
Break the proof into exhaustive cases, prove each separately.
Example: Prove that nยฒ + n is even for all integers n.
Case 1: n is even
n = 2k
nยฒ + n = (2k)ยฒ + 2k = 4kยฒ + 2k = 2(2kยฒ + k) โ even
Case 2: n is odd
n = 2k + 1
nยฒ + n = (2k+1)ยฒ + (2k+1)
= 4kยฒ + 4k + 1 + 2k + 1
= 4kยฒ + 6k + 2
= 2(2kยฒ + 3k + 1) โ even
All cases covered, so nยฒ + n is always even. โ5. Proof by Counterexample
To disprove a universal statement (โx P(x)), find ONE example where it's false.
Disprove: "All prime numbers are odd" Counterexample: 2 is prime and even. Therefore the statement is FALSE. โ
6. Mathematical Induction
(Already covered in Unit 6 โ used to prove statements for all natural numbers)
Proof Strategies Summary
| Method | When to Use | Key Idea |
|---|---|---|
| Direct Proof | P โ Q seems straightforward | Assume P, deduce Q |
| Contrapositive | ยฌQ โ ยฌP is easier than P โ Q | Prove equivalent statement |
| Contradiction | Existence proofs, irrationality | Assume ยฌP leads to absurdity |
| Cases | Natural divisions exist (even/odd) | Exhaust all possibilities |
| Counterexample | Disproving universal claims | Find one exception |
| Induction | Statements about all integers โฅ n | Base + inductive step |
Common Proof-Writing Tips
- Start clearly: State what you're proving
- Use definitions: Apply precise mathematical definitions
- Show all steps: Don't skip logical leaps
- Use proper notation: โ, โ, โ, โ correctly
- End with โ or QED: Signals proof is complete
- Check logic: Each step must follow from previous
๐ Congratulations!
You have completed the Discrete Mathematics Course by Pak Notes Hub! You now understand Logic, Sets, Graph Theory, Combinatorics, Proofs and more. Best of luck in your exams and future studies! ๐
๐ Course Summary โ 14 Units
Quick reference of all topics covered.
| # | Unit | Key Concepts |
|---|---|---|
| 1 | Introduction to Discrete Math | Discrete vs continuous, applications in CS |
| 2 | Propositional Logic | Propositions, truth tables, logical operators (โง, โจ, โ, โ) |
| 3 | Predicate Logic & Quantifiers | Predicates, โ (universal), โ (existential), negation rules |
| 4 | Sets & Set Operations | Union, intersection, difference, complement, Cartesian product, De Morgan's laws |
| 5 | Relations & Functions | Types of relations, equivalence relations, one-to-one, onto, bijective functions |
| 6 | Mathematical Induction | Base case, inductive hypothesis, inductive step, strong induction |
| 7 | Combinatorics | Permutations P(n,r), combinations C(n,r), counting principles |
| 8 | Discrete Probability | Basic probability, addition rule, multiplication rule, conditional probability, expected value |
| 9 | Graph Theory Basics | Vertices, edges, degree, paths, cycles, Euler and Hamilton paths, graph representation |
| 10 | Trees | Tree properties, binary trees, traversal methods (preorder, inorder, postorder), spanning trees |
| 11 | Boolean Algebra | Boolean operations, laws, De Morgan's laws, simplification, SOP and POS forms |
| 12 | Recurrence Relations | Recursive sequences, solving linear recurrences, characteristic equations, Fibonacci |
| 13 | Counting Principles | Inclusion-exclusion principle, pigeonhole principle, stars and bars method |
| 14 | Proof Techniques | Direct proof, contrapositive, contradiction, cases, counterexample, induction |
๐ Key Formulas โ Quick Reference
| Concept | Formula |
|---|---|
| Permutation | P(n,r) = n!/(nโr)! |
| Combination | C(n,r) = n!/[r!(nโr)!] |
| Pigeonhole Principle | โn/kโ objects in at least one box |
| Inclusion-Exclusion | |AโชB| = |A| + |B| โ |AโฉB| |
| Handshaking Lemma | ฮฃ deg(v) = 2|E| |
| Tree Edges | |E| = |V| โ 1 |
| Binary Tree Max Vertices | 2^(h+1) โ 1 |
| Stars and Bars | C(n+kโ1, kโ1) |
| Probability | P(E) = favorable/total |
| De Morgan's Laws | (AโชB)' = A'โฉB', (AโฉB)' = A'โชB' |

