DMATH
📚 DMATH.pdf
Brief overview
This document provides a comprehensive introduction to discrete mathematics concepts essential for computer science and advanced mathematics. It covers foundational topics in set theory, relations, functions, graph theory, and logic, culminating in Boolean algebra and circuit minimization. Understanding these areas is crucial for formal reasoning, algorithm design, and digital system analysis.
Key points
- Introduction to sets, notation, and common number sets.
- Set operations, properties, and their graphical representation.
- Relations, their properties, and equivalence relations.
- Functions, types, and their applications in algorithm design.
- Fundamentals of graph theory, including paths and cycles.
- Weighted graphs and algorithms for shortest paths and spanning trees.
- Basic logic, propositions, and propositional variables.
- Logical connectives, truth tables, and compound statements.
- Conditional, biconditional propositions, and their truth values.
- Tautologies, contradictions, contingencies, and predicate logic.
- Boolean algebra operations, expressions, and logic gates.
- Minimizing circuits using Karnaugh maps.
1. Introduction to sets
1.1 What is a set?
- A set is an unordered collection of objects.
- These objects are called elements or members of the set.
- A set contains its elements.
1.2 Membership in sets
- Notation:
- a∈A means 'a is an element of set A'.
- a∈/A means 'a is not an element of set A'.
- Lowercase letters usually represent elements.
Example:
📝 Example: Given A={2,4,5} and B={6,8}.
- 2∈A (2 is an element of A).
- 6∈/A (6 is not an element of A).
- 6∈B (6 is an element of B).
1.3 Describing sets
There are two main ways to describe a set:
-
Listing members:
- List all elements within braces {}.
- Example: The set with elements a, b, c, and d is written as {a,b,c,d}.
- Example: The set of integers from 1 to 5 is A={1,2,3,4,5}.
- Example: The set of vowels is C={a,e,i,o,u}.
-
Using ellipses (...):
- List some members to show a pattern, then use ellipses.
- Example: The set of positive integers less than 100 is {1,2,3,...,99}.
Table: Describing sets by listing
| Set Description | Notation |
|---|---|
| Integers 1 to 5 | {1,2,3,4,5} |
| Vowels in the English alphabet | {a,e,i,o,u} |
| Positive integers less than 100 | {1,2,3,...,99} |
1.4 Set builder notation
- This notation describes a set using a rule or condition.
- Format: {x∣condition for x} or {x:condition for x}.
Examples:
- The set O of odd positive integers less than 10 can be written as:
- O={x∣x is an odd positive integer less than 10}
- Or, specifying the universe of positive integers: O={x∣x is odd and x<10}.
Table: Set builder notation examples
| Set Description | Notation |
|---|---|
| Odd positive integers less than 10 | {x∣x is odd and x<10} |
| Integers from 1 to 5 | {x∣1≤x≤5,x is an integer} |
| Rational numbers (p/q form) | {p/q∣p∈Z,q∈Z,q=0} |
1.5 Common sets
These sets are often used in discrete mathematics:
| Set Name | Notation | Description |
|---|---|---|
| Natural numbers | N | {1,2,3,...} |
| Integers | Z | {…,−2,−1,0,1,2,…} |
| Positive integers | Z+ | {1,2,3,...} |
| Rational numbers | Q | {p/q∣p∈Z,q∈Z,q=0} |
| Real numbers | R | The set of all real numbers. |
1.6 Universal sets
- A universal set, denoted by ξ, contains all elements under consideration.
- It acts as a boundary for a specific problem or context.
Example:
📝 Example: If A={2,4,6,8} and the elements being considered are integers from 1 to 10, then the universal set is ξ={1,2,3,4,5,6,7,8,9,10}.
1.7 Complement of a set
- The complement of a set A, denoted A′, contains all elements in the universal set ξ that are not in A.
Example:
📝 Example: Given ξ={1,2,3,4,5,6,7,8,9,10} and A={2,3,4,5,7,8,9}. The complement of A is A′={1,6,10}.
🔑 Important: The complement of A (A′) includes everything in the universal set (ξ) except for the elements of A.
Table: Set complement in Venn diagram
| Area in Venn Diagram | Description | Notation |
|---|---|---|
| Shaded area outside A | Elements not in A | A′ |
| Area inside A | Elements in A | A |
| Entire rectangle | All elements | ξ |
2. Set operations and properties
2.1 Intersection of sets
- Intersection: The set of elements common to two or more sets.
- Symbol: ∩
- Example: If A={1,3,5,8} and B={2,3,5,7}, then A∩B={3,5} 15.
- Example: If P={M,A,T,H,E,I,C} and Q={E,N,G,L,I,S,H}, then P∩Q={E,H,I} 16.
Venn Diagram Representation: The overlapping region of sets A and B illustrates A∩B 17.
2.2 Complement of intersection
- Complement of Intersection: Elements that are in the universal set but not in the intersection of two sets.
- Notation: (A∩B)′
📝 Example: Given sets P,Q,R and a universal set ξ. The region representing (P∩Q)′ is the area in ξ outside of P∩Q 19.
📝 Example: For sets A,B,C and ξ, the region for A∩B∩C′ includes elements in A and B but not in C 20.
2.3 Union of sets
- Union: The set of all elements that belong to at least one of the sets.
- Symbol: ∪
- Example: If A={1,3,5} and B={2,3,4}, then A∪B={1,2,3,4,5} 21.
Venn Diagram Representation: The union A∪B is represented by the entire area covered by both set A and set B 22.
- Complement of Union: Elements in the universal set that are not in the union of two sets.
- Notation: (A∪B)′
- Venn Diagram Representation: This is shown as the shaded area within the universal set ξ that is outside of A∪B 23.
2.4 Set difference
- Set difference: The set of elements that are in the first set but not in the second set.
- Notation: A−B or A∖B. This means A−B={x∣x∈A and x∈/B}.
- Example: If A={1,3,5} and B={4,5,6}, then A−B={1,3}.
- Example: Using the same sets A and B, B−A={4,6} 27.
📝 Example: Let A={Counting numbers between 30 and 40} and B={Counting numbers between 20 and 50 divisible by 4}.
- A={31,32,33,34,35,36,37,38,39}
- B={24,28,32,36,40,44,48}
- A−B={31,33,34,35,37,38,39}.
- B−A={24,28,40,44,48} 31.
2.5 Symmetric difference
- Symmetric difference: The set of elements that are in either set A or set B, but not in both.
- Notation: A⊕B
- Definition: A⊕B={x∣(x∈A and x∈/B) or (x∈B and x∈/A)} 28.
- Relationship to set difference: A⊕B=(A−B)∪(B−A).
- Example: If A={a,b,c,d} and B={a,c,e,f,g}, then A⊕B={b,d,e,f,g} 29.
2.6 Disjoint sets
- Disjoint sets: Two sets are disjoint if they have no elements in common.
- Equivalently, their intersection is the empty set (A∩B=∅).
| Set A | Set B | Intersection | Are they disjoint? |
|---|---|---|---|
| {1,2,3} | {4,5,6} | ∅ | Yes |
| {a,b} | {b,c} | {b} | No |
| {even numbers} | {odd numbers} | ∅ | Yes |
2.7 Combined operations
- Complex set operations involve applying multiple operations like union, intersection, and complement in sequence.
- The order of operations matters and is typically determined by parentheses.
📝 Example: Given ξ={x:10≤x≤20,x is an integer}, A={x:x contains digit 5 or 7}, B={x:x is a prime number}, and C={x:x is a multiple of 5}.
- ξ={10,11,12,13,14,15,16,17,18,19,20}
- A={15,17}
- B={11,13,17,19}
- C={10,15,20}
To find A′∩B∪C:
- A′={10,11,12,13,14,16,18,19,20}
- A′∩B={11,13,17,19}
- (A′∩B)∪C={10,11,13,15,17,19,20}.
🔑 Important: Understanding the order of operations and how Venn diagrams represent these complex combinations is crucial for solving problems involving multiple set operations 26.
3. Relations and their properties
3.1 Introduction to relations
A relation from a set X to a set Y is a collection of ordered pairs (x,y), where x∈X and y∈Y. We write xRy if (x,y) is in the relation R.
Relations can be defined by a rule or represented using tables. The domain of a relation is the set of all first elements of the ordered pairs.
The range is the set of all second elements.
📝 Example: Given X={2,3,4} and Y={3,4,5,6,7}, and relation R where (x,y)∈R if x divides y. R={(2,4),(2,6),(3,3),(3,6),(4,4)} Domain of R is {2,3,4}. Range of R is {3,4,6} 39.
3.2 Representing relations
Relations can be visualized using directed graphs (digraphs). A digraph has vertices representing elements of a set and edges representing the ordered pairs in the relation.
An arrow from vertex ai to aj means (ai,aj) is in the relation.
📝 Example: For set A={1,2,3,4} and relation R={(1,1),(1,2),(2,1),(2,2),(2,4),(3,4),(4,2)}, the digraph shows self-loops for reflexive pairs and arrows for other pairs 44.
| Relation Element | Digraph Representation |
|---|---|
| (a,a) | Self-loop on vertex a |
| (a,b) | Arrow from a to b |
3.3 Properties of relations
Relations can have specific properties that simplify their understanding and application. These properties help classify relations and determine their behavior.
3.3.1 Reflexive relations
A relation R on a set X is reflexive if every element in X is related to itself. This means (x,x)∈R for all x∈X.
In a digraph, this is shown by a self-loop on every vertex.
A relation is irreflexive if no element is related to itself. This means (x,x)∈/R for any x∈X.
📝 Example: Relation R on X={1,2,3,4} defined by x≤y is reflexive because (1,1),(2,2),(3,3),(4,4) are all in R 47. Relation R on X={1,2,3,4} defined by x<y is irreflexive because no element is related to itself 48.
3.3.2 Symmetric relations
A relation R on a set A is symmetric if whenever aRb, then bRa is also true. In a digraph, if there's an edge from vertex a to vertex b, there must also be an edge from b to a.
📝 Example: The relation R={(a,a),(b,c),(c,b),(d,d)} on X={a,b,c,d} is symmetric because for (b,c)∈R, we also have (c,b)∈R 50.
A relation is nonsymmetric if there exists at least one pair (a,b) such that aRb but bRa is not true.
A relation is antisymmetric if for any distinct a and b, if aRb and bRa are both true, then a must equal b. Equivalently, if a=b, then we cannot have both aRb and bRa.
| Relation Type | Condition for (a,b) and (b,a) when a=b |
|---|---|
| Symmetric | If (a,b)∈R, then (b,a)∈R. |
| Nonsymmetric | There exists (a,b)∈R such that (b,a)∈/R. |
| Antisymmetric | If (a,b)∈R and (b,a)∈R, then a=b. |
3.3.3 Transitive relations
A relation R on a set A is transitive if for all a,b,c∈A, whenever (a,b)∈R and (b,c)∈R, then (a,c)∈R. In a digraph, if there's a path from a to b and from b to c, there must be a direct edge from a to c.
📝 Example: The relation "less than" (<) on integers is transitive because if a<b and b<c, then a<c 54. The relation R={(a,a),(b,c),(c,b),(d,d)} on X={a,b,c,d} is not transitive. Although (b,c)∈R and (c,b)∈R, (b,b) is not in R 55.
🔑 Important: Transitivity can be checked by looking for chains of relationships: if A relates to B, and B relates to C, does A relate to C?
3.4 Equivalence relations
A relation R on a set X is an equivalence relation if it is reflexive, symmetric, and transitive. Equivalence relations partition a set into disjoint subsets called equivalence classes.
📝 Example: The relation R={(a,a),(b,c),(c,b),(d,d)} on X={a,b,c,d} is not an equivalence relation because it is neither reflexive nor transitive 56.
🔑 Important: To be an equivalence relation, a relation must satisfy all three properties: reflexive, symmetric, and transitive.
4. Functions and their applications (part 1)
4.1 Introduction to functions
- Function: A rule that assigns each element from a set X to exactly one element in a set Y.
- Functions can be represented as sets of ordered pairs, like
(1, 55). - Formally, a function
ffrom set X to set Y (f:X→Y) is a subset of the Cartesian productX × Y. - This subset must have the property that for every
xin X, there is precisely oneyin Y such that(x, y)is inf.
4.2 Sets related to functions
- Domain: The set X, containing all possible input values for the function.
- Codomain: The set Y, containing all potential output values.
- Range: The set of actual output values
{y | (x, y) ∈ f}. The range is always a subset of the codomain.
📝 Example: If
f = {(1, a), (2, b), (3, a)}, then:
- Domain X =
{1, 2, 3}- Codomain Y =
{a, b, c}- Range =
{a, b}
🔑 Important: A set is not a function if an element in the domain is not assigned to any element in the codomain. It is also not a function if an element in the domain is assigned to more than one element in the codomain.
4.3 Types of functions
- Functions can be classified based on how their inputs map to outputs.
4.3.1 Injective functions
- Injective function (or one-to-one): A function where different inputs always produce different outputs.
- No two distinct elements in the domain map to the same element in the codomain.
- Mathematically: If
f(x₁) = f(x₂)forx₁, x₂in the domain, thenx₁ = x₂.
📝 Example: Prove
f(x) = 2x + 1from ℝ to ℝ is injective.
- Assume
f(x₁) = f(x₂):2x₁ + 1 = 2x₂ + 1- Subtract 1 from both sides:
2x₁ = 2x₂- Divide by 2:
x₁ = x₂- Since
f(x₁) = f(x₂)impliesx₁ = x₂, the function is injective.
4.3.2 Surjective functions
- Surjective function (or onto): A function where every element in the codomain is mapped to by at least one element from the domain.
- The range of the function is equal to its codomain.
- Formally: For every
yin the codomain B, there exists at least onexin the domain A such thatf(x) = y.
📝 Example: Prove
f(x) = x³from ℝ to ℝ is surjective.
- Let
ybe any real number. We need to find anxsuch thatf(x) = y.- So,
x³ = y.- Solving for
x, we get x=3√y.- Since the cube root of any real number is a real number, x=3√y is always in the domain ℝ.
- Therefore,
f(x) = x³is surjective.
4.3.3 Bijective functions
- Bijective function: A function that is both injective and surjective.
- It establishes a perfect one-to-one correspondence between the elements of the domain and the codomain.
- Every element in the codomain is mapped to by exactly one element in the domain.
📝 Example: Prove
f(x) = x + 4from ℝ to ℝ is bijective.
- Injective proof:
- Assume
f(x₁) = f(x₂):x₁ + 4 = x₂ + 4- Subtracting 4 gives
x₁ = x₂. Thus,fis injective.- Surjective proof:
- Let
ybe any real number. We seek anxsuch thatf(x) = y.x + 4 = y- Solving for
xgivesx = y - 4.- Since
y - 4is always a real number, such anxalways exists. Thus,fis surjective.- Since
fis both injective and surjective, it is bijective.
4.4 Function composition
- Function composition: Applying one function to the result of another.
- If g:X→Y and f:Y→Z, the composition of
fandgis denotedf ∘ g. - The rule for composition is
(f ∘ g)(x) = f(g(x)). This results in a function from X to Z.
🔑 Important: The order of composition matters.
f ∘ gis not generally the same asg ∘ f.
📝 Example: If
f(x) = x²andg(x) = x + 2, find when(f ∘ g)(x) = (g ∘ f)(x).
(f ∘ g)(x) = f(g(x)) = f(x + 2) = (x + 2)² = x² + 4x + 4(g ∘ f)(x) = g(f(x)) = g(x²) = x² + 2- Set them equal:
x² + 4x + 4 = x² + 2- Subtract
x²from both sides:4x + 4 = 2- Subtract 4:
4x = -2- Divide by 4:
x = -1/2
📝 Example: If
f(x) = 3x - 1andg(x) = x², find(f ∘ g)(x)and(g ∘ f)(x).
(f ∘ g)(x) = f(g(x)) = f(x²) = 3(x²) - 1 = 3x² - 1(g ∘ f)(x) = g(f(x)) = g(3x - 1) = (3x - 1)² = 9x² - 6x + 1
📝 Example: If
f(x) = 1/xforx ≠ 0, find(f ∘ f)(x).
(f ∘ f)(x) = f(f(x)) = f(1/x) = 1 / (1/x) = x
4.5 Inverse functions
- Inverse function (
f⁻¹): A function that reverses the mapping of another functionf. - If
f(a) = b, thenf⁻¹(b) = a. - The domain of
f⁻¹is the range off, and the range off⁻¹is the domain off.
🔑 Important: An inverse function
f⁻¹exists only if the original functionfis bijective (both injective and surjective).
📝 Example: If
f = {(1, a), (2, c), (3, b)}, thenf⁻¹ = {(a, 1), (c, 2), (b, 3)}.
📝 Example: Given f:x→2x−3 with domain X =
{1, 2, 3}and codomain Y ={-1, 1, 3}.
🔑 Important: Understanding the properties of injective, surjective, and bijective functions is crucial for determining if an inverse exists and for solving problems involving function composition. These concepts are fundamental for analyzing algorithms and data structures.
5. Functions and their applications (part 2)
5.1 Functions in algorithm design
-
Functions model data transformations, assignments, and mappings in algorithms.
-
They represent processes like database management, task scheduling, and encryption.
-
A function f:A→B maps each element in set A to exactly one element in set B.
- Input set = domain A.
- Output set = codomain B.
- Algorithm steps define the rule for f.
-
Example function: An algorithm that doubles an integer.
- f(x)=2x.
- This maps integers to integers (f:Z→Z).
- Every integer input produces exactly one integer output.
5.2 Types of functions and their algorithmic uses
Algorithms benefit from specific function types to ensure desired properties.
- Injective functions (one-to-one) ensure different inputs yield different outputs.
- Surjective functions (onto) ensure all possible outputs are used.
- Bijective functions are both injective and surjective, creating perfect one-to-one correspondences.
🔑 Important: Functions in algorithms map inputs to outputs, with specific types (injective, surjective, bijective) ensuring distinct properties for efficiency and correctness.
5.2.1 Injective functions
Injectivity is crucial when distinct inputs must not lead to identical outputs.
- Hash functions: Used in data structures to avoid collisions.
- Collisions occur when different inputs map to the same hash value (same slot).
- A good hash function spreads data evenly to minimize collisions.
- Unique ID generation: Ensures no two entities share the same identifier.
- Assigning student IDs requires injectivity so each student has a unique ID.
📝 Example: Assigning unique employee IDs.
- Algorithm: For each employee i, generate ID = i×100+1.
- Why injective: If i1=i2, then ID1=ID2. No two employees share an ID.
5.2.2 Surjective functions
Surjectivity guarantees that every element in the output set is utilized.
- Load balancing: Ensures all servers receive tasks.
- Resource allocation: Guarantees all resources are assigned.
- Covering problems: Used in combinatorics to ensure all parts of a problem are addressed.
📝 Example: Assigning tasks to departments.
- Algorithm: For task t, compute department = (t(mod3))+1.
- Why surjective: Departments 1, 2, and 3 each receive at least one task.
5.2.3 Bijective functions
Bijective functions are ideal for scenarios requiring a perfect, reversible mapping.
- Bijective functions are also known as perfect matchings.
- Data encoding/decoding: Each code maps to exactly one message, and vice versa.
- Permutations: Used in sorting algorithms to reorder elements.
- Cryptographic ciphers: Ensure unique encryption and decryption for each message.
📝 Example: A sorting algorithm rearranging numbers.
- The mapping from original indices to final indices after sorting is bijective.
- Each original index maps to exactly one final index, and every final index receives exactly one mapping.
📝 Example: Assigning lockers to employees.
- Algorithm: Assign locker numbers sequentially (e.g., starting from 101) and record the Employee → Locker and Locker → Employee mappings.
- Why bijective: Ensures a perfect one-to-one correspondence and allows finding an employee from a locker number.
🔑 Important: Bijective functions are vital for tasks requiring unique, reversible pairings, like data encoding and cryptographic ciphers.
6. Graph theory fundamentals (part 1)
6.1 Introduction to graphs
- A graph
G=(V,E)consists of a set of verticesVand a set of edgesE. - Vertices are the elements of
V. - Edges are the elements of
E, connecting pairs of vertices. - A graph can have an infinite set of vertices, making it an infinite graph.
- This chapter focuses on finite graphs, which have a limited number of vertices.
🔑 Important: Graphs are fundamental structures for representing relationships between objects.
6.2 Undirected graphs
- An undirected graph
G=(V,E)has a non-empty set of verticesV. - The edge set
Econtains unordered pairs of distinct vertices. - An edge between vertices
vandwcan be written as(v,w)or(w,v). - In an undirected graph, edges have no specific direction.
📝 Example: Imagine a social network where friendship is mutual. If person A is friends with person B, then person B is also friends with person A. This can be represented by an undirected edge between A and B.
6.3 Directed graphs
- A directed graph, or digraph,
G=(V,E)has a set of verticesVand a set of edgesE. - Each edge in
Eis an ordered pair of vertices. - A simple directed graph has no loops and no multiple edges.
- An edge from
vtowis written as(v,w)or v→w. - In v→w,
vis the source andwis the target.
📝 Example: Consider a one-way street system in a city. An edge from intersection A to intersection B means you can travel from A to B, but not necessarily from B to A.
6.4 Graph terminology
- An edge
econnecting verticesvandwis incident on bothvandw. - Vertices
vandware adjacent if they are connected by an edge. - Adjacent vertices are also called neighbors.
- An isolated vertex is not incident on any edge.
| Vertex | Adjacent to |
|---|---|
| 1 | 2, 3 |
| 2 | 1, 3 |
| 3 | 1, 2, 4 |
| 4 | 3 |
| 5 | (none) |
🔑 Important: Understanding adjacency is key to tracing paths and understanding connectivity in a graph.
6.5 Types of graphs
| Graph Type | Loops Allowed? | Multiple Edges Allowed? |
|---|---|---|
| Simple graph | No | No |
| Multigraph | No | Yes |
| Pseudograph | Yes | Yes |
- Parallel edges connect the same pair of vertices.
- A multigraph has parallel edges but no loops.
- A pseudograph allows both loops and parallel edges.
🔑 Important: The type of graph determines the properties and relationships that can be modeled.
6.6 Vertex degrees
- The degree of a vertex
v, denoteddeg(v), is the number of edges incident on it. - A loop at a vertex
vcounts as two edges for its degree. - This is because a loop connects
vto itself, essentially counting as two ends of an edge atv.
📝 Example: In a graph with vertices A, B, C, if vertex A has edges to B, C, and a loop at A, its degree is 1 (to B) + 1 (to C) + 2 (loop) = 4.
- The sum of degrees of all vertices in a graph equals twice the number of edges.
- This is because each edge connects two vertices, contributing one to the degree of each.
> Sum of degrees = 2 * Number of edges
🔑 Important: The degree of a vertex indicates its connectivity and how many connections it has.
</document_content>
7. Graph theory fundamentals (part 2)
7.1 Vertex degrees
- Degree of a vertex: The number of edges connected to it.
- Sum of degrees: Always twice the number of edges in the graph.
Sum of degrees = 2×(number of edges)
- Even vertex: A vertex with an even degree.
- Odd vertex: A vertex with an odd degree.
- Isolated vertex: A vertex with a degree of zero.
Vertex degrees in different graph types:
| Graph Type | Example Vertex | Degree Calculation | Vertex Type |
|---|---|---|---|
| Simple Graph | A | Connected edges | Even/Odd |
| Multigraph | D | Edges are counted as many times as they appear | Even/Odd |
7.2 Oriented degrees
When edges are directed, degrees are split into in-degrees and out-degrees.
- In-degree (deg−): Number of edges pointing into a vertex.
- Out-degree (deg+): Number of edges pointing out of a vertex.
Example of oriented degrees:
| Vertex | In-degree (deg−) | Out-degree (deg+) |
|---|---|---|
| 1 | 0 | 2 |
| 2 | 3 | 3 |
| 3 | 4 | 2 |
7.3 Subgraphs
A subgraph is a smaller graph created from a part of a larger graph. It includes some or all vertices and edges of the original graph.
Types of subgraphs:
| Type | Description | Includes |
|---|---|---|
| Induced subgraph | Formed by a subset of vertices and all edges between them. | All vertices in the chosen subset; all original edges connecting pairs within that subset. |
| Spanning subgraph | Includes all vertices of the original graph but only some edges. | All original vertices; a subset of original edges. |
| Proper subgraph | Any subgraph that is not identical to the original graph G. | Fewer vertices, fewer edges, or both. |
7.4 Paths and Cycles
- Path: An alternating sequence of vertices and edges, starting at v0 and ending at vn, where each edge connects its adjacent vertices in the sequence. No edge can be used more than once. The length of a path is the number of edges.
- Cycle (or circuit): A path of non-zero length that starts and ends at the same vertex, with no repeated edges.
A cycle is a path from a vertex back to itself.
Cycle examples:
| Path | Cycle? | Reason |
|---|---|---|
| (6,5,2,4,3,2,1) | No | Vertex 2 is repeated (not a simple path). |
| (6,5,2,4) | No | Starts and ends at different vertices. |
| (2,6,5,2,4,3,2) | Yes | Starts/ends at vertex 2, no repeated edges. |
| (5,6,2,5) | Yes | Starts/ends at vertex 5, no repeated edges. |
| 7 | No | Path length must be non-zero. |
7.5 Euler paths and circuits
These concepts involve traversing every edge of a graph exactly once.
- Euler path: A simple path that includes every edge of the graph exactly once. Vertices can be revisited, but edges cannot be reused. The start and end vertices do not have to be the same.
- Euler circuit: An Euler path that starts and ends at the same vertex. It is a simple circuit containing every edge of the graph.
Conditions for Euler paths and circuits:
| Graph Properties | Path/Circuit Type |
|---|---|
| Connected, all vertices have even degrees | Euler circuit |
| Connected, exactly two vertices have odd degrees | Euler path |
| Connected, more than two vertices have odd degrees | Neither |
| Not connected (and has edges) | Neither |
🔑 Important: Graphs with more than two odd-degree vertices cannot have an Euler path or circuit.
Example analysis of graphs:
| Graph Number | Number of Odd Vertices | Number of Even Vertices | Path Contains |
|---|---|---|---|
| 1 | 0 | 10 | Euler Circuit (C) |
| 2 | 0 | 6 | Euler Circuit (C) |
| 3 | 2 | 6 | Euler Path (P) |
| 4 | 2 | 4 | Euler Path (P) |
| 5 | 4 | 1 | Neither (N) |
| 6 | 8 | 0 | Neither (N) |
🔑 Important: The presence and type of an Euler path/circuit depend critically on the number of odd-degree vertices in a connected graph.
8. Graph theory fundamentals (part 3)
8.1 Euler paths and circuits
- An Euler path is a path that traverses every edge of a graph exactly once.
- An Euler circuit is an Euler path that starts and ends at the same vertex.
🔑 Important: Graphs with an Euler circuit must have all vertices with even degrees. Graphs with an Euler path but no circuit must have exactly two vertices with odd degrees.
8.2 Hamilton paths and circuits
- A Hamilton path visits every vertex in the graph exactly once.
- A Hamilton circuit is a Hamilton path that begins and ends at the same vertex.
📝 Example: In the graph with vertices {a, b, c, d, e}, the path a → b → c → d → e is a Hamilton path.
📝 Example: The path A → B → C → D → A in a graph with vertices {A, B, C, D} is a Hamilton circuit.
8.3 Determining path and circuit types
- Graphs can have an Euler path, an Euler circuit, or neither.
- They can also have a Hamilton path, a Hamilton circuit, or neither.
🔑 Important: Unlike Euler paths, there are no simple degree conditions to guarantee a Hamilton path or circuit. Their existence often requires deeper analysis or specific graph properties.
| Graph Feature | Definition |
|---|---|
| Euler path | Visits every edge exactly once. |
| Euler circuit | An Euler path that starts and ends at the same vertex. |
| Hamilton path | Visits every vertex exactly once. |
| Hamilton circuit | A Hamilton path that starts and ends at the same vertex. |
🔑 Important: Determining Hamilton paths and circuits is generally more complex than for Euler paths and circuits. No easy rules like vertex degrees exist for Hamilton paths.
🔑 Important: An Euler path covers every edge once. A Hamilton path covers every vertex once. These are distinct concepts. </document_content>
9. Weighted graphs and algorithms (part 1)
9.1 Weighted graphs
- A weighted graph has numbers, called weights, assigned to its edges.
- The weight of an edge often represents its "cost."
- Weights can signify distance, capacity, or energy requirements.
- Weighted graphs can be directed or undirected.
📝 Example: In a computer network, edge weights might represent communication costs or response times between nodes.
9.2 Dijkstra's algorithm
- Dijkstra's algorithm finds the shortest path from a single starting vertex (source) to all other vertices in a graph.
- This algorithm works only with graphs that have non-negative edge weights.
9.2.1 Initialization
- Set the distance of the source vertex to 0.
- Assign an infinite distance (∞) to all other vertices.
- Mark all vertices as unvisited.
9.2.2 Algorithm steps
- Visit current node: For each neighbor of the current vertex, calculate its potential new distance from the source.
- Update distance: If the newly calculated path is shorter than the neighbor's current recorded distance, update it.
- Mark as visited: Once a vertex's shortest path is determined, it is marked as visited and will not be reconsidered.
- Choose next node: Select the unvisited vertex with the smallest tentative distance from the source.
- Repeat: Continue this process until all vertices have been visited or the target destination is reached.
🔑 Important: Dijkstra's algorithm guarantees finding the shortest path in graphs with non-negative edge weights.
9.2.3 Example walkthrough
Let's find the shortest paths from vertex A in a sample graph.
-
Initial state:
- Distances: A: 0, B: ∞, C: ∞, D: ∞, E: ∞
- Unvisited: {A, B, C, D, E}
-
Step 1 (from A):
- Neighbors of A are B (weight 4) and C (weight 2).
- Distances update: A: 0, B: 4, C: 2, D: ∞, E: ∞
- A is now visited. Smallest distance among unvisited is C.
-
Step 2 (from C):
- Neighbors of C are A (weight 1), B (weight 3), and D (weight 4).
- Path to B via C: C's distance + edge B-C = 5. Current B distance is 4. No update.
- Path to D via C: C's distance + edge C-D = 6. Current D distance is ∞. Update D to 6.
- Distances: A: 0, B: 4, C: 2, D: 6, E: ∞
- C is now visited. Smallest distance among unvisited is B.
-
Step 3 (from B):
- Neighbors of B are A (weight 4), C (weight 3), D (weight 2), and E (weight 1).
- Path to D via B: B's distance + edge B-D = 6. Current D distance is 6. No update 2.
- Path to E via B: B's distance + edge B-E = 5. Current E distance is ∞. Update E to 5 1 4.
- Distances: A: 0, B: 4, C: 2, D: 6, E: 5
- B is now visited. Smallest distance among unvisited is E.
-
Step 4 (from E):
-
Step 5 (from D):
- D has no outgoing edges to unvisited nodes. D is now visited.
-
Final Shortest Paths from A:
- A to A: 0
- A to B: 4
- A to C: 2
- A to D: 6
- A to E: 5
🔑 Important: The algorithm repeatedly selects the unvisited node closest to the source and updates distances to its neighbors.
9.3 Spanning trees
- A spanning tree is a subgraph of an undirected graph that includes all vertices and is a tree.
- A graph must be connected to have a spanning tree.
- A graph can have multiple spanning trees.
📝 Example: In a network, a spanning tree ensures all devices can communicate without redundant connections, minimizing infrastructure costs.
🔑 Important: Spanning trees are crucial in network design to connect all nodes efficiently while avoiding cycles, ensuring connectivity and minimizing redundancy.
10. Weighted graphs and algorithms (part 2)
10.1 Spanning trees
- A spanning tree is a subgraph of a connected graph that connects all vertices without forming any cycles.
- It is used in networks to ensure data reaches destinations quickly without loops.
- A spanning tree of a connected graph with n vertices always has n−1 edges 160.
📝 Example: For a graph with vertices {a, b, c, d, e}, a spanning tree would connect all these vertices using exactly 4 edges, ensuring no path creates a loop. 161 163.
10.2 Minimum spanning trees
- A minimum spanning tree (MST) is a spanning tree of a weighted graph where the sum of the weights of all the edges is as small as possible.
- Finding an MST is useful for tasks like minimizing cable length in network design.
🔑 Important: An MST connects all vertices with the least total edge weight, guaranteeing no cycles 164.
10.3 Prim's algorithm for MST
- Prim's algorithm finds an MST by iteratively building the tree from a single vertex.
- It starts with an arbitrary vertex and adds the cheapest edge connecting a vertex in the growing tree to a vertex outside the tree 165.
10.3.1 Prim's algorithm steps
- Step 1: Arrange all edges of the weighted graph in decreasing order of weights.
- Step 2: Sequentially consider each edge. Delete an edge if it does not disconnect the graph. Continue until n−1 edges remain, forming the MST.
🔑 Important: Prim's algorithm prioritizes adding heavier edges first but strategically removes them to avoid cycles, ensuring a minimal total weight 166.
- Note: The document describes an alternative phrasing of Prim's algorithm that sorts edges by decreasing weight and deletes edges that don't disconnect the graph. This is less common but leads to the same result as the standard Prim's.
📝 Example: Consider a graph with vertices A, B, C, D, E, F and edges with weights. Sort edges by decreasing weight. Systematically remove edges that don't disconnect the graph until 5 edges remain. The resulting edges form the MST. 167.
- The MST found using this method for the example graph has a total weight of 24 168.
10.4 Kruskal's algorithm for MST
- Kruskal's algorithm finds an MST by selecting edges in increasing order of weight.
- It ensures that adding an edge does not form a cycle with the already selected edges.
10.4.1 Kruskal's algorithm steps
- Step 1: Arrange all edges of the weighted graph in increasing order of weights.
- Step 2: Starting with individual vertices, add edges sequentially if they do not create a cycle. Continue until n−1 edges are added.
🔑 Important: Kruskal's algorithm focuses on adding the cheapest available edges first, as long as they don't form cycles 173.
📝 Example: For the same weighted graph used for Prim's algorithm, order edges by increasing weight. Add edges BD (weight 3), AE (weight 4), DF (weight 4), CE (weight 6), and AF (weight 7) because they do not form cycles. 174 175.
- The MST obtained using Kruskal's algorithm for the example graph also has a total weight of 24.
- Note that the specific edges in the MST may differ between Prim's and Kruskal's algorithms, even if the total weight is the same.
🔑 Important: Both Prim's and Kruskal's algorithms produce a minimum spanning tree for a connected, weighted graph, but the exact set of edges in the MST might vary 177.
11. Weighted graphs and algorithms (part 3)
11.1 Graph theory in navigation
Graph theory models physical spaces as graphs. This helps agents navigate.
- Nodes (V) represent possible locations.
- Edges (E) represent movements between locations.
- Edge weights signify the cost of movement. Costs can be distance, time, or energy.
- Converting the physical world into a graph allows for pathfinding 180.
11.2 Applications of graph theory in navigation
Graph theory applications are widespread in navigation systems.
-
Robotics:
- Occupancy grids are used to map environments.
- Algorithms like Dijkstra's or A* find shortest paths.
- Robots use this to reach objects or charging docks.
-
GPS & Road Maps:
- Intersections become nodes.
- Roads are edges with travel time as weights.
- Dijkstra's algorithm finds the fastest routes.
-
Video Games:
- Game worlds are converted into navigation mesh graphs.
- Non-player characters (NPCs) use Dijkstra's to move.
- They move towards players or target objects 179.
11.3 Minimal spanning tree algorithms
Minimal spanning trees (MSTs) connect all vertices with minimum total edge weight.
🔑 Important: Prim's and Kruskal's algorithms are used to find MSTs.
11.3.1 Prim's algorithm for MST
Prim's algorithm grows an MST from a single vertex. It iteratively adds the cheapest edge connecting a vertex in the MST to one outside it.
11.3.2 Kruskal's algorithm for MST
Kruskal's algorithm sorts all edges by weight. It adds edges in increasing order of weight, ensuring no cycles are formed.
🔑 Important: Both Prim's and Kruskal's algorithms find a minimal spanning tree for a connected, undirected, weighted graph.
11.3.3 Practice problem
Consider a graph with 9 vertices and 8 edges. You need to find its minimal spanning tree.
-
Prim's algorithm approach:
- Start with an arbitrary vertex.
- Add the lowest-weight edge connecting to a vertex not yet in the tree.
- Repeat until all vertices are included.
- The total weight in the example is 37.
-
Kruskal's algorithm approach:
- List all edges and their weights.
- Sort edges by weight, from lowest to highest.
- Select edges if they do not form a cycle with previously selected edges.
- Continue until all vertices are connected 178.
🔑 Important: Drawing the minimal spanning tree visually confirms the algorithm's output and helps understand its structure.
🔑 Important: Applying graph theory in navigation converts real-world scenarios into graph problems, solvable by algorithms like Dijkstra's for shortest paths and Prim's/Kruskal's for network optimization. </document_content>
12. Basic logic and propositions
12.1 What is logic?
- Logic: The study of correct reasoning principles. It helps us tell good reasoning from bad reasoning 184.
- Logic also examines how conclusions follow from given assumptions. This helps us determine the validity of arguments 185.
12.2 Propositions
-
A proposition is a declarative sentence. It must be either true or false, but not both.
📝 Example: "The Earth is round." This is a proposition because it is a statement that is either true or false.
-
Sentences that are questions, commands, or statements whose truth depends on variables are not propositions.
📝 Example: "Buy two tickets." This is a command, not a proposition. 📝 Example: "8 + 2x = 32." The truth of this statement depends on the value of x 187.
-
To represent propositions, we use variables like p, q, and r. This is similar to using letters in algebra for numbers.
📝 Example: We can define p as the proposition "3 + 2 = 9" 191.
12.2.1 Identifying propositions
-
Sentences that can be definitively classified as true or false are propositions.
📝 Example: "Kedah is the biggest state in Malaysia." This is a proposition with a true or false value. 📝 Example: "2 + 5 = 10." This is a proposition, and it is false.
-
Sentences that are commands or questions cannot be propositions.
📝 Example: "Wake up!" This is a command. 📝 Example: "What time is it?" This is a question 190.
🔑 Important: Only declarative sentences that have a definite truth value (true or false, not both) are propositions 188.
13. Logical connectives and truth tables
13.1 Compound statements and logical connectives
- Compound statements are formed by combining simpler statements using logical connectives.
- These connectives allow us to build more complex propositions from basic ones.
13.1.1 Conjunction (AND)
- Conjunction of two propositions, p and q, is denoted by p∧q.
- It represents the idea of "p and q".
- The conjunction p∧q is true only when both p and q are true. Otherwise, it is false.
📝 Example: If p: "It is sunny" (True) and q: "It is warm" (True), then p∧q: "It is sunny and it is warm" is True.
13.1.2 Disjunction (OR)
- Disjunction of two propositions, p and q, is denoted by p∨q.
- It represents the idea of "p or q".
- The disjunction p∨q is true if at least one of the propositions (p or q) is true. It is false only when both p and q are false.
📝 Example: If p: "It is sunny" (False) and q: "It is warm" (False), then p∨q: "It is sunny or it is warm" is False.
13.1.3 Negation (NOT)
- Negation of a proposition p is denoted by ¬p.
- It represents the idea of "not p" or "it is not the case that p".
- The truth value of ¬p is the opposite of the truth value of p.
📝 Example: If p: "Mango is a vegetable" (False), then ¬p: "Mango is not a vegetable" is True. Note: Negation denies a statement, it does not correct it or provide an opposite meaning.
13.2 Truth tables
- Truth tables are used to systematically determine the truth values of compound statements.
- They list all possible combinations of truth values for the individual propositions.
- A truth table has n+1 columns for n input propositions. The first n columns show input combinations, and the last column shows the output.
🔑 Important: Truth tables provide a clear, step-by-step method to evaluate the truth of any logical expression.
13.2.1 Constructing truth tables
- Truth tables map all possible truth value combinations of the basic propositions to the truth value of the compound statement.
- Each row represents a unique combination of true (T) and false (F) for the propositions.
13.2.1.1 Conjunction truth table
- The truth table for conjunction (p∧q) shows that it is true only when both p and q are true.
| p | q | p∧q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | F |
13.2.1.2 Disjunction truth table
- The truth table for disjunction (p∨q) shows that it is true if at least one of p or q is true. It is false only when both are false.
| p | q | p∨q |
|---|---|---|
| T | T | T |
| T | F | T |
| F | T | T |
| F | F | F |
13.2.1.3 Negation truth table
- The truth table for negation (¬p) shows that its truth value is always the opposite of p.
| p | ¬p |
|---|---|
| T | F |
| F | T |
🔑 Important: For negation, ensure you are denying the statement, not asserting its opposite meaning. For example, "Alex is not tall" is the negation of "Alex is tall", not "Alex is short".
🔑 Important: When negating universal statements like "All vehicles have 4 wheels", the negation is not "No vehicles have 4 wheels" or "Some vehicles have 4 wheels". The correct negation is "It is not the case that all vehicles have 4 wheels", which means "There exists at least one vehicle that does not have 4 wheels".
🔑 Important: Master the structure and interpretation of basic truth tables for conjunction, disjunction, and negation. These are the building blocks for all more complex logical expressions.
14. Conditional and biconditional propositions
14.1 Conditional propositions
- A conditional proposition has the form "if p then q" or "p implies q".
- This is symbolized as p→q.
- The condition is the first part (p), and the effect is the second part (q).
📝 Example: "If students study hard, then they will pass the test." Here, "students study hard" is the condition (p), and "they will pass the test" is the effect (q).
- The truth value of p→q depends on the truth of p and q.
🔑 Important: The conditional operator → is evaluated last in complex logical expressions.
14.1.1 Truth table for conditional propositions
- A conditional proposition p→q is only false when the condition (p) is true and the effect (q) is false.
| p | q | p→q |
|---|---|---|
| True | True | True |
| True | False | False |
| False | True | True |
| False | False | True |
🔑 Important: If the condition (p) is false, the entire conditional statement (p→q) is true, regardless of q's truth value.
14.1.2 Rewriting propositions as conditional statements
- Many statements can be rephrased into "if p then q" form.
📝 Example: "Mary will be a good lecturer if she knows how to teach." can be rewritten as "If Mary knows how to teach, then she will be a good lecturer."
14.1.3 Variations of conditional propositions
- The converse, contrapositive, and inverse are related to a conditional proposition p→q.
🔑 Important: Only the contrapositive is logically equivalent to the original conditional proposition.
| Proposition | Form | Equivalence to p→q |
|---|---|---|
| Conditional | p→q | Original |
| Converse | q→p | Not necessarily equivalent |
| Contrapositive | ¬q→¬p | Logically equivalent |
| Inverse | ¬p→¬q | Not necessarily equivalent |
📝 Example: Original: "If it rained last night, then the sidewalk is wet."
- Converse: "If the sidewalk is wet, then it rained last night."
- Contrapositive: "If the sidewalk is not wet, then it did not rain last night."
- Inverse: "If it did not rain last night, then the sidewalk is not wet."
14.2 Biconditional propositions
- A biconditional proposition connects two propositions p and q with "if and only if".
- This is symbolized as p↔q.
- It means that p is true exactly when q is true, and p is false exactly when q is false.
📝 Example: "1 < 5 if and only if 2 < 8." Both "1 < 5" and "2 < 8" are true, so the biconditional statement is true.
14.2.1 Truth table for biconditional propositions
- A biconditional proposition p↔q is true only when both p and q have the same truth value.
| p | q | p↔q |
|---|---|---|
| True | True | True |
| True | False | False |
| False | True | False |
| False | False | True |
🔑 Important: A biconditional statement p↔q is true if and only if both p→q and q→p are true.
📝 Example: "x = 3 if and only if x2 = 9." This statement is false because when x = -3, x2 = 9 is true, but x = 3 is false.
🔑 Important: The most crucial concept for biconditional statements is that both parts must share the same truth value (both true or both false) for the entire statement to be true.
15. Tautologies, contradictions, and contingencies (part 1)
15.1 Classifying logical statements
- A tautology is a statement that is always true for all possible truth values of its variables.
- A contradiction is a statement that is always false for all possible truth values of its variables.
- A contingency is a statement that is neither a tautology nor a contradiction. Its truth value depends on the truth values of its variables.
🔑 Important: Truth tables are used to determine if a statement is a tautology, contradiction, or contingency.
15.1.1 Using truth tables for classification
Truth tables systematically list all possible truth combinations for the propositional variables in a statement. Evaluating the statement for each combination reveals its overall truth value.
- If the final column of a truth table contains only 'T' (True), the statement is a tautology.
- If the final column contains only 'F' (False), the statement is a contradiction.
- If the final column contains a mix of 'T' and 'F', the statement is a contingency.
📝 Example: To check if ((p→q)∧(q→r))→(p→r) is a tautology:
| p | q | r | p→q | q→r | p→r | (p→q)∧(q→r) | ((p→q)∧(q→r))→(p→r) |
|---|---|---|---|---|---|---|---|
| T | T | T | T | T | T | T | T |
| T | T | F | T | F | F | F | T |
| T | F | T | F | T | T | F | T |
| T | F | F | F | T | F | F | T |
| F | T | T | T | T | T | T | T |
| F | T | F | T | F | T | F | T |
| F | F | T | T | T | T | T | T |
| F | F | F | T | T | T | T | T |
Since all values in the final column are 'T', the statement is a tautology 227.
- The statement p∧(p∨q)→q is not a tautology. Its truth table shows mixed results 226.
15.2 Limitations of propositional logic
Propositional logic, which treats each statement as an indivisible unit, has limitations. It cannot adequately represent statements involving variables or properties of groups.
- Repetitive statements: Representing the same property for many individuals requires repeating the same logical structure. For example, if 'x' is a PKS graduate, then 'x' passed the diploma. This would need to be stated for John, Ann, Mary, and so on, individually 239.
- Group properties: Expressing properties about entire groups of objects is difficult. For instance, "All new cars must be registered" or "Not all birds fly" cannot be fully captured by simple propositions 240.
- Logical equivalences: Propositional logic cannot capture relationships between statements like "Not all birds fly" and "Some birds don't fly." It treats these as entirely separate statements. 236 237.
🔑 Important: To handle these complex statements and inferences, a more powerful logic system is needed.
15.3 Introduction to predicate logic
Predicate logic extends propositional logic by introducing predicates and quantifiers. This allows for the representation of statements about objects and their properties.
- A predicate is a verb phrase template describing a property or relationship. It uses variables that can be substituted with specific objects 241.
- For example, "is blue" is a predicate. When we say "The sky is blue," we substitute "The sky" for the variable.
- A statement with a predicate, like P(x) meaning "x is a prime number," is not a proposition on its own.
- Similarly, G(x,y) representing "x is greater than y" is not a proposition 243.
- However, G(9,4) meaning "9 is greater than 4" is a proposition.
🔑 Important: Predicate logic enables reasoning about statements involving variables and general properties, which propositional logic cannot do.
15.3.1 Predicates and propositional functions
- A predicate can be thought of as a propositional function. It takes one or more arguments (variables) and returns a truth value.
- The notation P(x) indicates that P is a predicate with one variable x. P(a) is the proposition obtained by substituting the constant a for the variable x 242.
- For instance, if Older(x,y) means "x is older than y", then Older(John,Peter) is a proposition 244.
- Older(x,y) itself is not a proposition; it becomes one upon substitution.
🔑 Important: Predicates allow us to generalize statements and make them applicable to many objects, overcoming the limitations of propositional logic.
16. Predicate logic and quantifiers
16.1 Propositional functions
- A propositional function, or predicate, is a statement with a variable.
- It becomes a proposition when the variable is replaced by a specific value from its domain.
- The domain of discourse is the set of all possible values for the variable.
📝 Example: Let P(n) be the statement "n is an odd integer." If the domain of discourse is the set of positive integers, then P is true ("3 is an odd integer"), and P is false ("8 is an odd integer"). This makes P(n) a propositional function 3 8.
- This applies to statements about specific groups or roles.
- For instance, "The baseball player hit over .300 in 2003" is a propositional function if the domain is all baseball players.
- Substituting "Barry Bonds" makes it a true proposition, while "Alex Rodriguez" makes it false.
16.2 Quantifiers
- Quantifiers extend propositional logic to statements about variables.
- They specify the extent to which a predicate is true within its domain.
Key types of quantifiers:
- Universal quantifier: States that a predicate is true for all members of the domain.
- Existential quantifier: States that a predicate is true for at least one member of the domain.
16.3 Universal quantifier
- The universal quantifier is written as ∀.
- A statement ∀xP(x) reads "For all x, P(x) is true."
- It is true if P(x) holds for every single element in the domain.
- It is false if there is at least one element in the domain for which P(x) is false.
Understanding ∀xP(x):
- True condition: P(x) is true for every x in the domain.
- False condition: There exists at least one x in the domain for which P(x) is false.
- A value that makes a universally quantified statement false is called a counterexample.
📝 Example: Consider ∀x(x2−1>0) with the domain of real numbers.
- If we test x=1, we get 12−1=0, which is not greater than 0.
- Since x=1 makes the statement false, it is a counterexample.
- Therefore, the statement ∀x(x2−1>0) is false.
16.4 Existential quantifier
- The existential quantifier is written as ∃.
- A statement ∃xP(x) reads "There exists an x such that P(x) is true."
- It is true if P(x) holds for at least one element in the domain.
- It is false if P(x) is false for every element in the domain.
Understanding ∃xP(x):
- True condition: There exists at least one x in the domain for which P(x) is true.
- False condition: P(x) is false for every x in the domain.
- Disproving an existential statement requires showing it is false for all possible values in the domain.
📝 Example: Consider the statement "There is a red car." This is true if at least one car is red.
- Consider ∃x(x2<0) for real numbers x.
- Since no real number squared is less than zero, this statement is false.
🔑 Important: Predicate logic allows us to make precise statements about collections of objects and their properties, moving beyond simple true/false propositions. Understanding quantifiers is key to expressing these complex relationships.
17. Boolean algebra fundamentals (part 1)
17.1 Introduction to Boolean algebra
- Boolean algebra is a mathematical system for working with the set {0, 1}.
- It uses three main operations:
- Complementation (NOT)
- Boolean sum (OR)
- Boolean product (AND)
17.2 Core Boolean operations
- Complementation (denoted by x or NOT) flips a value:
- 0=1
- 1=0
- Boolean sum (denoted by + or OR) is true if at least one input is true:
- 1+1=1
- 1+0=1
- 0+1=1
- 0+0=0
- Boolean product (denoted by ⋅ or AND) is true only if all inputs are true:
- 1⋅1=1
- 1⋅0=0
- 0⋅1=0
- 0⋅0=0
These operations correspond to logical operators: complementation is ¬ (NOT), Boolean sum is ∨ (OR), and Boolean product is ∧ (AND). Here, 0 represents False (F) and 1 represents True (T).
17.2.1 Evaluating Boolean expressions
- Expressions combine variables with operators.
- Evaluate them using the defined operation rules.
📝 Example: Evaluate 1⋅0+0+1.
1⋅0+0+1=0+0+1=0+1=1 264.
📝 Example: Translate 1⋅0+0+1=0 into logical equivalence.
(T∧F)∨¬(T∨F)≡F 265.
17.3 Boolean expressions and functions
- A Boolean expression is a logical statement. It evaluates to TRUE or FALSE.
- A Boolean function is represented by a Boolean expression.
📝 Example: The expression
5 == 5evaluates to TRUE because both sides are equal 267.
-
Common comparison operators yield Boolean values:
Operator Description ==Equal to !=Not equal to <Less than >Greater than <=Less than or equal to >=Greater than or equal to -
Common logical operators act on Boolean values:
Operator Description !Logical NOT &&Logical AND
17.3.1 Evaluating complex Boolean expressions
- When evaluating, follow operator precedence (usually NOT, then AND, then OR).
- Parentheses can clarify order.
📝 Example: Evaluate p∧q∨r where p is TRUE, q is FALSE, and r is FALSE.
T∧F∨F≡F∨F≡F 270.
📝 Example: Evaluate ¬q∨p∧r where p is TRUE, q is FALSE, and r is FALSE.
¬F∨T∧F≡T∨F≡T 271.
17.3.2 Evaluating Boolean functions with variables
- A Boolean function can have multiple input variables.
- Its output depends on the combination of input values.
📝 Example: Find the values of the Boolean function F(x,y,z)=xy+z.
x y z xy F(x,y,z)=xy+z 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 273.
🔑 Important: Boolean functions map input combinations to output values, typically represented by truth tables.
17.4 Boolean expression simplification
- Boolean algebra identities can simplify complex expressions.
- Simplification makes expressions easier to understand and implement.
📝 Example: Simplify C+BC.
C+BC=C(1+B) (Distributive Law) C(1+B)=C (Identity Law 1+x=1). C=C (Identity Law x⋅1=x). So, C+BC=C 276.
📝 Example: Simplify AB(A+B)B+B.
AB(A+B)B+B=(A⋅AB+AB⋅B)B+B (Distributive) =(AB+AB)B+B (Idempotent Law A⋅A=A) =(AB)B+B (Idempotent Law A+A=A) =ABB+B (Associative Law (AB)C=ABC) =AB+B (Idempotent Law B⋅B=B) =B(A+1) (Distributive Law) =B (Identity Law 1+x=1) 1. =B (Identity Law x⋅1=x) So, AB(A+B)B+B=B 277.
🔑 Important: Simplification uses laws like distributive, associative, commutative, identity, idempotent, and complementation to reduce expression complexity.
🔑 Important: Boolean algebra provides rules for simplifying expressions, which is crucial for designing efficient logic circuits.
18. Boolean algebra fundamentals (part 2)
18.1 Logic gates
Logic gates are the basic building blocks of electronic circuits. They implement Boolean algebra operations.
These circuits are found in computers and other electronic devices 279.
18.2 Basic logic gates
Logic gates perform fundamental Boolean operations. Each gate has specific input and output behavior based on Boolean logic.
-
NOT gate: This gate inverts the input signal. If the input is A, the output is NOT A. It is also called an inverter 280.
-
OR gate: This gate outputs a high signal if at least one input is high. The OR operation is shown with a plus sign (+)281.
-
AND gate: This gate outputs a high signal only when all inputs are high. The AND operation is shown with a dot (⋅) or omitted 1 282.
| Gate | Symbol | Operation | Description |
|---|---|---|---|
| NOT | A→A | A | Inverts the input. |
| OR | A+B | A+B | High output if any input is high. |
| AND | A⋅B | A⋅B | High output only if all inputs are high. |
18.3 Constructing circuits from Boolean expressions
Boolean expressions can be translated into logic gate circuits. Combinations of basic gates form more complex circuits.
Some gates may share inputs in these combined circuits 283.
- Circuit construction: You can build circuits for given Boolean expressions. This involves using NOT, OR, and AND gates according to the expression's structure 288.
📝 Example: Construct a circuit for Q=A+B. This circuit requires a NOT gate for input A and an OR gate to combine A with input B.
| Expression | Gate Combination |
|---|---|
| Q=A | Input A goes to a NOT gate. The output is Q. |
| Q=A+B | Inputs A and B go to an OR gate. The output is Q. |
| Q=A⋅B | Inputs A and B go to an AND gate. The output is Q. |
| Q=A+B | Input A goes to a NOT gate, its output and input B go to an OR gate for Q. |
| Q=(A⋅B)+C | A and B go to an AND gate. Its output and C go to an OR gate for Q. |
18.4 Deriving Boolean expressions from circuits
Conversely, you can write a Boolean expression for a given circuit diagram. Trace the signal flow through the gates from inputs to the final output 289.
- Circuit analysis: Identify the operations performed by each gate. Combine these operations step-by-step to form the overall expression for the output. 290 291.
📝 Example: For a circuit with inputs A and B feeding into an AND gate, the output expression is Q=A⋅B.
| Circuit Description | Boolean Expression |
|---|---|
| Two inputs A, B to an AND gate | Q=A⋅B |
| Input A inverted, then OR-ed with B | Q=A+B |
| A AND B, then NOT, then OR with C | Q=(A⋅B)+C |
🔑 Important: Understanding how to convert between Boolean expressions and circuit diagrams is crucial for designing and analyzing digital systems 284.
19. Minimization of circuits using Karnaugh maps
19.1 Introduction to circuit minimization
- Circuit efficiency: The number and arrangement of gates determine how efficient a combinational circuit is.
- Minimizing Boolean functions: This process creates circuits using fewer gates. It also reduces the number of inputs to the AND and OR gates. This leads to a simpler and more efficient circuit design 294.
19.2 Karnaugh maps (K-maps)
- Purpose: Karnaugh maps, or K-maps, were developed to help minimize circuits manually. They are effective for circuits with up to six variables 295.
- Visual grouping: A K-map is a graphical tool. It helps group together Boolean expressions that share common factors. This process eliminates unnecessary variables 296.
- Map structure: A K-map is a special arrangement of a truth table. Each square in the map corresponds to a row in the truth table. The map displays the output values directly.
- Variable representation: Variables are placed along the edges of the map. For a two-variable problem, one variable is on top and the other on the side.
📝 Example: For a two-variable function with inputs A and B, the map might have A values across the top and B values down the left side. The output '1's from the truth table are then placed into the corresponding squares on the map 297.
19.3 Rules for simplification using K-maps
The K-map uses specific rules for simplifying Boolean expressions by grouping adjacent cells containing '1's.
- Adjacent cells: Cells are considered adjacent if they are directly next to each other horizontally or vertically 299.
- Wrapping: Groups can wrap around the edges of the map. The leftmost cell in a row can be grouped with the rightmost. Similarly, the top cell in a column can be grouped with the bottom cell.
- Group size: Each group must contain a number of cells that is a power of 2 (1, 2, 4, 8, etc.).
- Maximizing group size: Groups should be as large as possible. This helps achieve maximum simplification.
- Covering all ones: Every '1' in the map must be included in at least one group.
- No zeros: Groups are formed only around '1's; '0's are not included in groups.
- No diagonals: Groups cannot be formed diagonally.
- Overlapping: Groups are allowed to overlap.
- Minimizing groups: The goal is to use the fewest number of groups possible. This ensures the most simplified expression 304.
🔑 Important: The primary goal is to cover all '1's with the largest possible groups, using the fewest groups, allowing for adjacency, wrapping, and overlap.
19.4 K-map simplification process
The simplification process involves filling the K-map, identifying groups of '1's, and deriving the simplified Boolean expression from these groups.
- Map filling: Copy the output values from a truth table into the corresponding cells of the K-map. Place '1's for true outputs and '0's for false outputs 298.
- Identifying groups: Look for opportunities to create the largest possible rectangular or square groups of adjacent '1's. Remember that groups can wrap around the edges 303 305.
- Deriving terms: Each group corresponds to a simplified product term in the final Boolean expression.
- If a variable's value is the same for all cells in a group, that variable appears in the term.
- If a variable changes value within a group, it is eliminated from the term.
- Combining terms: The final simplified expression is the sum of these product terms.
📝 Example: Consider a group of four '1's where the input 'A' is always '1', 'B' changes from '0' to '1', and 'C' changes from '0' to '1'. The term for this group would be just 'A', as only 'A' remains constant. If a group of two '1's had 'B' as '0' and 'C' as '1' consistently, the term would be BˉC. The full expression is the OR (sum) of all such terms 307.
19.5 K-map applications and practice
K-maps are used to solve practical minimization problems for logic circuits.
| Input Combination | Output (F) |
|---|---|
| ABC = 000 | 0 |
| ABC = 001 | 0 |
| ABC = 010 | 1 |
| ABC = 011 | 0 |
| ABC = 100 | 1 |
| ABC = 101 | 1 |
| ABC = 110 | 1 |
| ABC = 111 | 0 |
📝 Example: For the truth table above, the K-map would be filled with '1's at positions corresponding to 010, 100, 101, and 110. Grouping the '1's at (100, 101) yields the term ABˉ. Grouping the '1's at (100, 110) is not allowed as it is not rectangular. However, grouping (100, 110) is also not valid as it would mean selecting A and C as constant. The correct grouping is (010, 100, 110), but this is not a power of 2. The valid groups are:
🔑 Important: K-maps are a visual tool that simplifies Boolean algebra by grouping terms with common factors, leading to more efficient circuit designs.
© 2026 Maeve. All rights reserved. This content is protected by copyright.