math

1. Boolean algebra and logic gates (part 1)

This section introduces the foundational concepts of Boolean algebra, including its basic operations, the construction of Boolean expressions and functions, and their direct correspondence to logical operators and truth values.

1.1 Introduction to Boolean algebra

Boolean algebra is a mathematical system that deals with operations on a set of two values, typically represented as {0, 1}. It forms the bedrock for digital logic design and computer science, providing rules for manipulating logical statements. The three primary operations in Boolean algebra are complementation, Boolean sum, and Boolean product 3.

1.1.1 Boolean operations

  • Complementation: Denoted by a bar over the variable (e.g., Aˉ\bar{A}), it inverts the value of an element. Specifically, 0ˉ=1\bar{0} = 1 and 1ˉ=0\bar{1} = 0.

  • Boolean sum: Also known as the OR operation, denoted by + or OR. Its truth table is as follows:

    • 1+1=11 + 1 = 1
    • 1+0=11 + 0 = 1
    • 0+1=10 + 1 = 1
    • 0+0=00 + 0 = 0 4.
  • Boolean product: Also known as the AND operation, denoted by . or AND. Its rules are:

    • 1⋅1=11 \cdot 1 = 1
    • 1⋅0=01 \cdot 0 = 0
    • 0⋅1=00 \cdot 1 = 0
    • 0⋅0=00 \cdot 0 = 0 5.

Example: Evaluate 1⋅0+0+11 \cdot 0 + 0 + 1. Using the definitions of the operations: 1⋅0+0+1=0+0+1=0+1=11 \cdot 0 + 0 + 1 = 0 + 0 + 1 = 0 + 1 = 1 6.

1.1.2 Logical equivalence

The Boolean operations directly correspond to logical operators:

  • Complementation (Aˉ\bar{A}) corresponds to logical negation (¬A\neg A).
  • Boolean sum (A+BA+B) corresponds to logical OR (A∨BA \vee B).
  • Boolean product (A⋅BA \cdot B) corresponds to logical AND (A∧BA \wedge B).

In this correspondence, 0 represents FALSE (F) and 1 represents TRUE (T).

Example: Translate 1⋅0+0+1=11 \cdot 0 + 0 + 1 = 1 into a logical equivalence. This translates to (T∧F)∨(F∨T)≡T(T \wedge F) \vee (F \vee T) \equiv T, which simplifies to F∨T≡TF \vee T \equiv T, and finally T≡TT \equiv T 7.

1.2 Boolean expressions and Boolean functions

A Boolean expression is a logical statement composed of Boolean values (TRUE/FALSE) and logical connectives. A Boolean function is represented by a Boolean expression and produces a Boolean value as its output 8.

1.2.1 Comparison operators

In programming contexts, Boolean values are often produced by comparison operators that evaluate the relationship between two operands. Common comparison operators include:

  • x==yx == y: xx is equal to yy
  • x!=yx != y: xx is not equal to yy
  • x<yx < y: xx is less than yy
  • x>yx > y: xx is greater than yy
  • x<=yx <= y: xx is less than or equal to yy
  • x>=yx >= y: xx is greater than or equal to yy 10.

1.2.2 Logical operators

Logical operators are used to combine or modify Boolean variables and expressions:

  • !: Logical negation (NOT)
  • &&: Logical AND
  • ||: Logical OR 11.

Example: Evaluate the Boolean expression p∧q∨rp \land q \lor r, given p=TRUEp = TRUE, q=FALSEq = FALSE, r=FALSEr = FALSE. T∧F∨FT \land F \lor F F∨FF \lor F FF 12.

Example: Evaluate the Boolean expression !q∨p∧r!q \lor p \land r, given p=TRUEp = TRUE, q=FALSEq = FALSE, r=FALSEr = FALSE. !FALSE∨TRUE∧FALSE!\textit{FALSE} \lor \textit{TRUE} \land \textit{FALSE} TRUE∨FALSE\textit{TRUE} \lor \textit{FALSE} TRUE\textit{TRUE} 13.

Example: Evaluate −j>k∨k==1∧k>3-j > k \lor k == 1 \land k > 3, given j=12j = 12, k=15k = 15. −12>15∨15==1∧15>3-12 > 15 \lor 15 == 1 \land 15 > 3 FALSE∨FALSE∧TRUEFALSE \lor FALSE \land TRUE FALSE∨FALSEFALSE \lor FALSE FALSEFALSE 14.

1.2.3 Boolean functions and truth tables

A Boolean function can be represented by a Boolean expression, and its behavior can be illustrated using a truth table. A truth table systematically lists all possible input combinations for the variables in the function and the corresponding output for each combination.

Example: Find the values of the Boolean function F(x,y,z)=xy+zF(x, y, z) = xy + z. This involves evaluating the product xyxy first, then ORing the result with zz.

xxyyzzxyxyxy+zxy + z
11111
11011
10100
10001
01100
01001
00100
00001

1.3 Boolean expression simplification

Boolean algebra provides identities that can be used to simplify complex Boolean expressions. Simplification is crucial for designing more efficient logic circuits 17.

Example: Simplify C+BCC + BC. Using the distributive law A+AB=AA + AB = A: C+BC=C(1+B)C + BC = C(1 + B) (Distributive law) C(1+B)=CC(1 + B) = C (Identity law 1+A=11+A=1). C=CC = C (Identity law A⋅1=AA \cdot 1 = A). Therefore, C+BC=CC + BC = C 18.

Example: Simplify AB+A(B+C)AB + A(B + C). AB+A(B+C)=AB+AB+ACAB + A(B + C) = AB + AB + AC (Distributive law) AB+AB+AC=AB+ACAB + AB + AC = AB + AC (Idempotent law A+A=AA+A=A) AB+AC=A(B+C)AB + AC = A(B + C) (Distributive law) 19.

Example: Try to simplify the Boolean expression F=ABC+A′+AB′CF = ABC + A' + AB'C. F=A′+ABC+AB′CF = A' + ABC + AB'C F=A′+A(BC+B′C)F = A' + A(BC + B'C) (Distributive law) F=A′+AC(B+B′)F = A' + AC(B + B') (Distributive law) F=A′+ACF = A' + AC (Complement law B+B′=1B+B'=1). F=A′+ACF = A' + AC (Identity law A⋅1=AA \cdot 1 = A) F=(A′+A)(A′+C)F = (A' + A)(A' + C) (Distributive law) F=(A′+C)F = (A' + C) (Complement law A′+A=1A'+A=1) 1. F=A′+CF = A' + C (Identity law A⋅1=AA \cdot 1 = A) 20.

2. Boolean algebra and logic gates (part 2)

This section delves into the practical application of Boolean algebra in designing electronic circuits through logic gates, focusing on basic gate types and their combinations.

2.1 Logic gates as circuit elements

Logic gates are the fundamental building blocks of electronic circuits within computers and other devices. These gates are designed and implemented using the principles of Boolean algebra. Each circuit can be constructed by combining these basic gate elements to achieve a desired logical operation or output 21.

2.2 Basic types of logic gates

The foundational logic gates are derived directly from Boolean operations.

  • NOT gate (Inverter): This gate produces an output that is the logical inverse of its input. If the input variable is represented as AA, the output is NOT AA. This can also be denoted as A′A' or A‾\overline{A} 22.

    Example: If the input to a NOT gate is 11 (high), the output will be 00 (low), and vice versa.

  • OR gate: The OR gate is an electronic circuit that outputs a high signal (11) if one or more of its inputs are high. The OR operation is represented by the plus sign (++) 23.

    Example: For inputs AA and BB, the output of an OR gate is A+BA + B. If A=1A=1 or B=1B=1 (or both), the output is 11.

  • AND gate: The AND gate is an electronic circuit that outputs a high signal (11) only if all of its inputs are high. The AND operation is represented by a dot (⋅·), such as A⋅BA \cdot B. This dot is often omitted, and the expression is written as ABAB 24.

    Example: For inputs AA and BB, the output of an AND gate is A⋅BA \cdot B. The output is 11 only if both A=1A=1 and B=1B=1.

2.3 Combinations of gates

More complex logical functions can be realized by combining basic gates (inverters, OR gates, and AND gates). In such combinations, some gates may share inputs, meaning a single input signal can be fed into multiple gates simultaneously. The same circuit can often be represented in different ways, illustrating the flexibility in gate arrangement 25 26.

Note: Constructing circuits from Boolean expressions and deriving Boolean expressions from circuit diagrams are key skills in digital logic design.

2.3.1 Constructing circuits from Boolean expressions

Given a Boolean expression, one can design the corresponding logic circuit. This involves translating the operations (AND, OR, NOT) into their respective gate symbols and connecting them according to the expression's structure.

Example: Construct a circuit for the output C=A⋅B+AC = A \cdot B + A. This expression involves an AND operation (A⋅BA \cdot B) and an OR operation with AA 27.

Example: Construct a circuit for the output Q=(A⋅B)+CQ = (A \cdot B) + C. This circuit would first perform an AND operation on AA and BB, and then OR the result with CC 28.

Example: Construct a circuit for the output Q=(P⋅R)+(R⋅S)Q = (P \cdot R) + (R \cdot S). This requires two AND operations, the results of which are then combined by an OR gate 29.

2.3.2 Writing Boolean expressions from circuit diagrams

Conversely, given a circuit diagram, one can derive the corresponding Boolean expression that describes the circuit's output. This involves identifying the gates and their connections and systematically building the expression from the inputs to the final output.

Example: For a circuit diagram with inputs AA and BB feeding into an AND gate, followed by an inverter, the Boolean expression for the output QQ would be Q=A⋅B‾Q = \overline{A \cdot B} 31.

Example: For a circuit diagram with inputs AA and BB feeding into an OR gate, and input CC feeding into an inverter, with the outputs of these two feeding into an AND gate, the expression for output YY would be Y=(A+B)⋅C‾Y = (A + B) \cdot \overline{C} 32.

Example: For a circuit diagram where PP and QQ are OR-ed, and RR and SS are AND-ed, and the results are then OR-ed, the output QQ would be Q=(P+Q)+(R⋅S)Q = (P + Q) + (R \cdot S) 33.

The "DO IT YOURSELF" sections provide exercises for practicing both constructing circuits from expressions and deriving expressions from circuits 34 35.

2.4 Minimization of circuits

The efficiency of a combinational circuit is determined by the number and arrangement of its constituent gates. Minimizing a Boolean function leads to the construction of a circuit that uses the fewest gates and the fewest inputs to those gates. This results in a more streamlined and potentially faster circuit 36.

Tip: Circuit minimization is crucial for reducing manufacturing costs, power consumption, and signal propagation delays in electronic devices. Techniques such as Karnaugh maps or the Quine-McCluskey algorithm are often used for this purpose.

3. Karnaugh maps and circuit minimization

Karnaugh maps (K-maps) provide a visual method for simplifying Boolean expressions and minimizing digital circuits by grouping adjacent terms containing ones.

3.1 Introduction to Karnaugh maps

Karnaugh maps, developed in the 1950s, are a graphical tool specifically designed for the manual simplification of Boolean expressions and the minimization of logic circuits. They are particularly effective for circuits with up to six input variables. The core principle behind K-maps is to rearrange the information from a truth table into a special grid format, which then allows for the visual identification of redundant terms in a Boolean expression. By grouping adjacent cells that represent minterms (product terms) resulting in a '1' output, common factors can be exploited to eliminate unnecessary variables, thereby reducing the complexity of the circuit 37.

  • Pictorial Representation: K-maps offer a pictorial method for grouping expressions with common factors, leading to the elimination of unwanted variables. They can be considered a special arrangement of a truth table 38.
  • Correspondence with Truth Tables: For a given number of input variables, there is a direct correspondence between the rows of a truth table and the cells within a K-map. Each cell in the map represents a unique combination of input variable values, and its content is derived from the output column of the truth table. The input variable values are typically labeled around the edges of the map.

3.2 Rules for simplification using Karnaugh maps

The simplification process using Karnaugh maps relies on a set of rules for grouping adjacent cells containing '1's. The objective is to create the largest possible groups that adhere to these rules, ensuring that every '1' in the map is covered by at least one group, and that the total number of groups is minimized 41.

Key Rules for Grouping Cells:.

  • Adjacent Cells: Groups are formed by combining adjacent cells. Adjacency includes wrapping around the edges of the map (horizontally and vertically).
    • Wrap-around: The leftmost cell in a row can be grouped with the rightmost cell, and the top cell in a column can be grouped with the bottom cell 45.
  • Group Size: Groups must contain a number of cells that is a power of two (i.e., 1, 2, 4, 8, etc.).
  • Largest Possible Groups: Groups should be made as large as possible. This maximizes the simplification achieved.
  • Coverage: Every '1' in the K-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. This can be necessary to achieve the largest possible groups and the minimum number of groups.
  • Fewest Groups: The final minimized expression should be represented by the fewest possible number of groups 46 47.

Remember: The goal is to cover all '1's with the largest, fewest, and potentially overlapping groups, respecting the power-of-two size and adjacency rules.

3.3 Constructing and interpreting Karnaugh maps

Karnaugh maps are constructed based on the number of input variables. For two variables (A, B), the map is a 2x2 grid. For three variables (A, B, C), it's typically a 2x4 or 4x2 grid, and for four variables (A, B, C, D), it's a 4x4 grid. The arrangement of the labels along the axes is crucial; it follows a Gray code sequence, meaning that only one variable changes between adjacent cells. This ensures that adjacent cells differ by only a single variable, which is fundamental for the simplification rules 39.

  • Mapping Truth Table Outputs: The output values ('0' or '1') from the truth table are directly transcribed into the corresponding cells of the K-map 40.
  • Deriving Simplified Expressions: After forming the largest possible groups of '1's, each group corresponds to a product term in the minimized sum-of-products (SOP) expression. For each group, identify the variables that remain constant within that group. If a variable is constant at '0', it appears in its complemented form (e.g., Aˉ\bar{A}); if it's constant at '1', it appears in its uncomplemented form (e.g., AA). Variables that change within a group are eliminated from that term. The final minimized expression is the sum (OR) of these product terms 50.

Example: Consider a group of four cells in a 3-variable K-map where variable A is always '1', variable B changes from '0' to '1', and variable C is always '0'. The term derived from this group would be ACˉA\bar{C}.

Tip: When forming terms from groups, if a variable is constant across all cells in the group, include it in the term. If a variable changes within the group, it is eliminated from the term.

3.4 Applications and examples

Karnaugh maps are widely used in digital logic design to simplify Boolean functions representing combinational circuits. By minimizing the logic gates required, the overall cost, power consumption, and propagation delay of a circuit can be significantly reduced.

Example Problem: Minimize the Boolean function represented by the following truth table using a K-map 48.

ABCF
0000
0010
0101
0110
1001
1011
1101
1110

Solution using K-map:

  1. Construct a 3-variable K-map.
  2. Place '1's in the cells corresponding to the minterms where F=1F=1 (i.e., for inputs ABC=010,100,101,110ABC = 010, 100, 101, 110).
  3. Group the adjacent '1's. In this case, two groups can be formed:
  • A group of two cells for minterms 100100 and 101101. In this group, A=1A=1, B=0B=0, and CC changes. This group yields the term ABˉA\bar{B}.
  • A group of two cells for minterms 010010 and 110110. In this group, AA changes, B=1B=1, and C=0C=0. This group yields the term BCˉB\bar{C}.
  1. The minimized expression is the sum of these terms: F=ABˉ+BCˉF = A\bar{B} + B\bar{C} 51 52.

Important: The K-map method is especially useful for visualizing simplifications that might be less obvious when manipulating Boolean algebra rules directly. The method becomes more complex with more than four variables.

4. Propositional and predicate logic (part 1)

This section introduces the foundational concepts of logic, starting with propositional logic, defining propositions, logical connectives, and truth tables, before briefly touching upon predicate logic and quantifiers.

4.1 The nature of logic and propositions

Logic, derived from the Greek word "logos," is the study of the principles of correct reasoning. It enables us to differentiate sound reasoning from flawed reasoning by examining the validity of arguments and whether conclusions logically follow from given assumptions 57 58.

A proposition is a declarative sentence that can be definitively assigned a truth value of either true or false, but not both simultaneously. Questions, commands, and statements whose truth depends on variable assignments are not propositions 61 62.

Example:

  • "Kedah is the biggest state in Malaysia." is a proposition (its truth value can be determined).
  • "2 + 5 = 10" is a proposition (it is false).
  • "Wake up!" is not a proposition (it is a command).
  • "What time is it?" is not a proposition (it is a question).
  • "9 + b = 3" is not a proposition (its truth depends on the value of 'b') 63.

Propositions are commonly represented by variables, such as pp, qq, and rr, analogous to how letters are used for numbers in algebra. For instance, we can define a proposition pp as pp: 3+2=93+2=9 64.

4.2 Compound statements and logical connectives

Compound statements are formed by combining simpler statements (propositions or propositional variables) using logical connectives. These connectives allow us to build more complex logical expressions from basic propositions 65.

4.2.1 Conjunction

The conjunction of two propositions, pp and qq, is denoted by p∧qp \land q and represents the proposition "p and q." The conjunction p∧qp \land q is true only when both pp and qq are true; otherwise, it is false

Example: If pp: "It is a sunny day" and qq: "It is warm," then the conjunction p∧qp \land q is "It is a sunny day and it is warm". If both pp and qq are true, then p∧qp \land q is true 66 67.

4.2.2 Disjunction

The disjunction of two propositions, pp and qq, is denoted by p∨qp \lor q and represents the proposition "p or q." The disjunction p∨qp \lor q is true if at least one of pp or qq is true; it is false only when both pp and qq are false

Example: If pp: "It is a sunny day" and qq: "It is warm," then the disjunction p∨qp \lor q is "It is a sunny day or it is warm". If both pp and qq are false, then p∨qp \lor q is false 68 69.

4.3 Truth tables

Truth tables are used to systematically represent the truth values of compound statements. A truth table is a two-dimensional array that includes columns for each input proposition and a final column for the resulting logical operation. The rows list all possible combinations of truth values for the input propositions and their corresponding outputs 70.

A truth table with nn input propositions will have n+1n+1 columns and 2n2^n rows, accounting for all possible truth value assignments 71.

Example: The following truth table illustrates the behavior of the conjunction operator (∧\land):

ppqqp∧qp \land q
TTT
TFF
FTF
FFF

72.

This table clearly shows that the conjunction p∧qp \land q is true only when both pp and qq are true 73.

4.4 Introduction to predicate logic and quantifiers

While propositional logic deals with simple and compound statements as atomic units, predicate logic extends this by considering the internal structure of propositions and introducing quantifiers. Predicate logic allows us to make statements about objects and their properties, and to express generalizations about collections of objects [Not explicitly detailed on pages 54-73, but mentioned as the next step in topic description.

  • Predicate: A predicate is a statement about a subject, which becomes a proposition when the subject is specified. For example, "x is an even number" is a predicate; it becomes a proposition when xx is assigned a value (e.g., "4 is an even number" is true).
  • Quantifiers: These are logical symbols that indicate the extent to which a predicate is true for a range of individuals.
    • Universal Quantifier (∀\forall): Used to state that a predicate is true for all elements in a domain (e.g., "For all xx, P(x)P(x)").
    • Existential Quantifier (∃\exists): Used to state that a predicate is true for at least one element in a domain (e.g., "There exists an xx such that P(x)P(x)").

5. Propositional and predicate logic (part 2)

This section extends the fundamentals of propositional logic by detailing the negation, conditional, and biconditional operators, and exploring their associated logical relationships and truth value computations.

5.1 Logical connectives: negation, conditional, and biconditional

This part of the study guide focuses on three crucial logical connectives that build upon the basic propositions introduced earlier. These connectives allow for the construction of more complex logical statements.

5.1.1 Negation (~p)

The negation of a proposition p, denoted by ~p, is the statement "not p". It asserts the falsehood of p. The truth value of ~p is the opposite of the truth value of p. In English, negation can be phrased as "It is not the case that p" or more directly as "p is false". It is crucial to understand that negation does not involve correcting a statement or stating its opposite in a descriptive sense, but rather denying its truth.

Note: When negating statements involving quantifiers like "all" or "some," the negation reverses the quantifier and negates the predicate. For instance, the negation of "All vehicles have 4 wheels" is "There exists at least one vehicle that does not have 4 wheels." 80.

The truth table for negation is as follows:

pp∼p\sim p
TF
FT

5.1.2 Conditional proposition (p → q)

A conditional proposition, also known as an implication, has the form "if p then q" or "p implies q," denoted symbolically as p→qp \rightarrow q. The first proposition, pp, is called the antecedent or hypothesis, and the second proposition, qq, is called the consequent or conclusion. This statement asserts that if the condition pp is met, then the consequence qq will follow.

The truth value of p→qp \rightarrow q is defined by the following truth table:

ppqqp→qp \rightarrow q
TTT
TFF
FTT
FFT

Example: If pp: 2>32 > 3 (False) and qq: 5<95 < 9 (True), then the conditional proposition p→qp \rightarrow q is True. Conversely, if qq is True and pp is False, q→pq \rightarrow p would be False 83.

The order of operations for logical connectives, when not specified by parentheses, places the conditional operator (→\rightarrow) as the last to be evaluated.

Related conditional statements

For a conditional proposition p→qp \rightarrow q, several related statements can be formed:

  • Converse: q→pq \rightarrow p (If qq then pp)
  • Contrapositive: ∼q→∼p\sim q \rightarrow \sim p (If not qq then not pp)
  • Inverse: ∼p→∼q\sim p \rightarrow \sim q (If not pp then not qq)

Example: For the statement "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." 88 89.

Restating propositions as conditionals

Many everyday statements can be rephrased into conditional propositions. The key is to identify the condition (antecedent) and the result (consequent).

Examples:

  • "Mary will be a good lecturer if she knows how to teach." →\rightarrow "If Mary knows how to teach, then she will be a good lecturer."
  • "When you sing, my ears hurt." →\rightarrow "If you sing, then my ears hurt."
  • "A sufficient condition for Maria to visit Singapore is that she goes to the Suria Tower." →\rightarrow "If Maria goes to the Suria Tower, then she visits Singapore." 86 87.

Evaluating complex conditional propositions

When evaluating the truth value of compound propositions involving conditional statements, it's essential to follow the order of operations and substitute the given truth values.

Example: Assume pp is True, qq is False, and rr is True.

  • p∧q→rp \wedge q \rightarrow r: First, evaluate p∧qp \wedge q. Since pp is True and qq is False, p∧qp \wedge q is False. Then, False→TrueFalse \rightarrow True is True.
  • p→(q→r)p \rightarrow (q \rightarrow r): First, evaluate q→rq \rightarrow r. Since qq is False and rr is True, False→TrueFalse \rightarrow True is True. Then, True→TrueTrue \rightarrow True is True.
  • p∧(q→∼r)p \wedge (q \rightarrow \sim r): First, evaluate ∼r\sim r. Since rr is True, ∼r\sim r is False. Then, evaluate q→∼rq \rightarrow \sim r. Since qq is False and ∼r\sim r is False, False→FalseFalse \rightarrow False is True. Finally, p∧Truep \wedge True. Since pp is True, True∧TrueTrue \wedge True is True. 84 85.

5.1.3 Biconditional proposition (p  q)

A biconditional proposition, also known as a logical equivalence or "if and only if" statement, connects two propositions pp and qq. It is denoted by p↔qp \leftrightarrow q. This statement is true if and only if pp and qq have the same truth value; that is, both are true, or both are false.

The truth value of p↔qp \leftrightarrow q is defined by the following truth table:

ppqqp↔qp \leftrightarrow q
TTT
TFF
FTF
FFT

Example: The statement "1 < 5 if and only if 2 < 8" can be represented as p↔qp \leftrightarrow q, where pp is "1 < 5" (True) and qq is "2 < 8" (True). Since both pp and qq are true, p↔qp \leftrightarrow q is true 90.

5.2 Constructing truth tables for complex propositions

Truth tables are a systematic way to determine the truth value of a compound proposition for all possible combinations of truth values of its constituent propositions. To construct a truth table for a complex proposition, one typically breaks down the proposition into its simpler components and evaluates them step-by-step.

Example: Construct a truth table for the proposition p∨∼q∧rp \vee \sim q \wedge r. This involves propositions pp, qq, and rr. There will be 23=82^3 = 8 possible rows. The intermediate steps would involve evaluating ∼q\sim q and then p∨(∼q∧r)p \vee (\sim q \wedge r) or (∼q∧r)(\sim q \wedge r) depending on the assumed order of operations for ∨\vee and ∧\wedge. If standard precedence rules are followed where ∧\wedge binds tighter than ∨\vee, the expression would be evaluated as p∨(∼q∧r)p \vee (\sim q \wedge r). If parentheses are to be explicitly followed, the construction might vary. Given the example on page 93 is p∨∼q∧rp \vee \sim q \wedge r, a typical interpretation would be to evaluate negation first, then conjunction, and finally disjunction 93.

6. Propositional and predicate logic (part 3)

This section delves into the advanced concepts of propositional logic, including tautologies, contradictions, and contingencies, and then introduces the necessity and foundational elements of predicate logic.

6.1 Tautologies, contradictions, and contingencies

Within propositional logic, statements can be categorized based on their truth values across all possible assignments of truth values to their propositional variables.

  • Tautology: A proposition that is true for all possible truth value assignments of its propositional variables 98.
  • Contradiction: A proposition that is always false, regardless of the truth values of its variables 103.
  • Contingency: A proposition that is neither a tautology nor a contradiction; its truth value depends on the truth values of its variables 104.

Truth tables are the primary tool for determining whether a given proposition falls into one of these categories.

Example: To show that ((p→q)∧(q→r))→(p→r)((p \rightarrow q) \land (q \rightarrow r)) \rightarrow (p \rightarrow r) is a tautology, we construct a truth table. Since all possible truth value assignments result in the proposition being true, it is a tautology 100.

pqrp→qp \rightarrow qq→rq \rightarrow rp→rp \rightarrow r(p→q)∧(q→r)(p \rightarrow q) \land (q \rightarrow r)((p→q)∧(q→r))→(p→r)((p \rightarrow q) \land (q \rightarrow r)) \rightarrow (p \rightarrow r)
TTTTTTTT
TTFTFFFT
TFTFTTFT
TFFFTFFT
FTTTTTTT
FTFTFTFT
FFTTTTTT
FFFTTTTT

Note: Not all propositions are tautologies. For instance, the proposition p∧(p∨q)→qp \land (p \lor q) \rightarrow q is not a tautology because it evaluates to false for certain truth assignments of pp and qq 99.

6.2 Limitations of propositional logic

While propositional logic is fundamental, it has limitations in representing the full complexity of statements encountered in mathematics and computer science.

  • Inability to handle statements with variables: Propositional logic treats statements as atomic propositions. It cannot directly represent assertions like "xx is greater than 1" because its truth value depends on the variable xx. Such statements are not propositions until xx is assigned a specific value.
  • Difficulty with generalizations and equivalences: Propositional logic cannot capture logical equivalences that apply across many objects or situations. For example, it cannot express the general equivalence between "Not all birds fly" and "Some birds don't fly" without listing each specific instance as a separate proposition. [109-111]
  • Repetitive statements: For statements that must be repeated for many individual objects (e.g., "If John is a PKS graduate, then John has passed Diploma," "If Ann is a PKS graduate, then Ann has passed Diploma," etc.), propositional logic requires a separate proposition for each object. This is inefficient 112.

6.3 Introduction to predicate logic

Predicate logic extends propositional logic by introducing concepts that address its limitations. It provides a more powerful framework for expressing and reasoning about complex statements.

6.3.1 Predicates and variables

Predicate logic introduces predicates, which are properties or relations that can be true or false for specific arguments, and variables that represent these arguments. For example, "x is greater than 1" can be represented as a predicate P(x)P(x), where PP is the predicate "is greater than 1" and xx is the variable 108.

6.3.2 Quantifiers

To make statements with variables universally true or false, or true for at least one instance, quantifiers are used. These allow us to express properties of groups of objects.

  • Universal Quantifier (∀\forall): Used to state that a property holds for all members of a group. It is read as "for all" or "for every".
    • Example: ∀x(P(x))\forall x (P(x)) means "For all xx, P(x)P(x) is true.".
  • Existential Quantifier (∃\exists): Used to state that a property holds for at least one member of a group. It is read as "there exists" or "for some".
    • Example: ∃x(P(x))\exists x (P(x)) means "There exists an xx such that P(x)P(x) is true.".

These quantifiers enable the representation of statements like "All new cars must be registered" or "Some integers are not even," which are beyond the scope of propositional logic alone 113.

7. Propositional and predicate logic (part 4)

This part of the study guide delves into predicate logic, introducing predicates, propositional functions, domains of discourse, and the crucial concepts of quantifiers (universal and existential).

7.1 Predicates and propositional functions

A predicate is a verb phrase template that describes a property of objects or a relationship among objects represented by variables. When a specific object or set of objects is substituted for the variables, the predicate becomes a proposition, which can be definitively true or false.

  • Predicate: A statement with variables that becomes a proposition upon substitution. For instance, "is blue" is a predicate.
  • Propositional Function (Predicate Logic Statement): A predicate that takes one or more arguments. It is not a proposition itself because its truth value depends on the values of its variables.
    • Example: Let P(x)P(x) represent the statement "xx is a prime number." P(x)P(x) is a propositional function. PP (2 is a prime number) is a proposition (True). PP (4 is a prime number) is a proposition (False)4.
    • Example: Let G(x,y)G(x, y) represent the predicate "x>yx > y." This is a propositional function. Substituting values, G(9,19)G(9, 19) means "9 is greater than 19," which is a proposition (False).

Predicates can have multiple arguments to represent relationships between objects.

  • Example: Older(John,Peter)Older(John, Peter) denotes "John is older than Peter." This is a proposition.
  • Example: Older(x,y)Older(x, y) denotes "xx is older than yy." This is a propositional function.
  • Example: Let Q(x,y)Q(x, y) denote "x+5>yx + 5 > y." This is a propositional function. Q(3,6)Q(3, 6) means "3 + 5 > 6," which is a proposition (True).

Note: A propositional function is defined over a specific domain of discourse, which is the set of all possible values that the variable(s) in the function can take. For each element in this domain, the propositional function must evaluate to a proposition (either true or false) 119.

7.1.1 Examples of propositional functions

  • Statement: "nn is an odd integer."

    • Domain of Discourse: The set of positive integers.
    • Evaluation: For n=3n=3, PP is "3 is an odd integer" (True). For n=8n=8, PP is "8 is an odd integer" (False). Thus, "nn is an odd integer" is a propositional function with the domain of positive integers 8 120.
  • Statement: "n2+2nn^2 + 2n is an odd integer."

    • Domain of Discourse: The set of positive integers.
    • Evaluation: For n=1n=1, PP is "1^2 + 2 = 3 is an odd integer" (True). For n=2n=2, PP is "2^2 + 2 = 8 is an odd integer" (False). Thus, this is a propositional function 2 121.
  • Statement: "The baseball player hit over .300 in 2003."

    • Domain of Discourse: A set of baseball players.
    • Evaluation: Substituting "Barry Bonds" for "The baseball player" yields "Barry Bonds hit over.300 in 2003" (True). Substituting "Alex Rodriguez" yields "Alex Rodriguez hit over.300 in 2003" (False). Thus, this is a propositional function 122 123.

7.2 Quantifiers

Quantifiers are essential in predicate logic for expressing statements about collections of objects. They specify the extent to which a predicate is true over its domain of discourse.

7.2.1 Types of quantifiers

There are two primary types of quantifiers:

  • Universal Quantifier: Used to state that a predicate is true for all elements in the domain of discourse.
  • Existential Quantifier: Used to state that a predicate is true for at least one element in the domain of discourse 124.

7.2.2 The universal quantifier

  • Symbol: ∀\forall
  • Meaning: "For all," "for every," "for any."
  • Statement Form: ∀xP(x)\forall x P(x)
  • Reading: "For all xx such that P(x)P(x) is true," or "For every xx in the domain of discourse, P(x)P(x)."
  • Truth Condition: The statement ∀xP(x)\forall x P(x) is true if and only if P(x)P(x) is true for every xx in the domain of discourse. It is false if there exists at least one value aa in the domain such that P(a)P(a) is false 125.
  • Counterexample: A value aa from the universe for which P(a)P(a) is false. This value serves to disprove the universally quantified statement.

Example: Consider the statement ∀x(x2−1>0)\forall x (x^2 - 1 > 0) with the domain of discourse being the set of real numbers.

  • If we test x=1x=1, we get 12−1>01^2 - 1 > 0, which is 0>00 > 0 (False).
  • Since we found a value (x=1x=1) for which the predicate is false, x=1x=1 is a counterexample, and the statement ∀x(x2−1>0)\forall x (x^2 - 1 > 0) is false 127.

Example: The statement "Every car is red" (∀x(Car(x)  ⟹  Red(x))\forall x (Car(x) \implies Red(x))) is false because my car is gold, serving as a counterexample 126.

7.2.3 The existential quantifier

  • Symbol: ∃\exists
  • Meaning: "There exists," "for some," "there is at least one."
  • Statement Form: ∃xP(x)\exists x P(x)
  • Reading: "There exists an xx such that P(x)P(x) is true," or "For some xx in the domain of discourse, P(x)P(x)."
  • Truth Condition: The statement ∃xP(x)\exists x P(x) is true if and only if P(x)P(x) is true for at least one xx in the domain of discourse. It is false if and only if P(x)P(x) is false for every xx in the domain 128 130.

Example: The sentence "There is a red car" (∃x(Car(x)∧Red(x))\exists x (Car(x) \land Red(x))) is true because my friend's car is red, which is one instance where the predicate holds true.

Example: Consider the statement "For some xx, x2<0x^2 < 0."

  • With the domain of discourse being the set of real numbers, there is no real number whose square is negative.
  • Therefore, the predicate P(x):x2<0P(x): x^2 < 0 is false for all real numbers xx.
  • This makes the existentially quantified statement ∃x(x2<0)\exists x (x^2 < 0) false.

Tip: Disproving an existential statement (∃xP(x)\exists x P(x) is false) requires showing that P(x)P(x) is false for all elements in the domain. This can be challenging as it involves a universal claim. Conversely, disproving a universal statement (∀xP(x)\forall x P(x) is false) only requires finding a single counterexample 131.

8. Graph theory: Trees, spanning trees, and algorithms

This section explores the fundamental concepts of trees and spanning trees in graph theory, detailing algorithms for finding minimum spanning trees and discussing their applications in navigation systems.

8.1 Trees and spanning trees

A tree is a special type of graph crucial in computer science, characterized by specific structural properties. A rooted tree has a designated root vertex from which all other vertices are reachable, and importantly, there are no cycles. A spanning tree of an undirected, connected graph G=(V,E)G = (V, E) is a subgraph TT that is itself a tree and includes every vertex of GG. Spanning trees are essential in network data transmission to ensure connectivity without creating redundant paths (loops), thereby optimizing data flow and speed. A connected graph GG with nn vertices and mm edges requires the removal of m−(n−1)m - (n - 1) edges to form a spanning tree. A connected graph is guaranteed to have at least one spanning tree 140.

Note: Spanning trees are particularly important in multicasting over Internet Protocol networks, where they help construct efficient data distribution paths from a source to multiple destinations by avoiding loops 137.

8.2 Properties of trees

A set AA and a relation TT on AA define a tree if there exists a vertex v0∈Av_0 \in A such that there is no path from v0v_0 back to itself. This vertex v0v_0 is called the root of the tree, and TT is then referred to as a rooted tree. A rooted tree is denoted as (T,v0)(T, v_0) 135.

8.3 Minimal spanning trees

For a weighted graph GG, a minimal spanning tree (MST) is a spanning tree whose total edge weight is the smallest possible among all spanning trees of GG. MSTs are vital for finding the most cost-effective way to connect all vertices in a network 144.

8.3.1 Kruskal's algorithm

Kruskal's algorithm is a greedy approach to find a minimal spanning tree for a connected, weighted graph.

  • Algorithm Steps:
    1. Arrange all edges of the graph GG in ascending order of their weights.
    2. Initialize a forest where each vertex is a separate tree.
    3. Iterate through the sorted edges. For each edge (u,v)(u, v) with weight ww:
      • If adding edge (u,v)(u, v) does not create a cycle in the forest, add it to the MST.
    4. Continue until n−1n-1 edges have been added, where nn is the number of vertices in GG. At this point, the forest becomes a single spanning tree, which is the MST 153.

Example: Consider a weighted graph. First, sort edges by increasing weights. Then, add edges one by one, ensuring no cycle is formed. For instance, with edges sorted as BD AE DF BF CE AC AF BE BC the algorithm would add BD, AE, DF, CE, and AF, forming an MST with a total weight of 24155.

8.3.2 Prim's algorithm

Prim's algorithm is another greedy method for constructing an MST. It starts with an arbitrary vertex and grows the MST by adding the cheapest edge that connects a vertex in the growing tree to a vertex outside the tree.

  • Algorithm Steps:
    1. Choose an arbitrary starting vertex v0v_0.
    2. Maintain a set of vertices already included in the MST. Initially, this set contains only v0v_0.
    3. Repeatedly add the edge (u,v)(u, v) with the minimum weight such that uu is in the MST set and vv is not. Add vv to the MST set.
    4. Continue until all nn vertices are included in the MST set. The algorithm will have added n−1n-1 edges.

Note: The algorithm ensures that by selecting the minimum weight edge at each step, the cumulative weight of the spanning tree is minimized 145.

Example: Given a weighted graph, order edges by decreasing weights. Successively delete edges that do not disconnect the graph until n−1n-1 edges remain. For a graph with edges like BC AF AC BE CE BF AE DF BD deleting edges that would form cycles leads to an MST containing BE, CE, AE, DF, and BD, with a total weight of 24 8 148.

AlgorithmEdge SortingCycle HandlingResulting MST Edges
Kruskal'sIncreasing weightsAvoid adding edges that form cyclesBD, AE, DF, CE, AF
Prim's(Implicitly handled by selection)Select minimum weight edge connecting to the treeBE, CE, AE, DF, BD

8.4 Applications in object navigation

Graph theory, particularly concepts related to shortest paths (often built upon MST principles or related algorithms like Dijkstra's), finds extensive application in navigation systems.

  • Robotics: Warehouse robots and autonomous vacuum cleaners use graph representations (e.g., occupancy grids) to plan paths. Algorithms like Dijkstra's or A* are employed to find the shortest path to a destination, such as an object or a charging dock.
  • GPS and Road Maps: Navigation systems model real-world road networks as graphs, where intersections are nodes and roads are edges. Edge weights can represent travel time, distance, or other costs. Dijkstra's algorithm is then used to determine the fastest or shortest route to a specified destination.
  • Video Games: Game worlds are often converted into navigation mesh graphs. Non-player characters (NPCs) utilize graph algorithms like Dijkstra's to navigate the game environment efficiently, moving towards the player or designated targets 159.

In these applications, the physical world is abstracted into a graph G=(V,E)G=(V, E), where:

  • Nodes (VV): Represent distinct locations or points where an agent can be.
  • Edges (EE): Represent the possible movements or connections between these locations.
  • Weights: Assigned to edges to quantify the "cost" of traversing that edge, which can be distance, time, energy consumption, or risk 160.

9. Graph theory: Properties, paths, cycles, and algorithms (part 1)

This section introduces fundamental concepts in graph theory, focusing on the properties of graphs, their components, and the definition of paths and cycles, along with an initial look at algorithms.

9.1 Graph properties and definitions

A graph GG is formally defined as an ordered pair (V,E)(V, E), where VV is a non-empty set of vertices (also called nodes) and EE is a set of edges (or arcs) that connect pairs of vertices. The nature of these edges determines the type of graph 163:

  • Undirected Graph: In an undirected graph, edges are unordered pairs of distinct vertices. If an edge ee connects vertices vv and ww, it is represented as e=(v,w)e=(v,w) or e=(w,v)e=(w,v). The edges have no specific direction, as illustrated in 167.
  • Directed Graph (Digraph): A directed graph consists of a set VV of vertices and a set EE of edges, where each edge e∈Ee \in E is associated with an ordered pair of vertices (v,w)(v,w). This signifies an edge directed from vv to ww. The vertex vv is termed the source, and ww is the target. Such an edge can be denoted as v→wv \rightarrow w 169.

Graphs can also be categorized by their vertex set size:

  • Infinite Graph: A graph with an infinite set of vertices 164.
  • Finite Graph: A graph with a finite set of vertices, which is the primary focus of this chapter 165.

Further classifications of graphs based on their edges include:

  • Simple Graph: A graph that contains neither loops (edges connecting a vertex to itself) nor parallel edges (multiple edges connecting the same pair of vertices).
  • Multigraph: A graph that contains multiple edges between the same pair of vertices but does not allow loops.
  • Pseudograph: A graph that allows both loops and multiple edges 174.

Note: In a directed graph, an edge associated with an ordered pair (v,w)(v,w) is represented as v→wv \rightarrow w, indicating a direction from vv to ww 170.

9.1.1 Incidence and adjacency

Key relationships between vertices and edges include:

  • Incident: An edge ee connecting vertices vv and ww is said to be incident on both vv and ww. Conversely, vertices vv and ww are incident on edge ee.
  • Adjacent Vertices: Two vertices vv and ww are considered adjacent (or neighbors) if they are connected by an edge 171.

Example: In a graph with vertices {1, 2, 3, 4, 5}, vertex 1 is adjacent to vertices connected by an edge to 1. If vertex 2 is connected to vertex 1 by an edge, then 1 and 2 are adjacent.

  • Isolated Vertex: A vertex that is not incident on any edge is called an isolated vertex 172.

9.1.2 Loops and parallel edges

  • Loop: An edge that connects a vertex to itself. In directed graphs, a loop is represented by an ordered pair (v,v)(v,v). These can be used to model self-referential communication links.
  • Parallel Edges: If two or more edges connect the same pair of vertices, they are called parallel edges 178.

Important: A simple graph is defined as a graph that contains neither loops nor parallel edges 173.

9.2 Degree of vertices

The degree of a vertex vv in a graph GG, denoted as deg⁡(v)\deg(v), is the total number of edges incident on that vertex 179.

Note: For undirected graphs, each edge is counted once for each of the two vertices it connects.

A fundamental property concerning vertex degrees is The Handshaking Lemma:

  • The sum of the degrees of all vertices in a graph GG is equal to twice the number of edges in GG. This is because each edge contributes one degree to two different vertices (or two degrees to one vertex if it's a loop, though simple graphs exclude loops). ∑v∈Vdeg⁡(v)=2∣E∣\sum_{v \in V} \deg(v) = 2 |E| 180.

Remember: This lemma holds for finite undirected graphs. For directed graphs, the concepts of in-degree and out-degree are used.

9.3 Paths and cycles

Paths and cycles are fundamental structures within graphs that describe sequences of connected vertices and edges.

  • Path: A path in a graph is a sequence of vertices (v0,v1,…,vk)(v_0, v_1, \dots, v_k) such that for each ii from 0 to k−1k-1, there is an edge between viv_i and vi+1v_{i+1}. The length of the path is the number of edges, kk.

    • A path is simple if all its vertices are distinct.
    • A walk is a sequence of vertices and edges, where vertices and edges can be repeated. A path is a specific type of walk.
  • Cycle: A cycle is a path that starts and ends at the same vertex, i.e., v0=vkv_0 = v_k, and all other vertices (v0,…,vk−1v_0, \dots, v_{k-1}) are distinct.

Two specific types of cycles are of significant interest:

  • Eulerian Cycle/Path:

    • An Eulerian path is a path in a graph that visits every edge exactly once.
    • An Eulerian cycle (or circuit) is an Eulerian path that starts and ends on the same vertex. A graph has an Eulerian cycle if and only if every vertex has an even degree, and all vertices with non-zero degree belong to the same connected component.
  • Hamiltonian Cycle/Path:

    • A Hamiltonian path is a path in a graph that visits every vertex exactly once.
    • A Hamiltonian cycle is a Hamiltonian path that starts and ends on the same vertex. Determining the existence of Hamiltonian paths and cycles is a more complex problem (NP-complete).

Tip: Paths and cycles are essential for understanding connectivity, reachability, and network traversals.

10. Graph theory: Properties, paths, cycles, and algorithms (part 2)

This section delves into the properties of vertices, subgraphs, paths, cycles, and introduces the concepts of Eulerian and Hamiltonian paths/circuits, along with their associated algorithms.

10.1 Vertex degrees

The degree of a vertex in a graph is a fundamental property indicating the number of edges connected to it.

  • Definition: The degree of a vertex vv, denoted as deg(v)deg(v), is the number of edges incident to vv. In multigraphs, an edge connecting a vertex to itself (a loop) is counted twice, and other edges are counted according to their multiplicity. The sum of the degrees of all vertices in a graph is equal to twice the number of edges, a property known as the Handshaking Lemma: ∑v∈Vdeg(v)=2∣E∣\sum_{v \in V} deg(v) = 2|E|.
  • Classification of Vertices:
    • An even vertex has an even degree.
    • An odd vertex has an odd degree.
    • An isolated vertex has a degree of zero 182.

Example: For a graph with vertices A, B, C, D and edges (A,B), (A,C), (B,C), (B,D), (C,D), the degrees are deg(A)=2deg(A)=2, deg(B)=3deg(B)=3, deg(C)=3deg(C)=3, and deg(D)=2deg(D)=2. Vertices A and D are even, while B and C are odd 181.

For directed graphs (digraphs), vertex degrees are further categorized into in-degrees and out-degrees:

  • In-degree (deg−deg^-): The number of edges directed into a vertex.
  • Out-degree (deg+deg^+): The number of edges directed out of a vertex.

The sum of in-degrees equals the sum of out-degrees, and both are equal to the total number of edges in the directed graph: ∑v∈Vdeg−(v)=∑v∈Vdeg+(v)=∣E∣\sum_{v \in V} deg^-(v) = \sum_{v \in V} deg^+(v) = |E| 184.

Example: In a directed graph with vertices 1, 2, 3 and edges (1,2), (1,3), (2,1), (2,3), (3,1), (3,2), the degrees are:

  • deg−=2deg^- =2, deg+=2deg^+ =2 1.
  • deg−=3deg^- =3, deg+=3deg^+ =3 2.
  • deg−=2deg^- =2, deg+=2deg^+ =2.

Note: The provided example on page 185 has different edge directions leading to deg−=0deg^- =0, deg−=3deg^- =3, deg−=4deg^- =4 and deg+=2deg^+ =2, deg+=3deg^+ =3, deg+=2deg^+ =2. This implies a specific set of directed edges for that illustration. 3 185.

10.2 Subgraphs

A subgraph is a graph derived from a larger graph by selecting a subset of its vertices and edges.

  • Definition: A subgraph HH of a graph G=(V,E)G=(V, E) is a graph H=(V′,E′)H=(V', E') where V′⊆VV' \subseteq V and E′⊆EE' \subseteq E, and the edges in E′E' connect only vertices in V′V'.
  • Types of Subgraphs:
    • Induced Subgraph: If a subset of vertices W⊆VW \subseteq V is chosen, the induced subgraph on WW includes all vertices in WW and all edges from the original graph GG that connect pairs of vertices within WW. Once vertices are selected, all their connecting edges within the graph are automatically included.
    • Spanning Subgraph: A subgraph that includes all vertices of the original graph but only a subset of its edges.
    • Proper Subgraph: A subgraph that is not identical to the original graph GG. This means it must have either fewer vertices, fewer edges, or both, compared to GG 188.

10.3 Paths and Cycles

Paths and cycles are fundamental structures in graph traversal.

  • Path: A path from vertex v0v_0 to vertex vnv_n of length nn is a sequence of n+1n+1 vertices (v0,v1,…,vn)(v_0, v_1, \dots, v_n) and nn edges (e1,e2,…,en)(e_1, e_2, \dots, e_n) such that eie_i connects vi−1v_{i-1} and viv_i for i=1,…,ni=1, \dots, n. Crucially, no edge is used more than once in a path 189.

    Example: In a graph, the sequence (1,e1,2,e2,3,e3,4,e4,2)(1, e_1, 2, e_2, 3, e_3, 4, e_4, 2) represents a path of length 4 from vertex 1 to vertex 2, where edges e1,e2,e3,e4e_1, e_2, e_3, e_4 are traversed in sequence 190.

  • Cycle (Circuit): A cycle is a path of non-zero length that begins and ends at the same vertex. Like a path, a cycle does not repeat any edges 191.

    Example: Given a path, determining if it's a cycle involves checking if it starts and ends at the same vertex and uses distinct edges.

    • (2,6,5,2,4,3,2) is a cycle because it starts and ends at vertex 2 and reuses vertices but not edges in its traversal.
    • (5,6,2,5) is also a cycle, starting and ending at vertex 5 192 193.

10.4 Eulerian Paths and Circuits

Eulerian paths and circuits are specific types of traversals that visit every edge of a graph exactly once.

  • Eulerian Path: A simple path in a graph that traverses every edge exactly once. Vertices can be revisited, but edges cannot be repeated. The starting and ending vertices do not need to be the same.

    • A connected graph with exactly two vertices of odd degree contains an Eulerian path 195.
  • Eulerian Circuit (or Eulerian Tour): An Eulerian path that is also a cycle; it starts and ends at the same vertex. Every edge is traversed exactly once.

    • A connected graph has an Eulerian circuit if and only if all its vertices have even degrees. The contrapositive states that if any vertex has an odd degree, the graph cannot have an Eulerian circuit.

The existence of Eulerian paths and circuits is directly related to the number of odd-degree vertices in a connected graph:

Number of odd verticesNumber of even verticesType of path/circuit
0AllEulerian circuit
2All othersEulerian path
More than 2VariesNeither

197.

Example:

  • Graph 1 has 0 odd vertices and 10 even vertices, thus containing an Eulerian circuit 198.
  • Graph 3 has 2 odd vertices and 6 even vertices, thus containing an Eulerian path.
  • Graph 5 has 4 odd vertices, thus containing neither an Eulerian path nor a circuit 199.

Note: An Eulerian path exists in a connected graph if it has zero or two vertices with odd degrees. An Eulerian circuit exists if and only if all vertices have even degrees 194 196.

Example of an Eulerian Path: In a graph, E, D, B, A, C, D is an Eulerian path, visiting every edge exactly once. Example of an Eulerian Circuit: In a graph, 5, 3, 2, 1, 3, 4, 5 is an Eulerian circuit, starting and ending at vertex 5 and traversing all edges once 200.

10.5 Hamiltonian Paths and Circuits

A Hamiltonian path or circuit involves visiting vertices rather than edges.

  • Hamiltonian Path: A path in a graph that visits every vertex exactly once.
  • Hamiltonian Circuit: A Hamiltonian path that is also a cycle, meaning it starts and ends at the same vertex after visiting all other vertices exactly once.

Unlike Eulerian paths, there are no simple necessary and sufficient conditions based solely on vertex degrees for the existence of Hamiltonian paths or circuits. Determining their existence is generally a more complex problem, often requiring more advanced algorithms or specific graph properties.

Note: While the document briefly mentions cycles and paths, it does not explicitly define or detail Hamiltonian paths/circuits or algorithms like Dijkstra's in the provided page range (181-200). This summary focuses on the content present within the specified pages.

11. Graph theory: Properties, paths, cycles, and algorithms (part 3)

This section delves into specific types of paths and circuits in graph theory, namely Eulerian and Hamiltonian paths/circuits, and introduces the concept of weighted graphs along with Dijkstra's algorithm for finding shortest paths.

11.1 Eulerian paths and circuits

An Eulerian path is a trail within a graph that traverses every edge exactly once. If such a path begins and ends at the same vertex, it is classified as an Eulerian circuit. The existence of Eulerian paths and circuits is closely tied to the degrees of the vertices in the graph. A graph has an Eulerian circuit if and only if all vertices have an even degree and all vertices with non-zero degree belong to the same connected component. A graph has an Eulerian path but no Eulerian circuit if and only if it has exactly two vertices of odd degree. If a graph has more than two vertices of odd degree, it has neither an Eulerian path nor an Eulerian circuit 201.

Example: Consider a graph where vertex 'b' has a degree of 3. Since this is an odd degree, the graph cannot have an Eulerian circuit. If this is the only vertex with an odd degree, it cannot even have an Eulerian path. If there are exactly two vertices with odd degrees, an Eulerian path exists. If there are more than two, neither an Eulerian path nor a circuit exists 202.

11.2 Hamiltonian paths and circuits

A Hamiltonian path is a path in a graph that visits each vertex exactly once. A Hamiltonian circuit is a cycle that visits every vertex exactly once, with the exception that the start and end vertices are the same. Unlike Eulerian paths, which are defined by traversing edges, Hamiltonian paths are defined by visiting vertices. Determining the existence of Hamiltonian paths or circuits is generally a more complex problem (NP-complete) than for Eulerian paths. 204 205.

Example: In a graph with vertices labeled a, b, c, d, and e, the path a, b, c, d, e is a Hamiltonian path because it includes each vertex precisely once. If this path could be extended to return to 'a' (i.e., a, b, c, d, e, a), it would then be a Hamiltonian circuit 203.

Note: A graph might possess a Hamiltonian path but not a Hamiltonian circuit. For instance, a path traversing vertices (5, 7, 6, 4, 3, 1, 2) might be a Hamiltonian path, but if there's no edge connecting vertex 2 back to vertex 5, it cannot form a Hamiltonian circuit 206.

11.3 Weighted graphs

A weighted graph is a graph where each edge is assigned a numerical value, known as its weight. These weights are typically non-negative integers and are often referred to as the "cost" of traversing that edge. Weighted graphs are instrumental in modeling real-world scenarios such as computer networks, where edge weights can represent communication costs, response times, or distances between nodes. They can be directed or undirected. 212 213.

Applications of edge weights:

  • Communications Networks: Monthly leasing costs of telephone lines.
  • Computer Networks: Response times between computers.
  • Logistics and Transportation: Distances between locations or cities, travel times, fuel consumption.
  • Resource Allocation: Capacity of a communication line or pipeline.

11.4 Dijkstra's algorithm

Dijkstra's algorithm is a fundamental algorithm used to find the shortest path from a designated starting vertex (source) to all other vertices in a graph that has non-negative edge weights. It's a greedy algorithm that systematically explores the graph.

Steps of Dijkstra's Algorithm:

  1. Initialization:

    • Assign a distance of 0 to the source vertex.
    • Assign an infinite distance (∞\infty) to all other vertices.
    • Mark all vertices as unvisited.
  2. Visit Current Node:

    • For the currently selected vertex, calculate the tentative distance to each of its unvisited neighbors.
    • The tentative distance to a neighbor is the sum of the distance to the current vertex and the weight of the edge connecting them.
    • If this calculated distance is less than the neighbor's current recorded distance, update the neighbor's distance.
  3. Mark as Visited:

    • Once a vertex's shortest path from the source has been determined, it is marked as visited and will not be revisited.
  4. Choose Next Node:

    • Select the unvisited vertex with the smallest tentative distance from the source. This vertex becomes the "current node" for the next iteration.
  5. Repeat:

    • Continue this process until all vertices have been visited or until the target vertex (if a specific destination is sought) has been visited.

Example: Consider a graph with vertices A, B, C, D, E and non-negative edge weights. If A is the source, its distance is initialized to 0, and all others to ∞\infty.

  • Initial State:

  • Unvisited nodes: {A, B, C, D, E}

  • Distances: A: 0, B: ∞\infty, C: ∞\infty, D: ∞\infty, E: ∞\infty

  • After visiting A (smallest distance):

  • The algorithm examines neighbors of A. If edge (A, C) has weight 2 and edge (A, B) has weight 4, the distances are updated.

  • Distances: A: 0, B: 4, C: 2, D: ∞\infty, E: ∞\infty

  • Next, C is chosen as it has the smallest tentative distance. The algorithm then updates distances for C's neighbors. If there's an edge (C, B) with weight 3, the path A -> C -> B has a total weight of 2 + 3 = 5. If 5 is less than B's current distance B's distance remains 4. However, if there's an edge (C, D) with weight 4, the path A -> C -> D has a total weight of 2 + 4 = 6. This updates D's distance from ∞\infty to 6. 219 220.

Important Note: Dijkstra's algorithm is guaranteed to find the shortest path only for graphs with non-negative edge weights. If negative edge weights are present, other algorithms like the Bellman-Ford algorithm are required 216.

12. Graph theory: Properties, paths, cycles, and algorithms (part 4)

This section delves into Dijkstra's algorithm, a fundamental method for finding the shortest paths in a weighted graph.

12.1 Dijkstra's algorithm

Dijkstra's algorithm is a greedy algorithm used to find the shortest paths from a single source vertex to all other vertices in a graph with non-negative edge weights. It systematically explores the graph, maintaining the shortest distance found so far from the source to each vertex.

Algorithm Steps:

  1. Initialization:

    • Assign a distance value to every vertex: infinity for all vertices except the source vertex, which is assigned a value of 0.
    • Create a set of unvisited vertices, initially containing all vertices in the graph.
  2. Iteration:

    • While the set of unvisited vertices is not empty:
      • Select the unvisited vertex with the smallest distance value. Let this vertex be uu.
      • Mark uu as visited (remove it from the set of unvisited vertices).
      • For each unvisited neighbor vv of uu:
        • Calculate the distance from the source to vv through uu: distance(source,u)+weight(u,v)distance(source, u) + weight(u, v).
        • If this calculated distance is less than the current distance value assigned to vv, update the distance value of vv to this new shorter distance.
  3. Termination:

    • Once all vertices have been visited, the algorithm terminates. The distance values assigned to each vertex represent the shortest path distance from the source vertex.

Note: Dijkstra's algorithm assumes that all edge weights are non-negative. If the graph contains negative edge weights, other algorithms like the Bellman-Ford algorithm must be used.

Example Walkthrough:

Consider a weighted graph with vertices A, B, C, D, and E, and edge weights as depicted in the provided diagrams. We aim to find the shortest paths from vertex A.

  • Initial State:

    • Distances: A: 0, B: ∞\infty, C: ∞\infty, D: ∞\infty, E: ∞\infty
    • Unvisited vertices: {A, B, C, D, E}
  • Step 1: Visit A

    • Smallest distance is 0 (vertex A). Select A.
    • Mark A as visited.
    • Neighbors of A: B (weight 2), C (weight 1).
    • Update distances: B: 0+2=20 + 2 = 2, C: 0+1=10 + 1 = 1.
    • Distances: A: 0, B: 2, C: 1, D: ∞\infty, E: ∞\infty
    • Unvisited vertices: {B, C, D, E}
  • Step 2: Visit C

    • Smallest distance among unvisited is 1 (vertex C). Select C.
    • Mark C as visited.
    • Neighbors of C: B (weight 3), D (weight 2), E (weight 4).
    • Update distances:
      • For B: Current distance is 2. New path through C: distance(A,C)+weight(C,B)=1+3=4distance(A, C) + weight(C, B) = 1 + 3 = 4. Since 4>24 > 2, B's distance remains 2.
      • For D: Current distance is ∞\infty. New path through C: distance(A,C)+weight(C,D)=1+2=3distance(A, C) + weight(C, D) = 1 + 2 = 3. Update D's distance to 3.
      • For E: Current distance is ∞\infty. New path through C: distance(A,C)+weight(C,E)=1+4=5distance(A, C) + weight(C, E) = 1 + 4 = 5. Update E's distance to 5.
    • Distances: A: 0, B: 2, C: 1, D: 3, E: 5
    • Unvisited vertices: {B, D, E}
  • Step 3: Visit B

    • Smallest distance among unvisited is 2 (vertex B). Select B.
    • Mark B as visited.
    • Neighbors of B: D (weight 4), E (weight 3).
    • Update distances:
      • For D: Current distance is 3. New path through B: distance(A,B)+weight(B,D)=2+4=6distance(A, B) + weight(B, D) = 2 + 4 = 6. Since 6>36 > 3, D's distance remains 3.
      • For E: Current distance is 5. New path through B: distance(A,B)+weight(B,E)=2+3=5distance(A, B) + weight(B, E) = 2 + 3 = 5. Since 5≯55 \ngtr 5, E's distance remains 5.
    • Distances: A: 0, B: 2, C: 1, D: 3, E: 5
    • Unvisited vertices: {D, E}
  • Step 4: Visit D

    • Smallest distance among unvisited is 3 (vertex D). Select D.
    • Mark D as visited.
    • Neighbors of D: E (weight 1).
    • Update distances:
      • For E: Current distance is 5. New path through D: distance(A,D)+weight(D,E)=3+1=4distance(A, D) + weight(D, E) = 3 + 1 = 4. Since 4<54 < 5, update E's distance to 4.
    • Distances: A: 0, B: 2, C: 1, D: 3, E: 4
    • Unvisited vertices: {E}
  • Step 5: Visit E

    • Smallest distance among unvisited is 4 (vertex E). Select E.
    • Mark E as visited.
    • E has no unvisited neighbors.
    • Distances: A: 0, B: 2, C: 1, D: 3, E: 4
    • Unvisited vertices: {}

All nodes have been visited. The shortest paths from A are:

  • A to A: 0
  • A to B: 2
  • A to C: 1
  • A to D: 3
  • A to E: 4

Example: The shortest path from A to E has a total weight of 4. This path is A →\to C →\to D →\to E.

The final state shows the shortest path distances from the fixed node (A) to all other nodes in the graph 223 224.

13. Functions and relations (part 1)

This section introduces the fundamental concepts of functions, including their definition, types (injective, surjective, bijective), composition, and inverse functions, along with an initial exploration of relations.

13.1 Introduction to functions

A function is a special type of relation between two sets, X and Y, where each element in the first set (the domain) is associated with exactly one element in the second set (the codomain). This association can be represented as a set of ordered pairs (x,y)(x, y), where xx is from the domain and yy is from the codomain.

  • Formal Definition: A function ff from a set XX to a set YY, denoted as f:X→Yf: X \to Y, is a subset of the Cartesian product X×YX \times Y such that for every element x∈Xx \in X, there exists exactly one element y∈Yy \in Y with (x,y)∈f(x, y) \in f.
  • Domain: The set XX is called the domain of the function ff.
  • Codomain: The set YY is called the codomain of the function ff.
  • Range: The set of all yy values that are actually mapped to by the function is called the range of ff. Formally, it is {y∣(x,y)∈f}\{y \mid (x, y) \in f\}.

Example: The set f={(1,a),(2,b),(3,a)}f = \{(1, a), (2, b), (3, a)\} is a function from X={1,2,3}X = \{1, 2, 3\} to Y={a,b,c}Y = \{a, b, c\}. Each element in XX is mapped to exactly one element in YY. The domain is XX, the codomain is YY, and the range is {a,b}\{a, b\}. 228.

Note: A set of ordered pairs is NOT a function if an element in the domain is not mapped to any element in the codomain, or if an element in the domain is mapped to more than one element in the codomain. 230.

13.2 Types of functions

Functions can be classified based on how elements from the domain map to the codomain.

13.2.1 Injective (one-to-one) functions

A function f:A→Bf: A \to B is injective if distinct elements in the domain map to distinct elements in the codomain. In other words, no two different inputs produce the same output.

  • Formal Definition: A function ff is injective if for all x1,x2∈Ax_1, x_2 \in A, if f(x1)=f(x2)f(x_1) = f(x_2), then x1=x2x_1 = x_2.
  • Property: Every element in the domain maps to a unique element in the codomain.

Example: Prove that f(x)=2x+1f(x) = 2x + 1 from R→R\mathbb{R} \to \mathbb{R} is injective. Assume f(x1)=f(x2)f(x_1) = f(x_2). Then, 2x1+1=2x2+12x_1 + 1 = 2x_2 + 1. Subtracting 1 from both sides gives 2x1=2x22x_1 = 2x_2. Dividing by 2 yields x1=x2x_1 = x_2. Since f(x1)=f(x2)f(x_1) = f(x_2) implies x1=x2x_1 = x_2, the function is injective 233.

13.2.2 Surjective (onto) functions

A function f:A→Bf: A \to B is surjective if every element in the codomain is the image of at least one element from the domain. This means the range of the function is equal to its codomain.

  • Formal Definition: A function ff is surjective if for every y∈By \in B, there exists at least one x∈Ax \in A such that f(x)=yf(x) = y.

Example: Prove that f(x)=x3f(x) = x^3 from R→R\mathbb{R} \to \mathbb{R} is surjective. Let y∈Ry \in \mathbb{R} be an arbitrary element in the codomain. We need to find an x∈Rx \in \mathbb{R} such that f(x)=yf(x) = y. This means we need x3=yx^3 = y. Solving for xx, we get x=yx = \sqrt {y}. Since the cube root of any real number is also a real number, x=y∈Rx = \sqrt {y} \in \mathbb{R}. Thus, for any yy in the codomain, we can find a corresponding xx in the domain. Therefore, f(x)=x3f(x) = x^3 is surjective 235.

13.2.3 Bijective functions

A function f:A→Bf: A \to B is bijective if it is both injective and surjective.

  • Property: A bijective function establishes a perfect one-to-one correspondence between the elements of its domain and codomain. Every element in the codomain is mapped to by exactly one element from the domain.

Example: Prove that f(x)=x+4f(x) = x + 4 from R→R\mathbb{R} \to \mathbb{R} is bijective. 1. Injectivity: Assume f(x1)=f(x2)f(x_1) = f(x_2). Then x1+4=x2+4x_1 + 4 = x_2 + 4. Subtracting 4 from both sides gives x1=x2x_1 = x_2. Thus, ff is injective. 2. Surjectivity: Let y∈Ry \in \mathbb{R} be arbitrary. We want to find an xx such that f(x)=yf(x) = y, which means x+4=yx + 4 = y. Solving for xx, we get x=y−4x = y - 4. Since y−4y-4 is a real number, such an xx always exists in the domain. Thus, ff is surjective. Since ff is both injective and surjective, it is bijective. 237.

13.3 Composition of functions

The composition of two functions allows us to combine them to create a new function.

  • Definition: Let g:X→Yg: X \to Y and f:Y→Zf: Y \to Z be functions. The composition of ff and gg, denoted by f∘gf \circ g, is a function from XX to ZZ defined as (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x)) for all x∈Xx \in X.
  • Process: To find (f∘g)(x)(f \circ g)(x), you first apply the function gg to xx, and then apply the function ff to the result g(x)g(x).

Example: Given f(x)=x2f(x) = x^2 and g(x)=x+2g(x) = x + 2, find (f∘g)(x)(f \circ g)(x) and (g∘f)(x)(g \circ f)(x). (f∘g)(x)=f(g(x))=f(x+2)=(x+2)2=x2+4x+4(f \circ g)(x) = f(g(x)) = f(x+2) = (x+2)^2 = x^2 + 4x + 4. (g∘f)(x)=g(f(x))=g(x2)=x2+2(g \circ f)(x) = g(f(x)) = g(x^2) = x^2 + 2.

Example: If f(x)=1xf(x) = \frac{1}{x} for x≠0x \neq 0, what is (f∘f)(x)(f \circ f)(x)? (f∘f)(x)=f(f(x))=f(1x)(f \circ f)(x) = f(f(x)) = f(\frac{1}{x}). Since f(u)=1uf(u) = \frac{1}{u}, we substitute u=1xu = \frac{1}{x}. Thus, (f∘f)(x)=11x=x(f \circ f)(x) = \frac{1}{\frac{1}{x}} = x 241.

13.4 Inverse functions

An inverse function "reverses" the mapping of the original function.

  • Definition: If ff is a function from set AA to set BB, its inverse function, denoted by f−1f^{-1}, is a function from BB to AA such that for every y∈By \in B, f−1(y)=xf^{-1}(y) = x if and only if f(x)=yf(x) = y.
  • Condition: An inverse function f−1f^{-1} exists if and only if the function ff is bijective (both injective and surjective).
  • Properties:
    • The domain of f−1f^{-1} is the range of ff.
    • The range of f−1f^{-1} is the domain of ff.
    • If (x,y)(x, y) is an ordered pair in ff, then (y,x)(y, x) is an ordered pair in f−1f^{-1}.

Example: Given the function f={(1,a),(2,c),(3,b)}f = \{(1, a), (2, c), (3, b)\}, its inverse is f−1={(a,1),(c,2),(b,3)}f^{-1} = \{(a, 1), (c, 2), (b, 3)\} 243.

Example: Given f:x↦2x−3f: x \mapsto 2x - 3 with domain X={1,2,3}X = \{1, 2, 3\} and codomain Y={−1,1,3}Y = \{-1, 1, 3\}. The mapping is: f=2−3=−1f = 2 - 3 = -1, f=2−3=1f = 2 - 3 = 1, f=2−3=3f = 2 - 3 = 3 2. The inverse function f−1f^{-1} reverses these mappings: f−1(−1)=1f^{-1}(-1) = 1, f−1=2f^{-1} = 2, f−1=3f^{-1} = 3 3 244.

14. Functions and relations (part 2)

This section delves into the properties and applications of functions, specifically focusing on injective, surjective, and bijective types, along with their role in algorithms. It also introduces the concept of relations, their characteristics, and the significant category of equivalence relations.

14.1 Functions in algorithms

Functions serve as fundamental building blocks in algorithm design, modeling data transformations, assignments, and mappings. A function f:A→Bf: A \to B maps each element in a set AA (the domain) to exactly one element in a set BB (the codomain). In algorithmic contexts, the input set corresponds to the domain, the output set to the codomain, and the algorithm's steps define the rule of the function. For instance, an algorithm that doubles an integer, represented as f(x)=2xf(x) = 2x where f:Z→Zf: \mathbb{Z} \to \mathbb{Z}, exemplifies a function where each integer input yields a unique integer output 246 247.

14.1.1 Injective functions in algorithms

Injective functions, also known as one-to-one functions, ensure that distinct inputs always produce distinct outputs. This property is crucial in algorithms for applications such as:

  • Hash functions: Injectivity helps avoid collisions in data structures. A collision occurs when two different inputs map to the same hash value, potentially leading to slower data access. Effective hash functions aim to distribute data evenly. For example, if "cat" and "dog" both hash to the value 23, a collision occurs.
  • Unique ID generation: Algorithms that assign unique identifiers, like student IDs or employee IDs, must be injective to prevent duplicate assignments 248.

Example: An algorithm to assign unique employee IDs where each employee ii receives an ID generated by ID=i×100+1ID = i \times 100 + 1. For instance, Employee 1 gets ID 101, Employee 2 gets ID 201, and so on. This ensures that if i1≠i2i_1 \neq i_2, then ID1≠ID2ID_1 \neq ID_2 253.

14.1.2 Surjective functions in algorithms

Surjective functions, or onto functions, guarantee that every element in the codomain is mapped to by at least one element from the domain. This is important for ensuring comprehensive coverage and utilization in algorithms such as:

  • Load balancing: Distributing tasks across all available servers.
  • Resource allocation: Ensuring all resources are assigned to some process or task.
  • Covering problems: In combinatorics, ensuring all elements of a set are accounted for 249.

Example: An algorithm assigning tasks to departments. If there are three departments, a task tt can be assigned to department (tmod  3)+1(t \mod 3) + 1. This ensures that departments 1, 2, and 3 each receive at least one task, demonstrating surjectivity 254.

14.1.3 Bijective functions in algorithms

Bijective functions, which are both injective and surjective, establish a perfect one-to-one correspondence between elements of the domain and codomain. They are essential for applications requiring a unique mapping in both directions:

  • Data encoding/decoding: Each encoded message maps to a unique original message and vice versa.
  • Permutations: Used in sorting algorithms where elements are rearranged.
  • Cryptographic ciphers: One-to-one mappings ensure unique encryption and decryption for every message 250.

Example: A sorting algorithm can be viewed as a bijective function. The original indices of elements are mapped to their final sorted indices. Each original index maps to a unique final index, and every final index is mapped to by exactly one original index, signifying a bijective mapping 251.

Example: Assigning lockers to employees requires a perfect one-to-one correspondence. If employees are assigned lockers sequentially starting from 101, a mapping can be recorded for both Employee →\to Locker and Locker →\to Employee, facilitating retrieval from either perspective 255.

14.2 Relations

A relation can be understood as a set of ordered pairs. An ordered pair (a,b)(a, b) consists of two elements, aa and bb, where the order is significant, with aa appearing first and bb last 257.

Relations can be defined from a set XX to a set YY, or on a set XX (which means from XX to XX).

14.2.1 Defining and representing relations

Relations can be represented in various ways, including tables and sets of ordered pairs.

  • A relation can be explicitly listed as a set of ordered pairs. For example, a relation RR of Students to Courses might be represented as R={(Bill,Computer Studies),(Mary,Math),(Bill,Art),(Beth,History),(Beth,Computer Studies),(Dave,Math)}R = \{(\text{Bill}, \text{Computer Studies}), (\text{Mary}, \text{Math}), (\text{Bill}, \text{Art}), (\text{Beth}, \text{History}), (\text{Beth}, \text{Computer Studies}), (\text{Dave}, \text{Math})\} 259.
  • If (a,b)∈R(a, b) \in R, it can also be written as aRbaRb.

Example: Consider sets X={2,3,4}X = \{2, 3, 4\} and Y={3,4,5,6,7}Y = \{3, 4, 5, 6, 7\}. A relation RR from XX to YY is defined where (x,y)∈R(x, y) \in R if xx divides yy. The relation RR can be written as R={(2,4),(2,6),(3,3),(3,6),(4,4)}R = \{(2, 4), (2, 6), (3, 3), (3, 6), (4, 4)\}.

14.2.2 Domain and range of relations

The domain of a relation RR, denoted as Dom(R)Dom(R), is the set of all first elements of the ordered pairs in RR. The range of a relation RR, denoted as Ran(R)Ran(R), is the set of all second elements of the ordered pairs in RR.

Example: For the relation R={(Bill,Computer Studies),(Mary,Math),(Bill,Art),(Beth,History),(Beth,Computer Studies),(Dave,Math)}R = \{(\text{Bill}, \text{Computer Studies}), (\text{Mary}, \text{Math}), (\text{Bill}, \text{Art}), (\text{Beth}, \text{History}), (\text{Beth}, \text{Computer Studies}), (\text{Dave}, \text{Math})\}, the domain is X={Bill,Mary,Beth,Dave}X = \{\text{Bill}, \text{Mary}, \text{Beth}, \text{Dave}\} and the range is Y={Computer Studies,Math,Art,History}Y = \{\text{Computer Studies}, \text{Math}, \text{Art}, \text{History}\} 260.

Example: For the relation R={(2,4),(2,6),(3,3),(3,6),(4,4)}R = \{(2, 4), (2, 6), (3, 3), (3, 6), (4, 4)\}, Dom(R)={2,3,4}Dom(R) = \{2, 3, 4\} and Ran(R)={3,4,6}Ran(R) = \{3, 4, 6\} 262.

Example: Let RR be the relation on X={1,2,3,4}X = \{1, 2, 3, 4\} defined by (x,y)∈R(x, y) \in R if x≤yx \leq y. Then R={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)}R = \{(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)\}. Here, Dom(R)={1,2,3,4}Dom(R) = \{1, 2, 3, 4\} and Ran(R)={1,2,3,4}Ran(R) = \{1, 2, 3, 4\} 263.

Example: Let A={1,2,3,4,5}A = \{1, 2, 3, 4, 5\}. Define relation RR on AA as aRbaRb if a<ba < b. Then R={(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)}R = \{(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)\}. The domain is Dom(R)={1,2,3,4}Dom(R) = \{1, 2, 3, 4\} and the range is Ran(R)={2,3,4,5}Ran(R) = \{2, 3, 4, 5\} 264.

15. Functions and relations (part 3)

This section delves into the properties of relations, including reflexivity, symmetry, and transitivity, and introduces the concept of equivalence relations.

15.1 Relations and their representations

A relation RR on a set AA is a subset of the Cartesian product A×AA \times A. If aa is related to bb by relation RR, it is denoted as aRbaRb or (a,b)∈R(a, b) \in R. Relations can be visualized using digraphs, especially for finite sets.

15.1.1 Digraph of a relation

A digraph of a relation RR on a finite set AA is constructed by:

  • Representing each element of AA as a vertex (a small circle).
  • Drawing a directed edge (an arrow) from vertex aia_i to vertex aja_j if and only if (ai,aj)∈R(a_i, a_j) \in R.

Example: For A={1,2,3,4}A=\{1, 2, 3, 4\} and R={(1,1),(1,2),(2,1),(2,2),(2,4),(3,4),(4,2)}R=\{(1, 1), (1, 2), (2, 1), (2, 2), (2, 4), (3, 4), (4, 2)\}, the digraph shows loops at vertices 1 and 2, and edges between 1 and 2, 2 and 4, 3 and 4, and 4 and 2 267.

Example: Given a digraph, the relation can be determined by identifying all ordered pairs (ai,aj)(a_i, a_j) for which there is an edge from vertex aia_i to vertex aja_j. For instance, a digraph with edges (2,2),(3,3),(1,2),(3,1),(4,3)(2, 2), (3, 3), (1, 2), (3, 1), (4, 3) corresponds to the relation R={(2,2),(3,3),(1,2),(3,1),(4,3)}R=\{(2, 2), (3, 3), (1, 2), (3, 1), (4,3)\} 268.

15.2 Properties of relations

Relations can possess several important properties that classify their structure.

15.2.1 Reflexive and irreflexive relations

  • Reflexive relation: A relation RR on a set XX is reflexive if (x,x)∈R(x, x) \in R for every element x∈Xx \in X. This means every element is related to itself.

    Example: The relation RR on X={1,2,3,4}X=\{1, 2, 3, 4\} defined by (x,y)∈R(x, y) \in R if x≤yx \le y is reflexive because (1,1),(2,2),(3,3),(4,4)(1, 1), (2, 2), (3, 3), (4, 4) are all in RR 270.

  • Irreflexive relation: A relation RR on a set XX is irreflexive if no element is related to itself, meaning (x,x)∉R(x, x) \notin R for all x∈Xx \in X.

    Example: The relation RR on X={1,2,3,4}X=\{1, 2, 3, 4\} defined by (x,y)∈R(x, y) \in R if x<yx < y is irreflexive, as no element is related to itself 271. Note: A relation is not irreflexive if there exists at least one element xx such that (x,x)∈R(x, x) \in R. For instance, if R={(1,1),(1,2),(2,4)}R=\{(1, 1), (1, 2), (2, 4)\} on X={1,2,3,4}X=\{1, 2, 3, 4\}, it is not irreflexive because (1,1)∈R(1, 1) \in R 272.

15.2.2 Symmetric and non-symmetric relations

  • Symmetric relation: A relation RR on a set AA is symmetric if for all a,b∈Aa, b \in A, whenever aRbaRb, then bRabRa. In a digraph, this means if there is an edge from vertex aa to vertex bb, there must also be an edge from vertex bb to vertex aa.

    Example: The relation R={(a,a),(b,c),(c,b),(d,d)}R=\{(a, a), (b, c), (c, b), (d, d)\} on X={a,b,c,d}X=\{a, b, c, d\} is symmetric because for (b,c)∈R(b, c) \in R, we also have (c,b)∈R(c, b) \in R, and for (a,a),(d,d)∈R(a, a), (d, d) \in R, their reverses are themselves 273.

  • Non-symmetric relation: A relation RR is non-symmetric if there exist elements a,b∈Aa, b \in A such that aRbaRb but bRabRa is not true.

    Example: The relation RR on X={1,2,3}X=\{1, 2, 3\} defined by (x,y)∈R(x, y) \in R if x<yx < y is non-symmetric, as (2,3)∈R(2, 3) \in R but (3,2)∉R(3, 2) \notin R 274.

  • Asymmetric relation: A relation RR on a set AA is asymmetric if for all a,b∈Aa, b \in A, if aRbaRb, then bRabRa must not be true. This implies that no element can be related to itself, and if a≠ba \neq b and aRbaRb, then bRabRa is false.

    Example: The relation RR on A={1,2,3}A=\{1, 2, 3\} defined by aRbaRb if a<ba<b is asymmetric. For instance, (1,2)∈R(1, 2) \in R but (2,1)∉R(2, 1) \notin R. Also, (x,x)∉R(x, x) \notin R for any xx. Note: A relation is "not asymmetric" if there exist a,b∈Aa, b \in A such that aRbaRb and bRabRa. For example, R={(1,1),(1,2),(2,1),(3,2)}R=\{(1, 1), (1, 2), (2, 1), (3, 2)\} on A={1,2,3}A=\{1, 2, 3\} is not asymmetric because (1,2)∈R(1, 2) \in R and (2,1)∈R(2, 1) \in R 275.

15.2.3 Transitive relations

  • Transitive relation: A relation RR on a set AA is transitive if for all a,b,c∈Aa, b, c \in A, whenever (a,b)∈R(a, b) \in R and (b,c)∈R(b, c) \in R, it implies that (a,c)∈R(a, c) \in R. In a digraph, if there's a path from vertex aa to vertex bb and from vertex bb to vertex cc, there must also be a direct edge from vertex aa to vertex cc.

    Example: The "less than" relation (<<) on the set of integers ZZ is transitive. If a<ba < b and b<cb < c, then it logically follows that a<ca < c 277. Example: The relation R={(a,a),(b,c),(c,b),(d,d)}R=\{(a, a), (b, c), (c, b), (d, d)\} on X={a,b,c,d}X=\{a, b, c, d\} is not transitive because (b,c)∈R(b, c) \in R and (c,b)∈R(c, b) \in R, but (b,b)∉R(b, b) \notin R 278.

15.3 Equivalence relations

An equivalence relation is a special type of relation that satisfies three specific properties: reflexivity, symmetry, and transitivity.

  • Definition: A relation RR on a set XX is an equivalence relation if it is:
    1. Reflexive: (x,x)∈R(x, x) \in R for all x∈Xx \in X.
    2. Symmetric: If (x,y)∈R(x, y) \in R, then (y,x)∈R(y, x) \in R.
    3. Transitive: If (x,y)∈R(x, y) \in R and (y,z)∈R(y, z) \in R, then (x,z)∈R(x, z) \in R.

Example: To determine if R={(a,a),(b,c),(c,b),(d,d)}R=\{(a, a), (b, c), (c, b), (d, d)\} on X={a,b,c,d}X=\{a, b, c, d\} is an equivalence relation, we check the properties:

  • It is not reflexive because, for instance, (b,b)∉R(b, b) \notin R.
  • It is not transitive because (b,c)∈R(b, c) \in R and (c,b)∈R(c, b) \in R, but (b,b)∉R(b, b) \notin R. Since it fails to meet the criteria for reflexivity and transitivity, it is not an equivalence relation 279.

Note: A common example of an equivalence relation is the relation "is equal to" on a set, or "has the same remainder as" when divided by a specific number. Equivalence relations partition a set into disjoint subsets called equivalence classes.

16. Sets and set operations (part 1)

This section introduces the fundamental concepts of sets and their basic operations, focusing on definitions, notation, and operations such as complement, intersection, and union.

16.1 Introduction to sets

A set is defined as an unordered collection or group of objects, where these objects are referred to as elements or members of the set. A set is said to contain its elements 282.

  • Membership Notation:
    • The notation a∈Aa \in A signifies that aa is an element of set AA.
    • The notation a∉Aa \notin A indicates that aa is not an element of set AA.
    • Lowercase letters are typically used to represent elements of sets 283.

Example: Given A={2,4,5}A = \{2, 4, 5\} and B={6,8}B = \{6, 8\}, we can state that 2∈A2 \in A and 5∈A5 \in A. Conversely, 6∉A6 \notin A, although 6∈B6 \in B 284.

16.2 Describing sets

Sets can be described in several ways:

  • Listing Members: When feasible, the elements of a set are listed between braces. For instance, {a,b,c,d}\{a, b, c, d\} represents a set with four specific elements 285.
  • Using Ellipses: If a clear pattern exists, some members are listed, followed by ellipses (...), to indicate continuation. For example, the set of positive integers less than 100 can be denoted as {1,2,3,…,99}\{1, 2, 3, \dots, 99\} 287.
  • Set-Builder Notation: This method describes a set by stating a property that its elements must satisfy.
    • Example: A set of integers from 1 to 5 can be written as A={x:1≤x≤5,x is an integer}A = \{x: 1 \le x \le 5, x \text{ is an integer}\}.
    • Example: The set CC of all vowels in the English alphabet is C={a,e,i,o,u}C = \{a, e, i, o, u\} 286.
    • Example: The set OO of all odd positive integers less than 10 can be written as O={x∣x is an odd positive integer less than 10}O = \{x \mid x \text{ is an odd positive integer less than 10}\} or, by specifying the universe, O={x∣x is odd and x<10}O = \{x \mid x \text{ is odd and } x < 10\} 288.

16.2.1 Standard number sets

Certain sets, often denoted by boldface letters, are fundamental in discrete mathematics 289:

  • N={1,2,3,… }\mathbb{N} = \{1, 2, 3, \dots\}, the set of natural numbers.
  • Z={…,−2,−1,0,1,2,… }\mathbb{Z} = \{\dots, -2, -1, 0, 1, 2, \dots\}, the set of integers.
  • Z+={1,2,3,… }\mathbb{Z}^+ = \{1, 2, 3, \dots\}, the set of positive integers.
  • Q={p/q∣p∈Z,q∈Z, and q≠0}\mathbb{Q} = \{p/q \mid p \in \mathbb{Z}, q \in \mathbb{Z}, \text{ and } q \neq 0\}, the set of rational numbers.
  • R\mathbb{R}, the set of real numbers.

16.3 Universal sets and complements

16.3.1 Universal set

A universal set, typically denoted by ξ\xi, is a set that encompasses all elements currently under consideration.

Example: If A={2,4,6,8}A = \{2, 4, 6, 8\} and the scope of discussion includes all integers from 1 to 10, then the universal set is ξ={all integers from 1 to 10}\xi = \{\text{all integers from 1 to 10}\} 290.

16.3.2 Complement of a set

The complement of a set AA, denoted as A′A', consists of all elements in the universal set ξ\xi that are not in AA.

Example: Given ξ={all integers from 1 to 10}\xi = \{\text{all integers from 1 to 10}\} and A={2,3,4,5,7,8,9}A = \{2, 3, 4, 5, 7, 8, 9\}, then A′={1,6,10}A' = \{1, 6, 10\} 292.

In a Venn diagram, the complement A′A' is represented by the shaded region within ξ\xi that lies outside of AA 293.

16.4 Set operations

16.4.1 Intersection of sets

The intersection of two sets, AA and BB, denoted by A∩BA \cap B, is the set containing all elements that are common to both AA and BB.

Example: If A={1,3,5,8}A = \{1, 3, 5, 8\} and B={2,3,5,7}B = \{2, 3, 5, 7\}, then A∩B={3,5}A \cap B = \{3, 5\} because 3 and 5 are present in both sets 294.

Example: Given P={M,A,T,H,E,I,C}P = \{M, A, T, H, E, I, C\} and Q={E,N,G,L,I,S,H}Q = \{E, N, G, L, I, S, H\}, then P∩Q={E,H,I}P \cap Q = \{E, H, I\} 295.

In a Venn diagram, the intersection A∩BA \cap B is represented by the overlapping region of sets AA and BB 296.

16.4.2 Complement of the intersection of sets

The complement of the intersection of sets, denoted as (A∩B)′(A \cap B)', represents all elements in the universal set ξ\xi that are not in the intersection A∩BA \cap B. This is visualized in a Venn diagram as the shaded area within ξ\xi but outside the overlapping region of AA and BB 297.

The concept extends to more than two sets, such as (P∩Q∩R)′(P \cap Q \cap R)', which includes elements not common to PP, QQ, and RR simultaneously. Similarly, expressions like A∩B∩C′A \cap B \cap C' and A∩(B∩C)′A \cap (B \cap C)' involve intersections with complements of other sets 298 299.

16.4.3 Union of sets

The union of two sets, AA and BB, denoted by A∪BA \cup B, is the set of all elements that belong to AA, or to BB, or to both.

Example: Given A={1,3,5}A = \{1, 3, 5\} and B={2,3,4}B = \{2, 3, 4\}, the union of AA and BB is A∪B={1,2,3,4,5}A \cup B = \{1, 2, 3, 4, 5\}. The symbol ∪\cup is used to denote the union of two sets 300.

17. Sets and set operations (part 2)

This section delves into advanced set operations, including set difference, symmetric difference, and the concept of disjoint sets, building upon foundational set theory.

17.1 Set difference

The difference between two sets, A and B, denoted as A−BA-B, is the set containing all elements that are present in set A but not in set B. Mathematically, this is defined as: A−B={x∣x∈A and x∉B}A-B = \{x \mid x \in A \text{ and } x \notin B\}.

To find the difference A−BA-B:

  1. Identify all elements that are common to both sets A and B.
  2. From set A, remove any elements that are also present in set B.
  3. The remaining elements in A constitute the set difference A−BA-B.

Similarly, the difference B−AB-A contains all elements that are in set B but not in set A. B−A={x∣x∈B and x∉A}B-A = \{x \mid x \in B \text{ and } x \notin A\}.

Example: Given A={1,3,5}A = \{1, 3, 5\} and B={4,5,6}B = \{4, 5, 6\}. Then, A−B={1,3}A-B = \{1, 3\} because 1 and 3 are in A but not in B, while 5 is common to both. And, B−A={4,6}B-A = \{4, 6\} because 4 and 6 are in B but not in A, while 5 is common to both 306.

17.2 Symmetric difference

The symmetric difference between two sets, A and B, denoted by A⊕BA \oplus B, is the set of all elements that belong to either A or B, but not to both. This can be expressed as: A⊕B={x∣(x∈A and x∉B) or (x∈B and x∉A)}A \oplus B = \{x \mid (x \in A \text{ and } x \notin B) \text{ or } (x \in B \text{ and } x \notin A)\} 307.

An alternative way to define the symmetric difference is as the union of the differences of the two sets: A⊕B=(A−B)∪(B−A)A \oplus B = (A-B) \cup (B-A).

To calculate the symmetric difference A⊕BA \oplus B:

  1. Calculate the set difference A−BA-B.
  2. Calculate the set difference B−AB-A.
  3. Take the union of the results from steps 1 and 2.

Example: Let A={a,b,c,d}A = \{a, b, c, d\} and B={a,c,e,f,g}B = \{a, c, e, f, g\}. First, find the differences: A−B={b,d}A-B = \{b, d\} B−A={e,f,g}B-A = \{e, f, g\} Then, find the symmetric difference: A⊕B=(A−B)∪(B−A)={b,d}∪{e,f,g}={b,d,e,f,g}A \oplus B = (A-B) \cup (B-A) = \{b, d\} \cup \{e, f, g\} = \{b, d, e, f, g\} 308.

Remember: The steps for calculating set differences are crucial for finding the symmetric difference 309.

Exercise: If A={Counting numbers between 30 and 40}A = \{\text{Counting numbers between 30 and 40}\} and B={Counting numbers between 20 and 50 which are divisible by 4}B = \{\text{Counting numbers between 20 and 50 which are divisible by 4}\}, find A−BA-B and B−AB-A. A={31,32,33,34,35,36,37,38,39}A = \{31, 32, 33, 34, 35, 36, 37, 38, 39\} B={24,28,32,36,40,44,48}B = \{24, 28, 32, 36, 40, 44, 48\}

a) A−BA-B: Eliminate common elements (32, 36) from A. A−B={31,33,34,35,37,38,39}A-B = \{31, 33, 34, 35, 37, 38, 39\}.

b) B−AB-A: Eliminate common elements (32, 36) from B. B−A={24,28,40,44,48}B-A = \{24, 28, 40, 44, 48\} 310.

17.3 Disjoint sets

Two sets are considered disjoint if they share no common elements. This means their intersection is the empty set (∅\emptyset). Mathematically, sets A and B are disjoint if and only if A∩B=∅A \cap B = \emptyset.

Note: If two sets are disjoint, their symmetric difference is equal to their union, i.e., if A∩B=∅A \cap B = \emptyset, then A⊕B=A∪BA \oplus B = A \cup B 311.

Common mistakes to avoid

  • Review all topics thoroughly before exams
  • Pay attention to formulas and key definitions
  • Practice with examples provided in each section
  • Don't memorize without understanding the underlying concepts

© 2026 Maeve. All rights reserved. This content is protected by copyright.

See also