MTH202 HIGHLIGHTED HANDOUTS
Table of contents
- Logic
- Truth Tables
- Laws of Logic
- Biconditional
- Argument
- Applications of Logic
- Set theory
- Venn diagram
- Set identities
- Applications of Venn diagram
- Relations
- Types of Relations
- Matrix Representation of Relations
- Inverse of Relations
- Functions
- Types of functions
- Inverse function
- Composition of Functions
- Sequence
- Series
- Recursion I
- Recursion II
- Mathematical Induction
- Mathematical Induction for Divisibility
- Methods of proof
- Proof by Contradiction
- Algorithm
- Division algorithm
- Combinatorics
- Permutations
- Combinations
- K-Combinations
- Tree Diagram
- Inclusion-Exclusion Principle
- Probability
- Laws of Probability
- Conditional probability
- Random variable
- Introduction to graphs
- Paths and Circuits
- Matrix Representation of Graphs
- Isomorphism of graphs
- Planar graphs
- Trees
- Spanning Trees
1. Logic
1.1 Statements
A statement, also known as a proposition, is a declarative sentence that can be definitively classified as either true or false, but not both. The truth value of a statement is denoted by 'T' for true and 'F' for false.
Sentences that are commands, questions, or contain undefined variables or pronouns are not considered statements. However, if context clarifies pronoun or variable references, such sentences can be statements.
- Statement examples:
- "2 + 2 = 4" (True)
- "It is Sunday today" (Truth value depends on the day)
- "Grass is green" (True)
- "-1 > 0" (False)
- Non-statement examples:
- "Close the door." (Command)
- "x is greater than 2." (Undefined variable 'x')
- "May I come in?" (Question)
- "x + y = 12" (Undefined variables 'x' and 'y') 4 5.
1.2 Compound statements and logical connectives 5
A compound statement is formed by combining simple statements using logical connectives. These connectives allow for the construction of more complex logical expressions.
The primary logical connectives and their symbolic representations are:
| Symbol | Name | Meaning |
|---|---|---|
| ~ | Negation | not |
| | Conjunction | and |
| | Disjunction | or |
| | Conditional | if...then... |
| | Biconditional | if and only if |
📝 Let p = "It is hot", and q = "It is sunny". "It is hot and sunny" translates to p∧q. 5
1.3 Symbolic representation and translation
Statements are represented by letters such as p, q, and r. Compound statements can be translated between English and symbolic form using these variables and connectives.
-
Example translation from English to symbols: Let p = "It is hot", and q = "It is sunny".
-
"It is hot and sunny" translates to p∧q.
-
"It is not hot but sunny" translates to ¬p∧q.
-
"It is neither hot nor sunny" translates to ¬p∧¬q.
-
Example translation from symbols to English: Let m = "Ali is good in Mathematics" and c = "Ali is a Computer Science student".
-
¬c translates to "Ali is not a Computer Science student."
-
m∧¬c translates to "Ali is good in Mathematics but not a Computer Science student."
-
c∨m translates to "Ali is a Computer Science student or good in Mathematics." 5 6.
1.4 Truth tables
A truth table systematically lists all possible truth values for the individual statements within a compound statement and shows the resulting truth value of the compound statement for each combination. This is a crucial tool for analyzing the validity of logical arguments.
📝 The truth table for negation shows that if p is true, ¬p is false, and if p is false, ¬p is true. 7
1.5 Negation 7
The negation of a statement p, denoted by ¬p, is true when p is false, and false when p is true.
| p | ~p |
|---|---|
| T | F |
| F | T |
1.6 Conjunction 7
The conjunction of two statements p and q, denoted by p∧q, is true only when both p and q are true. Otherwise, it is false.
| p | q | p q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | F |
1.7 Disjunction (Inclusive OR) 7 8
The disjunction of two statements p and q, denoted by p∨q, is true when at least one of p or q is true. It is false only when both p and q are false.
| p | q | p q |
|---|---|---|
| T | T | T |
| T | F | T |
| F | T | T |
| F | F | F |
2. Truth Tables
2.1 Constructing truth tables
Truth tables are used to determine the truth values of compound logical statements based on the truth values of their individual components. Each row in a truth table represents a unique combination of truth values for the propositional variables 9.
To construct a truth table for a compound statement:
- Identify all propositional variables (e.g., p, q, r).
- Determine the number of rows needed: 2n, where n is the number of variables.
- List all possible combinations of truth values (True/T, False/F) for the variables.
- Systematically evaluate the truth values of each sub-expression, working from the simplest to the most complex.
- The final column represents the truth value of the entire compound statement for each combination of input variables 9.
The truth table for ~ p q shows that the statement is true only when p is false and q is true 9.
The truth table for ~ p (q ~ r) requires three variables (p, q, r), thus 23=8 rows. It systematically evaluates ~ r, then q ~ r, then ~ p, and finally combines them to find the truth value of the entire expression 9.
2.2 Inclusive and exclusive OR
In English, the word "or" can be used in two ways:
- Inclusive OR: This means "p or q, or both." The statement is true if either p is true, q is true, or both p and q are true. This is the standard interpretation in logic, represented by the symbol
. - Exclusive OR (XOR): This means "p or q, but not both." The statement is true if either p is true or q is true, but not if both are true. This is represented by the symbol
orXOR10.
The logical expression for exclusive OR can be derived from the inclusive OR and AND operations: (p q) ~ (p q) 10.
| p | q | p q | p q | ~ (p q) | (p q) ~ (p q) |
|---|---|---|---|---|---|
| T | T | T | T | F | F |
| T | F | T | F | T | T |
| F | T | T | F | T | T |
| F | F | F | F | T | F |
📝 The truth table for
~ p (q ~ r)requires three variables (p, q, r), thus 23=8 rows. It systematically evaluates~ r, thenq ~ r, then~ p, and finally combines them to find the truth value of the entire expression 9.
2.3 Logical equivalence
Two logical expressions are logically equivalent if they have the same truth values for all possible combinations of truth values of their propositional variables. This is denoted by the symbol ≡ 11.
A fundamental example is the double negation property: ~(~p) ≡ p. This means that negating a statement twice returns the original statement 11.
The statement "It is not true that I am not happy" can be simplified using this property. If p represents "I am happy," then ~p is "I am not happy," and ~(~p) is "It is not true that I am not happy."
Therefore, the statement is equivalent to p, meaning "I am happy." 11.
To show that ~ (p q) and ~ p ~ q are not logically equivalent, one would construct their truth tables and observe that they produce different truth values for at least one combination of p and q 11.
2.4 De Morgan's Laws
De Morgan's Laws provide rules for negating conjunctions (AND) and disjunctions (OR):
- The negation of an AND statement is equivalent to the OR statement where each component is negated:
~ (p q) ≡ ~ p ~ q. - The negation of an OR statement is equivalent to the AND statement where each component is negated:
~ (p q) ≡ ~ p ~ q12.
These laws are crucial for simplifying logical expressions and finding negations of complex statements 12.
Application Example:
- Statement: "The fan is slow or it is very hot."
- Negation: "The fan is not slow and it is not very hot." (
~ (p q) ≡ ~ p ~ q). - Statement: "Akram is unfit and Saleem is injured."
- Negation: "Akram is not unfit or Saleem is not injured." (
~ (p q) ≡ ~ p ~ q) 12.
Inequalities Example:
- Statement:
x > –1 AND x 4(which means-1 < x 4) - Negation using De Morgan's Law:
x –1 OR x > 412.
2.5 Tautology and contradiction
A tautology is a statement form that is always true, regardless of the truth values of its propositional variables. It is often represented by the symbol t 13.
A contradiction is a statement form that is always false, regardless of the truth values of its propositional variables. It is often represented by the symbol c 13.
To prove a statement is a tautology, its truth table column must contain only 'T' values. To prove it is a contradiction, its truth table column must contain only 'F' values 13.
Example of a Tautology: p ~ p is always true 13.
| p | ~ p | p ~ p |
|---|---|---|
| T | F | T |
| F | T | T |
Example of a Contradiction: p ~ p is always false 13.
| p | ~ p | p ~ p |
|---|---|---|
| T | F | F |
| F | T | F |
Key relationships:
- The negation of a tautology is a contradiction, and vice versa.
- Two statements are contradictory if their conjunction is a contradiction 13.
2.6 Logical equivalence involving tautology and contradiction
Logical equivalences can be shown using tautologies and contradictions:
p t ≡ p: Conjunction with a tautology yields the original statement.p c ≡ c: Conjunction with a contradiction yields a contradiction 14.
| p | t | p t |
|---|---|---|
| T | T | T |
| F | T | F |
| p | c | p c |
|---|---|---|
| T | F | F |
| F | F | F |
To show that ( p q ) (~ p ( p ~q )) is a tautology, its truth table must result in all 'T' values 14.
To show that (p ~q) (~pq) is a contradiction, its truth table must result in all 'F' values 14.
2.7 Laws of logic16
The laws of logic provide fundamental rules for manipulating and simplifying logical expressions 15.
| Law Name | Symbolic Representation |
|---|---|
| Commutative Laws | p q ≡ q p\np q ≡ q p |
| Associative Laws | ( p q ) r ≡ p ( q r ); ( p q ) r ≡ p ( q r ) |
| Distributive Laws | p ( q r ) ≡ ( p q ) ( p r )\np ( q r ) ≡ ( p q ) ( p r ) |
| Identity Laws | p t ≡ p\np c ≡ p |
| Double Negation Law | ~ ( ~p) ≡ p |
| Idempotent Laws | p p ≡ p\np p ≡ p |
| Negation Laws | p ~p ≡ t\np ~p ≡ c |
| DeMorgan’s Laws | ~ ( p q ) ≡ ~p ~q; ~ ( p q ) ≡ ~p ~q |
| Universal Bound Laws | p t ≡ t\np c ≡ c |
| Absorption Laws | p ( p q ) ≡ p\np ( p q ) ≡ p |
| Negation of t and c | ~ t ≡ c; ~ c ≡ t |
3. Laws of Logic
3.1 Applying laws of logic
Logical laws are used to simplify complex statements into more manageable forms. This process involves applying rules such as DeMorgan's Law, the Double Negative Law, the Associative Law, and the Idempotent Law 17.
- DeMorgan's Law: This law states that the negation of a conjunction is the disjunction of the negations, and the negation of a disjunction is the conjunction of the negations. Symbolically, ¬(p∧q)≡¬p∨¬q and ¬(p∨q)≡¬p∧¬q.
- Double Negative Law: This law states that negating a statement twice results in the original statement. Symbolically, ¬(¬p)≡p.
- Associative Law: This law allows for the regrouping of terms in a disjunction or conjunction without changing the result. For disjunction: (p∨q)∨r≡p∨(q∨r).
- Idempotent Law: This law states that a statement connected to itself by a disjunction or conjunction is equivalent to the statement itself. For disjunction: p∨p≡p 17.
The simplification of a statement form like p∨[¬(¬p∧q)] proceeds step-by-step using these laws: p∨[¬(¬p∧q)]≡p∨[¬(¬p)∨(¬q)] (DeMorgan's Law) ≡p∨[p∨(¬q)] (Double Negative Law) ≡[p∨p]∨(¬q) (Associative Law for ∨) ≡p∨(¬q) (Idempotent Law) 17.
3.2 Simplifying a statement
Complex conditions can be rephrased more simply using logical laws, particularly the distributive law 17.
Let p represent "You are hardworking," q represent "The sun shines," and r represent "It rains." The condition "You will get an A if you are hardworking and the sun shines, or you are hardworking and it rains" can be symbolized as (p∧q)∨(p∧r) 17.
Applying the distributive law in reverse: (p∧q)∨(p∧r)≡p∧(q∨r) 17.
Translating this simplified form back into English yields: "You will get an A if you are hardworking and the sun shines or it rains." 17.
📝 "If 1 = 1, then 3 = 3." (T → T) is TRUE. 18
3.3 Conditional statements
Conditional statements, also known as implications, express a relationship where one statement (the hypothesis or antecedent) implies another statement (the conclusion or consequent). They are typically written in the form "If p, then q" or "p implies q," denoted as p→q 18.
A conditional statement p→q is false only when the hypothesis p is true and the conclusion q is false. In all other cases, the statement is true 18.
3.4 Truth table for conditional statements
The truth values of a conditional statement can be systematically determined using a truth table 18.
See the table in section 2.2.
3.5 Practice with conditional statements
The truth value of a conditional statement can be determined by evaluating the truth of its components 18.
- "If 1 = 1, then 3 = 3." (T → T) is TRUE.
- "If 1 = 1, then 2 = 3." (T → F) is FALSE.
- "If 1 = 0, then 3 = 3." (F → T) is TRUE.
- "If 1 = 2, then 2 = 3." (F → F) is TRUE.
- "If 1 = 1, then 1 = 2 and 2 = 3." (T → (F ∧ F)) is FALSE.
- "If 1 = 3 or 1 = 2 then 3 = 3." (F ∨ F → T) is TRUE 18.
3.6 Alternative ways of expressing implications
Conditional statements can be expressed in various linguistic forms, all conveying the same logical relationship 19.
- "q is necessary for p"
- "p is sufficient for q"
- "q whenever p"
- "p only if q"
- "q if p"
- "if p, q"
- "q follows from p"
- "p implies q"
- "not p unless q"
- "if p then q" 19.
3.7 Translating English sentences to symbols
English sentences describing conditions can be translated into symbolic logic using propositional variables and connectives 19.
Let p = "you get an A on the final exam," q = "you do every exercise in this book," and r = "you get an A in this class." 19.
- "To get an A in this class it is necessary for you to get an A on the final." translates to r→p.
- "Getting an A on the final and doing every exercise in this book is sufficient for getting an A in this class." translates to (p∧q)→r 19.
3.8 Translating symbolic propositions to English
Symbolic logical expressions can be translated back into English sentences 19.
Let p = "you have the flu," q = "you miss the final exam," and r = "you pass the course." 19.
- p→q translates to "If you have flu, then you will miss the final exam." 19.
- ¬q→r translates to "If you don’t miss the final exam, you will pass the course.".
- ¬p∧¬q→r translates to "If you neither have flu nor miss the final exam, then you will pass the course." 20.
3.9 Hierarchy of operations for logical connectives
The order in which logical operations are performed is important for evaluating complex statements. The hierarchy is as follows 20:
- Negation (¬)
- Conditional (→)
- Conjunction (∧), Disjunction (∨)
📝 Construct a truth table for p∨¬q→¬p 20
3.10 Constructing truth tables
Truth tables can be constructed for complex statement forms by breaking them down into their constituent parts and evaluating each step 20.
Example: Construct a truth table for p∨¬q→¬p 20.
See the table in section 2.2.
Example: Construct a truth table for (p→q)∧(¬p→r) 20.
- p: q, r, pq, ¬p,
pr, (pq)(p r) - T: T, T, T, F, T, T
- T: T, F, T, F, T, T
- T: F, T, F, F, T, F
- T: F, F, F, F, T, F
- F: T, T, T, T, T, T
- F: T, F, T, T, F, F
- F: F, T, T, T, T, T
- F: F, F, T, T, F, F
3.11 Logical equivalence involving implication
Two statement forms are logically equivalent if they have the same truth values for all possible truth assignments of their variables. The implication p→q is logically equivalent to ¬p∨q 21.
See the table in section 2.2.
Since p→q and ¬q→¬p have the same truth values, they are logically equivalent 21.
The implication p→q is also equivalent to ¬p∨q 21.
3.12 Negation of a conditional statement
The negation of a conditional statement "if p then q" is logically equivalent to "p and not q" (p∧¬q). This means the negation of an if-then statement does not begin with "if." 21.
- The negation of "If Ali lives in Pakistan then he lives in Lahore" is "Ali lives in Pakistan and he does not live in Lahore.".
- The negation of "If my car is in the repair shop, then I cannot get to class" is "My car is in the repair shop and I can get to class.".
- The negation of "If x is prime then x is odd or x is 2" is "x is prime but x is not odd and x is not 2.".
- The negation of "If n is divisible by 6, then n is divisible by 2 and n is divisible by 3" is "n is divisible by 6 but n is not divisible by 2 or by 3." 22.
3.13 Inverse, converse, and contrapositive of a conditional statement
Conditional statements have related forms: the inverse, converse, and contrapositive. These forms are derived by negating and/or switching the hypothesis and conclusion 22.
📝 The contrapositive of "If today is Friday, then 2 + 3 = 5" is "If 2 + 3 = 5, then today is not Friday." 23
3.14 Inverse of a conditional statement
The inverse of a conditional statement p→q is ¬p→¬q. A conditional statement and its inverse are not logically equivalent, as shown by their differing truth values in certain cases 22.
- The inverse of "If today is Friday, then 2 + 3 = 5" is "If today is not Friday, then 2 + 3 = 5.".
- The inverse of "If it snows today, I will ski tomorrow" is "If it does not snow today I will not ski tomorrow.".
- The inverse of "If P is a square, then P is a rectangle" is "If P is not a square then P is not a rectangle.".
- The inverse of "If my car is in the repair shop, then I cannot get to class" is "If my car is not in the repair shop, then I shall get to the class." 22.
3.15 Converse of a conditional statement
The converse of a conditional statement p→q is q→p. A conditional statement and its converse are not logically equivalent, meaning the conditional operator (→) is not commutative 22.
- The converse of "If today is Friday, then 2 + 3 = 5" is "If 2 + 3 = 5, then today is Friday.".
- The converse of "If it snows today, I will ski tomorrow" is "I will ski tomorrow only if it snows today." 23.
3.16 Contrapositive of a conditional statement
The contrapositive of a conditional statement p→q is ¬q→¬p. A conditional statement and its contrapositive are logically equivalent 23.
- The contrapositive of "If today is Friday, then 2 + 3 = 5" is "If 2 + 3 = 5, then today is not Friday.".
- The contrapositive of "If it snows today, I will ski tomorrow" is "I will not ski tomorrow only if it does not snow today.".
- The contrapositive of "If P is a square, then P is a rectangle" is "If P is not a rectangle then P is not a square.".
- The contrapositive of "If my car is in the repair shop, then I cannot get to class" is "If I can get to the class, then my car is not in the repair shop." 23.
To show that p→q≡¬q→¬p, one can use a truth table, demonstrating that both expressions yield the same truth values for all combinations of p and q 23.
4. Biconditional
4.1 Biconditional statements
A biconditional statement, denoted p↔q, is formed from statement variables p and q and means "p if and only if q" (iff). It is true only when both p and q have the same truth value (both true or both false) 24.
See the table in section 2.2.
The biconditional p↔q can be rephrased in several ways:
- "p is necessary and sufficient for q."
- "If p then q, and conversely."
- "p is equivalent to q." 24.
4.2 Examples of biconditional statements
- "1+1 = 3 if and only if the earth is flat" is TRUE because both parts are false.
- "Sky is blue iff 1 = 0" is FALSE because the first part is true and the second is false.
- "Milk is white iff birds lay eggs" is TRUE because both parts are true.
- "33 is divisible by 4 if and only if a horse has four legs" is FALSE because the first part is false and the second is true.
- "x > 5 iff x² > 25" is FALSE because if x=−6, then x>5 is false, but x2>25 is true 24.
4.3 Rephrasing propositions
The following propositions are rephrased into the "p if and only if q" form:
- "If it is hot outside, you buy an ice cream cone, and if you buy an ice cream cone, it is hot outside." becomes "You buy an ice cream cone if and only if it is hot outside.".
- "For you to win the contest it is necessary and sufficient that you have the only winning ticket." becomes "You win the contest if and only if you hold the only winning ticket.".
- "It rains if it is a weekend day, and it is a weekend day if it rains." becomes "It rains if and only if it is a weekend day.".
- "The train runs late on exactly those days when I take it." becomes "The train runs late if and only if it is a day I take the train.".
- "This number is divisible by 6 precisely when it is divisible by both 2 and 3." becomes "This number is divisible by 6 if and only if it is divisible by both 2 and 3." 25.
4.4 Logical equivalence involving biconditional
A biconditional statement p↔q is logically equivalent to the conjunction of two implications: (p→q)∧(q→p). This means they have the same truth values for all combinations of truth values of p and q 25.
See the table in section 2.2.
4.5 Showing logical equivalence
- The statements ¬p↔q and p↔¬q are logically equivalent 27.
See the table in section 2.2.
- The statements ¬(p⊕q) and p↔q are logically equivalent, where ⊕ denotes the exclusive OR 27.
See the table in section 2.2.
4.6 Laws of logic involving biconditional
Several logical laws apply to biconditional statements:
- Commutative Law: p↔q≡q↔p. The order of statements does not affect the truth value.
- Equivalence: p↔q≡(p→q)∧(q→p). A biconditional is true if and only if both implications hold 27.
4.7 Application: Rewriting statement forms
Statement forms can be rewritten to eliminate symbols like → and ↔, using other logical equivalences 27.
- To rewrite p∧¬q→r:
- p∧¬q→r≡¬(p∧¬q)∨r (Implication Law).
- ≡(¬p∨¬(¬q))∨r (De Morgan's Law).
- ≡(¬p∨q)∨r (Double Negation Law).
- ≡¬p∨q∨r (Associative Law of ∨) 28.
- To rewrite ¬p∨q→r∨¬q:
- ¬p∨q→r∨¬q≡¬(¬p∨q)∨(r∨¬q) (Implication Law).
- ≡(¬(¬p)∧¬q)∨r∨¬q (De Morgan's Law).
- ≡(p∧¬q)∨r∨¬q (Double Negation Law).
- ≡p∧¬q∨r∨¬q (Associative Law of ∨) 28.
4.8 Tautology without truth tables
To show that ¬(p→q)→p is a tautology:
- ¬(p→q)→p (Given statement form).
- ≡¬(¬p∨q)→p (Implication Law).
- ≡(p∧¬q)→p (De Morgan's Law and Double Negation Law).
- ≡¬(p∧¬q)∨p (Implication Law).
- ≡(¬p∨¬(¬q))∨p (De Morgan's Law).
- ≡(¬p∨q)∨p (Double Negation Law).
- ≡(¬p∨p)∨q (Commutative and Associative Laws of ∨).
- ≡T∨q (Negation Law).
- ≡T (Universal Bound Law) 28.
📝 Suppose that p→q is false. Find the truth values of q↔p.
If p→q is false, then p must be true (T) and q must be false (F). For q↔p, we substitute these values: F↔T. A biconditional is false when the truth values differ. Therefore, q↔p is FALSE 28.
5. Argument
5.1 Argument definition
An argument is a sequence of statements, where some statements are designated as premises and one statement is designated as the conclusion. The symbol "" is used to indicate the conclusion 29.
- Premises: These are the statements assumed to be true, serving as the basis for the argument.
- Conclusion: This is the statement that is claimed to follow logically from the premises 29.
5.2 Valid and invalid arguments
An argument is considered valid if its conclusion is true whenever all of its premises are true. This means that it is impossible for the premises to be true and the conclusion false simultaneously 29.
- Validity: An argument is valid if the conjunction of its premises implies the conclusion. This can be represented as (P1∧P2∧⋯∧Pn)→C being a tautology.
- Invalidity: An argument is invalid if there exists at least one situation where all premises are true, but the conclusion is false.
- Critical rows: These are the rows in a truth table where all premises evaluate to True 29.
📝 The argument form with premises p→q and q, and conclusion p, is invalid because in the second critical row, the conclusion is false when the premises p→q and q are true 30.
5.3 Determining argument validity using truth tables 30
Truth tables are a systematic method to determine the validity of an argument by examining all possible truth value combinations for the propositions involved 29.
- Valid argument example: The argument form with premises p→q and p, and conclusion q, is valid because in the critical row where both premises are True, the conclusion is also True 29.
- Invalid argument example: The argument form with premises p→q and q, and conclusion p, is invalid because there is a critical row where both premises are True, but the conclusion is False.
- Argument form analysis: To determine if p→¬q, p→r, therefore r is valid, a truth table is constructed 30.
See the table in section 2.2.
- Invalidity determination: In the third critical row of the truth table, the conclusion r is False while all premises (p→¬q and p→r) are True. Therefore, this argument form is invalid 31.
5.4 Word problem: Team assignment
This problem involves translating a scenario into logical propositions and then using a truth table to determine the argument's validity 31.
- Propositional representation: Let t represent "Tariq is on team A" and h represent "Hameed is on team B". The argument is translated as: ¬t→h, ¬h→t, therefore ¬t∨¬h 31.
| t | h | ¬ t → h | ¬ h → t | ¬ t ∨ ¬ h |
|---|---|---|---|---|
| T | T | T | T | F |
| T | F | T | T | T |
| F | T | T | T | T |
| F | F | F | F | T |
- Invalidity: The argument is invalid because there are three critical rows where premises are True, and in the first critical row, the conclusion is False 31.
5.5 Exercise: Number divisibility 32
This exercise tests the ability to translate a word problem into symbolic logic and assess its validity 31.
- Symbolic translation: Let d be "at least one of these two numbers is divisible by 6" and p be "the product of these two numbers is divisible by 6". The argument is d→p, ¬d, therefore ¬p 31.
| d | p | d → p | ¬ d | ¬ p |
|---|---|---|---|---|
| T | T | T | F | F |
| T | F | F | F | T |
| F | T | T | T | F |
| F | F | T | T | T |
- Invalidity: In the first critical row, the conclusion ¬p is False when the premises (d→p and ¬d) are True. Thus, the argument is invalid 32.
5.6 Exercise: Stereo purchase
This exercise involves another word problem requiring translation into logical propositions and truth table analysis 32.
- Propositional representation: Let e be "I got an Eid bonus", m be "I sell my motorcycle", and s be "I'll buy a stereo". The argument is e→s, m→s, therefore e∨m→s 32.
- e: s, m, e \u2192 s, m \u2192 s, e \u2228 m, e \u2228 m \u2192 s
- T: T, T, T, T, T, T
- T: T, F, T, T, T, T
- T: F, T, F, T, T, F
- T: F, F, F, T, T, F
- F: T, T, T, T, T, T
- F: T, F, T, T, F, T
- F: F, T, T, F, T, F
- F: F, F, T, T, F, T 32.
- Validity: The argument is valid because in all five critical rows (where premises e→s and m→s are True), the conclusion e∨m→s is also True 32.
5.7 Exercise: Interesting teacher 33
This exercise revisits the initial example argument to be tested formally 32.
- Symbolic translation: Let t be "My teacher is interesting", a be "I stay awake", and m be "I am in Discrete Mathematics class". The argument is t→a, a∧m, therefore m∧t 32.
| t | a | m | t → a | a ∧ m | m ∧ t |
|---|---|---|---|---|---|
| T | T | T | T | T | T |
| T | T | F | T | F | F |
| T | F | T | F | F | T |
| T | F | F | F | F | F |
| F | T | T | T | T | F |
| F | T | F | T | F | F |
| F | F | T | T | T | F |
| F | F | F | T | F | F |
- Invalidity: In the second critical row, the conclusion m∧t is False while the premises (t→a and a∧m) are True. Therefore, the argument is invalid 33.
6. Applications of Logic
6.1 Switches in series and parallel 34 35
Logic can be applied to electrical circuits using switches. The state of a light bulb (on or off) can be determined by the configuration of switches.
Switches in series require both switches to be closed for the light bulb to be on. If either switch is open, the bulb remains off.
This behavior mirrors the logical AND operation.
Switches in parallel allow the light bulb to be on if at least one of the switches is closed. The bulb is only off if both switches are open.
This behavior mirrors the logical OR operation.
| Switch P | Switch Q | Light Bulb State |
|---|---|---|
| Closed | Closed | On |
| Closed | Open | Off |
| Open | Closed | Off |
| Open | Open | Off |
| Switch P | Switch Q | Light Bulb State |
|---|---|---|
| Closed | Closed | On |
| Closed | Open | On |
| Open | Closed | On |
| Open | Open | Off |
6.2 Basic logic gates
Logic gates are fundamental building blocks of digital circuits that perform logical operations on input signals to produce an output signal.
📝 For inputs P = 1, Q = 0, and R = 0, the circuit with an AND gate followed by an OR gate with R produces a final output of 0 36.
6.3 NOT-gate 35
A NOT-gate, also known as an inverter, has one input and one output. It inverts the input signal: if the input is 1, the output is 0, and if the input is 0, the output is 1.
| Input P | Output R |
|---|---|
| 1 | 0 |
| 0 | 1 |
6.4 AND-gate 35
An AND-gate has two inputs and one output. The output is 1 only if both input signals are 1. Otherwise, the output is 0.
| Input P | Input Q | Output R |
|---|---|---|
| 1 | 1 | 1 |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 0 |
6.5 OR-gate 35
An OR-gate has two inputs and one output. The output is 0 only if both input signals are 0. Otherwise, the output is 1.
See the table in section 6.4.
6.6 Combinational circuits
A combinational circuit is a type of digital circuit where the output is solely dependent on the current input values. These circuits are constructed using basic logic gates like NOT, AND, and OR.
6.7 Determining output for a given input
To determine the output of a combinational circuit for specific input values, one traces the signal path through each logic gate, applying the gate's function at each step.
For inputs P = 1, Q = 0, and R = 0 in a circuit with an AND gate followed by an OR gate with R:
- The AND gate receives P=1 and Q=0, producing an output of 0.
- This output is then fed into the OR gate along with R=0 .
- The OR gate receives 0 and 0, resulting in a final output of 0 36.
6.8 Constructing the input/output table for a circuit 36 37
An input/output table systematically lists all possible combinations of input values for a circuit and the corresponding output for each combination. This helps in understanding the circuit's behavior.
To construct such a table, one typically labels intermediate outputs of gates within the circuit. Then, for each possible input combination, the values of these intermediate outputs are calculated step-by-step until the final output is determined.
Consider a circuit with inputs P, Q, and R. Intermediate outputs X (from an OR gate with P and Q) and Y (from an AND gate with P and R) are calculated. The final output S is determined by an OR gate with X and Y.
| P | Q | R | X (P OR Q) | Y (P AND R) | S (X OR Y) |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 0 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 0 | 1 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 |
📝 For a circuit with inputs P, Q, and R, where X = P OR Q and Y = P AND R, and the final output S = X OR Y, the input/output table shows S is 0 only when P=0, Q=0, and R=1, or when P=0, Q=0, and R=0 37.
6.9 Finding a Boolean expression for a circuit
A Boolean expression represents the logical function of a circuit using variables and logical operators (AND, OR, NOT). To find the expression, trace the circuit from inputs to output, writing the Boolean operation at each gate.
For a circuit where P and Q are ANDed, and this result is ORed with R:
- The first gate is an AND gate with inputs P and Q, producing P∧Q.
- This output is then ORed with R, resulting in the Boolean expression (P∧Q)∨R 37 38.
6.10 Circuit corresponding to a Boolean expression
Conversely, a Boolean expression can be translated into a circuit diagram. Each variable in the expression corresponds to an input, and each logical operator corresponds to a logic gate.
To construct a circuit for the Boolean expression (P∧Q)∨¬R:
- An AND gate takes inputs P and Q, producing P∧Q.
- A NOT gate takes input R, producing ¬R.
- An OR gate takes the outputs from the AND gate (P∧Q) and the NOT gate (¬R), producing the final output (P∧Q)∨¬R 38.
📝 To construct a circuit for the Boolean expression (P∧Q)∨¬R, use an AND gate for P∧Q, a NOT gate for ¬R, and an OR gate to combine their outputs 38.
6.11 Circuit diagram and Boolean expression equivalence 39 40
Different circuit diagrams can represent the same Boolean expression, and conversely, different Boolean expressions can be logically equivalent and thus represent the same circuit behavior.
Consider the circuit diagram for ¬P∧Q∧R.
- This circuit requires a NOT gate for P, producing ¬P.
- Then, three inputs (¬P, Q, and R) are fed into an AND gate.
The input/output table for this circuit shows that the output is 1 only when P=0, Q=1, and R=1.
| Input P | Input Q | Input R | Output S |
|---|---|---|---|
| 1 | 1 | 1 | 0 |
| 1 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 0 | 0 | 0 |
The Boolean expression for this circuit is ¬P∧Q∧R 39.
We can also analyze the expression (P∧Q)∨(¬P∧Q)∨(P∧¬Q). By applying Boolean algebra laws, this expression can be shown to be equivalent to P∧Q.
| Statement | Reason |
|---|---|
| (P Q) ( | Given expression |
| (Q P) t | Commutative law |
| P Q | Identity law |
| Q P | Commutative law |
| Q (P ~Q) | Identity law |
| (Q P) (Q ~Q) | Distributive law |
| (Q P) t | Negation law |
| t Q (P ~Q) | Negation law |
| (P | Distributive law |
| Thus (P Q) ( | Conclusion |
This demonstrates that the two circuits, despite appearing different, are logically equivalent 40.
7. Set theory
7.1 Sets and elements
A set is a well-defined collection of distinct objects, called elements or members. Sets are denoted by capital letters (e.g., A, B, X), and their elements are represented by lowercase letters (e.g., a, b, x).
Membership is indicated by the symbol (e.g., x A means "x belongs to A"), while non-membership is shown by (e.g., x A means "x does not belong to A") 41.
Sets can be described in three main ways:
- Tabular form: Listing all elements within braces, separated by commas. For example,
A = {1, 2, 3, 4, 5}. The ellipsis (…) indicates continuation. - Descriptive form: Stating the elements in words. For example, "A = set of first five Natural Numbers.".
- Set builder form: Using a symbolic representation of a common characteristic shared by all elements. For example,
A = {x N | x 5}41.
7.2 Number sets
Several standard sets of numbers are frequently used in mathematics 42:
| Set Name | Symbol | Definition |
|---|---|---|
| Natural Numbers | N | {1, 2, 3, … } |
| Whole Numbers | W | {0, 1, 2, 3, … } |
| Integers | Z | {…, -3, -2, -1, 0, +1, +2, +3, …} or {0, 1, 2, 3, …} |
| Even Integers | E | {0, 2, 4, 6, …} |
| Odd Integers | O | { 1, 3, 5, …} |
| Prime Numbers | P | {2, 3, 5, 7, 11, 13, 17, 19, …} |
| Rational Numbers | Q | { x |
| Irrational Numbers | Q' or Q | { x |
| Real Numbers | R | Q Q' |
| Complex Numbers | C | {z |
7.3 Subsets
A set A is a subset of set B if every element of A is also an element of B. This is denoted as A B. If A B, then B is called a superset of A. Every set is a subset of itself 42.
A proper subset (denoted A ⊂ B) is a subset where there is at least one element in B that is not in A 43.
Equal sets (denoted A = B) occur when every element of A is in B, and every element of B is in A. This is equivalent to A B and B A. Sets can contain duplicate elements, but these do not change the set; for example, {1, 2, 3, 6} and {1, 2, 2, 3, 6, 6, 6} represent the same set 43.
7.4 Special sets
- Null set (or empty set): A set containing no elements, denoted by
or{}43. - Universal set: The set of all elements under consideration, usually denoted by
U44.
7.5 Finite and infinite sets 45
A set is finite if it contains a specific, non-negative integer number of distinct elements. The number of elements is its cardinality, denoted |S| or n(S) 44.
A set is infinite if it is not finite 44.
Here's a classification of sets as finite or infinite 45:
| Set Description | Type |
|---|---|
| {month in the year} | FINITE |
| {even integers} | INFINITE |
| {positive integers less than 1} | FINITE |
| {animals living on the earth} | FINITE |
| {lines parallel to x-axis} | INFINITE |
| {x R | x^100 + 29x^50 – 1 = 0} |
| {circles through origin} | INFINITE |
7.6 Venn diagrams and membership tables
A Venn diagram graphically represents sets using regions in a plane, with the universal set typically shown as a rectangle and other sets as disks within it 44.
A membership table displays whether elements belong to sets, using '1' for membership and '0' for non-membership. These tables can be used to prove set identities.
For example, the complement of set A (A^c) has a '1' where A has a '0', and vice versa 45.
📝 Consider the sets
U = {1, 2, 3, 4, 5, 6},A = {2, 4, 6}, andB = {1, 3, 5}. The universal setUcontains all elements under consideration. SetAconsists of even numbers withinU, and setBconsists of odd numbers withinU44.
8. Venn diagram
8.1 Union of sets
The union of two sets A and B, denoted A∪B, is the set of all elements that are in A, or in B, or in both. It represents the combination of all elements from both sets 46.
- Union definition: A∪B={x∈U∣x∈A or x∈B}.
- Commutativity: A∪B=B∪A.
- Subset property: A⊆A∪B and B⊆A∪B 46.
The membership table for union is analogous to the truth table for the logical disjunction (∨) operator 46.
| A | B | A ∪ B |
|---|---|---|
| 1 | 1 | 1 |
| 1 | 0 | 1 |
| 0 | 1 | 1 |
| 0 | 0 | 0 |
📝 Given U={a,b,c,d,e,f,g}, A={a,c,e,g}, and B={d,e,f,g}, the union A∪B is {a,c,d,e,f,g} 46.
8.2 Intersection of sets
The intersection of two sets A and B, denoted A∩B, is the set of all elements that are common to both A and B 47.
- Intersection definition: A∩B={x∈U∣x∈A and x∈B}.
- Commutativity: A∩B=B∩A.
- Subset property: A∩B⊆A and A∩B⊆B.
- Disjoint sets: If A∩B=∅, then A and B are called disjoint sets 47.
The membership table for intersection is analogous to the truth table for the logical conjunction (∧) operator 47.
| A | B | A ∩ B |
|---|---|---|
| 1 | 1 | 1 |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 0 |
📝 Given U={a,b,c,d,e,f,g}, A={a,c,e,g}, and B={d,e,f,g}, the intersection A∩B is {e,g} 47.
8.3 Set difference 48
The difference of sets A and B, denoted A−B or A∖B, is the set of all elements that are in A but not in B 47.
- Difference definition: A−B={x∈U∣x∈A and x∈/B} 47.
- Non-commutativity: A−B=B−A.
- Disjoint subsets: A−B, A∩B, and B−A are mutually disjoint sets.
- Subset property: A−B⊆A 48.
The membership table for set difference is analogous to the truth table for the implication (p→q) operator 48.
| A | B | A – B |
|---|---|---|
| 1 | 1 | 0 |
| 1 | 0 | 1 |
| 0 | 1 | 0 |
| 0 | 0 | 0 |
📝 Given U={a,b,c,d,e,f,g}, A={a,c,e,g}, and B={d,e,f,g}, the difference A−B is {a,c} 47.
8.4 Complement of a set
The complement of a set A, denoted Ac, A′, or A, is the set of all elements in the universal set U that are not in A 48.
- Complement definition: Ac={x∈U∣x∈/A} 48.
The membership table for the complement is analogous to the truth table for the logical negation (∼) operator 48.
| A | Aᶜ |
|---|---|
| 1 | 0 |
| 0 | 1 |
📝 Given U={a,b,c,d,e,f,g} and A={a,c,e,g}, the complement Ac is {b,d,f} 48.
8.5 Enumerating sets and operations
Sets can be defined using set-builder notation, and their elements can be enumerated to perform operations like union, intersection, and difference 49.
Given U={1,2,3,…,10}, X={1,2,3,4,5}, Y={y∣y=2x,x∈X}, and Z={z∣z2−9z+14=0}:
- First, enumerate the sets:
- U={1,2,3,4,5,6,7,8,9,10}
- X={1,2,3,4,5}
- Y={2,4,6,8,10}
- Z={2,7} (solving z2−9z+14=0) 49.
Performing the requested operations:
-
X∩Y={2,4}.
-
Y∪Z={2,4,6,7,8,10}.
-
X−Z={1,3,4,5}.
-
Yc=U−Y={1,3,5,7,9}.
-
Xc={6,7,8,9,10} and Zc={1,3,4,5,6,8,9,10}. Thus, Xc−Zc={7}.
-
(X−Z)c=U−(X−Z)={2,6,7,8,9,10} 49.
-
Note: (X−Z)c=Xc−Zc 49.
8.6 Set operations with specific conditions
Given a universal set U and its subsets P and Q, specific conditions can define the sets and lead to further operations 49.
Let U={x∣x∈Z,0≤x≤10}, P={x∣x is a prime number}, and Q={x∣x2<70}.
- Enumerating the sets:
- U={0,1,2,3,4,5,6,7,8,9,10}.
- P={2,3,5,7} (prime numbers between 0 and 10).
- Q={0,1,2,3,4,5,6,7,8} (numbers whose squares are less than 70) 50.
To find Pc∩Q:
- Pc=U−P={0,1,4,6,8,9,10}.
- Pc∩Q={0,1,4,6,8,9,10}∩{0,1,2,3,4,5,6,7,8}={0,1,4,6,8} 50.
8.7 Finding unknown sets based on given conditions
When relationships between sets are provided, it's possible to determine the elements of an unknown set 50.
Let U={1,2,3,4,5} and C={1,3}. Find set A under various conditions:
-
Condition (i): A∪B=U, A∩B=∅, and B={1}.
-
Since A∪B=U and A∩B=∅, A and B are complements of each other.
-
A=Bc={1}c={2,3,4,5} 50.
-
Condition (ii): A⊂B and A∪B={4,5}.
-
If A⊂B, then A∪B=B. Thus, B={4,5}.
-
Since A is a proper subset of B, A can be {4} or {5} 50.
-
Condition (iii): A∩B={3}, A∪B={2,3,4}, and B∪C={1,2,3}.
-
Given C={1,3}.
-
Since 3∈A∩B and 3∈C, 3 is placed in the intersection of all three sets.
-
Since 1∈B∪C and 1∈/A∪B, 1 must be in C but not in B.
-
Since 4∈A∪B and 4∈/B∪C, 4 must be in A but not in B or C.
-
Since 2∈A∪B and 2∈B∪C, and 2∈/A∩B, 2 must be in B but not in A or C.
-
This leads to A={3,4} and B={2,3} 51.
-
Condition (iv): A and B are disjoint, B and C are disjoint, and A∪B={1,2}.
-
Given C={1,3}.
-
If A∩B=∅ and A∪B={1,2}, then A and B partition {1,2}.
-
If B∩C=∅ and B contains elements from {1,2}, and C={1,3}, then B cannot contain 1.
-
Therefore, B={2} and A={1} 51.
8.8 Representing set operations using Venn diagrams
Venn diagrams can visually represent complex set operations involving complements, unions, intersections, and differences 51.
For a universal set U and subsets A, B, and C:
- (i) (A∩B)∩Cc: This represents the elements that are in both A and B, but not in C.
- (ii) Ac∪(B∪C): This represents the elements that are not in A, or are in B, or are in C, or any combination thereof.
- (iii) (A−B)∩C: This represents the elements that are in A but not in B, and are also in C.
- (iv) (A∩Bc)∪Cc: This represents the elements that are in A but not in B, or are not in C, or both 52.
8.9 Proving set identities using Venn diagrams
Venn diagrams provide a graphical method to prove set identities by showing that the shaded regions for both sides of an identity are identical 53.
- Identity (i): A−(A−B)=A∩B. The shaded regions for both expressions are the same 53.
- Identity (ii): (A∩B)c=Ac∪Bc. The shaded regions for both expressions are identical 54.
- Identity (iii): A−B=A∩Bc. The shaded regions for both expressions are the same 55 56.
8.10 Proving set identities using membership tables57
Membership tables offer a systematic, algebraic method to prove set identities by comparing the membership status (1 for in the set, 0 for not in the set) of elements for each side of the identity 56.
- Identity (i): A−(A−B)=A∩B. The final columns for A−(A−B) and A∩B are identical 56.
See the table in section 8.3.
-
Identity (ii): (A∩B)c=Ac∪Bc. The fourth and last columns of the table are identical 56 57.
-
Identity (iii): A−B=A∩Bc. The columns for A−B and A∩Bc are identical 57.
See the table in section 8.3.
9. Set identities
9.1 Set identities
Several fundamental laws govern set operations, providing rules for simplifying set expressions and proving equalities. These identities are crucial for manipulating sets algebraically and understanding their relationships 58.
The primary set identities include:
- Idempotent Laws: These state that the union or intersection of a set with itself results in the same set.
- A∪A=A.
- A∩A=A.
- Commutative Laws: These laws indicate that the order of sets in a union or intersection does not affect the result.
- A∪B=B∪A.
- A∩B=B∩A.
- Associative Laws: These laws allow for the grouping of sets in a union or intersection without changing the outcome.
- A∪(B∪C)=(A∪B)∪C.
- A∩(B∩C)=(A∩B)∩C.
- Distributive Laws: These laws describe how union and intersection interact, similar to multiplication distributing over addition in arithmetic.
- A∩(B∪C)=(A∩B)∪(A∩C).
- A∪(B∩C)=(A∪B)∩(A∪C).
- Identity Laws: These laws involve the empty set (∅) and the universal set (U).
- A∪∅=A.
- A∩∅=∅.
- A∪U=U.
- A∩U=A.
- Complement Laws: These laws relate a set to its complement (Ac).
- A∪Ac=U.
- A∩Ac=∅.
- Uc=∅.
- ∅c=U.
- Double Complement Law: The complement of a complement of a set is the original set.
- (Ac)c=A.
- DeMorgan’s Laws: These laws describe the complement of a union or intersection.
- (A∪B)c=Ac∩Bc.
- (A∩B)c=Ac∪Bc.
- Alternative Representation for Set Difference: The set difference A−B can be expressed using intersection and complement.
- A−B=A∩Bc.
- Subset Laws: These laws relate subsets to unions and intersections.
- A∪B⊆C if and only if A⊆C and B⊆C.
- C⊆A∩B if and only if C⊆A and C⊆B.
- Absorption Laws: These laws show how a set can be absorbed by another in a union or intersection.
- A∪(A∩B)=A.
- A∩(A∪B)=A 58.
These laws are fundamental for proving set equalities and simplifying complex set expressions 58.
9.2 Proving set identities
Set identities can be proven using two primary methods: element chasing and algebraic manipulation using the established laws.
9.3 Element chasing proofs
An element chasing proof involves showing that two sets are equal by demonstrating that an arbitrary element of one set is also an element of the other, and vice versa. This relies on the definition of set operations and subset relationships 58.
For example, to prove A⊆A∪B:
- Let x be an arbitrary element of A (x∈A).
- If x∈A, then it is true that x∈A or x∈B (x∈A∨x∈B).
- By the definition of union, x∈A∪B.
- Since x was an arbitrary element of A, this shows that A⊆A∪B 58.
Another example is proving A−B⊆A:
- Let x be an arbitrary element of A−B (x∈A−B).
- By the definition of set difference, x∈A and x∈/B.
- Since x∈A is part of the condition, x is an element of A.
- Therefore, A−B⊆A 59.
To prove A⊆B if and only if Bc⊆Ac:
- Assume A⊆B:
- Let x∈Bc. This means x∈/B.
- Since A⊆B, if x∈/B, then x∈/A.
- Thus, x∈Ac. This shows Bc⊆Ac.
- Assume Bc⊆Ac:
- Let x∈A. This means x∈/Ac.
- Since Bc⊆Ac, if x∈/Ac, then x∈/Bc.
- Thus, x∈B. This shows A⊆B 59.
9.4 Algebraic proofs using set identities
Algebraic proofs involve transforming one side of an identity into the other by applying known set laws. This method is often more concise than element chasing 60.
Example: Prove A−B=A∩Bc
- Start with the left-hand side (LHS): A−B.
- Apply the alternative representation for set difference: A∩Bc.
- This is the right-hand side (RHS) 60.
Example: Prove DeMorgan’s Law (A∪B)c=Ac∩Bc
- Start with the LHS: (A∪B)c.
- Apply the definition of complement: x∈/A∪B.
- Apply DeMorgan's Law for logic: x∈/A and x∈/B.
- Apply the definition of complement: x∈Ac and x∈Bc.
- Apply the definition of intersection: x∈Ac∩Bc.
- This is the RHS 60.
Example: Prove the associative law A∩(B∩C)=(A∩B)∩C
- Start with the LHS: A∩(B∩C).
- Apply the definition of intersection: x∈A and x∈B∩C.
- Apply the definition of intersection again: x∈A and x∈B and x∈C.
- Rearrange using the commutative law for intersection: x∈A and x∈C and x∈B. (This step is implicit in the next).
- Apply the definition of intersection: x∈A∩B and x∈C.
- Apply the definition of intersection: x∈(A∩B)∩C.
- This is the RHS 60.
Example: Prove the distributive law A∪(B∩C)=(A∪B)∩(A∪C)
- Start with the LHS: A∪(B∩C).
- Consider two cases for an element x:
- Case I: x∈A. Then x∈A∪B and x∈A∪C. Thus, x∈(A∪B)∩(A∪C).
- Case II: x∈B∩C. Then x∈B and x∈C. Since x∈B, x∈A∪B. Since x∈C, x∈A∪C. Thus, x∈(A∪B)∩(A∪C).
- In both cases, x∈(A∪B)∩(A∪C). This shows A∪(B∩C)⊆(A∪B)∩(A∪C).
- Conversely, start with the RHS: (A∪B)∩(A∪C).
- Consider two cases for an element x:
- Case I: x∈A. Then x∈A∪(B∩C).
- Case II: x∈/A. Since x∈A∪B and x∈/A, it must be that x∈B. Since x∈A∪C and x∈/A, it must be that x∈C. Thus, x∈B∩C. Therefore, x∈A∪(B∩C).
- In both cases, x∈A∪(B∩C). This shows (A∪B)∩(A∪C)⊆A∪(B∩C).
- Combining both directions proves the equality 61.
Example: Prove (A−B)∪(A∩B)=A
- LHS = (A−B)∪(A∩B)
- Substitute A−B=A∩Bc: (A∩Bc)∪(A∩B)
- Apply the distributive law: A∩(Bc∪B)
- Apply the complement law (Bc∪B=U): A∩U
- Apply the identity law: A
- RHS = A 62.
Example: Prove A−(A−B)=A∩B
- LHS = A−(A−B)
- Substitute A−B=A∩Bc: A−(A∩Bc)
- Substitute again: A∩(A∩Bc)c
- Apply DeMorgan’s Law: A∩(Ac∪(Bc)c)
- Apply Double Complement Law: A∩(Ac∪B)
- Apply Distributive Law: (A∩Ac)∪(A∩B)
- Apply Complement Law (A∩Ac=∅): ∅∪(A∩B)
- Apply Identity Law: A∩B
- RHS = A∩B 63.
Example: Prove (A−B)−C=(A−C)−B
- LHS = (A−B)−C
- Substitute A−B=A∩Bc: (A∩Bc)−C
- Substitute again: (A∩Bc)∩Cc
- Apply Associative Law: A∩(Bc∩Cc)
- Apply Commutative Law: A∩(Cc∩Bc)
- Apply Associative Law: (A∩Cc)∩Bc
- Substitute A∩Cc=A−C: (A−C)∩Bc
- Substitute again: (A−C)−B
- RHS = (A−C)−B 63.
Example: Simplify (Bc∪(Bc−A))c
- (Bc∪(Bc−A))c
- Substitute Bc−A=Bc∩Ac: (Bc∪(Bc∩Ac))c
- Apply DeMorgan’s Law: (Bc)c∩(Bc∩Ac)c
- Apply Double Complement Law: B∩((Bc)c∪(Ac)c)
- Apply DeMorgan’s Law and Double Complement Law: B∩(B∪A)
- Apply Absorption Law: B 63.
9.5 Proving set identities using membership tables
Membership tables are a systematic way to prove set identities by examining all possible membership combinations of elements in the involved sets. Each row represents a unique combination of an element's presence or absence in the sets 64.
See the table in section 8.3.
- A: B, A ∩ B, (A ∩ B) c, A c, B c, A c ∪ B c
- 1: 1, 1, 0, 0, 0, 0
- 1: 0, 0, 1, 0, 1, 1
- 0: 1, 0, 1, 1, 0, 1
- 0: 0, 0, 1, 1, 1, 1 64.
See the table in section 8.3.
9.6 Properties of subsets
Certain properties relate subset relationships to set operations 58.
- Transitivity of Subsets: If set A is a subset of set B, and set B is a subset of set C, then set A is a subset of set C.
- If A⊆B and B⊆C, then A⊆C.
- Subset and Union/Intersection:
- A⊆A∪B 58.
- A−B⊆A.
- If A⊆B, then Ac⊇Bc (or Bc⊆Ac) 59.
- Properties when A⊆B:
- A∩B=A.
- A∪B=B 62.
These properties are essential for reasoning about set containment and simplifying expressions involving subsets 58 59 62.
9.7 Set difference and its representations
The set difference A−B represents all elements that are in set A but not in set B. It has an important alternative representation using complements and intersections 58.
This identity is useful for algebraic manipulation, allowing the conversion of set difference operations into intersections with complements 60.
📝 Prove that A−(A−B)=A∩B.
- LHS = A−(A−B)
- Substitute A−B=A∩Bc: A−(A∩Bc)
- Substitute again using the definition of set difference: A∩(A∩Bc)c
- Apply DeMorgan’s Law: A∩(Ac∪(Bc)c)
- Apply Double Complement Law: A∩(Ac∪B)
- Apply Distributive Law: (A∩Ac)∪(A∩B)
- Apply Complement Law (A∩Ac=∅): ∅∪(A∩B)
- Apply Identity Law: A∩B
- RHS = A∩B 63.
10. Applications of Venn diagram
10.1 Shading Venn diagrams for configurations
Venn diagrams are used to visually represent sets and their relationships, aiding in solving counting and logic problems. Different shaded areas within a Venn diagram correspond to specific combinations of set memberships 65.
The following configurations can be represented by shading specific regions in a Venn diagram:
- Modem and printer but no scanner: This represents the intersection of the modem (M) and printer (P) sets, excluding any overlap with the scanner (S) set.
- Scanner but no printer and no modem: This represents the region within the scanner (S) set that does not overlap with either the printer (P) or modem (M) sets.
- Scanner or printer but no modem: This represents the union of the scanner (S) and printer (P) sets, excluding any elements that are also in the modem (M) set 65.
- No modem and no printer: This represents the area outside both the modem (M) and printer (P) sets, which can include elements in the scanner (S) set or outside all sets 66.
10.2 Survey problems with Venn diagrams
Venn diagrams can be used to solve problems involving surveys of individuals or items with multiple characteristics. By representing the survey data in a Venn diagram, unknown quantities can be determined by setting up and solving equations based on the total number of participants and the given overlaps 66.
Consider a survey of 21 typists using manual (M), electronic (E), and word processors (W).
- Information representation: The data can be mapped onto a Venn diagram, with specific regions representing typists using combinations of these tools.
- Solving for unknowns: If the number of typists using electronic typewriters is equal to the number using word processors, equations can be formed to find the number of typists using only word processors or only electronic typewriters 66 67.
Let x be the number of typists using electronic typewriters only, and y be the number using word processors only.
- Equation 1: Based on the condition that the number of typists using electronic typewriters equals the number using word processors: x−y=1.
- Equation 2: Based on the total number of typists: x+y=9. Solving these equations yields x=5 and y=4.
- Word processors only: The number of typists using word processors only is y=4.
- Total electronic typewriters: The total number of typists using electronic typewriters is 1+5+4+x=1+5+4+5=15 67.
📝 In a survey of 21 typists, if the number using electronic typewriters only (x) and word processors only (y) satisfy x−y=1 and x+y=9, then x=5 and y=4.
10.3 Exercise: Software package usage
In a school of 100 students, access to three software packages (A, B, C) is surveyed.
- Venn diagram setup: A Venn diagram is drawn, with regions enumerated as much as possible. Two subsets that cannot be immediately determined are labeled x and y 67.
- Simultaneous equations: Given that twice as many students used package B as package A, a pair of simultaneous equations in x and y can be formulated.
- The equation derived from the condition "twice as many students used package B as package A" is y=2x+3.
- The equation derived from the total number of students is x+y=18.
- Solving for x and y: Solving these equations yields x=5 and y=13.
- Students using package C: The number of students using package C is calculated as x+y+10+7=5+13+10+7=35 68.
10.4 Testing argument validity with diagrams
Venn diagrams can be used to visually test the validity of logical arguments by representing premises and checking if the conclusion necessarily follows 68.
10.5 Valid argument: Human beings and mortality
- Premise 1: "All human beings are mortal." This is represented by placing a disk labeled "human beings" inside a disk labeled "mortals." 68.
- Premise 2: "Zeus is not mortal." This is represented by placing a dot labeled "Zeus" outside the "mortals" disk.
- Conclusion: "Zeus is not a human being." Since Zeus is outside the "mortals" disk, and the "human beings" disk is entirely within the "mortals" disk, Zeus must also be outside the "human beings" disk. Therefore, the argument is valid 69.
📝 For the argument "All human beings are mortal. Zeus is not mortal. Therefore, Zeus is not a human being," Zeus is placed outside the "mortals" disk, which is itself inside the "human beings" disk, showing the argument is valid.
10.6 Invalid argument: Human beings and Farhan
- Premise 1: "All human beings are mortal." Represented by a "human beings" disk inside a "mortals" disk.
- Premise 2: "Farhan is mortal." Represented by a dot labeled "Farhan" placed inside the "mortals" disk.
- Conclusion: "Farhan is a human being." The dot for "Farhan" can be placed inside the "mortals" disk but outside the "human beings" disk, showing that the premises can be true while the conclusion is false. Therefore, the argument is invalid 69.
10.7 Valid argument: Polynomial functions and asymptotes
- Premise 1: "No polynomial functions have horizontal asymptotes." Represented by two disjoint disks: "polynomial functions" and "functions with horizontal tangents.".
- Premise 2: "This function has a horizontal asymptote." Represented by placing a dot for "this function" within the "functions with horizontal tangents" disk.
- Conclusion: "This function is not polynomial." Since the dot is in the "functions with horizontal tangents" disk, and this disk is disjoint from the "polynomial functions" disk, the conclusion necessarily follows. The argument is valid 70.
📝 For the argument "No polynomial functions have horizontal asymptotes. This function has a horizontal asymptote. Therefore, this function is not polynomial," the "polynomial functions" and "functions with horizontal tangents" disks are disjoint, and "this function" is placed in the latter, making the argument valid.
10.8 Argument with true premises and false conclusion
- Premise 1: "All dogs are carnivorous." Represented by a "dogs" disk inside a "carnivorous" disk.
- Premise 2: "Jack is not a dog." Represented by placing a dot for "Jack" outside the "dogs" disk 70.
- Conclusion: "Jack is not carnivorous." To show the argument can have a false conclusion, the dot for "Jack" can be placed inside the "carnivorous" disk but outside the "dogs" disk. This makes the conclusion false while the premises remain true 71.
10.9 Invalid argument: Cafeteria food, good food, and waste
- Premise 1: "No college cafeteria food is good." Represented by two disjoint disks: "college cafeteria food" and "good food.".
- Premise 2: "No good food is wasted." Represented by a "wasted food" disk that does not overlap with the "good food" disk.
- Conclusion: "No college cafeteria food is wasted." The "wasted food" disk may intersect with the "college cafeteria food" disk, meaning some college cafeteria food could be wasted. Therefore, the argument is invalid 71.
10.10 Partition of a set
A partition of a set divides it into non-empty, mutually disjoint subsets whose union is the original set 71.
A partition of a set A is a collection of nonempty subsets {A1,A2,…,An} of A such that:
- A=A1∪A2∪⋯∪An (The union of the subsets equals the original set).
- Ai∩Aj=∅ for all i=j (The subsets are mutually disjoint) 71.
10.11 Power set
The power set of a set A, denoted P(A), is the set containing all possible subsets of A 72.
- Example: If A={1,2}, then P(A)={∅,{1},{2},{1,2}}.
- Size of power set: If a set A has n elements, its power set P(A) has 2n elements 72.
10.12 Exercise: Power sets of the empty set
- a. Find P(∅): Since the empty set ∅ has no elements (n=0), its power set P(∅) has 20=1 element. P(∅)={∅}.
- b. Find P(P(∅)): Since P(∅) has one element (∅), P(P(∅)) has 21=2 elements. P(P(∅))={∅,{∅}}.
- c. Find P(P(P(∅))): Since P(P(∅)) has two elements (∅ and {∅}), P(P(P(∅))) has 22=4 elements. P(P(P(∅)))={∅,{∅},{{∅}},{∅,{∅}}} 72.
11. Relations
11.1 Ordered pairs and n-tuples
An ordered pair is a set of two elements where the order matters. The ordered pair (a,b) is equal to (c,d) if and only if a=c and b=d.
An ordered n-tuple (a1,a2,…,an) is a sequence of n elements where the order is significant. Two ordered n-tuples (a1,a2,…,an) and (b1,b2,…,bn) are equal if and only if ai=bi for all i from 1 to n 73.
- Equality of ordered pairs: (a,b)=(c,d) if and only if a=c and b=d. Note that (a,b)=(b,a) unless a=b.
- Ordered n-tuple definition: (a1,a2,…,an) consists of elements a1,a2,…,an with a defined order. An ordered 2-tuple is an ordered pair, and an ordered 3-tuple is an ordered triple.
- Equality of ordered n-tuples: (a1,a2,…,an)=(b1,b2,…,bn) if and only if ai=bi for all i=1,2,…,n 73.
11.2 Cartesian product of sets74
The Cartesian product of two sets A and B, denoted A×B, is the set of all ordered pairs (a,b) where a is an element of A and b is an element of B. The Cartesian product can be extended to more than two sets, forming ordered n-tuples 73.
| Set Operation | Definition |
|---|---|
| Cartesian product of A and B | A×B={(a,b)∣a∈A and b∈B} |
| Cartesian product of A1,A2,…,An | A1×A2×⋯×An={(a1,a2,…,an)∣ai∈Ai, for i=1,2,…,n} |
- If set A has m elements and set B has n elements, then A×B has m×n elements.
- Properties of Cartesian products:
- A×B=B×A for non-empty and unequal sets A and B.
- A×∅=∅×A=∅.
- ∣A×B∣=∣A∣×∣B∣ 73.
📝 If A={1,2} and B={a,b,c}, then A×B={(1,a),(1,b),(1,c),(2,a),(2,b),(2,c)} 73.
11.3 Binary relations
A binary relation R from set A to set B is defined as any subset of the Cartesian product A×B. If an ordered pair (a,b) is in the relation R, it means that a is related to b by R, denoted as aRb.
Conversely, if (a,b) is not in R, it is written as aRb 74.
- A relation on a set A is a relation from A to A, meaning it is a subset of A×A.
- The total number of binary relations from a set A with m elements to a set B with n elements is 2m×n 75.
📝 For A={1,2} and B={1,2,3}, if R={(a,b)∈A×B∣a<b}, then R={(1,2),(1,3),(2,3)} 74.
11.4 Domain and range of a relation
The domain of a relation R from A to B is the set of all first elements of the ordered pairs in R. The range of a relation R from A to B is the set of all second elements of the ordered pairs in R 74.
| Term | Definition |
|---|---|
| Domain of R (Dom(R)) | {a \in A \mid (a, b) \in R} |
| Range of R (Ran(R)) | {b \in B \mid (a, b) \in R} |
- Example: For A={1,2} and B={1,2,3}, if R={(a,b)∈A×B∣a<b}, then R={(1,2),(1,3),(2,3)}. The domain of R is {1,2}, and the range of R is {2,3} 74 75.
11.5 Types of relations on a set
Relations on a set can be categorized by their properties, such as being universal or empty. The universal relation on a set A is A×A, containing all possible ordered pairs.
The empty relation on a set A is the empty set, ∅ 75.
- Example: For A={1,2,3,4}, the relation R where (a,b)∈R if a divides b is R={(1,1),(1,2),(1,3),(1,4),(2,2),(2,4),(3,3),(4,4)} 75.
- Example: For the set of integers Z, the relation E where mEn if m−n is even includes pairs like (0,0), (6,6), (−1,7), but not (5,2) because 5−2=3 is odd. For any even integer n, nE0 because n−0=n, which is even 76.
11.6 Representing relations
Relations can be visually and systematically represented using various diagrams and matrices. These representations help in understanding the structure and properties of the relation 76 77 78.
11.7 Coordinate diagram (graph)
A coordinate diagram (or graph) of a relation from set A to set B plots the ordered pairs of the relation on a coordinate plane. The horizontal axis typically represents elements of A, and the vertical axis represents elements of B 76.
- Example: For A={1,2,3} and B={x,y}, the relation R={(1,y),(2,x),(2,y),(3,x)} is plotted with points (1,y), (2,x), (2,y), and (3,x)77.
- Example: The relation C on R defined by x2+y2=1 represents a circle centered at the origin with a radius of 1. The graph is limited to −1≤x≤1 and −1≤y≤1 76.
11.8 Arrow diagram
An arrow diagram visually represents a relation by drawing arrows from elements in the domain set to elements in the codomain set, corresponding to the ordered pairs in the relation 77.
- Example: For A={1,2,3} and B={x,y}, the relation R={(1,y),(2,x),(2,y),(3,x)} is shown with arrows from 1 to y, 2 to x and y, and 3 to x 77.
11.9 Directed graph
A directed graph is used to represent relations on a single set. Each element of the set is a vertex, and an edge (arrow) is drawn from vertex a to vertex b if (a,b) is in the relation.
Loops are drawn for pairs (a,a) 77.
- Example: For A={0,1,2,3} and R={(0,0),(1,3),(2,1),(2,2),(3,0),(3,1)}, the directed graph has vertices 0, 1, 2, 3. There are loops at 0 and 2. Arrows go from 1 to 3, 2 to 1, 3 to 0, and 3 to 1 77 78.
11.10 Matrix representation
A matrix representation of a relation R from set A={a1,…,an} to set B={b1,…,bm} is an n×m matrix M. The entry mij is 1 if (ai,bj)∈R, and 0 otherwise 78.
- Example: For A={1,2,3} and B={x,y} with R={(1,y),(2,x),(2,y),(3,x)}, the matrix M is: x y 1. 2. 3 1.
- Example: Given the matrix M=110001 for a relation from A={1,2,3} to B={1,2,3}, the ordered pairs are R={(1,1),(2,1),(3,2)} 78.
11.11 Operations on relations
Relations can be combined using set operations such as union and intersection. The union of two relations R and S (R∪S) contains all ordered pairs present in either R or S.
The intersection (R∩S) contains only the ordered pairs present in both R and S 79.
- Example: Let A={2,4} and B={6,8,10}.
- Relation R where xRy if x divides y: R={(2,6),(2,8),(2,10),(4,8)}.
- Relation S where y−4=x: S={(2,6),(4,8)}.
- R∪S={(2,6),(2,8),(2,10),(4,8)}, which is equal to R.
- R∩S={(2,6),(4,8)}, which is equal to S 79.
12. Types of Relations
12.1 Reflexive relations
A relation R on a set A is reflexive if every element in A is related to itself. This means that for all elements a∈A, the pair (a,a) must be in R, or aRa.
If there is even one element a∈A such that (a,a)∈/R, the relation is not reflexive. The directed graph of a reflexive relation will have a loop at every point.
For a relation represented by a matrix M, it is reflexive if all elements on the main diagonal are 1 80 81.
| Relation | Set A | Pairs in R | Reflexive? |
|---|---|---|---|
| R1 | {1, 2, 3, 4} | {(1, 1), (3, 3), (2, 2), (4, 4)} | Yes |
| R2 | {1, 2, 3, 4} | {(1, 1), (1, 4), (2, 2), (3, 3), (4, 3)} | No (missing (4,4)) |
| R3 | {1, 2, 3, 4} | {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)} | Yes |
| R4 | {1, 2, 3, 4} | {(1, 3), (2, 2), (2, 4), (3, 1), (4, 4)} | No (missing (1,1), (3,3)) |
12.2 Symmetric relations
A relation R on a set A is symmetric if, for any elements a,b∈A, whenever (a,b)∈R, it must also be true that (b,a)∈R. In other words, if aRb, then bRa.
If there exists a pair (a,b)∈R such that (b,a)∈/R, the relation is not symmetric. In a directed graph, symmetry means that for every arrow from point a to point b, there must be a corresponding arrow from b to a.
A relation's matrix representation is symmetric if it is equal to its transpose (M=Mt) 81 82 83.
| Relation | Set A | Pairs in R | Symmetric? |
|---|---|---|---|
| R1 | {1, 2, 3, 4} | {(1, 1), (1, 3), (2, 4), (3, 1), (4, 2)} | Yes |
| R2 | {1, 2, 3, 4} | {(1, 1), (2, 2), (3, 3), (4, 4)} | Yes (vacuously true) |
| R3 | {1, 2, 3, 4} | {(2, 2), (2, 3), (3, 4)} | No (missing (3,2) for (2,3)) |
| R4 | {1, 2, 3, 4} | {(1, 1), (2, 2), (3, 3), (4, 3), (4, 4)} | No (missing (3,4) for (4,3)) |
📝 R3 = {(2, 2), (2, 3), (3, 4)} on A = {1, 2, 3, 4} is not symmetric because (2,3) R3 but (3,2) R3 82.
12.3 Transitive relations
A relation R on a set A is transitive if, for any elements a,b,c∈A, whenever (a,b)∈R and (b,c)∈R, it must also be true that (a,c)∈R. This means if aRb and bRc, then aRc.
The elements a,b,c do not need to be distinct. A relation is not transitive if there exist a,b,c∈A such that (a,b)∈R and (b,c)∈R, but (a,c)∈/R.
In a directed graph, transitivity implies that if there's a path from a to c through b, there must be a direct arrow from a to c 83 84.
| Relation | Set A | Pairs in R | Transitive? |
|---|---|---|---|
| R1 | {1, 2, 3, 4} | {(1, 1), (1, 2), (1, 3), (2, 3)} | Yes |
| R2 | {1, 2, 3, 4} | {(1, 2), (1, 4), (2, 3), (3, 4)} | No (missing (1,3) for (1,2) and (2,3)) |
| R3 | {1, 2, 3, 4} | {(2, 1), (2, 4), (2, 3), (3, 4)} | Yes |
12.4 Properties of the null and universal relations
The null relation (∅) and the universal relation (A×A) on a set A have specific properties:
- Reflexive:
- ∅ is not reflexive because it contains no pairs, so (a,a)∈/∅ for any a∈A.
- A×A is reflexive because it contains all possible pairs (a,a) for all a∈A.
- Symmetric:
- ∅ is symmetric because the condition "if (a,b)∈∅" is never met, making the implication vacuously true.
- A×A is symmetric because if (a,b)∈A×A, then (b,a) is also in A×A.
- Transitive:
- ∅ is transitive because the condition "if (a,b)∈∅ and (b,c)∈∅" is never met, making the implication vacuously true.
- A×A is transitive because if (a,b)∈A×A and (b,c)∈A×A, then (a,c) is also in A×A 85.
12.5 Relation examples and checks
Let A = {0, 1, 2} and R = {(0,2), (1,1), (2,0)}.
- R is not reflexive because (0,0)∈/R and (2,2)∈/R. R is symmetric because (0,2)∈R implies (2,0)∈R. R is not transitive because (0,2)∈R and (2,0)∈R, but (0,0)∈/R.
- To make R reflexive, (0,0) and (2,2) must be added. To make it transitive, (0,0) and (2,2) are also needed, as shown by the pairs (0,2),(2,0) and (2,0),(0,2) 86.
Consider the relation L on real numbers R defined by xLy⟺x<y.
- L is not reflexive because x<x is never true.
- L is not symmetric because if x<y, then y<x is false.
- L is transitive because if x<y and y<z, then x<z is true 86.
Consider the relation R on positive integers Z+ defined by aRb⟺a×b is odd.
- R is not reflexive because 2×2=4 is even, so 2R2 is false.
- R is symmetric because if a×b is odd, then b×a is also odd.
- R is transitive because if a×b is odd (meaning a and b are odd) and b×c is odd (meaning b and c are odd), then a and c are both odd, so a×c is odd 86.
Consider the "divides" relation D on integers Z, where mDn⟺m∣n.
- D is reflexive because every integer divides itself (m∣m).
- D is not symmetric because if m∣n, it does not necessarily mean n∣m (e.g., 2∣4 but 4∤2).
- D is transitive because if m∣n and n∣p, then m∣p 87.
Consider the relation R on the set of people A, where pRq⟺p has the same first name as q.
- R is reflexive because every person has the same first name as themselves.
- R is symmetric because if p has the same first name as q, then q has the same first name as p.
- R is transitive because if p has the same first name as q, and q has the same first name as r, then p has the same first name as r 87 88.
12.6 Equivalence relations
A binary relation R on a non-empty set A is an equivalence relation if it is reflexive, symmetric, and transitive 88.
12.7 Congruences (Modular relations)
For integers m and n, and a positive integer d, the notation m≡n(modd) means that d divides (m−n), i.e., there exists an integer k such that m−n=d⋅k 88.
| Congruence | Check | Result |
|---|---|---|
| 22≡1(mod3) | 22−1=21=3×7 | True |
| −5≡10(mod3) | −5−10=−15=3×(−5) | True |
| 7≡7(mod3) | 7−7=0=3×0 | True |
| 14≡4(mod3) | 14−4=10, and 3 does not divide 10 | False |
The relation mRn⟺m≡n(mod3) on the set of integers Z is an equivalence relation:
- Reflexive: m≡m(mod3) because m−m=0=3×0.
- Symmetric: If m≡n(mod3), then m−n=3k for some integer k. Thus, n−m=−3k=3(−k), so n≡m(mod3).
- Transitive: If m≡n(mod3) and n≡p(mod3), then m−n=3r and n−p=3s for integers r,s. Adding these gives (m−n)+(n−p)=3r+3s, which simplifies to m−p=3(r+s). Therefore, m≡p(mod3) 88 89.
13. Matrix Representation of Relations
13.1 Properties of Relations under Intersection
When two relations, R and S, on a set A share certain properties, their intersection (R S) also exhibits these properties.
- Reflexive: If R and S are reflexive, then R S is reflexive. This is because for every element 'a' in A, (a,a) is in both R and S, meaning it is also in their intersection.
- Symmetric: If R and S are symmetric, then R S is symmetric. If (a,b) is in R S, then (a,b) is in R and (a,b) is in S. Since R and S are symmetric, (b,a) must be in both R and S, thus (b,a) is in R S.
- Transitive: If R and S are transitive, then R S is transitive. If (a,b) and (b,c) are in R S, then they are in R and in S individually. Since R and S are transitive, (a,c) must be in both R and S, therefore (a,c) is in R S 90.
13.2 Irreflexive Relations
A binary relation R on a set A is irreflexive if no element in A is related to itself. This means that for all elements 'a' in A, the pair (a,a) is not in R 91.
- A relation is not irreflexive if there exists at least one element 'a' in A such that (a,a) is in R.
- A relation can be neither reflexive nor irreflexive.
- In the directed graph of an irreflexive relation, there are no loops at any point representing the elements of A.
- The matrix representation of an irreflexive relation has all zeros on its main diagonal, as self-related elements correspond to 1s on the diagonal 91.
13.3 Example: Irreflexive relation matrix
Let A = {1,2,3} and R = {(1,3), (2,1), (2,3), (3,2)}. The matrix representation is: M=010001110 Since all diagonal elements are 0, R is irreflexive 92.
13.4 Antisymmetric Relations
A binary relation R on a set A is antisymmetric if for any two elements 'a' and 'b' in A, whenever (a,b) is in R and (b,a) is in R, it must be that a = b 92.
- A relation is not antisymmetric if there exist distinct elements 'a' and 'b' in A such that (a,b) is in R and (b,a) is in R.
- Symmetric and antisymmetric properties are not opposites of each other. A relation can be both symmetric and antisymmetric (e.g., R1 = {(1,1),(2,2),(3,3)}), or neither.
- In the directed graph of an antisymmetric relation, there is no pair of arrows between two distinct elements of A 92.
- The matrix representation of an antisymmetric relation has a 1 in the i-th row and j-th column (where i ≠ j) only if the j-th row and i-th column contains a 0, and vice versa 93.
13.5 Example: Antisymmetric relation matrix
Let A = {1,2,3} and R = {(1,1), (1,2), (2,3), (3,1)}. The matrix representation is: M=101100010 This matrix represents an antisymmetric relation because for any i ≠ j, if M_ij = 1, then M_ji = 0 93.
13.6 Partial Order Relations
A binary relation R on a set A is a partial order relation if it is reflexive, antisymmetric, and transitive. A set A with a partial order relation R is called a partially ordered set (poset) 93.
13.7 Properties of Partial Order Relations 93
| Property | Definition |
|---|---|
| Reflexive | For all a ∈ A, (a,a) ∈ R |
| Antisymmetric | For all a, b ∈ A, if (a,b) ∈ R and (b,a) ∈ R, then a = b |
| Transitive | For all a, b, c ∈ A, if (a,b) ∈ R and (b,c) ∈ R, then (a,c) ∈ R |
13.8 Examples of Partial Order Relations
- "Less than or equal to" (≤) on real numbers: This relation is reflexive (x ≤ x), antisymmetric (if x ≤ y and y ≤ x, then x = y), and transitive (if x ≤ y and y ≤ z, then x ≤ z). 93.
- "Subset" (⊆) on the power set of A (P(A)): This relation is reflexive (X ⊆ X), antisymmetric (if X ⊆ Y and Y ⊆ X, then X = Y), and transitive (if X ⊆ Y and Y ⊆ Z, then X ⊆ Z).
- "Divides" (|) on a set of positive integers A: This relation is reflexive (a|a, since a = 1⋅a), antisymmetric (if a|b and b|a, then a=b), and transitive (if a|b and b|c, then a|c). 94.
- aRb iff b = a^r for some positive integer r, on the set of integers Z: This relation is reflexive (a = a^1), antisymmetric (if b = a^r and a = b^s, then r=s=1, so a=b), and transitive (if b = a^r and c = b^s, then c = a^rs). 95 96.
📝 The relation "less than or equal to" (≤) on the set of real numbers is a partial order relation because it is reflexive, antisymmetric, and transitive. 93 94.
14. Inverse of Relations
14.1 Definition of inverse relation
The inverse relation R−1 from set B to set A is defined for a relation R from A to B as the set of all ordered pairs (b,a) such that (a,b) is in R. This is achieved by interchanging the elements of all ordered pairs in the original relation R 97.
14.2 Example of an inverse relation
Let A = {2, 3, 4} and B = {2, 6, 8}, with relation R defined as "divides" (a | b). R = {(2,2), (2,6), (2,8), (3,6), (4,8)} The inverse relation R−1 from B to A is: R−1 = {(2,2), (6,2), (8,2), (6,3), (8,4)} In words, R−1 can be defined as "is a multiple of" 97.
14.3 Arrow diagram of an inverse relation
An inverse relation can be visualized by reversing the direction of arrows in the original relation's arrow diagram. If R has an arrow from 'a' in set A to 'b' in set B, then R−1 has an arrow from 'b' in set B to 'a' in set A 97.
14.4 Matrix representation of an inverse relation
The matrix representation of an inverse relation R−1 is obtained by taking the transpose of the matrix representing the original relation R. This involves swapping rows and columns 98.
| Relation R | Matrix M |
|---|---|
| A={2,3,4}, B={2,6,8}, R: a | b |
14.5 Properties of inverse relations
The properties of a relation R are transferred to its inverse relation R−1 as follows:
- Reflexive: If R is reflexive, then R−1 is reflexive. This is because if (a,a)∈R for all a∈A, then (a,a)∈R−1 for all a∈A.
- Symmetric: If R is symmetric, then R−1 is symmetric. If (a,b)∈R−1, then (b,a)∈R. Since R is symmetric, (a,b)∈R. By definition of R−1, this means (b,a)∈R−1.
- Transitive: If R is transitive, then R−1 is transitive. If (a,b)∈R−1 and (b,c)∈R−1, then (b,a)∈R and (c,b)∈R. Since R is transitive, (c,a)∈R. By definition of R−1, this means (a,c)∈R−1.
- Antisymmetric: If R is antisymmetric, then R−1 is antisymmetric. If (a,b)∈R−1 and (b,a)∈R−1, then (b,a)∈R and (a,b)∈R. Since R is antisymmetric, a=b 98.
14.6 Relation R is symmetric if and only if R = R⁻¹
A relation R on a set A is symmetric if and only if it is equal to its inverse, R−1.
- Proof (R is symmetric ⇒ R = R⁻¹): If R is symmetric, then for any (a,b)∈R, we have (b,a)∈R. By the definition of R−1, this implies (a,b)∈R−1. Thus, R⊆R−1. Conversely, if (c,d)∈R−1, then (d,c)∈R. Since R is symmetric, (c,d)∈R. Thus, R−1⊆R. Therefore, R=R−1.
- Proof (R = R⁻¹ ⇒ R is symmetric): If R=R−1, let (a,b)∈R. Since R=R−1, (a,b)∈R−1. By the definition of R−1, this means (b,a)∈R. Thus, R is symmetric 99.
14.7 Complementary relation
The complementary relation Rˉ of a relation R from set A to set B is the set of all ordered pairs in A×B that are not in R. Symbolically, Rˉ={(a,b)∈A×B∣(a,b)∈/R} 99.
14.8 Example of a complementary relation
Let A = {1,2,3} and R = {(1,1), (1,3), (2,2), (2,3), (3,1)} be a relation on A. The complementary relation Rˉ is: Rˉ = {(1,2), (2,1), (3,2), (3,3)} 99.
14.9 Complementary relation and reflexivity
A relation R on a set A is reflexive if and only if its complementary relation Rˉ is irreflexive.
- Proof (R is reflexive ⇒ Rˉ is irreflexive): If R is reflexive, then for all a∈A, (a,a)∈R. By the definition of Rˉ, (a,a)∈/Rˉ for all a∈A. Thus, Rˉ is irreflexive.
- Proof (Rˉ is irreflexive ⇒ R is reflexive): If Rˉ is irreflexive, then for all a∈A, (a,a)∈/Rˉ. By the definition of Rˉ, this means (a,a)∈R for all a∈A. Thus, R is reflexive 99.
14.10 Composite relation
The composite of two relations, R from A to B and S from B to C, denoted S∘R, is a relation from A to C. It consists of ordered pairs (a,c) where a∈A, c∈C, and there exists an element b∈B such that (a,b)∈R and (b,c)∈S 100.
14.11 Example of a composite relation
Let R = {(a,1), (a,4), (b,3), (c,1), (c,4)} be a relation from A to B, and S = {(1,x), (2,x), (3,y), (3,z)} be a relation from B to C. The composite relation S∘R is: S∘R = {(a,x), (b,y), (b,z), (c,x)} 100.
14.12 Composite relation from arrow diagram
The composite relation can be visualized by following paths through the arrow diagrams of the individual relations. An arrow from 'a' to 'c' exists in S∘R if there is a path from 'a' to 'c' through an intermediate element 'b' in set B, where (a,b)∈R and (b,c)∈S 100.
14.13 Matrix representation of a composite relation
The matrix representation of a composite relation S∘R is found using the Boolean product of the matrices for R (MR) and S (MS). The Boolean product uses Boolean addition (OR) and Boolean multiplication (AND) 101.
| Boolean Operation | Result |
|---|---|
| 1 + 1 | 1 |
| 1 + 0 | 1 |
| 0 + 0 | 0 |
| 1. 1 | 1 |
| 1. 0 | 0 |
| 0. 0 | 0 |
14.14 Composite relation matrix example
Given matrices for relations R and S: MR=110010100 MS=001100011
The matrix for S∘R is MS∘R=MR⊗MS: MS∘R=100110010
The matrix for R∘S is MR∘S=MS⊗MR: MR∘S=011101010 101.
14.15 Reflexivity of composite relations
If R and S are reflexive relations on a set A, then their composite relation S∘R is also reflexive. For any a∈A, since R and S are reflexive, (a,a)∈R and (a,a)∈S.
By the definition of the composite relation, this implies (a,a)∈S∘R for all a∈A 101.
📝 Let R and S be reflexive relations on set A. Since R is reflexive, for any element a∈A, (a,a)∈R. Similarly, since S is reflexive, for any element a∈A, (a,a)∈S. According to the definition of a composite relation, S∘R contains (a,c) if there exists a b such that (a,b)∈R and (b,c)∈S. In this case, we can choose b=a. Thus, (a,a)∈R and (a,a)∈S, which means (a,a)∈S∘R. Therefore, S∘R is reflexive 101.
15. Functions
15.1 Relations and functions
A function from a set X to a set Y is a specific type of relation where every element in X is associated with exactly one element in Y. This means two conditions must be met:
- Every element in the domain (X) must be the first element of at least one ordered pair in the function.
- No two distinct ordered pairs in the function can share the same first element.
Let's examine some relations to see if they are functions:
- R1 = {(2,4), (4,1)} from X = {2,4,5} to Y={1,2,4,6} is not a function because the element 5 from set X is not included as a first element in any ordered pair.
- R2 = {(2,4), (4,1), (4,2), (5,6)} from X = {2,4,5} to Y={1,2,4,6} is not a function because the element 4 from set X is associated with two different elements in Y (1 and 2).
- R3 = {(2,4), (4,1), (5,6)} from X = {2,4,5} to Y={1,2,4,6} is a function because every element in X is paired with exactly one element in Y 102.
Consider relations R and S from A = {4,5,6} to B = {5,6}:
- R is defined by x≥y. As a set of ordered pairs, R = {(5,5), (6,5), (6,6)}. R is not a function because the element 4 from set A is not related to any element in set B.
- S is defined by 2∣(x−y) (the difference between x and y is divisible by 2). As a set of ordered pairs, S = {(4,6), (5,5), (6,6)}. S is a function because each element in A is related to a unique element in B 102.
15.2 Function definition and notation
A function f from a set X to a set Y, denoted f:X→Y, is a relation where each element of X is related to a unique element of Y.
- The set X is called the domain of f.
- The set Y is called the co-domain of f.
- The unique element y∈Y related to x∈X is denoted as f(x) and is called the value of f at x or the image of x under f 103.
📝 For a set X with 3 elements and a set Y with 4 elements, the number of functions from X to Y is 43=64 107.
15.3 Arrow diagrams
Arrow diagrams visually represent functions. For an arrow diagram to depict a function f:X→Y:
- Every element in the domain X must have an arrow originating from it.
- No element in the domain X can have more than one arrow originating from it 103.
Consider these arrow diagrams for functions from X = {2,4,5} to Y = {1,2,4,6}:
- Diagram (a) is not a function because there is no arrow originating from 5 in X.
- Diagram (b) is not a function because there are two arrows originating from 4 in X, meaning 4 is related to more than one element in Y 103.
15.4 Range of a function
The range of a function f:X→Y is the set of all elements in the co-domain Y that are images of elements from the domain X.
- Range of f={y∈Y∣y=f(x) for some x∈X}.
- The range is always a subset of the co-domain.
- The range of f is also called the image of X under f.
- When y=f(x), x is called the pre-image of y.
- The set of all elements in X related to some y∈Y is the inverse image of y 104.
Determine the range for the following functions from X = {2,4,5} to Y = {1,2,4,6}:
- f={(2,1),(4,6),(5,1)}. Range of f={1,6}.
- g={(2,6),(4,2),(5,1)}. Range of g={1,2,6}.
- h(2)=4,h(4)=4,h(5)=1. Range of h={1,4} 104.
15.5 Graph of a function
The graph of a real-valued function f:R→R is the set of all points (x,y) in the Cartesian plane where x is in the domain of f and y=f(x) 104.
📝 The graph of y=x2 passes the vertical line test and thus defines a function, while the graph of x=y2 does not 105.
15.6 Vertical line test
The vertical line test determines if a graph represents a function. If any vertical line intersects the graph at most once, the graph represents a function.
- The graph of y=x2 passes the vertical line test and thus defines a function.
- The graph of x=y2 does not pass the vertical line test because a vertical line can intersect it at two points, meaning one x-value corresponds to two y-values. Therefore, x=y2 does not define a function 105.
15.7 Counting functions
The number of functions from a set A with m elements to a set B with n elements is nm. This is because each of the m elements in A can be mapped to any of the n elements in B independently 107.
- For a set X with 3 elements and a set Y with 4 elements, the number of functions from X to Y is 43=64 107.
| Set A (m elements) | Set B (n elements) | Number of Binary Relations | Number of Functions |
|---|---|---|---|
| m | n | 2^mn | n^m |
The fraction of binary relations from A to B that are functions is 2mnnm 107.
15.8 Functions not well-defined
A function is well-defined if each element in its domain maps to a unique element in its co-domain 108.
Consider these definitions for functions from Z to R:
- f(n)=±n: This is not well-defined because each integer n maps to two values, +n and −n.
- f(n)=n2−41: This is not well-defined because f(2) and f(−2) are undefined (division by zero).
- f(n)=n: This is not well-defined for negative integers n, as it results in imaginary values, which are not in the co-domain R.
- f(n)=n2+1n: This is well-defined because each integer n maps to a unique real number 108.
Student C defines a function h:Q→Q by h(nm)=nm. Student D claims h is not well-defined.
- Consider the rational number 21. h(21)=21.
- However, 21 can also be represented as 42. h(42)=42=21.
- Since the rational number 21 can be represented in different ways, leading to the same output value, this definition is not well-defined because it implies that different representations of the same rational number could potentially lead to different images, or that a single rational number has multiple representations that are evaluated differently by the rule. The rule should ensure that if x1=x2, then h(x1)=h(x2) 108.
Let g:R→R+ be defined by g(x)=x2+1.
- Show that g is well-defined: Let x1,x2∈R such that x1=x2. Squaring both sides gives x12=x22.
Adding 1 to both sides gives x12+1=x22+1. By the definition of g, this means g(x1)=g(x2).
Therefore, g is well-defined 108. 2. Determine the domain, co-domain, and range of g:
- Domain: R (the set of all real numbers).
- Co-domain: R+ (the set of positive real numbers).
- Range: Since x2≥0 for all x∈R, then x2+1≥1. Thus, the range of g is all real numbers greater than or equal to 1, which is the interval [1,∞) 109.
📝 If f maps {1,2} to {b} and {2,3} to {b,c}, then the image of {1,2} under f is f({1,2})={b} 109.
15.9 Image and inverse image of a set
Let f:X→Y be a function.
- The image of a set A (where A⊆X) under f, denoted f(A), is the set of all elements in Y that are images of elements in A: f(A)={y∈Y∣y=f(x) for some x∈A}.
- Example: If f maps {1,2} to {b} and {2,3} to {b,c}, then f({1,2})={b} and f({2,3})={b,c}.
- The inverse image of a set C (where C⊆Y) under f, denoted f−1(C), is the set of all elements in X whose images under f are in C: f−1(C)={x∈X∣f(x)∈C}.
- Example: If f−1({a})={1,2}, f−1({b,c})={3,4}, and f−1({d})=∅, then the inverse images are as shown 109.
15.10 Properties of image and inverse image
Let f:X→Y be a function, A,B⊆X, and C,D⊆Y.
- If A⊆B, then f(A)⊆f(B).
- f(A∪B)=f(A)∪f(B).
- f(A∩B)⊆f(A)∩f(B).
- f(A−B)⊇f(A)−f(B).
- If C⊆D, then f−1(C)⊆f−1(D).
- f−1(C∪D)=f−1(C)∪f−1(D).
- f−1(C∩D)=f−1(C)∩f−1(D).
- f−1(C−D)=f−1(C)−f−1(D) 110.
15.11 Binary operations
A binary operation "*" on a set A assigns to each ordered pair (a,b) of elements from A a uniquely determined element a\astb that is also in A.
- "+" and "." are binary operations on the set of natural numbers N.
- "-" is not a binary operation on N because, for example, 3−5=−2, which is not in N.
- "-" is a binary operation on the set of integers Z.
- "÷" is a binary operation on the set of non-zero rational numbers Q−{0}, but not on Z (e.g., 1÷2 is not an integer) 110.
15.12 Binary operation as a function 111
A binary operation "*" on a set A can be viewed as a function from the Cartesian product A×A to A: ∗:A×A→A.
- The notation ∗(a,b) is commonly written as a\astb 110.
Examples of binary operations:
- Set operations: union (∪), intersection (∩), and set difference (-) are binary operations on the power set P(A) of any set A.
- Logical connectives: ∨ (OR), ∧ (AND), → (implication), ↔ (biconditional) are binary operations on the set {T,F}.
- Logic gates: OR and AND are binary operations on {0,1} 110.
See the table in section 8.3.
See the table in section 8.3.
The logic gate NOT is a unary operation (operates on a single element) on {0,1} 111.
| A | NOT A |
|---|---|
| 1 | 0 |
| 0 | 1 |
16. Types of functions
16.1 Injective or one-to-one function
A function f:X→Y is injective, or one-to-one, if distinct elements in the domain X are mapped to distinct elements in the codomain Y. This means that for any x1,x2∈X, if x1=x2, then f(x1)=f(x2).
An equivalent way to state this is that if f(x1)=f(x2), then x1=x2. A function that is not one-to-one maps distinct elements of the domain to the same element in the codomain 112 113.
- One-to-one function: Maps distinct domain elements to distinct codomain elements.
- Not one-to-one function: Maps distinct domain elements to the same codomain element 112.
- Alternative definition: A function f:X→Y is one-to-one if and only if for all x1,x2∈X, if f(x1)=f(x2), then x1=x2 113.
- Graphical test: A graph of a function is one-to-one if every horizontal line intersects the graph at most once 115.
16.2 Counting one-to-one functions
The number of one-to-one functions from a set with m elements to a set with n elements, where m≤n, is given by the permutation formula P(n,m)=(n−m)!n! 114 115.
- If the domain has more elements than the codomain, no one-to-one function can exist 114.
16.3 Examples of one-to-one functions
- Consider f:R→R defined by f(x)=4x−1. To check if it's one-to-one, assume f(x1)=f(x2). This leads to 4x1−1=4x2−1, which simplifies to x1=x2. Thus, f is one-to-one.
- Consider g:Z→Z defined by g(n)=n2. If g(n1)=g(n2), then n12=n22, which implies n1=n2 or n1=−n2. Since n1 does not always equal n2 (e.g., g(2)=4 and g(−2)=4), g is not one-to-one 113 114.
📝 The arrow diagram for function f shows distinct elements in X mapping to distinct elements in Y, confirming f is one-to-one. The arrow diagram for function g shows elements a and c in X both mapping to element 2 in Y, indicating g is not one-to-one 113.
📝 The graph of y=x for x∈R+ is one-to-one because any horizontal line intersects it at most once. The graph of y=x2 for x∈R is not one-to-one because horizontal lines above the x-axis intersect it twice (e.g., at (−2,4) and (2,4)) 115.
16.4 Surjective function or onto function
A function f:X→Y is surjective, or onto, if every element in the codomain Y is the image of at least one element in the domain X. This means that for every y∈Y, there exists at least one x∈X such that f(x)=y.
In other words, the range of the function is equal to its codomain. A function that is not onto has at least one element in its codomain that is not mapped to by any element in its domain 116.
- Onto function: Every element in the codomain is an image of at least one domain element.
- Not onto function: There exists at least one element in the codomain that is not an image of any domain element 116.
- Graphical test: A graph of a function is onto if every horizontal line intersects the graph in at least one point 118.
16.5 Examples of surjective functions
- Consider f:R→R defined by f(x)=4x−1. To check if it's onto, let y∈R. We need to find an x∈R such that f(x)=y. Solving 4x−1=y for x gives x=4y+1. Since for any y∈R, x=4y+1 is also in R, f is onto 117.
- Consider h:Z→Z defined by h(n)=4n−1. Let m∈Z. We seek an n∈Z such that h(n)=m. Solving 4n−1=m for n gives n=4m+1. This value of n is not always an integer for all m∈Z (e.g., if m=0, n=41∈/Z). Thus, h is not onto 118.
- Consider f:P({a,b,c})→Z where f(A) is the number of elements in set A. This function is not onto because there is no subset of {a,b,c} with 4 elements, so no element in Z maps to 4.
- Consider f:Z→Z+ defined by f(x)=∣x∣. For any a∈Z+, there exist a and −a in Z such that f(a)=a and f(−a)=a. Thus, f is onto 119.
📝 The arrow diagram for function f shows that element 3 in Y is not mapped to by any element in X, so f is not onto. The arrow diagram for function g shows that every element in Y is mapped to by at least one element in X (e.g., 1=g(c), 2=g(d), 3=g(a)=g(b)), so g is onto 117.
📝 The graph of y=∣x∣ for x∈R is onto R+ because every horizontal line at or above y=0 intersects the graph at least once. The graph of y=ex for x∈R is not onto R because horizontal lines below the x-axis do not intersect the graph 118.
16.6 Bijective function
A function f:X→Y that is both injective (one-to-one) and surjective (onto) is called a bijective function, or a one-to-one correspondence. This means that each element in the domain maps to a unique element in the codomain, and every element in the codomain is mapped to by exactly one element in the domain 120.
- Bijective function: A function that is both injective and surjective 120.
- Graphical test: A graph of a function is bijective if every horizontal line intersects the graph at exactly one point 121.
16.7 Examples of bijective functions
- The function f:R→R defined by f(x)=x3 is bijective. It is one-to-one because if x13=x23, then x1=x2. It is onto because for any y∈R, there exists x=3y∈R such that f(x)=y 120 121.
- The identity function iX:X→X defined by iX(x)=x for all x∈X is bijective. It is injective because if iX(x1)=iX(x2), then x1=x2. It is surjective because for any y∈X (codomain), there exists y∈X (domain) such that iX(y)=y 122.
📝 The function f shown in the arrow diagram is both one-to-one (each element in X maps to a unique element in Y) and onto (every element in Y is mapped to), thus it is a bijective function 120.
📝 The graph of y=x for x∈R is bijective because every horizontal line intersects it at exactly one point. The graph of y=x3 for x∈R is also bijective for the same reason 121.
16.8 Identity function
The identity function on a set X, denoted by iX, is a function from X to X defined by iX(x)=x for all x∈X. It maps each element of the set to itself 121.
- The identity function on any non-empty set X is always bijective 122.
📝 For the set X={1,2,3,4}, the identity function iX maps 1→1, 2→2, 3→3, and 4→4, as shown in the arrow diagram 121.
16.9 Constant function
A function f:X→Y is a constant function if it maps all elements of the domain X to a single element c in the codomain Y. That is, for all x∈X, f(x)=c for some fixed c∈Y 122.
- A constant function is one-to-one if and only if its domain is a singleton set (contains only one element).
- A constant function is onto if and only if its codomain is a singleton set 122.
📝 The function f shown in the arrow diagram maps elements 1,2,3,4 from set X all to the single element 7 in set Y. Therefore, f is a constant function 122.
17. Inverse function
17.1 Equality of functions
Two functions, f and g, from a set X to a set Y are considered equal (f=g) if and only if they produce the same output for every input in X. This means f(x)=g(x) for all x∈X 123.
For example, if f(x)=∣x∣ and g(x)=x2 for all real numbers x, then f=g because ∣x∣=x2 for all x∈R 123.
Similarly, if f(x)=2x and g(x)=x2+12x3+2x for all x∈R, then f=g because g(x) simplifies to 2x, and x2+1 is never zero 123.
17.2 Inverse of a function
The inverse of a function f, denoted as f−1, is a function that "reverses" the action of f. If f maps an element x from set X to an element y in set Y, then f−1 maps y back to x 124.
It is important to note that the inverse of a function may not always be a function itself 124.
📝 If f(x)=4x−1, then y=4x−1. Solving for x gives x=4y+1, so f−1(y)=4y+1 126.
17.3 Inverses and function types
- Injective function: The inverse of an injective (one-to-one) function may not be a function.
- Surjective function: The inverse of a surjective (onto) function may not be a function 124.
- Bijective function: The inverse of a bijective function (which is both injective and surjective) is always a function 125.
17.4 Inverse function definition
Suppose f:X→Y is a bijective function. The inverse function, f−1:Y→X, is defined such that for every y∈Y, f−1(y)=x if and only if y=f(x) 125.
This means f−1 maps each element in Y back to its original element in X that was mapped by f 125.
A function for which an inverse function exists is called an invertible function 125.
17.5 Inverse function from an arrow diagram
An arrow diagram visually represents a function and its inverse. If f maps elements from X to Y, the inverse function f−1 maps elements from Y back to X by reversing the direction of the arrows 125 126.
17.6 Inverse function from a formula
To find the inverse function from a formula, follow these steps:
- Set y=f(x).
- Solve the equation y=f(x) for x in terms of y.
- The expression for x in terms of y is the formula for f−1(y) 126.
For example, if f(x)=4x−1, we set y=4x−1. Solving for x, we get 4x=y+1, so x=4y+1.
Therefore, f−1(y)=4y+1 126.
17.7 Finding the inverse function
To find the inverse function f−1 for a bijective function f:X→Y defined by f(x)=y:
- Solve the equation f(x)=y for x in terms of y.
- The expression for x obtained in step 1 is f−1(y) 127.
Example: Let f(x)=x−1x+1 for x=1.
- To show f is bijective:
- Injective: If f(x1)=f(x2), then x1−1x1+1=x2−1x2+1. Cross-multiplying gives (x1+1)(x2−1)=(x2+1)(x1−1), which simplifies to x1x2−x1+x2−1=x1x2−x2+x1−1. This further simplifies to 2x2=2x1, so x1=x2. Thus, f is injective.
- Surjective: For any y∈R−{1}, we need to find an x∈R−{1} such that f(x)=y. Setting x−1x+1=y and solving for x yields x=y−1y+1. Since y=1, y−1=0, and x is a real number. Thus, f is surjective.
- To find the inverse function: We have y=x−1x+1. Solving for x: y(x−1)=x+1 yx−y=x+1 yx−x=y+1 x(y−1)=y+1 x=y−1y+1 Therefore, f−1(y)=y−1y+1 for y=1 127 128.
Example: Let f(x)=x3+5.
- One-to-one: If f(x1)=f(x2), then x13+5=x23+5, which implies x13=x23. Taking the cube root of both sides gives x1=x2. Thus, f is one-to-one.
- Onto: For any y∈R, we seek an x∈R such that f(x)=y. Setting x3+5=y, we get x3=y−5, so x=3y−5. Since for every y there exists a real cube root, f is onto.
- Inverse formula: From y=x3+5, we solve for x to get x=3y−5. Thus, f−1(y)=3y−5 128.
17.8 Composition of functions
The composition of two functions, g∘f, is a function that applies f first and then applies g to the result. For g∘f to be defined, the range of f must be a subset of the domain of g.
The composition is defined as (g∘f)(x)=g(f(x)) for all x in the domain of f 128 129.
17.9 Composition by arrow diagrams
When functions are defined by arrow diagrams, composition involves tracing the path from the initial set, through the intermediate set, to the final set 129.
Example: Let f:{1,2,3}→{a,b,c,d} and g:{a,b,c,d}→{x,y,z} be defined by arrow diagrams. To find (g∘f)(1), we first find f(1), then apply g to that result: (g∘f)(1)=g(f(1)) 129.
17.10 Composition by formulas
When functions are defined by formulas, their compositions are found by substitution 130.
Example: Let f(n)=n+1 and g(n)=n2 for n∈Z.
- (g∘f)(n)=g(f(n))=g(n+1)=(n+1)2.
- (f∘g)(n)=f(g(n))=f(n2)=n2+1 130.
The composition of functions is generally not commutative, meaning f∘g=g∘f. In the example above, (g∘f)(1)=(1+1)2=4, while (f∘g)(1)=12+1=2 130.
17.11 Composition with the identity function
The identity function, iX, on a set X maps every element to itself (iX(x)=x). When composing a function f with an identity function:
- f∘iX=f
- iY∘f=f
For example, if f:X→Y and iX is the identity on X, then (f∘iX)(x)=f(iX(x))=f(x) for all x∈X 130 131.
17.12 Composing a function with its inverse
When a function f:X→Y is composed with its inverse f−1:Y→X, the results are identity functions:
- (f−1∘f)(x)=x for all x∈X. This means f−1∘f=iX.
- (f∘f−1)(y)=y for all y∈Y. This means f∘f−1=iY 131 132.
Two functions f:X→Y and g:Y→X are inverses of each other if and only if g∘f=iX and f∘g=iY 132.
Example: Let f(x)=3x+2 and g(x)=3x−2.
- (g∘f)(x)=g(f(x))=g(3x+2)=3(3x+2)−2=33x=x 132.
- (f∘g)(x)=f(g(x))=f(3x−2)=3(3x−2)+2=(x−2)+2=x. Since both compositions result in the identity function, f and g are inverses of each other 133.
18. Composition of Functions
18.1 Composition of one-to-one functions
If two functions, f:X→Y and g:Y→Z, are both one-to-one, their composition g∘f:X→Z is also one-to-one. This is proven by assuming (g∘f)(x1)=(g∘f)(x2), which implies g(f(x1))=g(f(x2)).
Since g is one-to-one, f(x1)=f(x2). Because f is also one-to-one, it follows that x1=x2, thus proving g∘f is one-to-one 134.
18.2 Composition of onto functions
If functions f:X→Y and g:Y→Z are both onto, their composition g∘f:X→Z is also onto. To show this, let z be any element in Z.
Since g is onto, there exists a y in Y such that g(y)=z. Since f is onto, there exists an x in X such that f(x)=y.
Therefore, for any z∈Z, there exists an x∈X such that (g∘f)(x)=g(f(x))=g(y)=z, proving g∘f is onto 134.
📝 If f:X→Y and g:Y→Z are both onto functions, and z is any element in Z, then there exists a y∈Y such that g(y)=z. Since f is also onto, there exists an x∈X such that f(x)=y, meaning (g∘f)(x)=z. 134
18.3 Associativity of function composition
The composition of functions is associative. For any three functions f:W→X, g:X→Y, and h:Y→Z, the property (h∘g)∘f=h∘(g∘f) holds.
This is demonstrated by showing that both sides of the equation assign the same image to every element x in the domain W.
- ((h∘g)∘f)(x)=(h∘g)(f(x))=h(g(f(x)))
- (h∘(g∘f))(x)=h((g∘f)(x))=h(g(f(x))) Since both expressions are equal, the associativity is proven 134.
18.4 Inverse of function composition
If f:X→Y and g:Y→Z are bijective functions, their composition g∘f:X→Z is also bijective, and its inverse (g∘f)−1:Z→X exists. Furthermore, the inverse of the composition is equal to the composition of the inverses in reverse order: (g∘f)−1=f−1∘g−1.
This is proven by showing that (f−1∘g−1)∘(g∘f)=iX and (g∘f)∘(f−1∘g−1)=iZ, where iX and iZ are identity functions 135.
18.5 Real-valued functions
A function f:X→R that maps elements of a set X to real numbers is called a real-valued function. If the domain X is also the set of real numbers (R), then f:R→R is a real-valued function of a real variable 135.
18.6 Operations on functions 135 136
For real-valued functions f:X→R and g:X→R with the same domain X, the following operations are defined:
| Operation | Definition | Example |
|---|---|---|
| Sum | (f+g)(x) = f(x) + g(x) | If f(x) = x^2 + 1 and g(x) = x + 2, then (f+g)(x) = x^2 + x + 3. |
| Difference | (f-g)(x) = f(x) - g(x) | If f(x) = x^2 + 1 and g(x) = x + 2, then (f-g)(x) = x^2 - x - 1. |
| Product | (f·g)(x) = f(x) · g(x) | If f(x) = x^2 + 1 and g(x) = x + 2, then (f·g)(x) = x^3 + 2x^2 + x + 2. |
| Quotient | (f/g)(x) = f(x) / g(x), where g(x) ≠ 0 | If f(x) = x^2 + 1 and g(x) = x + 2, then (f/g)(x) = (x^2 + 1) / (x + 2) for x ≠ -2. |
📝 If f(x)=x2+1 and g(x)=x+2, then the product function (f⋅g)(x)=(x2+1)(x+2)=x3+2x2+x+2. 136
18.7 Scalar multiplication of functions
Given a real-valued function f:X→R and a non-zero real number c, the scalar multiplication c⋅f:X→R is defined as (c⋅f)(x)=c⋅f(x) for all x∈X. This operation can be combined with addition and subtraction, for example, (3f−2g)(x)=3f(x)−2g(x) 137.
18.8 Properties of sum and scalar multiplication
- If f and g are one-to-one functions, f+g is not necessarily one-to-one. For example, if f(x)=x and g(x)=−x, both are one-to-one, but (f+g)(x)=0 for all x, which is not one-to-one.
- If f and g are onto functions, f+g is not necessarily onto. For example, if f(x)=x and g(x)=−x, both are onto, but (f+g)(x)=0 for all x, meaning only 0 has a preimage.
- If f:R→R is one-to-one and c=0, then c⋅f is also one-to-one 137.
- If f:R→R is onto and c=0, then c⋅f is also onto 138.
18.9 Zero function
The zero function 0X:X→R is defined by 0X(x)=0 for all x∈X. For any function f:X→R:
- f+0X=f
- f⋅0X=0X 138.
18.10 Characteristic functions
For a set S and a subset A⊆S, the characteristic function χA:S→{0,1} is defined as: χA(x)={10if x∈Aif x∈/A Properties for subsets A and B of S:
📝 For a set S and a subset A, the characteristic function χA(x) is 1 if x∈A and 0 if x∈/A. For example, if S={1,2,3} and A={1,2}, then χA(1)=1, χA(2)=1, and χA(3)=0. 138
18.11 Properties of relations and functions
For a set A={1,2,3} and functions F,G,H from A to A:
- If F is reflexive, every element in A is related to itself (aFa for all a∈A). Since F is a function, this means F must be the identity function 140.
- If G is symmetric, then if aGb, it implies bGa for all a,b∈A. This means G must be a bijective function (both one-to-one and onto).
- If H is transitive and onto, it must be the identity function. Transitivity means if aHb and bHc, then aHc for all a,b,c∈A 141.
18.12 Finite and infinite sets
- A finite set is either the empty set or can be put into a one-to-one correspondence with {1,2,…,n} for some positive integer n.
- An infinite set is a non-empty set that cannot be put into a one-to-one correspondence with {1,2,…,n} for any positive integer n 141.
18.13 Cardinality and countable sets
Cardinality refers to the number of elements in a set. A countable set is a set that is either finite or has the same cardinality as the set of positive integers (Z+), meaning there is a one-to-one correspondence between the set and Z+.
A set that is not countable is called uncountable. The set of all integers (Z) and the set of all even integers (2Z) are examples of countable sets 141 142.
18.14 Image of a set
Let f:X→Y be a function and A be a subset of X. The image of A under f, denoted f(A), is the set of all elements in Y that are the image of some element in A: f(A)={y∈Y∣y=f(x) for some x∈A} 142.
18.15 Inverse image of a set
Let f:X→Y be a function and C be a subset of Y. The inverse image of C under f, denoted f−1(C), is the set of all elements in X whose image under f is in C: f−1(C)={x∈X∣f(x)∈C} 143.
18.16 Results on images and inverse images 143
Let f:X→Y be a function, A,B⊆X, and C,D⊆Y.
| Property | Statement |
|---|---|
| Image subset | If A⊆B, then f(A)⊆f(B) |
| Image union | f(A∪B)=f(A)∪f(B) |
| Image intersection | f(A∩B)⊆f(A)∩f(B) |
| Image difference | f(A−B)⊇f(A)−f(B) |
| Inverse image subset | If C⊆D, then f−1(C)⊆f−1(D) |
| Inverse image union | f−1(C∪D)=f−1(C)∪f−1(D) |
| Inverse image intersection | f−1(C∩D)=f−1(C)∩f−1(D) |
| Inverse image difference | f−1(C−D)=f−1(C)−f−1(D) |
19. Sequence
19.1 Sequences
A sequence is a list of elements, typically arranged in a row. These elements are often referred to as terms.
The ellipsis (...) is used to indicate that the sequence continues indefinitely 144.
A formal definition of a sequence is a function whose domain is a set of integers greater than or equal to a specific starting integer, usually 1 or 0. The notation an represents the n-th term of the sequence 144.
19.2 Finding terms of a sequence given by an explicit formula 146
An explicit formula, or general formula, provides a rule to determine any term in a sequence based on its position 144.
For a sequence defined by ak=k+1k for k≥1, the first four terms are:
- a1=1+11=21
- a2=2+12=32
- a3=3+13=43
- a4=4+14=54 144.
For a sequence defined by bj=1+2j for j≥0, the first four terms are:
- b0=1+2(0)=1
- b1=1+2(1)=3
- b2=1+2(2)=5
- b3=1+2(3)=7 145.
The sequence defined by Cn=1+(−1)n for n≥0 oscillates between 2 and 0:
- C0=1+(−1)0=1+1=2
- C1=1+(−1)1=1−1=0
- C2=1+(−1)2=1+1=2
- C3=1+(−1)3=1−1=0
- C4=1+(−1)4=1+1=2
- C5=1+(−1)5=1−1=0 145.
A sequence whose terms alternate in sign is called an alternating sequence 145.
Explicit formulas can be found for sequences given their initial terms 145 146.
| Sequence | Explicit Formula |
|---|---|
| 0, 1, -2, 3, -4, 5, … | a_n = (-1)^{n+1}n for n \ge 0 |
| 1 - 1/2, 1 - 1/3, 1 - 1/4, 1 - 1/5, … | b_k = 1 - \frac{1}{k+1} for k \ge 1 |
| 2, 6, 12, 20, 30, 42, 56, … | C_n = n(n+1) for n \ge 1 |
| 1/4, 2/9, 3/16, 4/25, 5/36, 6/49, … | d_i = \frac{i}{(i+1)^2} for i \ge 1 or d_j = \frac{j+1}{(j+2)^2} for j \ge 0 |
📝 For a sequence defined by ak=k+1k for k≥1, the first four terms are a1=21, a2=32, a3=43, and a4=54 144.
19.3 Arithmetic sequence
An arithmetic sequence, or arithmetic progression (A.P.), is a sequence where each term after the first is obtained by adding a constant value to the preceding term. This constant value is known as the common difference (d) 146.
Examples of arithmetic sequences include:
- 5, 9, 13, 17,... (common difference = 4)
- 0, -5, -10, -15,... (common difference = -5)
- x + a, x + 3a, x + 5a,... (common difference = 2a) 146.
19.4 General term of an arithmetic sequence
The general term (an) of an arithmetic sequence is given by the formula an=a+(n−1)d, where a is the first term and d is the common difference. This formula applies for all integers n≥1 146.
To find the 20th term of the arithmetic sequence 3, 9, 15, 21,...:
- First term (a) = 3
- Common difference (d) = 9 - 3 = 6
- Term number (n) = 20 Using the formula an=a+(n−1)d: a20=3+(20−1)6=3+19×6=3+114=117 146 147.
To find which term of the arithmetic sequence 4, 1, -2,... is -77:
- First term (a) = 4
- Common difference (d) = 1 - 4 = -3
- Term value (an) = -77 Using the formula an=a+(n−1)d: −77=4+(n−1)(−3) −81=(n−1)(−3) 27=n−1 n=28. Thus, -77 is the 28th term 147.
To find the 36th term of an arithmetic sequence where the 3rd term is 7 and the 8th term is 17:
- Let the first term be a and the common difference be d.
- a3=a+(3−1)d=a+2d=7
- a8=a+(8−1)d=a+7d=17 Subtracting the first equation from the second: (a+7d)−(a+2d)=17−7, which gives 5d=10, so d=2. Substituting d=2 into a+2d=7: a+2(2)=7, so a=3.
The general term is an=3+(n−1)2. The 36th term is a36=3+(36−1)2=3+35×2=3+70=73 147 148.
📝 To find the 20th term of the arithmetic sequence 3, 9, 15, 21,..., use an=a+(n−1)d with a=3, d=6, and n=20, resulting in a20=3+(20−1)6=117 146 147.
19.5 Geometric sequence
A geometric sequence, or geometric progression (G.P.), is a sequence where each term after the first is obtained by multiplying the preceding term by a constant number. This constant number is called the common ratio (r) 148.
Examples of geometric sequences include:
- 1, 2, 4, 8, 16,... (common ratio = 2)
- 3, -3/2, 3/4, -3/8,... (common ratio = -1/2)
- 0.1, 0.01, 0.001, 0.0001,... (common ratio = 0.1) 148.
19.6 General term of a geometric sequence
The general term (an) of a geometric sequence is given by the formula an=arn−1, where a is the first term and r is the common ratio. This formula applies for all integers n≥1 148.
To find the 8th term of the geometric sequence 4, 12, 36, 108,...:
- First term (a) = 4
- Common ratio (r) = 12/4 = 3
- Term number (n) = 8 Using the formula an=arn−1: a8=4×38−1=4×37=4×2187=8748 148.
To find which term of a geometric sequence is 1/8, given the first term is 4 and the common ratio is 1/2:
- First term (a) = 4
- Common ratio (r) = 1/2
- Term value (an) = 1/8 Using the formula an=arn−1: 81=4(21)n−1 321=(21)n−1 (21)5=(21)n−1 5=n−1 n=6. Thus, 1/8 is the 6th term 148 149.
To write a geometric sequence with positive terms where the second term is 9 and the fourth term is 1:
- Let the first term be a and the common ratio be r.
- a2=ar2−1=ar=9
- a4=ar4−1=ar3=1 Dividing the second equation by the first: arar3=91, which simplifies to r2=91. Since the terms are positive, r=31 (rejecting r=−31).
Substituting r=31 into ar=9: a(31)=9, so a=27. The geometric sequence is 27, 9, 3, 1, 1/3, 1/9,.. 149.
19.7 Sequences in computer programming
In computer programming, finite sequences are often represented as one-dimensional arrays. An array is a single variable that can store a sequence of values 149.
For example, the names of k students in a class can be stored in an array named "name" as: name[0], name[1], name[2],..., name[k-1] 150.
20. Series
20.1 Series and summation notation
A series is formed by summing the terms of a sequence. If a sequence is represented by a1,a2,a3,…, the corresponding series is a1+a2+a3+….
This can be written concisely using summation notation, employing the Greek capital letter sigma (∑) 151.
The notation ∑k=mnak represents the sum of terms ak where the index k ranges from a lower limit m to an upper limit n. Here, k is the index of summation, m is the lower limit, and n is the upper limit 151.
20.2 Computing summations
Given a sequence a0=2,a1=3,a2=−2,a3=1, and a4=0, we can compute specific summations:
- ∑i=04ai=a0+a1+a2+a3+a4=2+3+(−2)+1+0=4.
- ∑j=02a2j=a0+a2+a4=2+(−2)+0=0.
- ∑k=14ak=a1+a2+a3+a4=3+(−2)+1+0=2 151.
20.3 Exercises: Computing summations
- Compute ∑i=13(2i−1). This involves summing the terms (2i−1) for i=1,2,3.
- (2(1)−1)+(2(2)−1)+(2(3)−1)=1+3+5=9 151.
- Compute ∑k=−11(k3+2). This involves summing the terms (k3+2) for k=−1,0,1.
- ((−1)3+2)+(03+2)+(13+2)=(−1+2)+(0+2)+(1+2)=1+2+3=6 152.
📝 Compute ∑i=13(2i−1)=(2(1)−1)+(2(2)−1)+(2(3)−1)=1+3+5=9 151.
20.4 Summation notation to expanded form
To write the summation ∑i=0ni+1(−1)i in expanded form, we substitute each value of i from 0 to n: 0+1(−1)0+1+1(−1)1+2+1(−1)2+3+1(−1)3+⋯+n+1(−1)n=1−21+31−41+⋯+n+1(−1)n 152.
20.5 Expanded form to summation notation
To express the series 1+n+12+n+23+⋯+2nn+1 using summation notation, we identify the pattern for the k-th term. The numerators form an arithmetic sequence 1,2,3,…,n+1, where the k-th term is k.
The denominators form an arithmetic sequence n,n+1,n+2,…,2n, where the k-th term is n+(k−1)=n+k−1. Thus, the k-th term of the series is n+k−1k.
The series can be written as ∑k=1n+1n+k−1k 152.
An alternative representation is ∑k=0nn+kk+1 153.
20.6 Transforming a sum by a change of variable
The index of a summation is a dummy variable, meaning it can be replaced by any other symbol without changing the sum's value. For example, ∑k=13k2=∑i=13i2 153.
Consider the sum ∑k=1n+1n−1+kk. By substituting k=j+1, which implies j=k−1, we can transform the summation.
When k=1, j=0. When k=n+1, j=n.
The sum becomes ∑j=0nn−1+(j+1)j+1=∑j=0nn+jj+1. Changing the dummy variable back to k, we get ∑k=0nn+kk+1 153.
To transform ∑i=0n−1(n−i)2 by making the change of variable j=i−1, we have i=j+1. When i=0, j=−1.
When i=n−1, j=n−2. The sum becomes ∑j=−1n−2(n−(j+1))2=∑j=−1n−2(n−1−j)2 153.
20.7 Properties of summations
The following properties hold for summations, where ak,bk∈R, c∈R, i∈N, and m≤n 153:
| Property | Formula |
|---|---|
| Sum of sums | \sum_{k=m}^{n} (a_k + b_k) = \sum_{k=m}^{n} a_k + \sum_{k=m}^{n} b_k |
| Constant multiple | \sum_{k=m}^{n} c a_k = c \sum_{k=m}^{n} a_k |
| Index shift (addition) | \sum_{k=a-i}^{b-i} (k+i) = \sum_{k=a}^{b} k |
| Index shift (subtraction) | \sum_{k=a+i}^{b+i} (k-i) = \sum_{k=a}^{b} k |
| Sum of a constant | \sum_{k=1}^{n} c = nc |
20.8 Simplifying summations
To simplify 3∑k=13(2k−3)+∑k=13(4−5k), we can combine the terms: 3∑k=13(2k−3)+∑k=13(4−5k)=∑k=13[3(2k−3)+(4−5k)]=∑k=13(6k−9+4−5k)=∑k=13(k−5). This can be further simplified as ∑k=13k−∑k=135=∑k=13k−5(3)=∑k=13k−15 154.
20.9 Arithmetic series
An arithmetic series is the sum of terms in an arithmetic sequence. For example, 1+3+5+7+… is an arithmetic series of positive odd integers 154.
If a is the first term and d is the common difference, the series is a+(a+d)+(a+2d)+… 154.
20.10 Sum of n terms of an arithmetic series
Let a be the first term and d be the common difference. The n-th term is an=a+(n−1)d.
The sum of the first n terms, Sn, can be calculated using two formulas:
- Sn=2n(a+an)
- Sn=2n[2a+(n−1)d] 155.
20.11 Example: Sum of first n natural numbers
The sum of the first n natural numbers, Sn=1+2+3+⋯+n, is an arithmetic series with a=1 and d=1. Using the formula Sn=2n[2a+(n−1)d], we get: Sn=2n[2(1)+(n−1)(1)]=2n[2+n−1]=2n(n+1) 155.
20.12 Example: Sum of two-digit integers
Find the sum of all two-digit positive integers that are neither divisible by 5 nor by 2. The series is 11+13+17+19+⋯+91+93+97+99. Grouping terms in fours yields an arithmetic series: (11+13+17+19)+(21+23+27+29)+⋯+(91+93+97+99)=60+100+140+⋯+380.
This series has a=60, d=40, and l=380. To find n, we use an=a+(n−1)d: 380=60+(n−1)40, which gives 320=(n−1)40, so n−1=8 and n=9.
The sum is S9=29(60+380)=29(440)=1980 155.
📝 The sum of two-digit integers that are neither divisible by 5 nor by 2 is 11+13+17+19+⋯+91+93+97+99, which groups into an arithmetic series 60+100+140+⋯+380. The sum of this series is S9=29(60+380)=1980 155.
20.13 Geometric series
A geometric series is the sum of terms in a geometric sequence. For example, 1+2+4+8+16+… is a geometric series 156.
If a is the first term and r is the common ratio, the series is a+ar+ar2+ar3+… 156.
20.14 Sum of n terms of a geometric series
Let a be the first term and r be the common ratio. The n-th term is an=arn−1.
The sum of the first n terms, Sn, is given by: Sn=1−ra(1−rn), provided r=1 156.
20.15 Example: Sum of a geometric series
Find the sum of the geometric series 6−2+32−92+… to 10 terms. Here, a=6, r=−62=−31, and n=10. S10=1−(−31)6(1−(−31)10)=1+316(1−3101)=346(1−590491)=418(1−590491)=29(1−590491). 156 157.
20.16 Infinite geometric series
An infinite geometric series is of the form a+ar+ar2+⋯+arn−1+… 157.
If the sequence of partial sums Sn converges to a limit S as n→∞, the series is convergent and S is its sum 157.
20.17 Sum of an infinite geometric series
If ∣r∣<1, then rn→0 as n→∞. The sum of an infinite geometric series is: S=limn→∞Sn=1−ra.
If Sn increases indefinitely as n becomes very large, the series is divergent 157.
20.18 Example: Sum of an infinite geometric series
Find the sum of the infinite geometric series 9+3+1+32+…. Here, a=9 and r=93=31.
Since ∣r∣<1, the sum is: S=1−ra=1−319=329=9×23=227 157.
20.19 Example: Recurring decimal to fraction
To express the recurring decimal 0.818181… as a common fraction, we can write it as an infinite geometric series: 0.81+0.0081+0.000081+…. Here, a=0.81 and r=0.810.0081=0.01. Since ∣r∣<1, the sum is: S=1−ra=1−0.010.81=0.990.81=9981=119 158.
20.20 Important sums
The following are standard formulas for sums of powers of integers 158:
| Summation | Formula |
|---|---|
| Sum of first n integers | \sum_{k=1}^{n} k = \frac{n(n+1)}{2} |
| Sum of first n squares | \sum_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6} |
| Sum of first n cubes | \sum_{k=1}^{n} k^3 = \left(\frac{n(n+1)}{2}\right)^2 |
20.21 Example: Sum of a series with product terms
Find the sum to n terms of the series 1⋅5+5⋅11+9⋅17+…. The k-th term, Tk, can be expressed as [1+(k−1)4][5+(k−1)6]=(4k−3)(6k−1)=24k2−22k+3.
The sum Sn is ∑k=1nTk=∑k=1n(24k2−22k+3). Using the properties of summations and the important sums formulas: Sn=24∑k=1nk2−22∑k=1nk+∑k=1n3 Sn=24(6n(n+1)(2n+1))−22(2n(n+1))+3n Sn=n[4(n+1)(2n+1)−11(n+1)+3] Sn=n[4(2n2+3n+1)−11n−11+3] Sn=n[8n2+12n+4−11n−8] Sn=n[8n2+n−4] 158.
21. Recursion I
21.1 Recursion
Recursion is the process of defining an object in terms of smaller versions of itself. A recursive definition consists of two parts: a base case, which is an initial simple definition that cannot be expressed in terms of smaller versions, and a recursion part, which defines the object in terms of smaller versions of itself.
Recursive definitions can be used in a generative manner 159.
- Base: The simplest case of a recursive definition, which does not rely on further recursion.
- Recursion: The rule that defines an object in terms of smaller instances of itself 159.
21.2 Recursively defined functions
A function is recursively defined if it refers to itself. This requires two conditions:
- Base values: Specific arguments for which the function does not refer to itself.
- Argument reduction: Each recursive call must use an argument that is closer to a base value 159.
21.3 Example: f(n+1) = 2f(n) + 3
Suppose a function f is defined recursively by f(0)=3 and f(n+1)=2f(n)+3.
- f(1)=2f(0)+3=2(3)+3=9.
- f(2)=2f(1)+3=2(9)+3=21.
- f(3)=2f(2)+3=2(21)+3=45.
- f(4)=2f(3)+3=2(45)+3=93 160.
21.4 Example: f(n+1) = f(n) + 3f(n-1)
Find f(2), f(3), and f(4) if f is defined recursively by f(0)=−1, f(1)=2, and for n=1,2,3,…, f(n+1)=f(n)+3f(n−1).
- f(2)=f(1)+3f(0)=2+3(−1)=−1.
- f(3)=f(2)+3f(1)=(−1)+3(2)=5.
- f(4)=f(3)+3f(2)=5+3(−1)=2 160.
21.5 The factorial of a positive integer
The factorial of a positive integer n, denoted n!, is the product of all integers from 1 to n. Zero factorial is defined as 1 160.
- Definition: n!=n⋅(n−1)⋅(n−2)⋅⋯⋅3⋅2⋅1.
- Base case: 0!=1 160.
21.6 Recursive definition of factorial
The factorial function F(n)=n! can be defined recursively:
- F(0)=1.
- F(n)=nF(n−1) for n≥1 161.
21.7 Sum of the first n positive integers
Let S(n) be the sum of the first n positive integers. A recursive definition for S(n) is:
- S(0)=0.
- S(n)=n+S(n−1) for n≥1 161.
21.8 Quotient-like recursion 161
A function Q(a,b) is defined recursively as:
| Condition | Definition |
|---|---|
| a<b | 0 |
| b≤a | Q(a−b,b)+1 |
- Q(2,3)=0 because 2<3.
- Q(14,3)=Q(11,3)+1=Q(8,3)+2=Q(5,3)+3=Q(2,3)+4=0+4=4 161.
This function calculates the integer quotient when a is divided by b. For example, Q(3355,7)=479 162.
21.9 The Fibonacci sequence
The Fibonacci sequence is defined as follows:
- F0=1.
- F1=1.
- Fk=Fk−1+Fk−2 for all integers k≥2 162.
The first few terms are:
- F2=F1+F0=1+1=2.
- F3=F2+F1=2+1=3.
- F4=F3+F2=3+2=5.
- F5=F4+F3=5+3=8 162.
21.10 Recurrence relation
A recurrence relation for a sequence a0,a1,a2,… is a formula relating each term ak to its predecessors ak−1,ak−2,…,ak−i, where i is a fixed integer and k≥i. Initial conditions specify the values of a0,a1,…,ai−1 162.
21.11 Example: bk = bk-1 + 2k
Find the first four terms of the sequence defined by b1=2 and bk=bk−1+2⋅k for k≥2.
- b1=2.
- b2=b1+2⋅2=2+4=6.
- b3=b2+2⋅3=6+6=12.
- b4=b3+2⋅4=12+8=20 162.
21.12 Example: tk = tk-1 + 2tk-2
Find the first five terms of the sequence defined by t0=−1, t1=1, and tk=tk−1+2⋅tk−2 for k≥2.
21.13 Sequence bn = 5^n
Show that the sequence bn=5n satisfies the recurrence relation bk=5bk−1 for k≥1.
- bk=5k.
- bk−1=5k−1.
- 5⋅bk−1=5⋅5k−1=5k=bk 163.
21.14 Sequence dn = 2^n - 1
Show that the sequence dn=2n−1 satisfies the recurrence relation dk=3dk−1−2dk−2 for k≥2.
- dk=2k−1.
- dk−1=2k−1−1.
- dk−2=2k−2−1.
- Right-hand side: 3dk−1−2dk−2=3(2k−1−1)−2(2k−2−1)=3⋅2k−1−3−2⋅2k−2+2=3⋅2k−1−2k−1−1=(3−1)⋅2k−1−1=2⋅2k−1−1=2k−1=dk 163.
21.15 The Tower of Hanoi
The Tower of Hanoi puzzle involves moving disks of decreasing size stacked on three poles. The goal is to transfer all disks from one pole to another, with the rule that a larger disk can never be placed on top of a smaller one 164.
Let mn be the minimum number of moves to transfer n disks. The recursive relation is:
- m1=1.
- mk=2mk−1+1 for k≥2 164.
The first few terms are:
- m2=2⋅m1+1=2⋅1+1=3.
- m3=2⋅m2+1=2⋅3+1=7.
- m4=2⋅m3+1=2⋅7+1=15.
- m5=2⋅m4+1=2⋅15+1=31 164.
The general formula is mn=2n−1. For n=64, m64=264−1, which is approximately 1.844×1019 moves 164.
📝 The minimum number of moves mk to transfer k disks in the Tower of Hanoi puzzle follows m1=1 and mk=2mk−1+1 for k≥2, resulting in m3=2⋅m2+1=2⋅3+1=7 moves 164.
21.16 Use of recursion
Recursion often provides elegant and concise algorithmic solutions in computer science and mathematics. It is commonly used for:
- Mathematical functions.
- Number sequences.
- Data structure definitions.
- Data structure manipulations.
- Language definitions 164.
22. Recursion II
22.1 Recursive definition of a set
A recursive definition for a set establishes its elements through three types of rules: base, recursion, and restriction. The base rule states which initial objects belong to the set.
The recursion rule provides methods to construct new set elements from existing ones. The restriction rule ensures that only elements formed by the base and recursion rules are included in the set 165.
- Base: This rule explicitly states certain objects that are members of the set.
- Recursion: This rule defines how to generate new elements for the set using elements already established as members.
- Restriction: This rule clarifies that no other objects are part of the set beyond those generated by the base and recursion rules 165.
Let S be a set defined recursively by: I. BASE: 5∈S. II. RECURSION: If x∈S and y∈S, then x+y∈S.
III. RESTRICTION: S contains no elements other than those obtained from rules I and II. This definition implies that S is the subset of all positive integers divisible by 5 165.
📝 To show that S is a subset of all positive integers divisible by 5:
- Base case: 5∈S is given, and 5 is divisible by 5 (5=5×1).
- Inductive step: Assume x∈S and y∈S. This means x=5p and y=5q for some integers p,q. Then x+y=5p+5q=5(p+q), which shows x+y is divisible by 5. Thus, if x,y∈S, then x+y∈S.
- Conclusion: By the recursive definition, all elements of S are positive integers divisible by 5 165.
22.2 Recursive definition of Boolean expressions
Boolean expressions are defined recursively, starting with basic symbols and then combining them using logical operations. Each symbol from the alphabet is a base Boolean expression.
New expressions are formed by applying logical AND, OR, and NOT operations to existing Boolean expressions 165.
- Base: Each symbol of the alphabet is considered a Boolean expression.
- Recursion: If P and Q are Boolean expressions, then (P∧Q), (P∨Q), and ¬P are also Boolean expressions.
- Restriction: No other expressions are considered Boolean expressions beyond those formed by the base and recursion rules 165.
Show that the following is a Boolean expression over the English alphabet: ((p∨q)∨¬((p∧¬s)∧r)) 166.
📝 To show ((p∨q)∨¬((p∧¬s)∧r)) is a Boolean expression:
- p,q,r,s are Boolean expressions by the base rule.
- ¬s is a Boolean expression by rule II(c) applied to s.
- (p∧¬s) is a Boolean expression by rule II(a) applied to p and ¬s.
- ((p∧¬s)∧r) is a Boolean expression by rule II(a) applied to (p∧¬s) and r.
- ¬((p∧¬s)∧r) is a Boolean expression by rule II(c) applied to ((p∧¬s)∧r).
- (p∨q) is a Boolean expression by rule II(b) applied to p and q.
- ((p∨q)∨¬((p∧¬s)∧r)) is a Boolean expression by rule II(b) applied to (p∨q) and ¬((p∧¬s)∧r) 166.
22.3 Recursive definition of strings over an alphabet
The set of all finite strings over a given alphabet can be defined recursively. The base case is the null string.
New strings are formed by concatenating existing strings with elements of the alphabet 166.
- Base: The null string, denoted ϵ, is in the set of strings.
- Recursion: If s is a string in the set, then sa and sb are also strings in the set, where a and b are elements of the alphabet.
- Restriction: Only strings formed by the base and recursion rules are included 166.
Consider the alphabet Σ={a,b}. The set of all finite strings over Σ is denoted Σ∗ 166.
📝 To show that abb is in Σ∗:
- ϵ∈Σ∗ by the base rule.
- a=ϵa∈Σ∗ by concatenating ϵ with a.
- ab∈Σ∗ by concatenating a with b.
- abb∈Σ∗ by concatenating ab with b 166.
Give a recursive definition of all strings of 0s and 1s for which all the 0s precede all the 1s 167.
- Base: The null string ϵ is in the set.
- Recursion: If s is in the set, then 0s and s1 are also in the set.
- Restriction: No strings are in the set other than those formed by the base and recursion rules 167.
22.4 Parenthesis structure
A set of grammatical parenthesis configurations can be defined recursively. The base case is a single pair of parentheses.
New configurations are formed by enclosing existing configurations in parentheses or by concatenating two existing configurations 167.
- Base: The pair of parentheses () is in the set P.
- Recursion: If E is in P, then (E) is in P. If E and F are in P, then EF is in P.
- Restriction: No parenthesis configurations are in P other than those derived from the base and recursion rules 167.
Derive the fact that ((()))()) is in the set P of grammatical configurations of parentheses 167.
📝 To derive ((()))()) in P:
- () is in P by the base rule.
- (()) is in P by rule II(a) applied to ().
- ((())) is in P by rule II(a) applied to (()).
- () is in P by the base rule.
- ((()))() is in P by rule II(b) applied to ((())) and () 167.
22.5 Set of arithmetic expressions
The set of arithmetic expressions over real numbers is defined recursively. Base expressions are real numbers themselves.
New expressions are formed using arithmetic operations like addition, subtraction, multiplication, and division, applied to existing expressions 167.
- Base: Each real number r is an arithmetic expression.
- Recursion: If u and v are arithmetic expressions, then (+u), (−u), (u+v), (u−v), (u⋅v), and (vu) are also arithmetic expressions.
- Restriction: No arithmetic expressions exist other than those formed by the base and recursion rules 167.
Give derivations showing that the following is an arithmetic expression: ((4−7)⋅6)(9⋅(6.1+2)) 168.
📝 To show ((4−7)⋅6)(9⋅(6.1+2)) is an arithmetic expression:
- 9,6.1,2,4,7,6 are arithmetic expressions by the base rule.
- (6.1+2) is an arithmetic expression by rule II(c) applied to 6.1 and 2.
- (9⋅(6.1+2)) is an arithmetic expression by rule II(e) applied to 9 and (6.1+2).
- (4−7) is an arithmetic expression by rule II(d) applied to 4 and 7.
- ((4−7)⋅6) is an arithmetic expression by rule II(e) applied to (4−7) and 6.
- ((4−7)⋅6)(9⋅(6.1+2)) is an arithmetic expression by rule II(f) applied to (9⋅(6.1+2)) and ((4−7)⋅6) 168.
22.6 Recursive definition of sum
The summation of a sequence of numbers a1,a2,…,an can be defined recursively. The base case is the sum of a single element.
The recursive step defines the sum of n elements in terms of the sum of n−1 elements and the n-th element 168.
- Base: The sum of the first element is ∑i=11ai=a1.
- Recursion: The sum of n elements is ∑i=1nai=(∑i=1n−1ai)+an 168.
22.7 Recursive definition of union of sets
The union of a sequence of sets A1,A2,…,An can be defined recursively. The base case is the first set.
The recursive step defines the union of n sets as the union of the first n−1 sets with the n-th set 168.
- Base: The union of the first set is ⋃i=11Ai=A1.
- Recursion: The union of n sets is ⋃i=1nAi=(⋃i=1n−1Ai)∪An 168.
22.8 Recursive definition of intersection of sets
The intersection of a sequence of sets A1,A2,…,An is defined recursively. The base case is the first set.
The recursive step defines the intersection of n sets as the intersection of the first n−1 sets with the n-th set 169.
- Base: The intersection of the first set is ⋂i=11Ai=A1.
- Recursion: The intersection of n sets is ⋂i=1nAi=(⋂i=1n−1Ai)∩An 169.
23. Mathematical Induction
23.1 Principle of mathematical induction
Mathematical induction is a proof technique used to establish that a statement or formula is true for all positive integers, or for all integers greater than or equal to a specific starting integer. It involves two key steps: a basis step and an inductive step 170.
- Basis step: The proposition must be proven true for the first integer in the sequence, typically n=1.
- Inductive step: If the proposition is assumed to be true for an arbitrary integer k (where k is greater than or equal to the starting integer), it must also be proven true for the next integer, k+1. This is often expressed as: if P(k) is true, then P(k+1) is true 170.
23.2 Proof of the sum of the first n integers
This section demonstrates the principle of mathematical induction to prove the formula for the sum of the first n positive integers 170.
The formula to be proven is: 1+2+3+⋯+n=2n(n+1) 170.
- Basis step: For n=1, the left-hand side (LHS) is 1. The right-hand side (RHS) is 21(1+1)=21(2)=1. Since LHS = RHS, the proposition is true for n=1.
- Inductive step: Assume the formula is true for some integer k≥1, meaning 1+2+⋯+k=2k(k+1).
- To prove it for k+1, consider the sum 1+2+⋯+k+(k+1).
- Substitute the assumed formula for the sum up to k: 2k(k+1)+(k+1).
- Factor out (k+1): (k+1)(2k+1) 170.
- Simplify to 2(k+1)(k+2), which is the formula for n=k+1 171.
📝 Proving 1+2+⋯+n=2n(n+1) for n=3. LHS = 1+2+3=6. RHS = 23(3+1)=23(4)=6.
23.3 Proof of the sum of the first n odd numbers
This section uses mathematical induction to prove the formula for the sum of the first n odd positive integers 171.
The formula to be proven is: 1+3+5+⋯+(2n−1)=n2 171.
- Basis step: For n=1, LHS is 1. RHS is 12=1. The proposition holds for n=1.
- Inductive step: Assume the formula is true for some integer k≥1, so 1+3+⋯+(2k−1)=k2.
- To prove for k+1, consider the sum 1+3+⋯+(2k−1)+[2(k+1)−1].
- This simplifies to k2+(2k+1), using the inductive hypothesis.
- Factoring k2+2k+1 gives (k+1)2, which is the formula for n=k+1 171.
23.4 Proof of the sum of powers of two
This section applies mathematical induction to prove a formula involving powers of two 171.
The formula to be proven is: 1+2+22+⋯+2n=2n+1−1 for all integers n≥0 171.
- Basis step: For n=0, LHS is 1. RHS is 20+1−1=21−1=1. The proposition is true for n=0.
- Inductive step: Assume the formula is true for some integer k≥0, so 1+2+⋯+2k=2k+1−1.
- To prove for k+1, consider the sum 1+2+⋯+2k+2k+1.
- Using the inductive hypothesis, this becomes (2k+1−1)+2k+1.
- This simplifies to 2⋅2k+1−1=2k+2−1, which is the formula for n=k+1 172.
23.5 Proof of the sum of the first n squares
Mathematical induction is used here to prove a formula for the sum of the squares of the first n positive integers 172.
The formula to be proven is: 12+22+32+⋯+n2=6n(n+1)(2n+1) for all integers n≥1 172.
- Basis step: For n=1, LHS is 12=1. RHS is 61(1+1)(2(1)+1)=61(2)(3)=1. The proposition holds for n=1.
- Inductive step: Assume the formula is true for some integer k≥1, so 12+⋯+k2=6k(k+1)(2k+1) 172.
- To prove for k+1, consider the sum 12+⋯+k2+(k+1)2.
- Substitute the inductive hypothesis: 6k(k+1)(2k+1)+(k+1)2.
- Combine terms by finding a common denominator: 6k(k+1)(2k+1)+6(k+1)2.
- Factor out (k+1): 6(k+1)[k(2k+1)+6(k+1)].
- Simplify the expression in the brackets: 6(k+1)(2k2+k+6k+6)=6(k+1)(2k2+7k+6).
- Factor the quadratic: 6(k+1)(k+2)(2k+3). This matches the formula for n=k+1 173.
23.6 Proof of a sum involving fractions
This section demonstrates the use of mathematical induction to prove a formula for a sum of fractions 173.
The formula to be proven is: 1⋅21+2⋅31+⋯+n(n+1)1=n+1n for all integers n≥1 173.
- Basis step: For n=1, LHS is 1⋅21=21. RHS is 1+11=21. The proposition holds for n=1.
- Inductive step: Assume the formula is true for some integer k≥1, so 1⋅21+⋯+k(k+1)1=k+1k 173.
- To prove for k+1, consider the sum 1⋅21+⋯+k(k+1)1+(k+1)(k+2)1.
- Substitute the inductive hypothesis: k+1k+(k+1)(k+2)1.
- Combine terms with a common denominator: (k+1)(k+2)k(k+2)+1.
- Simplify the numerator: (k+1)(k+2)k2+2k+1=(k+1)(k+2)(k+1)2.
- This simplifies to k+2k+1, which is the formula for n=k+1 174.
23.7 Proof of a sum involving i * 2^i
This section uses mathematical induction to prove a summation formula involving terms of the form i⋅2i 174.
The formula to be proven is: ∑i=1n+1i⋅2i=n⋅2n+2+2 for all integers n≥0 174.
- Basis step: For n=0, LHS is ∑i=10+1i⋅2i=1⋅21=2. RHS is 0⋅20+2+2=0⋅22+2=0+2=2. The proposition holds for n=0.
- Inductive step: Assume the formula is true for some integer k≥0, so ∑i=1k+1i⋅2i=k⋅2k+2+2 174.
- To prove for k+1, consider the sum ∑i=1k+2i⋅2i.
- This can be written as (∑i=1k+1i⋅2i)+(k+2)⋅2k+2.
- Substitute the inductive hypothesis: (k⋅2k+2+2)+(k+2)⋅2k+2.
- Combine terms: (k+k+2)⋅2k+2+2=(2k+2)⋅2k+2+2.
- Simplify: 2(k+1)⋅2k+2+2=(k+1)⋅2k+3+2. This matches the formula for n=k+1 175.
23.8 Proof of a product involving (1 - 1/k^2)
This section uses mathematical induction to prove a formula for a product of terms of the form (1−1/k2) 175.
The formula to be proven is: (1−221)⋅(1−321)⋯(1−n21)=2nn+1 for all integers n≥2 175.
- Basis step: For n=2, LHS is 1−221=1−41=43. RHS is 2(2)2+1=43. The proposition holds for n=2.
- Inductive step: Assume the formula is true for some integer k≥2, so (1−221)⋯(1−k21)=2kk+1 175.
- To prove for k+1, consider the product (1−221)⋯(1−k21)(1−(k+1)21).
- Substitute the inductive hypothesis: 2kk+1(1−(k+1)21).
- Simplify the term in parentheses: 2kk+1((k+1)2(k+1)2−1).
- Further simplification yields: 2kk+1((k+1)2k2+2k)=2kk+1((k+1)2k(k+2)).
- This reduces to 2(k+1)k+2, which is the formula for n=k+1 176.
23.9 Proof of a sum involving i(i!)
This section uses mathematical induction to prove a formula for the sum of terms i(i!) 176.
The formula to be proven is: ∑i=1ni(i!)=(n+1)!−1 for all integers n≥1 176.
- Basis step: For n=1, LHS is 1(1!)=1. RHS is (1+1)!−1=2!−1=2−1=1. The proposition holds for n=1.
- Inductive step: Assume the formula is true for some integer k≥1, so ∑i=1ki(i!)=(k+1)!−1 176.
- To prove for k+1, consider the sum ∑i=1k+1i(i!).
- This can be written as (∑i=1ki(i!))+(k+1)(k+1)!.
- Substitute the inductive hypothesis: ((k+1)!−1)+(k+1)(k+1)!.
- Rearrange and factor: (k+1)!+(k+1)(k+1)!−1=[1+(k+1)](k+1)!−1.
- Simplify: (k+2)(k+1)!−1=(k+2)!−1, which is the formula for n=k+1 177.
23.10 Generalization of DeMorgan's Law
This section proves a generalized version of DeMorgan's Law for set complements using mathematical induction 177.
The generalized DeMorgan's Law to be proven is: ⋂j=1nAjc=(⋃j=1nAj)c where Aj are subsets of a universal set U, for n≥2 177.
- Basis step: For n=2, LHS is A1c∩A2c. By DeMorgan's Law, this equals (A1∪A2)c, which is the RHS. The proposition holds for n=2.
- Inductive step: Assume the law is true for some integer k≥2, so ⋂j=1kAjc=(⋃j=1kAj)c 177.
- To prove for k+1, consider the intersection ⋂j=1k+1Ajc.
- This can be written as (⋂j=1kAjc)∩Ak+1c.
- Substitute the inductive hypothesis: (⋃j=1kAj)c∩Ak+1c.
- Applying DeMorgan's Law again, this becomes ((⋃j=1kAj)∪Ak+1)c.
- This simplifies to (⋃j=1k+1Aj)c, which is the formula for n=k+1 178.
24. Mathematical Induction for Divisibility
24.1 Divisibility proofs
Mathematical induction is used to prove statements about divisibility for all positive integers. The process involves a basis step and an inductive step.
The basis step verifies the statement for the smallest integer (usually n=1). The inductive step assumes the statement is true for an arbitrary integer k and then proves it is also true for k+1 179.
-
Divisibility definition: An integer n is divisible by an integer d (where d=0), written as d∣n, if there exists an integer k such that n=d⋅k. This means n is a multiple of d, or d is a divisor or factor of n 179.
-
Proof of n3−n divisible by 3:
-
Basis Step (n=1): 13−1=0, which is divisible by 3 (0=0⋅3).
-
Inductive Step: Assume k3−k is divisible by 3 for some positive integer k, so k3−k=3q for some integer q.
-
Prove for k+1: (k+1)3−(k+1)=(k3+3k2+3k+1)−(k+1)=k3+3k2+2k=(k3−k)+3k2+3k=3q+3k2+3k=3(q+k2+k). This shows (k+1)3−(k+1) is divisible by 3 179.
-
Proof of 22n−1 divisible by 3:
-
Basis Step (n=1): 22(1)−1=4−1=3, which is divisible by 3.
-
Inductive Step: Assume 22k−1=3q for some integer q.
-
Prove for k+1: 22(k+1)−1=22k+2−1=22k⋅22−1=4⋅22k−1=4(3q+1)−1=12q+4−1=12q+3=3(4q+1). This shows 22(k+1)−1 is divisible by 3 180.
-
Proof of the product of two consecutive positive integers divisible by 2:
-
Basis Step (n=1): 1(1+1)=2, which is divisible by 2.
-
Inductive Step: Assume k(k+1)=2q for some integer q.
-
Prove for k+1: (k+1)(k+1+1)=(k+1)(k+2)=k(k+1)+2(k+1)=2q+2(k+1)=2(q+k+1). This shows (k+1)(k+2) is divisible by 2 180.
-
Proof of n3−n divisible by 6:
-
Basis Step (n=2): 23−2=8−2=6, which is divisible by 6.
-
Inductive Step: Assume k3−k=6q for some integer q.
-
Prove for k+1: (k+1)3−(k+1)=(k3−k)+3k(k+1). Since k(k+1) is the product of two consecutive integers, it is even, so k(k+1)=2r for some integer r. Thus, (k+1)3−(k+1)=6q+3(2r)=6q+6r=6(q+r). This shows (k+1)3−(k+1) is divisible by 6 181.
-
Proof of xn−yn divisible by x−y:
-
Basis Step (n=1): x1−y1=x−y, which is divisible by x−y 181.
-
Inductive Step: Assume xk−yk is divisible by x−y.
-
Prove for k+1: xk+1−yk+1=x⋅xk−y⋅yk=x⋅xk−x⋅yk+x⋅yk−y⋅yk=x(xk−yk)+yk(x−y). Both terms are divisible by x−y (the first by the inductive hypothesis, the second by the factor x−y). Therefore, xk+1−yk+1 is divisible by x−y 182.
📝 For n=1, n3−n=13−1=0, which is divisible by 3 179.
24.2 Proving an inequality
Mathematical induction can also be used to prove inequalities for integers. The steps are similar: establish the basis case and then prove the inductive step 182.
-
Proof of 2n+1<2n for n≥3:
-
Basis Step (n=3): 2(3)+1=7 and 23=8. Since 7<8, the statement is true for n=3.
-
Inductive Step: Assume 2k+1<2k for some integer k≥3.
-
Prove for k+1: 2(k+1)+1=2k+2+1=(2k+1)+2. By the inductive hypothesis, (2k+1)+2<2k+2. Since k≥3, 2<2k. Thus, 2k+2<2k+2k=2⋅2k=2k+1. Therefore, 2(k+1)+1<2k+1 182.
-
Proof of 1+nx≤(1+x)n for x>−1 and n≥2:
-
Basis Step (n=2): 1+2x≤(1+x)2=1+2x+x2. Since x2≥0, this inequality holds 182.
-
Inductive Step: Assume 1+kx≤(1+x)k for some integer k≥2.
-
Prove for k+1: Multiply both sides of the inductive hypothesis by (1+x) (which is positive since x>−1): (1+x)(1+kx)≤(1+x)k+1. Expanding the left side gives 1+kx+x+kx2=1+(k+1)x+kx2. Since k≥2 and x2≥0, kx2≥0. Thus, 1+(k+1)x≤1+(k+1)x+kx2≤(1+x)k+1. Therefore, 1+(k+1)x≤(1+x)k+1 183.
-
Proof of ∑i=1ni21<2−n1 for n>1:
-
Basis Step (n=2): LHS = 1+41=45=1.25. RHS = 2−21=23=1.5. Since 1.25<1.5, the statement is true for n=2 184.
-
Inductive Step: Assume ∑i=1ki21<2−k1 for some integer k>1.
-
Prove for k+1: ∑i=1k+1i21=(∑i=1ki21)+(k+1)21. By the inductive hypothesis, this is less than (2−k1)+(k+1)21. We need to show that 2−k1+(k+1)21≤2−k+11. This simplifies to showing k1−(k+1)21≥k+11. Rearranging gives k1−k+11≥(k+1)21, which is k(k+1)k+1−k≥(k+1)21, or k(k+1)1≥(k+1)21. This inequality holds because k(k+1)<(k+1)2 for k>1. Thus, ∑i=1k+1i21<2−k+11 185.
24.3 Proving properties of sequences
Mathematical induction is used to prove formulas for terms of recursively defined sequences 183.
-
Sequence an defined by a1=2 and ak=5ak−1 for k≥2:
-
Prove an=2⋅5n−1 for n≥1.
-
Basis Step (n=1): a1=2⋅51−1=2⋅50=2⋅1=2, which matches the definition.
-
Inductive Step: Assume ak=2⋅5k−1 for some integer k≥1.
-
Prove for k+1: ak+1=5ak (by definition). Substituting the inductive hypothesis: ak+1=5(2⋅5k−1)=2⋅(5⋅5k−1)=2⋅5k=2⋅5(k+1)−1. This matches the formula for n=k+1 183.
-
Sequence dn defined by d1=2 and dk=kdk−1 for k≥2:
-
Prove dn=n!2 for n≥1.
-
Basis Step (n=1): d1=1!2=12=2, which matches the definition.
-
Inductive Step: Assume dk=k!2 for some integer k≥1.
-
Prove for k+1: dk+1=k+1dk (by definition). Substituting the inductive hypothesis: dk+1=k+12/k!=(k+1)k!2=(k+1)!2. This matches the formula for n=k+1 184.
25. Methods of proof
25.1 Direct proof
A direct proof demonstrates that if a premise p is true, then a conclusion q must also be true. This method establishes that the scenario where p is true and q is false never occurs 186.
The core idea of a direct proof is to start with the assumption that the hypothesis is true and logically derive the conclusion. This is often done by using definitions, axioms, and previously proven theorems 186.
25.2 Basics for proofs
- Even integer: An integer n is even if n=2k for some integer k.
- Odd integer: An integer n is odd if n=2k+1 for some integer k.
- Prime integer: An integer n>1 is prime if its only positive integer divisors are 1 and itself.
- Composite integer: An integer n>1 is composite if it can be expressed as a product of two positive integers r and s, where r=1 and s=1.
- Rational number: A real number r is rational if r=ba for some integers a and b, with b=0.
- Divisibility: For integers n and d with d=0, d divides n (written d∣n) if n=d⋅k for some integer k.
- Perfect square: An integer n is a perfect square if n=k2 for some integer k 187.
25.3 Examples of direct proofs
- Sum of two odd integers is even: Let m and n be odd integers. Then m=2k+1 and n=2l+1 for some integers k,l. m+n=(2k+1)+(2l+1)=2k+2l+2=2(k+l+1).
Since k+l+1 is an integer, m+n is even 187.
-
Even integer raised to any power is even: If n is an even integer, then n=2k for some integer k. (−1)n=(−1)2k=[(−1)2]k=1k=1 187.
-
Product of an even and an odd integer is even: Let m be even (m=2k) and n be odd (n=2l+1). m⋅n=(2k)(2l+1)=2[k(2l+1)]. Since k(2l+1) is an integer, m⋅n is even 187.
-
Square of an even integer is even: If n is an even integer, n=2k. n2=(2k)2=4k2=2(2k2). Since 2k2 is an integer, n2 is even 188.
-
If n is odd, then n3+n is even: Let n be odd, so n=2k+1. n3+n=n(n2+1)=(2k+1)((2k+1)2+1)=(2k+1)(4k2+4k+1+1)=(2k+1)(4k2+4k+2)=2(2k+1)(2k2+2k+1). Since (2k+1)(2k2+2k+1) is an integer, n3+n is even 188.
-
If the sum of two integers is even, their difference is also even: Suppose m+n=2k for some integer k. Then m=2k−n. m−n=(2k−n)−n=2k−2n=2(k−n).
Since k−n is an integer, m−n is even 188.
-
Sum of two rational numbers is rational: Let r=ba and s=dc be rational numbers (b,d=0). r+s=ba+dc=bdad+bc. Since ad+bc and bd are integers, and bd=0, r+s is rational 188 189.
-
Existence of a rational number between two distinct rationals: Given distinct rationals r<s. Consider x=2r+s.
Since r<s, adding r to both sides gives 2r<r+s, so r<2r+s. Adding s to both sides gives r+s<2s, so 2r+s<s.
Thus, r<x<s. The sum of two rationals is rational, and dividing by 2 (a non-zero rational) results in a rational number 189.
- Transitivity of divisibility: If a∣b and b∣c, then a∣c. If a∣b, then b=a⋅r for some integer r. If b∣c, then c=b⋅s for some integer s.
Substituting b, we get c=(a⋅r)⋅s=a⋅(r⋅s). Since r⋅s is an integer, a∣c 189.
- If a∣b and a∣c, then a∣(b+c): If a∣b, then b=a⋅r for some integer r. If a∣c, then c=a⋅s for some integer s. b+c=a⋅r+a⋅s=a(r+s).
Since r+s is an integer, a∣(b+c) 190.
- Sum of three consecutive integers is divisible by 3: Let the integers be n,n+1,n+2. Their sum is n+(n+1)+(n+2)=3n+3=3(n+1).
Since n+1 is an integer, the sum is divisible by 3 190.
-
Existence of an integer n>5 such that 2n−1 is prime: Let n=7. Then 2n−1=2(7)−1=14−1=13. 13 is a prime number 190.
-
Existence of real numbers a and b such that a+b=a+b: Squaring both sides: a+b=(a+b)2=a+b+2ab. This simplifies to 0=2ab, which implies ab=0.
This means either a=0 or b=0. Let a=0 and b=3.
Then 0+3=3 and 0+3=0+3=3. The condition is satisfied 190 191.
25.4 Disproof by counterexample
A counterexample is used to disprove a universal statement ("for all"). If a statement claims something is true for all cases, finding just one case where it is false is sufficient to disprove it 191.
25.5 Examples of disproof by counterexample
- Statement: For all real numbers a and b, if a<b, then a2<b2. Counterexample: Let a=−5 and b=−2. Here, −5<−2.
However, a2=(−5)2=25 and b2=(−2)2=4. Since 25>4, the statement a2<b2 is false 191.
-
Statement: For all integers n, n2−n+11 is a prime number. Counterexample: Let n=11. n2−n+11=(11)2−11+11=121. 121=11×11, which is not a prime number 191.
-
Statement: The product of any two irrational numbers is an irrational number. Counterexample: Let the irrational number be 2. Consider the product (2)⋅(2)=(2)2=2.
The result, 2, is a rational number 191.
- Proposition: For every prime number n, n+2 is prime. Counterexample: Let n=7 (a prime number). Then n+2=7+2=9.
The number 9 is not prime (9=3×3) 192.
26. Proof by Contradiction
26.1 Proof by contradiction
A proof by contradiction, also known as reductio ad absurdum, is a method of proof that relies on showing that an assumption leads logically to an impossibility or absurdity. If the supposition that a statement is false leads to a contradiction, then the original statement must be true.
This method is particularly useful for proving conditional statements of the form p→q. The negation of p→q is p∧¬q.
To prove p→q by contradiction, one assumes p∧¬q is true and derives a contradiction.
The general steps for a proof by contradiction are:
- Assume the statement to be proved is false. This is the initial supposition.
- Show that this supposition leads logically to a contradiction. This involves a series of logical deductions.
- Conclude that the statement to be proved is true. Since the supposition led to an absurdity, it must be incorrect.
26.2 No greatest integer
- Supposition: Assume there exists a greatest integer, denoted by N.
- Construction: Consider the integer M=N+1.
- Contradiction: Since M is the sum of two integers, it is also an integer. Furthermore, M>N because M=N+1. This means M is an integer greater than the supposed greatest integer N, which is a contradiction 193.
📝 Assume there exists a greatest integer, denoted by N. Consider the integer M=N+1. Since M is the sum of two integers, it is also an integer. Furthermore, M>N, which contradicts the assumption that N is the greatest integer 193.
26.3 If n2 is even, then n is even
- Statement: If n2 is an even integer, then n is an even integer.
- Supposition: Assume n2 is even and n is not even (i.e., n is odd).
- Deduction: If n is odd, then n=2k+1 for some integer k. Squaring n gives n2=(2k+1)2=4k2+4k+1=2(2k2+2k)+1.
- Contradiction: This shows n2 is odd, which contradicts the initial supposition that n2 is even. Therefore, the original statement is true 193.
26.4 If n3+5 is odd, then n is even
- Statement: If n is an integer and n3+5 is odd, then n is even.
- Supposition: Assume n3+5 is odd and n is odd.
- Deduction: If n is odd, then n2 is odd (product of two odds) and n3 is odd (odd times odd). The difference between two odd numbers is even.
- Contradiction: Consider 5=(n3+5)−n3. Since n3+5 is odd and n3 is odd, their difference, 5, must be even. This contradicts the fact that 5 is odd. Therefore, the supposition is wrong, and the statement is true 194.
26.5 If n and m are odd integers, then n+m is even
- Statement: If n and m are odd integers, then n+m is an even integer.
- Supposition: Assume n and m are odd, and n+m is odd.
- Deduction: If n is odd, n=2p+1 for some integer p. If m is odd, m=2q+1 for some integer q.
- Contradiction: Then n+m=(2p+1)+(2q+1)=2p+2q+2=2(p+q+1). This result is even, contradicting the assumption that n+m is odd. Thus, the statement is true 194.
26.6 Sum of a rational and an irrational number
- Statement: The sum of any rational number and any irrational number is irrational.
- Supposition: Suppose there exists a rational number r and an irrational number s such that their sum, r+s, is rational.
- Deduction: Let r=ba and r+s=dc, where a,b,c,d are integers, b=0, and d=0.
- Contradiction: Rearranging the equation r+s=dc gives s=dc−r=dc−ba=bdbc−ad. Since a,b,c,d are integers, bc−ad and bd are integers, and bd=0. This implies s is rational, which contradicts the supposition that s is irrational. Therefore, the statement is true 194.
26.7 2 is irrational
- Statement: 2 is irrational.
- Supposition: Assume 2 is rational. Then 2=nm for integers m and n with no common factors.
- Deduction: Squaring both sides gives 2=n2m2, so m2=2n2. This implies m2 is even, which means m must be even. Let m=2k for some integer k.
- Contradiction: Substituting m=2k into m2=2n2 gives (2k)2=2n2, so 4k2=2n2, which simplifies to n2=2k2. This implies n2 is even, so n must also be even. If both m and n are even, they share a common factor of 2, contradicting the initial supposition that m and n have no common factors. Therefore, 2 is irrational 195.
📝 Assume 2 is rational, so 2=nm where m and n have no common factors. Squaring both sides gives m2=2n2, implying m2 is even, so m is even. Let m=2k. Then (2k)2=2n2, so 4k2=2n2, which simplifies to n2=2k2. This implies n2 is even, so n is also even. Both m and n being even contradicts the assumption that they have no common factors 195.
26.8 6−72 is irrational
- Statement: 6−72 is irrational.
- Supposition: Assume 6−72 is rational. Then 6−72=ba for integers a and b with b=0.
- Deduction: Rearranging the equation gives 72=6−ba=b6b−a.
- Contradiction: Since a and b are integers, 6b−a and b are integers, and b=0. This implies 72 is rational. However, it is known that 2 is irrational, and operations involving it typically result in irrational numbers. The statement implies that 72 is rational, which contradicts the known irrationality of 2 and related expressions. Therefore, 6−72 is irrational 196.
26.9 If p∣a, then p∤(a+1)
- Statement: For any integer a and prime p, if p∣a, then p∤(a+1).
- Supposition: Suppose there exists an integer a and a prime p such that p∣a and p∣(a+1).
- Deduction: If p∣a, then a=pr for some integer r. If p∣(a+1), then a+1=ps for some integer s.
- Contradiction: Subtracting the first equation from the second gives (a+1)−a=ps−pr, which simplifies to 1=p(s−r). This implies p divides 1. Since p is a prime number, p>1. The only divisors of 1 are 1 and -1. Thus, p cannot divide 1, which is a contradiction. Therefore, the statement is true 196.
26.10 2+3 is irrational
- Statement: 2+3 is irrational.
- Supposition: Assume 2+3 is rational. Then 2+3=ba for integers a and b with b=0.
- Deduction: Squaring both sides gives (2+3)2=(ba)2, which expands to 2+3+26=b2a2. This simplifies to 5+26=b2a2, so 26=b2a2−5=b2a2−5b2.
- Contradiction: This implies 6=2b2a2−5b2. Since a and b are integers, a2−5b2 and 2b2 are integers, and 2b2=0. This means 6 is rational. However, 6 is known to be irrational. This contradiction shows that the initial supposition is false, and 2+3 is irrational 197.
26.11 The set of prime numbers is infinite
- Statement: The set of prime numbers is infinite.
- Supposition: Assume the set of prime numbers is finite. Let the primes be p1,p2,…,pn.
- Construction: Consider the integer N=p1⋅p2⋅⋯⋅pn+1.
- Contradiction: Since N>1, it must be divisible by some prime number, say p. This prime p must be one of p1,p2,…,pn because we assumed these are all the primes. If p divides the product p1⋅p2⋅⋯⋅pn, and p also divides N, then p must divide their difference, which is N−(p1⋅p2⋅⋯⋅pn)=1. However, no prime number can divide 1. This is a contradiction. Therefore, the set of prime numbers must be infinite 197.
26.12 Proof by contraposition
Proof by contraposition is a method that leverages the logical equivalence between a conditional statement and its contrapositive. The statement "if p then q" (p→q) is logically equivalent to "if not q then not p" (¬q→¬p).
To prove a statement using contraposition, one proves its contrapositive directly.
The steps for proof by contraposition are:
- Express the statement in the form "if p then q."
- Rewrite the statement in its contrapositive form: "if not q then not p."
- Prove the contrapositive statement directly.
26.13 If n2 is even, then n is even
- Statement: For all integers n, if n2 is even, then n is even.
- Contrapositive: If n is not even (i.e., odd), then n2 is not even (i.e., odd).
- Direct Proof of Contrapositive: Assume n is odd. Then n=2k+1 for some integer k. Squaring n gives n2=(2k+1)2=4k2+4k+1=2(2k2+2k)+1. This shows n2 is odd. Since the contrapositive is true, the original statement is true 198.
26.14 If 3n+2 is odd, then n is odd
- Statement: If 3n+2 is odd, then n is odd.
- Contrapositive: If n is not odd (i.e., even), then 3n+2 is not odd (i.e., even).
- Direct Proof of Contrapositive: Assume n is even. Then n=2k for some integer k. Substituting into the expression gives 3n+2=3(2k)+2=6k+2=2(3k+1). This shows 3n+2 is even. Since the contrapositive is true, the original statement is true 198.
26.15 If n3+5 is odd, then n is even
- Statement: If n is an integer and n3+5 is odd, then n is even.
- Contrapositive: If n is not even (i.e., odd), then n3+5 is not odd (i.e., even).
- Direct Proof of Contrapositive: Assume n is odd. The product of two odd integers is odd, so n2=n⋅n is odd. Similarly, n3=n2⋅n is odd. The sum of two odd integers is even, so n3+5 is even. Since the contrapositive is true, the original statement is true 199.
26.16 If n2 is not divisible by 25, then n is not divisible by 5
- Statement: If n2 is not divisible by 25, then n is not divisible by 5.
- Contrapositive: If n is divisible by 5, then n2 is divisible by 25.
- Direct Proof of Contrapositive: Assume n is divisible by 5. Then n=5k for some integer k. Squaring both sides gives n2=(5k)2=25k2. Since k2 is an integer, n2 is divisible by 25. The contrapositive is true, so the original statement is true 199.
26.17 If ∣x∣>1, then x>1 or x<−1
- Statement: For all x∈R, if ∣x∣>1, then x>1 or x<−1.
- Contrapositive: If it is not the case that (x>1 or x<−1), then it is not the case that ∣x∣>1. This simplifies to: If −1≤x≤1, then ∣x∣≤1.
- Direct Proof of Contrapositive: Assume −1≤x≤1. This inequality directly implies that the absolute value of x, ∣x∣, is less than or equal to 1. Thus, ∣x∣≤1. The contrapositive is true, so the original statement is true 199.
26.18 If m+n is even, then m and n are both even or both odd
- Statement: For all integers m and n, if m+n is even, then m and n are both even or m and n are both odd.
- Contrapositive: For all integers m and n, if m and n are not both even and not both odd (i.e., one is even and the other is odd), then m+n is not even (i.e., odd).
- Direct Proof of Contrapositive: Suppose one integer is even and the other is odd.
- Case 1: m is even and n is odd. Then m=2p and n=2q+1 for integers p,q. Their sum is m+n=2p+(2q+1)=2(p+q)+1, which is odd.
- Case 2: m is odd and n is even. Then m=2p+1 and n=2q for integers p,q. Their sum is m+n=(2p+1)+2q=2(p+q)+1, which is odd. In both cases, if one integer is even and the other is odd, their sum is odd. The contrapositive is true, so the original statement is true 200.
27. Algorithm
27.1 Algorithm definition
An algorithm is a step-by-step method for performing a task. A computer program is a specific instance of an algorithm written in a particular programming language.
Formal descriptions of algorithms typically include their name, input/output variables, a description of their operation, data types, and explanatory comments 201.
- Input/output variables: Algorithms are described with lists of input and output variables, specifying their data types.
- Algorithm body: This section contains the executable statements and explanatory comments that define the algorithm's logic.
- End statement: A formal algorithm concludes with an end statement 201.
27.2 The division algorithm
The Quotient-Remainder Theorem states that for any integer n and positive integer d, there exist unique integers q (quotient) and r (remainder) such that n=d⋅q+r and 0≤r<d. The division algorithm finds these unique integers by repeatedly subtracting the divisor d from the dividend n until the result is less than d but still nonnegative 201.
- Example of quotient-remainder theorem: For n=54 and d=4, 54=4⋅13+2, so q=13 and r=2.
- Example with negative dividend: For n=−54 and d=4, −54=4⋅(−14)+2, so q=−14 and r=2.
- Example with dividend smaller than divisor: For n=54 and d=70, 54=70⋅0+54, so q=0 and r=54 201.
27.3 Tracing the division algorithm
Tracing the division algorithm with a=54 and d=11 shows how the variables a, d, r, and q change through each iteration. Initially, r=a=54 and q=0.
In each step, d is subtracted from r, and q is incremented, until r becomes less than d 202.
| Variable | Iteration Number |
|---|---|
| a | 54 |
| d | 11 |
| r | 54 |
| r | 43 |
| r | 32 |
| r | 21 |
| r | 10 |
| q | 0 |
| q | 1 |
| q | 2 |
| q | 3 |
| q | 4 |
27.4 Predicates
A predicate is a sentence containing variables that becomes a statement when specific values are substituted for those variables. The set of all possible values for a predicate variable is called its domain 202.
- Predicate symbol: A predicate symbol represents a property or relation, such as P for "is a student at the Virtual University" or Q for "is a student at.".
- Predicate notation: Predicates with variables are symbolized as P(x) or Q(x,y), where x and y are predicate variables 202.
27.5 Pre-conditions and post-conditions
Pre-conditions and post-conditions are predicates that describe the initial and final states of an algorithm, respectively. The pre-condition specifies the state before the algorithm begins, while the post-condition specifies the desired state upon completion 203.
| Algorithm | Pre-condition | Post-condition |
|---|---|---|
| Compute product of two nonnegative integers | Input variables m and n are nonnegative integers. | Output variable p equals m · n. |
| Find quotient and remainder of division | Input variables a and b are positive integers. | Output variables q and r are positive integers such that a = b · q + r and 0 ≤ r < b. |
| Sort a one-dimensional array | Input variable A,..., A[n is an array of real numbers. | Output variable B1,..., B[n is an array with the same elements as A, sorted such that B[i ≤ B[j whenever i ≤ j. |
- Division algorithm conditions: For the division algorithm, the pre-condition is that a is a nonnegative integer, d is a positive integer, r=a, and q=0. The post-condition is that q and r are nonnegative integers satisfying a=q⋅d+r and 0≤r<d 203.
27.6 Loop invariants
Loop invariants are used to prove the correctness of loops within algorithms, based on the principle of mathematical induction. A loop is considered correct if its pre- and post-conditions are met whenever the algorithm variables satisfy the pre-condition and the loop executes 203.
- Loop definition: A loop is correct if, starting from a state satisfying the pre-condition, its execution results in a state satisfying the post-condition 203.
27.7 Loop invariant theorem
The loop invariant theorem provides four properties that, if true, guarantee a while loop's correctness with respect to its pre- and post-conditions. These properties ensure that the loop invariant holds initially, is maintained through iterations, eventually terminates, and leads to the correct post-condition 204.
| Property | Description |
|---|---|
| I. Basis Property | The loop pre-condition implies that the loop invariant I is true before the first iteration. |
| II. Inductive Property | If the guard G and loop invariant I(k) are true before an iteration, then I(k + 1) is true after the iteration. |
| III. Eventual Falsity of Guard | After a finite number of iterations, the loop's guard condition G becomes false. |
| IV. Correctness of the Post-Condition | If N is the minimum number of iterations after which G is false and I(N) is true, then the algorithm variables satisfy the post-condition. |
- Proof of theorem: Properties I and II establish that I(n) is true for any number of iterations n. Property III ensures termination, and Property IV confirms that the resulting state matches the post-condition 204.
📝 Consider an algorithm to find the sum of the first n positive integers.
- Pre-condition: n is a positive integer.
- Post-condition: The output variable S equals ∑i=1ni.
- Loop Invariant I(k): Before the k-th iteration, S=∑i=1k−1i and the loop counter is k.
- Basis Property: Before the first iteration (k=0), S=0 and the counter is 1. This matches the invariant if we consider the sum of zero terms to be zero.
- Inductive Property: If S=∑i=1k−1i and the counter is k before an iteration, then after adding k to S and incrementing the counter to k+1, we have S=∑i=1ki and the counter is k+1.
- Eventual Falsity of Guard: The loop continues as long as the counter k≤n. After n iterations, the counter becomes n+1, making the guard false.
- Correctness of Post-Condition: After N=n iterations, the invariant I(n+1) implies S=∑i=1ni, which matches the post-condition 203 204.
28. Division algorithm
28.1 A loop to compute a product
This section describes a loop designed to compute the product of a real number x and a nonnegative integer m. The loop iteratively adds x to a running product and increments a counter i until i reaches m.
The correctness of this loop is established using a loop invariant 205.
The loop invariant I(n) states that at the beginning of each iteration, i is equal to n and product is equal to n * x 205.
- Basis Property:
I(0)is true before the first iteration, meaningi = 0andproduct = 0 * x = 0. - Inductive Property: If
I(k)is true before an iteration, thenI(k+1)is true after the iteration. This is shown by updatingproducttoproduct_old + xanditoi_old + 1, resulting inproduct = (k+1) * xandi = k+1. - Eventual Falsity of Guard: The loop guard
i!= mwill eventually become false after a finite number of iterations. - Correctness of Post-Condition: When the guard is false and the invariant
I(N)holds, the post-conditionproduct = m * xis satisfied 205.
📝 If
m = 3andx = 5, the loop will execute as follows:
- Initial:
i = 0,product = 0- Iteration 1:
product = 0 + 5 = 5,i = 1- Iteration 2:
product = 5 + 5 = 10,i = 2- Iteration 3:
product = 10 + 5 = 15,i = 3The loop terminates, and the post-conditionproduct = 3 * 5 = 15is met 205.
28.2 The division algorithm
The division algorithm describes how to find a quotient q and a remainder r when a nonnegative integer a is divided by a positive integer d. The algorithm repeatedly subtracts d from a (stored in r) and increments q until r is less than d.
This process guarantees that a = q * d + r and 0 <= r < d 206.
The loop invariant I(n) for this algorithm is r = a - n * d and n = q 206.
- Basis Property:
I(0)is true initially, withr = aandq = 0. - Inductive Property: If
I(k)holds, then after one iteration,rbecomesa - (k+1) * dandqbecomesk+1, satisfyingI(k+1). The conditionr >= 0is maintained becauser_new = r - d >= d - d = 0. - Eventual Falsity of Guard: The guard
r >= dwill eventually become false. - Correctness of Post-Condition: When the guard is false,
r < d, and the invariantI(N)holds, the post-conditiona = q * d + rwith0 <= r < dis met 206.
28.3 The Euclidean algorithm
The Euclidean algorithm is used to find the greatest common divisor (gcd) of two integers A and B, where A > B >= 0. It leverages the property that gcd(a, b) = gcd(b, r), where r is the remainder when a is divided by b.
The algorithm repeatedly applies the division algorithm until the remainder is 0. The last non-zero remainder is the gcd 207.
The algorithm proceeds as follows:
- Divide
abybto geta = q * b + r. - Replace
awithbandbwithr. - Repeat until
bis 0. The gcd is the value ofaat this point 207.
📝 To find gcd(330, 156):
- 330 = 156 * 2 + 18
- 156 = 18 * 8 + 12
- 18 = 12 * 1 + 6
- 12 = 6 * 2 + 0 The last non-zero remainder is 6, so gcd(330, 156) = 6 207.
The loop invariant for the Euclidean algorithm is gcd(a, b) = gcd(A, B) and 0 <= b < a 208.
- Basis Property:
I(0)is true initially, withgcd(a, b) = gcd(A, B)and0 <= B < A. - Inductive Property: If
I(k)holds, then after one iteration,gcd(a_new, b_new) = gcd(b_old, r_new) = gcd(a_old, b_old) = gcd(A, B), and0 <= b_new < a_newis maintained 208. - Eventual Falsity of Guard: The guard
b!= 0will eventually become false. - Correctness of Post-Condition: When the guard is false (
b = 0) andI(N)holds,acontainsgcd(A, B)209.
29. Combinatorics
29.1 The sum rule
Combinatorics is the branch of mathematics concerned with counting and arranging objects. The sum rule applies when there are distinct choices for an event, and you want to find the total number of ways one of these choices can occur.
If one event can occur in n1 ways and a second, mutually exclusive event can occur in n2 ways, then exactly one of the events can occur in n1+n2 ways 210.
- Generalized sum rule: If there are m mutually exclusive events, and the first can occur in n1 ways, the second in n2 ways,..., and the m-th in nm ways, then exactly one of these events can occur in n1+n2+⋯+nm ways.
- Sum rule in terms of sets: For finite disjoint sets A1,A2,…,Am, the number of elements in their union is the sum of the number of elements in each set: n(A1∪A2∪⋯∪Am)=n(A1)+n(A2)+⋯+n(Am) 211.
📝 A student can choose a computer project from one of three lists containing 23, 15, and 19 projects, respectively. The total number of possible projects to choose from is 23+15+19=57 210.
29.2 The product rule
The product rule is used when a procedure consists of a sequence of events, and the number of ways each event can occur is independent of the choices made in previous events. If one event can occur in n1 ways, and for each of these ways, a second event can occur in n2 ways, then both events can occur in n1×n2 ways 211.
- Generalized product rule: If a sequence of k events can occur in n1,n2,…,nk ways, respectively, then the total number of ways all events can occur in the specified order is n1×n2×⋯×nk.
- Product rule in terms of sets: For finite sets A1,A2,…,Am, the number of elements in their Cartesian product is the product of the number of elements in each set: n(A1×A2×⋯×Am)=n(A1)×n(A2)×⋯×n(Am) 211.
📝 An organization with 15 members needs to elect a president, treasurer, and secretary. The president can be elected in 15 ways, the treasurer in 14 ways (since one person is already president), and the secretary in 13 ways. The total number of ways to elect officers is 15×14×13=2730 212.
29.3 Applications of sum and product rules
The sum and product rules are fundamental in solving various counting problems, from simple arrangements to complex scenarios like license plates and bit strings.
- Bit strings: A bit string is a sequence of 0s and 1s. For a bit string of length k, each of the k positions can be filled in 2 ways (0 or 1). A bit string of length k has 2k possibilities.
📝 There are 24=16 different bit strings of length 4 212.
- License plates: License plates often consist of a combination of letters and digits. The number of possible plates is calculated by multiplying the number of choices for each position.
📝 A license plate with three letters followed by three digits has 263×103=17,576,000 possible combinations if repetitions are allowed 213.
- Variable names: In programming, variable names have specific formation rules. The total number of possible names is found by applying the sum rule to different valid structures.
📝 A variable name can be a single letter (26 possibilities) or a letter followed by a digit (26×10=260 possibilities). By the sum rule, there are 26+260=286 possible variable names 214.
- Integer divisibility: To count integers with specific properties, like divisibility by 5, the sum rule can be applied to different cases (e.g., ending in 0 or ending in 5) 215.
| Case | Calculation | Number of Integers |
|---|---|---|
| Three-digit integers ending in 0 | 9 (choices for first digit) × 10 (choices for second digit) × 1 (choice for last digit) | 90 |
| Three-digit integers ending in 5 | 9 (choices for first digit) × 10 (choices for second digit) × 1 (choice for last digit) | 90 |
The total number of three-digit integers divisible by 5 is 90+90=180 215.
29.4 Counting arrangements with restrictions 213 214
When counting arrangements, restrictions such as distinct characters or specific starting/ending conditions require careful application of the product rule.
- Distinct characters: If all characters (letters or digits) in an arrangement must be distinct, the number of choices decreases for each subsequent position 214.
- Specific prefixes/suffixes: If an arrangement must begin or end with certain characters, those positions have only one choice, and the remaining positions are filled according to the rules 213.
| Scenario | Calculation | Number of License Plates |
|---|---|---|
| Begin with A and end with 0 | 1 (A) × 26 × 26 × 10 × 10 × 1 | 67,600 |
| Begin with PQR | 1 (P) × 1 (Q) × 1 (R) × 10 × 10 × 10 | 1,000 |
| All letters and digits distinct | 26 × 25 × 24 × 10 × 9 × 8 | 11,232,000 |
| Begin with AB and all distinct | 1 (A) × 1 (B) × 24 × 10 × 9 × 8 | 17,280 |
29.5 Counting iterations in nested loops 216 217
The number of times the inner loop of a nested loop structure executes can be determined using the product rule or the sum rule, depending on how the inner loop's iterations depend on the outer loop.
- Independent iterations: If the number of iterations of the inner loop is constant for each iteration of the outer loop, the total number of iterations is the product of the number of iterations of each loop.
📝 For loops
for i = 1 to 4andfor j = 1 to 3, the inner loop iterates 4×3=12 times 216.
- Dependent iterations: If the number of iterations of the inner loop varies based on the outer loop's current iteration, the sum rule is applied to the varying number of inner loop executions.
📝 If the inner loop's iterations depend on the outer loop, the sum rule is applied, as in
for i = 1 to 4andfor j = 1 to i, resulting in 1+2+3+4=10 iterations 217.
| Outer Loop Range | Inner Loop Range | Total Inner Loop Iterations |
|---|---|---|
| i = 1 to 4 | j = 1 to 3 | 4 × 3 = 12 |
| i = 5 to 50 | j = 10 to 20 | (50 - 5 + 1) × (20 - 10 + 1) = 46 × 11 = 506 |
| i = 1 to 4 | j = 1 to i | 1 + 2 + 3 + 4 = 10 |
30. Permutations
30.1 Factorial
The factorial of a positive integer n, denoted by n!, is the product of all integers from 1 to n. By definition, 0!=1.
Factorial can also be defined recursively: 0!=1, and n!=n⋅(n−1)! for any positive integer n 218.
-
Factorial calculation:
-
7!/5!=(7⋅6⋅5!)/5!=7⋅6=42.
-
(−2)! is undefined.
-
(n+1)!/n!=(n+1)⋅n!/n!=n+1.
-
(n−1)!/(n+1)!=(n−1)!/((n+1)⋅n⋅(n−1)!)=1/((n+1)⋅n)=1/(n2+n) 218.
-
Expressing products using factorials:
-
25⋅24⋅23⋅22=(25⋅24⋅23⋅22⋅21!)/21!=25!/21!.
-
n(n−1)(n−2)⋯(n−r+1)=n!/(n−r)! 218.
-
n(n−1)(n−2)⋯(n−r+1)/r!=n!/(r!(n−r)!) 219.
30.2 Counting Formulas: k-Sample, k-Permutation, k-Selection, k-Combination
The number of ways to choose k elements from a set of n distinct elements depends on whether repetition is allowed and whether the order of elements matters. These conditions lead to four counting methods 219.
| Order Matters | Order Does Not Matter |
|---|---|
| Repetition Allowed | k-sample |
| Repetition Not Allowed | k-permutation |
📝 The number of 2-permutations of 4 elements is P(4,2)=4!/(4−2)!=4⋅3=12. The permutations are: WX, WY, WZ, XW, XY, XZ, YW, YX, YZ, ZW, ZX, ZY 222.
30.3 k-Sample
A k-sample from a set of n elements is a selection of k elements where the order matters and elements can be repeated. Since repetition is allowed, k can be greater than n.
The total number of ways to form a k-sample from n distinct elements is nk 219.
-
Coin toss outcomes: The number of possible outcomes when a fair coin is tossed three times is 23=8 220.
-
Forming three-digit numbers:
-
Total numbers: 63=216.
-
Numbers less than 400: The first digit can be 2 or 3 (2 options). The remaining two digits can be any of the 6 digits. So, 2⋅6⋅6=72.
-
Even numbers: The last digit must be 2 or 4 (2 options). The first two digits can be any of the 6 digits. So, 6⋅6⋅2=72.
-
Odd numbers: The last digit must be 3, 5, 7, or 9 (4 options). The first two digits can be any of the 6 digits. So, 6⋅6⋅4=144 220.
-
Multiples of 5: The last digit must be 5 (1 option). The first two digits can be any of the 6 digits. So, 6⋅6⋅1=36 221.
-
Light bulb samples: A box contains 10 different colored light bulbs. The number of ordered samples of size 3 with replacement is 103=1000 221.
-
Multiple choice test:
-
If every question is answered, the number of ways is 410=1,048,576.
-
If the student can leave answers blank, there are 5 options per question (4 answers + blank). The number of ways is 510=9,765,625 221.
30.4 k-Permutation
A k-permutation of a set of n elements is an ordered selection of k elements where repetition is not allowed. This requires k≤n.
The number of k-permutations is denoted by P(n,k) or nPk, and the formula is P(n,k)=n!/(n−k)! 222.
-
Formula for k-permutation:
-
The first element can be chosen in n ways.
-
The second element can be chosen in (n−1) ways.
-
The k-th element can be chosen in (n−(k−1)) ways.
-
The total number of ways is n⋅(n−1)⋅(n−2)⋯(n−k+1) 222.
-
2-Permutations of {W, X, Y, Z}:
-
The number of 2-permutations of 4 elements is P(4,2)=4!/(4−2)!=4⋅3=12.
-
The permutations are: WX, WY, WZ, XW, XY, XZ, YW, YX, YZ, ZW, ZX, ZY 222.
-
Calculating P(n, k):
-
P(8,3)=8!/(8−3)!=8⋅7⋅6=336.
-
P(8,8)=8!/(8−8)!=8!/0!=8!=40,320.
-
P(8,1)=8!/(8−1)!=8!/7!=8.
-
P(6,8) is undefined because k>n 223.
-
Finding n:
-
If P(n,2)=72, then n(n−1)=72, which gives n2−n−72=0. The positive solution is n=9.
-
If P(n,4)=42P(n,2), then n(n−1)(n−2)(n−3)=42n(n−1). For n=0,1, this simplifies to (n−2)(n−3)=42, or n2−5n+6=42. The equation n2−5n−36=0 has a positive solution n=9 223.
-
Proof: For integers n≥3, P(n+1,3)−P(n,3)=3P(n,2).
-
LHS: P(n+1,3)−P(n,3)=(n+1)n(n−1)−n(n−1)(n−2)=n(n−1)[(n+1)−(n−2)]=n(n−1)[3]=3n(n−1).
-
RHS: 3P(n,2)=3⋅n(n−1).
-
LHS = RHS 223.
-
Arranging letters:
-
The number of ways to select and arrange five letters from the word ALGORITHM (9 distinct letters) is P(9,5)=9!/(9−5)!=9⋅8⋅7⋅6⋅5=15,120.
-
If the first two letters must be TH, the remaining three letters are chosen from the remaining 7 letters: P(7,3)=7!/(7−3)!=7⋅6⋅5=210 224.
-
Arranging people: The number of ways seven persons can arrange themselves in a row of seven chairs is P(7,7)=7!=5,040 224.
-
Debating team arrangement: A team of 3 boys and 2 girls sits in a row with boys together and girls together. There are 2 arrangements for the groups (BBBGG or GGBBB). Boys can arrange in 3! ways, and girls in 2! ways. Total ways = 2⋅3!⋅2!=2⋅6⋅2=24 224.
-
Book arrangement: Five large, four medium, and three small books are placed on a shelf with books of the same size together. The blocks of books can be arranged in 3! ways. Within each block, books can be arranged: large books in 5! ways, medium in 4! ways, and small in 3! ways. Total ways = 3!⋅5!⋅4!⋅3!=6⋅120⋅24⋅6=103,680 225.
31. Combinations
31.1 K-combinations
A k-combination of a set of n elements is a selection of k elements where the order of selection does not matter and elements cannot be repeated. The number of k-combinations from a set of n elements is denoted by C(n, k), also written as nCk or (kn).
For k-combinations, it must be that k≤n 226.
- Example: For the set X = {a, b, c}, the 2-combinations are {a, b}, {a, c}, and {b, c}. Thus, C(3, 2) = 3.
- Example: For the set X = {a, b, c, d, e}, the 3-combinations are {a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e}, {a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}. Thus, C(5, 3) = 10 226.
31.2 Permutations and combinations
The number of k-permutations of n elements, P(n, k), is related to the number of k-combinations, C(n, k), by the formula P(n,k)=C(n,k)⋅k!. This implies that C(n,k)=k!P(n,k) 227.
The formula for calculating the number of k-combinations from a set of n elements is: C(n,k)=(n−k)!k!n! 227.
- Example: Compute C(9, 6). C(9,6)=(9−6)!6!9!=3!⋅6!9⋅8⋅7⋅6!=3⋅2⋅19⋅8⋅7=84 227.
31.3 Important results for combinations
Several key identities simplify combination calculations 227:
- C(n,0)=1
- C(n,n)=1
- C(n,1)=n
- C(n,2)=2n(n−1)
- C(n,k)=C(n,n−k)
- C(n,k)+C(n,k+1)=C(n+1,k+1)
31.4 Exam and team selection problems
Combinations are frequently used to solve problems involving selections for exams, teams, or committees 227 228.
-
Example: A student must answer eight out of ten questions on an exam.
-
The number of ways to choose eight questions is C(10,8)=45.
-
If the first three questions are compulsory, the student must choose 5 more questions from the remaining 7. The number of ways is C(7,5)=21 227.
-
Example: An exam paper has 5 questions in section A and 5 in section B. A total of 8 questions must be answered, with at least 4 from section A.
-
Case 1: 4 from A and 4 from B. Number of ways = C(5,4)⋅C(5,4)=5⋅5=25.
-
Case 2: 5 from A and 3 from B. Number of ways = C(5,5)⋅C(5,3)=1⋅10=10.
-
Total ways = 25+10=35 228.
-
Example: A computer programming team has 14 members.
-
(a) Number of ways to choose a group of seven: C(14,7)=3432 228.
-
(b) With 8 women and 6 men:
-
(i) Groups of seven with 4 women and 3 men: C(8,4)⋅C(6,3)=70⋅20=1400.
-
(ii) Groups of seven with at least one man: Total groups - groups with no men = C(14,7)−C(8,7)=3432−8=3424.
-
(iii) Groups of seven with at most three women:
-
0 women: C(8,0)⋅C(6,7)=0 (impossible)
-
1 woman: C(8,1)⋅C(6,6)=8⋅1=8.
-
2 women: C(8,2)⋅C(6,5)=28⋅6=168.
-
3 women: C(8,3)⋅C(6,4)=56⋅15=840.
-
Total = 0+8+168+840=1016 229.
-
(c) Two members refuse to work together. Let them be A and B.
-
Groups with neither A nor B: C(12,7)=792.
-
Groups with A but not B: C(12,6)=924.
-
Groups with B but not A: C(12,6)=924.
-
Total ways = 792+924+924=2640.
-
(d) Two members insist on working together or not at all. Let them be C and D.
-
Groups with neither C nor D: C(12,7)=792.
-
Groups with both C and D: C(12,5)=792.
-
Total ways = 792+792=1584 230.
-
Example: 16-bit strings.
-
(a) Exactly 9 ones: C(16,9)=11440.
-
(b) At least one 1: Total strings - strings with no 1s = 216−1=65536−1=65535 230.
31.5 K-selections
A k-selection from a set of n elements is a choice of k elements where the order of selection does not matter, but elements can be repeated. These are also known as k-combinations with repetition or multisets of size k. Unlike k-combinations, k does not need to be less than or equal to n 230.
The number of k-selections from a set of n elements is given by: C(k+n−1,k)=(kk+n−1) 231.
- Example: A camera shop stocks ten different types of batteries.
- (a) Number of ways to distribute an inventory of 30 batteries among 10 types: k=30,n=10. C(30+10−1,30)=C(39,30)=9!30!39!=211,915,132.
- (b) Inventory of 30 batteries, including at least four A76 batteries (one of the 10 types): k=26 (since 4 are already accounted for), n=10. C(26+10−1,26)=C(35,26)=9!26!35!=70,607,460 231.
| Order Matters | Order Does Not Matter |
|---|---|
| Repetition Allowed | nk (k-sample) |
| Repetition Not Allowed | P(n, k) (k-permutation) |
32. K-Combinations
32.1 K-selections 233
A k-selection from a set of n elements is a choice of k elements where order does not matter and repetitions are allowed. These are also known as multisets of size k. Unlike standard combinations, the number of selections k can be greater than the number of elements n. The number of k-selections from a set of n elements is given by the formula C(k+n−1,k) 232.
- k-selection: A choice of k elements from a set of n elements where order is irrelevant and repetition is permitted.
- Multiset: An alternative term for a k-selection, emphasizing that elements can appear multiple times 232.
The number of ways to distribute 30 batteries among 10 different types is calculated as a k-selection problem. Here, k=30 (the total number of batteries) and n=10 (the number of battery types).
The number of ways is C(30+10−1,30)=C(39,30)=21,191,5132 232.
If at least four batteries of a specific type (A76) must be included, the problem is adjusted. We pre-assign four A76 batteries, leaving 26 batteries to be distributed among the 10 types.
In this case, k=26 and n=10. The number of ways is C(26+10−1,26)=C(35,26)=70,607,460 232 233.
| Order Matters | Repetition Allowed | Order Doesn't Matter | Repetition Not Allowed |
|---|---|---|---|
| k-sample (nk) | k-selection (C(n+k−1,k)) | k-permutation (P(n,k)) | k-combination (C(n,k)) |
32.2 Ordered and Unordered Partitions 234 235
An unordered partition of a set S is a collection of disjoint, nonempty subsets (cells) whose union is S. An ordered partition is a list of these cells where the order of the cells matters. For example, partitioning the set {1, 2, 3, 4, 5, 6, 7} into [{1,2}, {3,4,5}, {6,7}] and [{6,7}, {3,4,5}, {1,2}] results in the same unordered partition but distinct ordered partitions 233.
The number of ordered partitions of a set S with n elements into k cells, where cell Ai contains ni elements and ∑i=1kni=n, is given by the multinomial coefficient n1!n2!⋯nk!n! 234.
- Ordered partition: A division of a set into a specific sequence of subsets.
- Unordered partition: A division of a set into a collection of subsets where the order of the subsets does not matter 233.
Consider dividing nine toys among four children, where the youngest receives three toys and the other three receive two each. This is an ordered partition problem.
The number of ways is 3!2!2!2!9!=2520 234.
When dividing 12 students into three groups of 4 for different subjects (English, History, Mathematics), the groups are distinct, making it an ordered partition. The number of ways is 4!4!4!12!=34,650 234.
If the 12 students are divided into three groups of 4 for the same subject (Mathematics), the groups are indistinguishable, requiring an unordered partition. The number of ways is 4!4!4!⋅3!12!=5775 234.
When dividing 8 students into two teams of five and three, the distinct team sizes make the teams distinguishable, so the number of unordered partitions equals the number of ordered partitions: 5!3!8!=56 235.
For dividing 8 students into two teams of four, the teams are indistinguishable. First, calculate the ordered partitions: 4!4!8!=70.
Since the two teams are of equal size and unlabeled, divide by 2!: 270=35 unordered partitions 235.
To partition a class of 10 students into teams A1,A2 (2 students each) and B1,B2 (3 students each), first find the ordered partitions: 2!2!3!3!10!=25,200. Since there are two pairs of teams with identical sizes (A1,A2 and B1,B2), divide by 2!⋅2! for unordered partitions: 425,200=6300 235.
| Scenario | Partition Type | Calculation | Result |
|---|---|---|---|
| 12 students into 3 groups of 4 for English, History, Mathematics | Ordered | 4!4!4!12! | 34,650 |
| 12 students into 3 groups of 4 for Mathematics | Unordered | 4!4!4!⋅3!12! | 5,775 |
| 8 students into teams of 5 and 3 | Unordered (distinct sizes) | 5!3!8! | 56 |
| 8 students into two teams of 4 | Unordered (identical sizes) | 4!4!⋅2!8! | 35 |
| 10 students into A1,A2 (2 each) and B1,B2 (3 each) | Unordered (two pairs of identical sizes) | 2!2!3!3!⋅2!⋅2!10! | 6,300 |
32.3 Generalized Permutations (Permutations with Repetitions)237
Generalized permutations, also known as permutations with repetitions, count the number of distinct arrangements of n elements where some elements are identical. The formula for the number of permutations of n elements, with n1 identical elements of type 1, n2 identical elements of type 2,..., and nk identical elements of type k, is n1!n2!⋯nk!n!.
This is also referred to as a multinomial coefficient 236.
- Multinomial coefficient: A notation for generalized permutations with repetitions, (n1,n2,…,nkn)=n1!n2!⋯nk!n! 236.
The number of distinct permutations of the letters in "BENZENE" is calculated using this formula. The word has 7 letters: three E's and two N's.
The number of permutations is 3!2!7!=420 236.
To form signals with six flags from four identical red flags and two identical blue flags, we find the permutations of 6 elements with 4 alike and 2 alike: 4!2!6!=15 236.
Consider the word ELEVEN. It has six letters with three E's.
The total number of distinct "words" is 3!6!=120 236.
If words formed from ELEVEN must begin with L, there are 5 remaining positions for the three E's: 3!5!=20 237.
If words must begin and end with E, the remaining four distinct letters can be arranged in 4!=24 ways 237.
If words must begin with E and end with N, the remaining four positions must be filled with two E's and two other distinct letters. The number of arrangements is 2!4!=12 237.
For the word BASEBALL, there are 8 letters with two B's, two A's, and two L's. The total number of permutations is 2!2!2!8!=5040 237.
If the two B's in BASEBALL must be together, treat them as a single unit. This results in 7 units to permute, with two A's and two L's: 2!2!7!=1260 237.
For words formed from BASEBALL to begin and end in a vowel (A or E), there are three cases: A...A, A...E, or E...A. In each case, the remaining 6 letters (two B's, two L's, and one vowel) can be arranged in 2!2!6!=540 ways 237.
| Word/Letters | Total Letters (n) | Repetitions | Formula | Result |
|---|---|---|---|---|
| BENZENE | 7 | 3 E's, 2 N's | 3!2!7! | 420 |
| Flags (4 red, 2 blue) | 6 | 4 red, 2 blue | 4!2!6! | 15 |
| ELEVEN | 6 | 3 E's | 3!6! | 120 |
| ELEVEN (starts with L) | 5 | 3 E's | 3!5! | 20 |
| ELEVEN (starts and ends with E) | 4 | No repetitions | 4! | 24 |
| ELEVEN (starts with E, ends with N) | 4 | 2 E's | 2!4! | 12 |
| BASEBALL | 8 | 2 B's, 2 A's, 2 L's | 2!2!2!8! | 5,040 |
| BASEBALL (two B's together) | 7 | 2 A's, 2 L's | 2!2!7! | 1,260 |
| BASEBALL (starts and ends with vowel) | 6 | 2 B's, 2 L's | 2!2!6! | 540 (per case) |
33. Tree Diagram
33.1 Tree diagram
A tree diagram is a visual tool used to list all possible outcomes of a sequence of events, especially when each event has a finite number of possibilities. It consists of a root, branches representing choices, and leaves (endpoints) representing the final outcomes.
The diagram is typically constructed from left to right, with each path from the root to a leaf representing a unique sequence of choices 238.
- Construction: Branches represent possible choices, and the leaves at the end of the branches show the possible outcomes.
- Application: Used in counting problems to enumerate all logical possibilities 238.
33.2 Permutations of {a, b, c}
The number of permutations of 3 elements is calculated as P(3,3)=(3−3)!3!=3!=6. A tree diagram can illustrate these six permutations 238.
📝 The six permutations of {a, b, c} are: abc, acb, bac, bca, cab, cba 238.
33.3 Product set A B C
To find the product set A×B×C, where A={1,2}, B={a,b,c}, and C={3,4}, a tree diagram can map out all combinations. Each path from the start to an endpoint represents an element in the product set 239.
📝 The product set A×B×C contains the elements: (1,a,3), (1,a,4), (1,b,3), (1,b,4), (1,c,3), (1,c,4), (2,a,3), (2,a,4), (2,b,3), (2,b,4), (2,c,3), (2,c,4) 239.
33.4 Tournament outcomes
In a tournament where the first team to win two games wins, a tree diagram can show all possible ways the tournament can unfold 239.
📝 The tournament can occur in 6 ways: AA, ABA, ABB, BAA, BAB, BB 239.
33.5 Bit strings without consecutive 1s
A tree diagram can enumerate bit strings of a specific length that do not contain two consecutive 1s. Each branch represents a bit (0 or 1), with constraints applied to prevent consecutive 1s 240.
📝 There are 8 bit strings of length four without two consecutive 1s: 0000, 0001, 0010, 0100, 0101, 1000, 1001, 1010 240.
33.6 Officer selection with constraints
When selecting officers with specific restrictions (e.g., one person cannot hold a certain position, or a specific person must hold another), a possibility tree helps visualize and count the valid combinations 240.
📝 Under the given conditions, there are eight possible ways to choose the officers 241.
33.7 The inclusion-exclusion principle
The inclusion-exclusion principle is a counting technique used to find the number of elements in the union of sets. It accounts for elements that are counted multiple times when simply summing the sizes of individual sets 241.
- Disjoint Sets: If sets A and B are disjoint (have no common elements), the size of their union is the sum of their individual sizes: n(A∪B)=n(A)+n(B).
- Overlapping Sets: If sets A and B overlap, the size of their union is the sum of their individual sizes minus the size of their intersection (elements counted twice): n(A∪B)=n(A)+n(B)−n(A∩B) 241.
33.8 Calculating union size
The principle helps calculate the total number of elements when there is overlap. By subtracting the intersection, elements counted in both sets are only included once 241.
📝 If there are 15 girl students and 25 boy students, the total number of students is 15+25=40 241.
33.9 Application to swimming and jogging
This principle can determine the number of people in a group who participate in one activity or another, given the total number of participants, those in one activity, and those in both 242.
📝 Among 200 people, if 150 swim or jog or both, 85 swim, and 60 swim and jog, then 125 people jog 242.
33.10 Set difference formula
The size of the set difference A∖B (elements in A but not in B) can be found by subtracting the size of the intersection of A and B from the size of A. This is because A can be seen as the union of two disjoint sets: A∖B and A∩B 242.
- Formula: n(A∖B)=n(A)−n(A∩B).
- Complement: The size of the complement of a set A (A′) within a universal set U is n(A′)=n(U)−n(A) 242.
📝 Given n(A)=10, n(B)=15, n(A′)=12, and n(A∩B)=8 for a universal set U, n(A∪B′)=15 243.
33.11 Calculating intersection size
The inclusion-exclusion principle can also be rearranged to find the size of the intersection of two sets when the size of their union, individual sets, and the universal set are known 243.
- Rearranging the union formula: n(A∩B)=n(A)+n(B)−n(A∪B).
- Using the complement of the union: n(A∪B)=n(U)−n((A∪B)′) 243.
33.12 Newspaper readership
This principle can be applied to problems involving overlapping groups, such as readership of different newspapers, to find the number of individuals in specific categories (e.g., only Urdu newspaper readers) 243.
- The union of sets can be expressed as the sum of disjoint parts: E∪U=(E∖U)∪(E∩U)∪(U∖E).
- Therefore, n(E∪U)=n(E∖U)+n(E∩U)+n(U∖E) 244.
33.13 Food preferences
Problems involving preferences for different types of food can be solved using set theory and the inclusion-exclusion principle, especially when dealing with individuals who like one type, both, or neither 244.
- The number of people who like Chinese but not fast food (C∖F) can be found using the relationship n(C∪F)=n(C∖F)+n(F).
- The size of the union n(C∪F) is derived from the total number of people and those who like neither: n(C∪F)=n(U)−n((C∪F)′) 244.
34. Inclusion-Exclusion Principle
34.1 Inclusion-Exclusion Principle for Two Sets
The inclusion-exclusion principle is a counting technique used to find the number of elements in the union of two or more sets. For two sets, A and B, the principle states that the number of elements in their union is the sum of the number of elements in each set minus the number of elements in their intersection.
This method helps avoid double-counting elements that belong to both sets.
- To find the number of integers from 1 through 1000 that are multiples of 3 or 5, let A be the set of multiples of 3 and B be the set of multiples of 5.
- The number of multiples of 3 up to 1000 is ⌊1000/3⌋=333.
- The number of multiples of 5 up to 1000 is ⌊1000/5⌋=200.
- The number of multiples of both 3 and 5 (i.e., multiples of 15) up to 1000 is ⌊1000/15⌋=66.
- Using the inclusion-exclusion principle, n(A∪B)=n(A)+n(B)−n(A∩B)=333+200−66=467.
- To find the number of integers from 1 through 1000 that are neither multiples of 3 nor 5, subtract the number of integers that are multiples of 3 or 5 from the total number of integers.
- This is 1000−n(A∪B)=1000−467=533 245.
34.2 Inclusion-Exclusion Principle for Three and Four Sets
The inclusion-exclusion principle can be extended to more than two sets. For three sets (A, B, C), the formula involves adding the sizes of individual sets, subtracting the sizes of pairwise intersections, and finally adding the size of the intersection of all three sets.
This pattern continues for four or more sets, with alternating signs for intersections of increasing numbers of sets.
- For three sets A, B, and C: n(A∪B∪C)=n(A)+n(B)+n(C)−n(A∩B)−n(B∩C)−n(A∩C)+n(A∩B∩C).
- For four sets A, B, C, and D: n(A∪B∪C∪D)=n(A)+n(B)+n(C)+n(D)−n(A∩B)−n(A∩C)−n(A∩D)−n(B∩C)−n(B∩D)−n(C∩D)+n(A∩B∩C)+n(A∩B∩D)+n(A∩C∩D)+n(B∩C∩D)−n(A∩B∩C∩D) 245.
34.3 Application of Inclusion-Exclusion Principle
This section demonstrates the application of the inclusion-exclusion principle in a survey scenario involving college students and their possessions. The principle is used to determine the number of students who own specific items based on given data about ownership and non-ownership.
- A survey of 100 college students provided the following data:
- 8 owned a car (C).
- 20 owned a motorcycle (M).
- 48 owned a bicycle (B).
- 38 owned neither a car nor a motorcycle nor a bicycle 245.
- No student who owned a car also owned a motorcycle (n(C∩M)=0).
- The goal is to find how many students owned a bicycle and either a car or a motorcycle, which translates to finding n(B∩C)+n(B∩M).
- The number of students owning at least one of the items is n(C∪M∪B)=n(U)−n((C∪M∪B)′)=100−38=62.
- Using the inclusion-exclusion principle for three sets: n(C∪M∪B)=n(C)+n(M)+n(B)−n(C∩M)−n(C∩B)−n(M∩B)+n(C∩M∩B) 62=8+20+48−0−n(C∩B)−n(M∩B)+0.
- This simplifies to n(C∩B)+n(M∩B)=8+20+48−62=76−62=14.
- Therefore, 14 students owned a bicycle and either a car or a motorcycle 246.
📝 A survey of 100 college students found that 8 owned a car (C), 20 owned a motorcycle (M), and 48 owned a bicycle (B). If 38 owned none of these, and no student owned both a car and a motorcycle, then n(C∩B)+n(M∩B)=14 students owned a bicycle and either a car or a motorcycle 246.
34.4 Pigeonhole Principle
The pigeonhole principle states that if more items (pigeons) are placed into a fixed number of containers (pigeonholes) than there are containers, then at least one container must contain more than one item. This principle is fundamental in proving existence without explicitly constructing the items.
- Basic Pigeonhole Principle: If k+1 or more pigeons fly into k pigeonholes, at least one pigeonhole must contain two or more pigeons.
- Example: Among any group of 367 people, at least two share the same birthday, as there are only 366 possible birthdays.
- Example: In any set of 27 English words, at least two begin with the same letter, as there are 26 letters in the alphabet.
- Question: What is the minimum number of students in a class to guarantee at least two are born in the same month?
- With 12 months (pigeonholes), 13 students (pigeons) are needed to ensure at least two share a birth month 247.
- Question: Given any set of seven integers, must there be two that have the same remainder when divided by 6?
- The possible remainders when dividing by 6 are {0, 1, 2, 3, 4, 5}, which are 6 pigeonholes. With 7 integers (pigeons), at least two must have the same remainder.
- Question: How many integers from 1 through 100 must you pick to be sure of getting one divisible by 5?
- There are 20 integers divisible by 5 and 80 not divisible by 5. To guarantee picking one divisible by 5, you must pick 80+1=81 integers.
- Example: Let A = {1, 2,..., 10}. If six integers are chosen from A, must two have a sum of 11?
- Partition A into subsets where elements sum to 11: {1, 10}, {2, 9}, {3, 8}, {4, 7}, {5, 6}. These are 5 pigeonholes. Selecting 6 integers guarantees at least two come from the same subset, summing to 11 248.
34.5 Generalized Pigeonhole Principle
The generalized pigeonhole principle extends the basic principle by specifying the minimum number of items that must be in one container when there are more items than containers. It quantifies the "at least two" to "at least k+1" for a given number of containers.
- Generalized Pigeonhole Principle: If n⋅k+1 or more pigeons fly into n pigeonholes, then at least one pigeonhole must contain k+1 or more pigeons.
- Example: A laundry bag contains red, white, and blue socks. What is the minimum number of socks to choose to get two pairs (four socks) of the same color?
- Here, n=3 colors (pigeonholes) and we want k+1=4 socks of the same color, so k=3. We need to choose n⋅k+1=3⋅3+1=10 socks 248.
34.6 Floor and Ceiling Functions
The floor and ceiling functions are mathematical tools used to round real numbers down or up to the nearest integer, respectively. They are essential in number theory and discrete mathematics, particularly when dealing with division and distribution problems.
-
Floor of x (⌊x⌋): The largest integer less than or equal to x.
-
Ceiling of x (⌈x⌉): The smallest integer greater than or equal to x 248.
-
Examples:
-
⌊25/4⌋=⌊6.25⌋=6; ⌈25/4⌉=⌈6.25⌉=7.
-
⌊0.999⌋=0; ⌈0.999⌉=1.
-
⌊−2.01⌋=−3; ⌈−2.01⌉=−2 249.
-
Finding N using Ceiling Function:
-
What is the smallest integer N such that ⌈N/7⌉=5?
-
N=7⋅(5−1)+1=7⋅4+1=29.
-
What is the smallest integer N such that ⌈N/9⌉=6?
-
N=9⋅(6−1)+1=9⋅5+1=46 249.
34.7 Pigeonhole Principle with Ceiling Function
This formulation of the pigeonhole principle uses the ceiling function to directly calculate the minimum number of items guaranteed to be in one category. It provides a concise way to determine the required number of pigeons to ensure a certain number of pigeons per pigeonhole.
- Pigeonhole Principle (Ceiling Form): If N pigeons fly into k pigeonholes, then at least one pigeonhole must contain ⌈N/k⌉ or more pigeons.
- Example: Among 100 people, at least ⌈100/12⌉=⌈8.33⌉=9 were born in the same month.
- Question: What is the minimum number of students required in a Discrete Mathematics class to ensure at least six receive the same grade, if there are five possible grades (A, B, C, D, F)?
- We need to find the smallest N such that ⌈N/5⌉=6.
- The smallest such integer is N=5(6−1)+1=5⋅5+1=26 249.
35. Probability
35.1 Introduction to probability
Probability theory originated in the 17th century with the analysis of gambling games by Blaise Pascal. Later, in the 18th century, Pierre-Simon Laplace defined probability as the ratio of successful outcomes to total outcomes 250.
- Experiment: A procedure that results in a set of possible outcomes.
- Sample space (S): The set of all possible outcomes of an experiment.
- Event (E): A subset of the sample space 250.
35.2 Die toss examples
When a single die is tossed, the sample space is S = {1, 2, 3, 4, 5, 6}. Events can be defined as specific outcomes or sets of outcomes:
- E1: A 6 occurs. E1 = {6}.
- E2: An even number occurs. E2 = {2, 4, 6}.
- E3: An odd number occurs. E3 = {1, 3, 5}.
- E4: A prime number occurs. E4 = {2, 3, 5}.
- E5: A number less than 5 occurs. E5 = {1, 2, 3, 4}.
- E6: A number greater than 6 occurs. E6 = ∅ (the empty set) 250.
When a pair of dice is tossed, the sample space S consists of 36 ordered pairs, such as (1, 1), (1, 2),..., (6, 6) 250. An example event is E, where the sum of the numbers is ten.
E = {(4, 6), (5, 5), (6, 4)} 251.
35.3 Calculating probability
The probability of an event E is calculated as the number of outcomes in E divided by the total number of outcomes in the sample space S, assuming all outcomes are equally likely 251.
- Probability of an event P(E): P(E)=number of total outcomes in Snumber of outcomes in E=n(S)n(E).
- The probability of any event is always between 0 and 1, inclusive (0≤P(E)≤1) 251.
35.4 Probability examples
What is the probability of getting a number greater than 4 when a die is tossed? The sample space is S = {1, 2, 3, 4, 5, 6}.
The event E (number greater than 4) is {5, 6}.
📝 The probability of getting a number greater than 4 when a die is tossed is P(E)=n(S)n(E)=62=31 251.
What is the probability of getting a total of eight or nine when a pair of dice is tossed? The sample space has 36 outcomes.
The event E (sum is eight or nine) is {(2, 6), (3, 5), (4, 4), (5, 3), (6, 2), (3, 6), (4, 5), (5, 4), (6, 3)}.
📝 The probability of getting a total of eight or nine when a pair of dice is tossed is P(E)=n(S)n(E)=369=41 251.
An urn contains four red and five blue balls. What is the probability that a ball chosen from the urn is blue?
The total number of balls is 4 + 5 = 9. The number of favorable outcomes (blue balls) is 5.
📝 The probability of drawing a blue ball is 95 252.
Two cards are drawn at random from an ordinary pack of 52 cards. Find the probability p that (i) both are spades, (ii) one is a spade and one is a heart.
The total number of ways to draw 2 cards from 52 is (252)=1326.
- For (i), there are 13 spades, so the number of ways to draw 2 spades is (213)=78.
📝 The probability that both cards are spades is 132678=171.
- For (ii), there are 13 spades and 13 hearts. The number of ways to draw one spade and one heart is (113)(113)=169.
📝 The probability that one card is a spade and one is a heart is 1326169=10213 252.
In a lottery, players win the first prize by matching three digits in the correct order. A second prize is won if only two digits match.
There are 103=1000 ways to choose three digits.
- (a) Winning the first prize requires matching all three digits correctly, so there is only 1 way.
📝 The probability of winning the first prize is 10001=0.001 252.
- (b) Winning the second prize involves matching exactly two digits. There are three scenarios for which digit is incorrect: the first, second, or third. For each scenario, there are 9 choices for the incorrect digit and 1 choice for each of the two correct digits. This gives 9+9+9=27 ways to match exactly two digits.
📝 The probability of winning the second prize is 100027=0.027 253.
What is the probability that a hand of five cards contains four cards of one kind? The total number of different five-card hands is (552)=2,598,960.
- The number of ways to pick one kind is (113). The number of ways to pick four of that kind is (44). The number of ways to pick the fifth card from the remaining 48 cards is (148).
Find the probability that a hand of five cards contains three cards of one kind and two of another kind. The total number of different five-card hands is (552)=2,598,960.
- The number of ways to pick two kinds is (213). The number of ways to pick three of the first kind is (34). The number of ways to pick two of the second kind is (24).
- The probability is (552)(213)×(34)×(24)=2,598,96078×4×6=2,598,9601872≈0.00072. 253 254.
What is the probability that a randomly chosen positive two-digit number is a multiple of 6? There are 90 positive two-digit numbers (from 10 to 99).
- The positive integers from 1 to 99 that are divisible by 6 are 16. Of these, 6 is not a two-digit number, leaving 15 two-digit multiples of 6.
📝 The probability that a randomly chosen positive two-digit number is a multiple of 6 is 9015=61≈0.166667 254.
35.5 Complementary events
The complement of an event E, denoted as Ec, is the event that E does not occur. It is the set of outcomes in the sample space S that are not in E (Ec=S∖E) 254.
- Theorem: The probability of the complementary event Ec is given by P(Ec)=1−P(E) 254.
35.6 Complementary event examples
Two items are chosen at random from a lot containing 12 items, of which 4 are defective. What is the probability that (i) none of the items chosen are defective, (ii) at least one item is defective?
The total number of ways to choose 2 items from 12 is (212)=66.
- (i) Let A be the event that none of the items chosen are defective. There are 8 non-defective items, so the number of ways to choose 2 non-defective items is (28)=28. Thus, P(A)=6628=3314.
- (ii) Let B be the event that at least one item chosen is defective. This is the complement of event A (B=Ac).
📝 The probability that at least one item is defective is P(B)=P(Ac)=1−P(A)=1−3314=3319. 254 255.
Three light bulbs are chosen at random from 15 bulbs, of which 5 are defective. Find the probability p that (i) none is defective, (ii) exactly one is defective, (iii) at least one is defective.
The total number of ways to choose 3 bulbs from 15 is (315)=455.
- (i) There are 10 non-defective bulbs. The number of ways to choose 3 non-defective bulbs is (310)=120.
- (ii) There are 5 defective bulbs and 10 non-defective bulbs. The number of ways to choose 1 defective bulb and 2 non-defective bulbs is (15)(210)=5×45=225.
- (iii) The event "at least one is defective" is the complement of "none are defective" 255.
| Scenario | Calculation | Probability |
|---|---|---|
| (i) None defective | (310) ways | 455120=9124 |
| (ii) Exactly one defective | (15)(210) ways | 455225=9145 |
| (iii) At least one defective | 1−P(none defective) | 1−9124=9167 |
36. Laws of Probability
36.1 Addition law for disjoint events
The addition law for disjoint events states that if two events, A and B, cannot occur simultaneously (they are mutually exclusive), the probability of either A or B occurring is the sum of their individual probabilities. This is because the intersection of disjoint events is empty, meaning there is no overlap in their outcomes 256.
The formula is expressed as: P(A∪B)=P(A)+P(B)
This principle is derived from the inclusion-exclusion principle for sets, where the number of elements in the union of two disjoint sets is simply the sum of the number of elements in each set. Dividing by the total number of outcomes in the sample space yields the probability formula 256.
36.2 Example: Rolling a die
Consider rolling a standard six-sided die. Let event A be rolling a 1, and event B be rolling an even number (2, 4, or 6).
These events are disjoint because a single roll cannot be both a 1 and an even number.
- The probability of rolling a 1 is P(A)=61.
- The probability of rolling an even number is P(B)=63. The probability of rolling a 1 or an even number is P(A∪B)=P(A)+P(B)=61+63=64=32 256.
📝 The probability of rolling a 1 is P(A)=61. The probability of rolling an even number is P(B)=63. The probability of rolling a 1 or an even number is P(A∪B)=61+63=64=32 256.
36.3 Example: Drawing balls from a bag
A bag contains 6 white, 5 black, and 4 red balls. The probability of drawing a white ball (event A) is 156, and the probability of drawing a black ball (event B) is 155.
Since drawing a white ball and drawing a black ball are mutually exclusive events in a single draw, the probability of drawing either a white or a black ball is P(A∪B)=P(A)+P(B)=156+155=1511 257.
36.4 Example: Rolling a pair of dice
When a pair of dice is thrown, there are 36 possible outcomes. The probability of getting a total of 5 (event A) is 364 (outcomes: (1,4), (2,3), (3,2), (4,1)).
The probability of getting a total of 11 (event B) is 362 (outcomes: (5,6), (6,5)). Since these totals cannot occur simultaneously, the events are disjoint.
The probability of getting a total of 5 or 11 is P(A∪B)=P(A)+P(B)=364+362=366=61 257.
36.5 Probability of event A minus event B
The probability of event A occurring but not event B, denoted as P(A∖B) or P(A∩B′), can be calculated by subtracting the probability of the intersection of A and B from the probability of A. This is because event A can be partitioned into two disjoint events: A occurring without B (A∖B) and A occurring with B (A∩B) 257.
The formula is: P(A∖B)=P(A)−P(A∩B)
36.6 Example: Calculating probabilities
Given P(A)=0.65, P(B)=0.30, and P(A∩B)=0.15:
- The probability of A∩B′ (A occurring but not B) is P(A)−P(A∩B)=0.65−0.15=0.50 258.
36.7 General addition law of probability
The general addition law applies to any two events, A and B, whether they are disjoint or not. It accounts for the possibility that both events might occur simultaneously.
The probability of A or B (or both) occurring is the sum of their individual probabilities minus the probability of their intersection 258.
The formula is: P(A∪B)=P(A)+P(B)−P(A∩B)
This formula is derived from the inclusion-exclusion principle for sets, which states that to find the total number of elements in the union of two sets, you add the number of elements in each set and then subtract the number of elements in their intersection to avoid double-counting 258.
36.8 Example: Calculating probabilities with overlap
Given P(A)=0.65, P(B)=0.30, and P(A∩B)=0.15:
- The probability of A∪B is P(A)+P(B)−P(A∩B)=0.65+0.30−0.15=0.80.
- The probability of A′∩B′ (neither A nor B occurring) can be found using De Morgan's Law: P(A′∩B′)=P((A∪B)′)=1−P(A∪B)=1−0.80=0.20. 258 259.
36.9 Example: Drawing a card
For a standard deck of 52 cards, let A be the event of drawing a spade and B be the event of drawing an ace.
- P(A)=5213 (13 spades).
- P(B)=524 (4 aces).
- The intersection A∩B is drawing the ace of spades, so P(A∩B)=521. The probability of drawing a spade or an ace is P(A∪B)=P(A)+P(B)−P(A∩B)=5213+524−521=5216=134 260.
📝 For a standard deck of 52 cards, the probability of drawing a spade is P(A)=5213, and the probability of drawing an ace is P(B)=524. The probability of drawing the ace of spades is P(A∩B)=521. The probability of drawing a spade or an ace is P(A∪B)=5213+524−521=5216=134 260.
36.10 Example: Class demographics
In a class of 10 boys and 20 girls, half the boys and half the girls have brown eyes. Let A be the event of choosing a boy, and B be the event of choosing a student with brown eyes.
- P(A)=3010.
- P(B)=305 boys+10 girls=3015.
- P(A∩B) is the probability of choosing a boy with brown eyes, which is 305. The probability of choosing a boy or a student with brown eyes is P(A∪B)=P(A)+P(B)−P(A∩B)=3010+3015−305=3020=32 260.
36.11 Example: Divisibility of integers
An integer is chosen randomly from the first 100 positive integers. Let A be the event that the integer is divisible by 6, and B be the event that it is divisible by 8. The intersection A∩B is the event that the integer is divisible by both 6 and 8, meaning it's divisible by their least common multiple, 24.
- Number of integers divisible by 6: ⌊6100⌋=16. So, P(A)=10016.
- Number of integers divisible by 8: ⌊8100⌋=12. So, P(B)=10012.
- Number of integers divisible by 24: ⌊24100⌋=4. So, P(A∩B)=1004. The probability that the integer is divisible by 6 or 8 is P(A∪B)=P(A)+P(B)−P(A∩B)=10016+10012−1004=10024=256 261.
36.12 Example: Student attendance
A student attends mathematics class with probability P(A)=0.7, skips accounting class with probability 0.4 (meaning they attend accounting with P(B)=1−0.4=0.6), and attends both with probability P(A∩B)=0.5.
- The probability that the student attends at least one class is P(A∪B)=P(A)+P(B)−P(A∩B)=0.7+0.6−0.5=0.8.
- The probability that the student attends exactly one class is the sum of the probabilities of attending mathematics only (A∩B′) and attending accounting only (A′∩B).
- P(A∩B′)=P(A)−P(A∩B)=0.7−0.5=0.2.
- P(A′∩B)=P(B)−P(A∩B)=0.6−0.5=0.1. The probability of attending exactly one class is 0.2+0.1=0.3. 261 262.
36.13 Probability of a sub-event
If event A is a subset of event B (A⊆B), it means that every outcome in A is also an outcome in B. Consequently, the probability of A occurring cannot be greater than the probability of B occurring 262.
The relationship is: P(A)≤P(B)
This can be proven by noting that event B can be expressed as the union of two disjoint events: A and the part of B that is not A (B∩A′). Thus, P(B)=P(A)+P(B∩A′).
Since P(B∩A′)≥0, it follows that P(B)≥P(A) 262.
36.14 Example: Maximum and minimum probability of union
Given P(A)=0.7 and P(B)=0.5. Using the general addition law, P(A∪B)=P(A)+P(B)−P(A∩B)=0.7+0.5−P(A∩B)=1.2−P(A∩B).
- Maximum P(A∪B): The maximum probability of any event is 1. So, the maximum P(A∪B)=1. This occurs when P(A∩B)=1.2−1=0.2.
- Minimum P(A∪B): To minimize P(A∪B), we need to maximize P(A∩B). Since A∩B is a subset of both A and B, P(A∩B)≤P(A) and P(A∩B)≤P(B). The maximum possible value for P(A∩B) is min(P(A),P(B))=min(0.7,0.5)=0.5. Therefore, the minimum P(A∪B)=1.2−0.5=0.7. 262 263.
36.15 Addition law for three events
For any three events A, B, and C, the probability that at least one of them occurs is given by the addition law for three events. This law accounts for the probabilities of individual events, pairs of intersections, and the triple intersection 263.
The formula is: P(A∪B∪C)=P(A)+P(B)+P(C)−P(A∩B)−P(A∩C)−P(B∩C)+P(A∩B∩C)
If the three events are mutually disjoint, the formula simplifies to P(A∪B∪C)=P(A)+P(B)+P(C) 263.
36.16 Example: Newspaper readership
In a city, survey data shows:
- P(A)=0.20 (reads newspaper A)
- P(B)=0.16 (reads newspaper B)
- P(C)=0.14 (reads newspaper C)
- P(A∩B)=0.08 (reads A and B)
- P(A∩C)=0.05 (reads A and C)
- P(B∩C)=0.04 (reads B and C)
- P(A∩B∩C)=0.02 (reads all three)
The probability that a randomly chosen person reads at least one of the papers is: P(A∪B∪C)=0.20+0.16+0.14−0.08−0.05−0.04+0.02=0.35.
The probability that a person reads none of the papers is P((A∪B∪C)′)=1−P(A∪B∪C)=1−0.35=0.65. 263 264.
📝 The probability that a person reads newspaper A is P(A)=0.20, newspaper B is P(B)=0.16, and newspaper C is P(C)=0.14. The probability of reading A and B is P(A∩B)=0.08, A and C is P(A∩C)=0.05, B and C is P(B∩C)=0.04, and all three is P(A∩B∩C)=0.02. The probability of reading at least one paper is P(A∪B∪C)=0.20+0.16+0.14−0.08−0.05−0.04+0.02=0.35 263.
36.17 Example: Disjoint events and partitions
Given events A, B, and C in a sample space S such that A∪B∪C=S and A∩(B∪C)=ϕ. This means A is disjoint from the union of B and C.
- P(A)=0.2, P(B)=0.5, P(C)=0.7.
- Since A is disjoint from B∪C, P(A∪(B∪C))=P(A)+P(B∪C).
- As A∪B∪C=S, P(A∪(B∪C))=P(S)=1.
- So, 1=P(A)+P(B∪C)⇒1=0.2+P(B∪C)⇒P(B∪C)=0.8.
- Using the addition law for B and C: P(B∪C)=P(B)+P(C)−P(B∩C).
- 0.8=0.5+0.7−P(B∩C)⇒0.8=1.2−P(B∩C)⇒P(B∩C)=0.4 264.
| Event Type | Formula |
|---|---|
| Disjoint Events A and B | P(A∪B)=P(A)+P(B) |
| General Events A and B | P(A∪B)=P(A)+P(B)−P(A∩B) |
| Event A minus Event B | P(A∖B)=P(A)−P(A∩B) |
| Three Events A, B, C | P(A∪B∪C)=P(A)+P(B)+P(C)−P(A∩B)−P(A∩C)−P(B∩C)+P(A∩B∩C) |
37. Conditional probability
37.1 Conditional probability
Conditional probability quantifies the likelihood of an event occurring given that another event has already occurred. This concept is fundamental in understanding how new information can alter probability assessments.
- Conditional probability of event E given event F, denoted P(E∣F), is defined as the probability of event E occurring, knowing that event F has already occurred.
- The formula for conditional probability is: P(E∣F)=P(F)P(E∩F) where P(F)=0.
- P(E∩F) represents the probability that both events E and F occur 265.
📝 An urn contains 3 red, 2 blue, and 4 white balls. If a ball is selected at random, the probability of it being red is P(E)=3/9. If it is known that the selected ball is not white, the probability of it being red becomes 3/5, as there are now only 5 non-white balls (3 red, 2 blue). This illustrates P(red∣not white)=3/5 265.
37.2 Calculating conditional probability
Conditional probability calculations involve using the defined formula and understanding the intersection of events. These calculations can be applied to various scenarios, including dice rolls and selections from an urn.
- Given probabilities: If P(B)=1/4 and P(A∩B)=1/6, the conditional probability P(A∣B) is calculated as: P(A∣B)=P(B)P(A∩B)=1/41/6=64=32.
- Multiple probabilities: For events A and B with P(A)=1/2, P(B)=1/3, and P(A∩B)=1/4:
- P(A∣B)=P(B)P(A∩B)=1/31/4=43.
- P(B∣A)=P(A)P(B∩A)=1/21/4=21.
- P(A∪B)=P(A)+P(B)−P(A∩B)=1/2+1/3−1/4=7/12 266.
- P(Ac∣Bc)=P(Bc)P(Ac∩Bc)=P(Bc)P((A∪B)c)=1−P(B)1−P(A∪B)=1−1/31−7/12=2/35/12=85 267.
37.3 Special cases for conditional probability
The relationship between events, such as subset or mutual exclusivity, simplifies conditional probability calculations.
- A is a subset of B: When A is a subset of B (A⊆B), then A∩B=A. Therefore, P(B∣A)=P(A)P(B∩A)=P(A)P(A)=1.
- Mutually exclusive events: When A and B are mutually exclusive, A∩B=∅, so P(A∩B)=0. Thus, P(B∣A)=P(A)P(A∩B)=P(A)0=0, provided P(A)=0 267.
📝 An urn contains three red balls (1, 2, 3), one blue ball and four white balls (5, 6, 7, 8) 4.
- Probability of red: P(red)=3/8.
- Probability of an even number: P(even)=4/8=1/2 (numbers 2, 4, 6, 8).
- Probability of red given even number: P(red∣even)=P(even)P(red∩even)=4/81/8=1/4. The intersection is ball '2'.
- Probability of even number given red: P(even∣red)=P(red)P(red∩even)=3/81/8=1/3 268.
37.4 Conditional probability with dice and children
Conditional probability problems can involve scenarios like rolling dice or analyzing family structures, requiring careful definition of events and sample spaces.
📝 A pair of dice is tossed, and the sum is 7. Find the probability that one of the dice shows a 2.
- Let E be the event that a 2 appears on at least one die: E={(1,2),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),(3,2),(4,2),(5,2),(6,2)}.
- Let F be the event that the sum is 7: F={(1,6),(2,5),(3,4),(4,3),(5,2),(6,1)}.
- The intersection E∩F={(2,5),(5,2)}.
- P(F)=6/36 and P(E∩F)=2/36.
- The conditional probability is P(E∣F)=P(F)P(E∩F)=6/362/36=31 268.
📝 A family has two children. One child, a boy, enters the room. Find the probability the other child is also a boy.
- Sample space S={bb,bg,gb,gg}.
- Let A be the event both children are boys: A={bb}.
- Case (i): The other child is known to be elder. Let B be the event the younger is a boy: B={bb,bg}. A∩B={bb}. P(A∣B)=P(B)P(A∩B)=2/41/4=1/2.
- Case (ii): Nothing is known about the other child. Let C be the event one child is a boy: C={bb,bg,gb}. A∩C={bb}. P(A∣C)=P(C)P(A∩C)=3/41/4=1/3 269.
37.5 Multiplication theorem
The multiplication theorem provides a way to calculate the probability of the intersection of two or more events. It is derived directly from the definition of conditional probability.
- For two events E and F, the probability of their intersection is: P(E∩F)=P(F)P(E∣F) or equivalently, P(E∩F)=P(E)P(F∣E).
- For a sequence of events E1,E2,…,En, the probability of their intersection is: P(E1∩E2∩⋯∩En)=P(E1)P(E2∣E1)P(E3∣E1∩E2)…P(En∣E1∩E2∩⋯∩En−1) 269.
📝 A lot has 12 items, 4 of which are defective. Three items are drawn sequentially without replacement. What is the probability all three are non-defective?
- Let A1 be the event the first item is non-defective. P(A1)=8/12.
- Let A2 be the event the second item is non-defective, given the first was. P(A2∣A1)=7/11.
- Let A3 be the event the third item is non-defective, given the first two were. P(A3∣A1∩A2)=6/10.
- The probability of all three being non-defective is P(A1∩A2∩A3)=P(A1)P(A2∣A1)P(A3∣A1∩A2)=128×117×106=5514 269.
37.6 Independent events
Two events are considered independent if the occurrence of one does not affect the probability of the other. This simplifies probability calculations, particularly for intersections.
- An event A is independent of event B if P(A∣B)=P(A) 269.
- If A and B are independent, the multiplication theorem simplifies to: P(A∩B)=P(A)P(B) 270.
- This also implies P(B∣A)=P(B).
📝 Let A be the event a 4-bit string starts with 1, and B be the event it has an even number of 0s.
- Total 4-bit strings: 24=16.
- Event A: Strings starting with 1. There are 23=8 such strings. P(A)=8/16=1/2.
- Event B: Strings with an even number of 0s (0, 2, or 4 zeros). There are 8 such strings. P(B)=8/16=1/2.
- Intersection A∩B: Strings starting with 1 and having an even number of 0s. These are {1001, 1010, 1100, 1111}. P(A∩B)=4/16=1/4.
- Check for independence: P(A)P(B)=(1/2)(1/2)=1/4. Since P(A∩B)=P(A)P(B), events A and B are independent 270.
37.7 Pairwise independence
When dealing with three or more events, pairwise independence means that each pair of events is independent, but the events as a whole may not be mutually independent.
📝 A fair coin is tossed three times. Let A be the event the first toss is heads, B the second is heads, and C the event exactly two consecutive heads occur. Examine pairwise independence.
- Sample space S={HHH,HHT,HTH,HTT,THH,THT,TTH,TTT}.
- A={HHH,HHT,HTH,HTT}, P(A)=4/8=1/2.
- B={HHH,HHT,THH,THT}, P(B)=4/8=1/2.
- C={HHT,THH}, P(C)=2/8=1/4.
- A∩B={HHH,HHT}, P(A∩B)=2/8=1/4. P(A)P(B)=(1/2)(1/2)=1/4. A and B are independent 270.
- A∩C={HHT}, P(A∩C)=1/8. P(A)P(C)=(1/2)(1/4)=1/8. A and C are independent.
- B∩C={HHT,THH}, P(B∩C)=2/8=1/4. P(B)P(C)=(1/2)(1/4)=1/8. B and C are dependent 271.
📝 The probability A hits a target is 1/3, and B hits it is 2/5. What is the probability the target is hit if both shoot?
- Assume A and B are independent events.
- The probability the target is hit is P(A∪B).
- Using the formula for the union of independent events: P(A∪B)=P(A)+P(B)−P(A)P(B)=1/3+2/5−(1/3)(2/5)=1/3+2/5−2/15=5/15+6/15−2/15=9/15=3/5 271.
38. Random variable
38.1 Random variable
A random variable is a rule that assigns a numerical value to each outcome in a sample space. It functions as a mapping from the sample space to the set of real numbers.
Random variables are typically denoted by capital letters (e.g., X, Y), and the values they take are represented by corresponding lowercase letters 272.
- Stochastic variable: An alternative term for a random variable, emphasizing its probabilistic nature.
- Range space: The set of numerical values assigned by a random variable to the outcomes in its sample space 272.
Example: When a pair of fair dice is tossed, the sample space S contains 36 ordered pairs. If X assigns the sum of the numbers to each outcome, X is a random variable with a range space of {2, 3,..., 12}.
If Y assigns the maximum of the two numbers, its range space is {1, 2,..., 6} 272.
38.2 Probability distribution of a random variable274
The probability distribution (or probability function) of a random variable X, denoted by f(xi), assigns a probability to each possible value xi in its range space. It is defined as the sum of the probabilities of all sample space points that map to xi.
The distribution must satisfy two conditions: f(xi) ≥ 0 for all xi, and the sum of all f(xi) must equal 1 273.
Example: For a pair of fair dice tossed, where X is the sum of the numbers:
- P(X=2) = P({(1,1)}) = 1/36
- P(X=3) = P({(1,2), (2,1)}) = 2/36
- P(X=4) = P({(1,3), (2,2), (3,1)}) = 3/36 *...and so on, up to P(X=12) = P({(6,6)}) = 1/36 273.
Example: A box contains 12 items, 3 defective. A sample of 3 is selected.
If X is the number of defective items:
- P(X=0) = (3 choose 0) * (9 choose 3) / (12 choose 3) = 84/220
- P(X=1) = (3 choose 1) * (9 choose 2) / (12 choose 3) = 108/220
- P(X=2) = (3 choose 2) * (9 choose 1) / (12 choose 3) = 27/220
- P(X=3) = (3 choose 3) * (9 choose 0) / (12 choose 3) = 1/220 274.
| xi | f(xi) |
|---|---|
| 2 | 1/36 |
| 3 | 2/36 |
| 4 | 3/36 |
| 5 | 4/36 |
| 6 | 5/36 |
| 7 | 6/36 |
| 8 | 5/36 |
| 9 | 4/36 |
| 10 | 3/36 |
| 11 | 2/36 |
| 12 | 1/36 |
| 1 | 1/36 |
| xi | pi |
|---|---|
| 0 | 84/220 |
| 1 | 108/220 |
| 2 | 27/220 |
| 3 | 1/220 |
38.3 Expectation of a random variable 277
The expectation of a random variable X, denoted E(X) or μ, is the weighted average of its possible values, where the weights are the probabilities of those values. It is calculated by summing the product of each value xi and its probability f(xi) 275.
The formula for expectation is: E(X)=μ=∑i=1nxif(xi) 275.
Example: For three fair coins tossed, where X is the number of heads:
- Possible values of X: 0, 1, 2, 3
- Probabilities: P(X=0)=1/8, P(X=1)=3/8, P(X=2)=3/8, P(X=3)=1/8
- E(X) = (0 * 1/8) + (1 * 3/8) + (2 * 3/8) + (3 * 1/8) = 12/8 = 1.5 275.
Example: A player tosses two fair coins, winning Rs. 1 for one head, Rs. 2 for two heads, and losing Rs. 5 for no heads.
- P(Two heads) = P(HH) = 1/4
- P(One head) = P(HT, TH) = 2/4
- P(No heads) = P(TT) = 1/4
- Expected value E = (2 * 1/4) + (1 * 2/4) + (-5 * 1/4) = 2/4 + 2/4 - 5/4 = -1/4 = -0.25. The game is unfavorable 276.
Example: A weighted coin with P(H) = 3/4 and P(T) = 1/4 is tossed three times. X is the number of heads.
- Distribution of X:
- P(X=0) = P(TTT) = (1/4)^3 = 1/64
- P(X=1) = P(HTT, THT, TTH) = 3 * (3/4) * (1/4)^2 = 9/64
- P(X=2) = P(HHT, HTH, THH) = 3 * (3/4)^2 * (1/4) = 27/64
- P(X=3) = P(HHH) = (3/4)^3 = 27/64
- E(X) = (0 * 1/64) + (1 * 9/64) + (2 * 27/64) + (3 * 27/64) = (9 + 54 + 81) / 64 = 144/64 = 2.25 277.
| xi | f(xi) |
|---|---|
| 0 | 1/64 |
| 1 | 9/64 |
| 2 | 27/64 |
| 3 | 27/64 |
38.4 Variance and standard deviation of a random variable 279
The variance of a random variable X, denoted Var(X) or σ², measures the spread or dispersion of its values around the mean μ. It is calculated as the expected value of the squared difference between X and its mean 277.
The formulas for variance are: σ2=Var(X)=∑i=1n(xi−μ)2f(xi)=E((X−μ)2) A more convenient form for computation is: σ2=E(X2)−μ2=∑i=1nxi2f(xi)−μ2 278.
The standard deviation, denoted σₓ, is the non-negative square root of the variance 278.
Example: For a distribution with values xi and probabilities f(xi):
- xi: 1, 3, 4, 5
- f(xi): 0.4, 0.1, 0.2, 0.3
- μ = E(X) = 1(0.4) + 3(0.1) + 4(0.2) + 5(0.3) = 0.4 + 0.3 + 0.8 + 1.5 = 3.0.
- E(X²) = 1²(0.4) + 3²(0.1) + 4²(0.2) + 5²(0.3) = 0.4 + 0.9 + 3.2 + 7.5 = 12.0.
- σ² = Var(X) = E(X²) - μ² = 12.0 - (3.0)² = 12.0 - 9.0 = 3.0.
- σ = √3.0 ≈ 1.7 278.
Example: A pair of fair dice is thrown. X denotes the maximum of the two numbers.
- Distribution of X:
- P(X=1) = 1/36
- P(X=2) = 3/36
- P(X=3) = 5/36
- P(X=4) = 7/36
- P(X=5) = 9/36
- P(X=6) = 11/36
- μ = E(X) = (11 + 23 + 35 + 47 + 59 + 611) / 36 = 161/36 ≈ 4.5.
- E(X²) = (1²1 + 2²3 + 3²5 + 4²7 + 5²9 + 6²11) / 36 = 791/36 ≈ 22.0.
- σ² = Var(X) = E(X²) - μ² ≈ 22.0 - (4.5)² ≈ 22.0 - 20.25 = 1.75 (Note: source states 17.5, likely a typo in calculation or transcription).
- σₓ = √Var(X) ≈ √1.75 ≈ 1.3 279.
See the table in section 38.2.
39. Introduction to graphs
39.1 Graph definition and terminology
A graph is a mathematical structure consisting of a set of vertices (points or nodes) and a set of edges (line segments) that connect pairs of vertices. This structure is fundamental in computer science for modeling relationships and networks 280.
- An edge connects one or two vertices, called its endpoints.
- A loop is an edge that connects a vertex to itself, having only one endpoint.
- Adjacent vertices are connected by an edge. A vertex is adjacent to itself if it has a loop.
- An incident edge connects to a vertex; the edge is incident on its endpoints.
- An isolated vertex has no edges incident on it.
- Parallel edges are distinct edges that share the same set of endpoints 280.
| Graph Element | Description |
|---|---|
| Vertex Set (V) | A finite set of points or nodes. |
| Edge Set (E) | A finite set of line segments connecting pairs of vertices. |
| Endpoints of an edge | The vertices connected by an edge. |
| Loop | An edge connecting a vertex to itself. |
| Adjacent vertices | Two vertices connected by an edge. |
| Incident edge | An edge connected to a vertex. |
| Isolated vertex | A vertex with no incident edges. |
| Parallel edges | Distinct edges with the same endpoints. |
39.2 Simple graphs
A simple graph is a graph that contains no loops and no parallel edges 282.
📝 A graph with vertices {v1, v2, v3, v4} and edges {e1, e2, e3} where e1 connects {v1, v2}, e2 connects {v1, v3}, and e3 connects {v3} is a simple graph because it has no loops and no parallel edges 282.
39.3 Degree of a vertex
The degree of a vertex, denoted deg(v), is the number of edges incident on it. A loop is counted twice in the degree calculation 283.
- The total degree of a graph is the sum of the degrees of all its vertices 283.
39.4 The Handshaking Theorem
The Handshaking Theorem states that the sum of the degrees of all vertices in any graph is equal to twice the number of edges. This is because each edge contributes exactly one to the degree of each of its two endpoints, or two to the degree of the vertex if it's a loop 283 284.
- Corollary: The total degree of any graph is always an even number 284.
| Property | Description |
|---|---|
| Total degree of G | Sum of degrees of all vertices in G. |
| Relationship to edges | Total degree of G = 2 * (Number of edges in G). |
| Parity of total degree | Always an even number. |
39.5 Graph existence based on vertex degrees
The Handshaking Theorem can be used to determine if a graph with a specified set of vertex degrees can exist. If the sum of the specified degrees is odd, no such graph is possible 284.
- Example: A graph with four vertices of degrees 1, 2, 3, and 3 has a total degree of 1 + 2 + 3 + 3 = 9, which is odd. Therefore, no such graph can exist.
- Example: A graph with four vertices of degrees 1, 2, 3, and 4 is possible because the total degree is 1 + 2 + 3 + 4 = 10, which is even.
- Example: A simple graph with four vertices of degrees 1, 2, 3, and 4 is not possible. A vertex with degree 4 in a simple graph with only four vertices would need to connect to four other distinct vertices, which is impossible 284.
39.6 Complete graphs
A complete graph on n vertices, denoted Kn, is a simple graph where every distinct pair of vertices is connected by an edge 285.
- For a complete graph Kn:
- Each vertex has a degree of n−1.
- The total degree is n(n−1).
- The number of edges is (2n)=2n(n−1) 286.
| Graph Type | Description |
|---|---|
| Complete graph Kn | A simple graph with n vertices where every pair of distinct vertices is connected by an edge. |
39.7 Regular graphs
A graph G is regular of degree k, or k-regular, if every vertex in G has a degree of k 286.
- A complete graph Kn is (n−1)-regular 286.
| Graph Type | Degree of Each Vertex |
|---|---|
| 0-regular graph | 0 |
| 1-regular graph | 1 |
| 2-regular graph | 2 |
| k-regular graph | k |
| Complete graph Kn | n-1 |
39.8 Bipartite graphs
A bipartite graph is a simple graph whose vertex set can be divided into two disjoint, non-empty subsets, say A and B, such that every edge connects a vertex in A to one in B. No edges exist between vertices within the same subset (A to A, or B to B) 287.
39.9 Determining if a graph is bipartite
A graph can be determined to be bipartite using a labeling procedure:
- Label an arbitrary vertex with 'a'.
- Label all vertices adjacent to 'a' with 'b'.
- Label all vertices adjacent to a 'b'-labeled vertex with 'a'.
- Continue alternating labels. If at any point a vertex needs to be labeled with both 'a' and 'b', or if an edge connects two vertices with the same label, the graph is not bipartite. If all vertices can be labeled distinctly without conflict, the graph is bipartite 287.
- Example: A graph with vertices labeled 'a' and 'b' where an edge connects two 'a' vertices is not bipartite.
- Example: A graph where vertices can be consistently labeled 'a' or 'b' such that all edges connect an 'a' vertex to a 'b' vertex is bipartite 288.
39.10 Complete bipartite graphs
A complete bipartite graph on (m+n) vertices, denoted Km,n, is a bipartite graph where the vertex set is partitioned into two subsets A (with m vertices) and B (with n vertices), and every vertex in A is connected to every vertex in B. No edges exist within A or within B 288.
| Graph Type | Description |
|---|---|
| Bipartite graph | Vertex set partitioned into two sets A and B; edges only connect vertices between A and B. |
| Complete bipartite graph Km,n | A bipartite graph with vertex sets A (m vertices) and B (n vertices), where every vertex in A is connected to every vertex in B. |
40. Paths and Circuits
40.1 Walks, Circuits, and Paths
A walk is a sequence of alternating vertices and edges in a graph, starting and ending at specified vertices. Different types of walks are defined by restrictions on repeated vertices and edges, and whether they start and end at the same point.
These definitions are crucial for understanding graph traversal 289 290.
- Walk: A sequence v0e1v1e2…vn−1envn where v0 is the start vertex and vn is the end vertex. Vertices and edges can be repeated.
- Trivial walk: A walk consisting of a single vertex.
- Closed walk: A walk that starts and ends at the same vertex (v0=vn) 289.
- Circuit: A closed walk where no edge is repeated. Vertices can be repeated.
- Simple circuit: A circuit where no vertex is repeated, except for the start and end vertex being the same.
- Path: A walk from vertex v to vertex w where no edge is repeated. Vertices can be repeated.
- Simple path: A path where no vertex is repeated 290.
| Type | Repeated Edge Allowed | Repeated Vertex Allowed | Starts and Ends at Same Point |
|---|---|---|---|
| Walk | Yes | Yes | Yes |
| Closed walk | Yes | Yes | Yes |
| Circuit | No | Yes | Yes |
| Simple circuit | No | No (except start/end) | Yes |
| Path | No | Yes | Yes |
| Simple path | No | No | No |
The following examples classify given sequences based on these definitions:
- (a) v1e2v2e3v3e4v4e5v2e2v1e1v0: This is a walk because vertex v2 and edge e2 are repeated, and it does not start and end at the same vertex.
- (b) v1v2v3v4v5v2: This is a path because vertex v2 is repeated, but no edges are repeated.
- (c) v4v2v3v4v5v2v4: This is a closed walk because vertices v2 and v4 are repeated, the graph starts and ends at v4, and edge e5 is repeated.
- (d) v2v1v5v2v3v4v2: This is a circuit because vertex v2 is repeated, it starts and ends at v2, and no edges are repeated 291.
- (e) v0v5v2v3v4v2v1: This is a path because vertex v2 is repeated, but no edges are repeated.
- (f) v5v4v2v1: This is a simple path because neither vertices nor edges are repeated 292.
40.2 Connectedness
A graph is considered connected if there is a walk between any two vertices within the graph. This property ensures that all parts of the graph are reachable from each other 292.
- Connectedness: A graph G is connected if for any two vertices v,w∈V(G), there exists a walk from v to w 292.
Consider the following examples to determine connectedness:
- (a) This graph is connected as there is a walk between any two vertices.
- (b) This graph is connected.
- (c) This graph is connected 292.
40.3 Euler Circuits
An Euler circuit is a specific type of circuit that traverses every edge of a graph exactly once and visits every vertex at least once, starting and ending at the same vertex 292.
- Euler circuit: A circuit that includes every vertex and every edge of a graph 292.
A graph has an Euler circuit if and only if it is connected and every vertex has an even degree 293.
- Theorem: A graph G has an Euler circuit ⟺ G is connected and deg(v) is even for all v∈V(G) 293.
Applying this theorem to the Königsberg Bridges problem:
- The Königsberg Bridges problem graph has vertices with odd degrees (3, 3, 3, and 5), thus it does not have an Euler circuit.
- A graph with deg(v1)=5 (an odd degree) does not have an Euler circuit.
- A graph where all vertices have even degrees (deg(a)=2,deg(b)=4,…,deg(i)=4) has an Euler circuit. One example is a→b→c→d→e→f→g→d→f→i→h→c→g→h→b→i→a 293.
40.4 Euler Paths
An Euler path is a sequence that traverses every edge of a graph exactly once, starting at one vertex and ending at another 294.
- Euler path: A path from vertex v to vertex w that passes through every vertex at least once and traverses every edge exactly once 294.
A graph has an Euler path between two vertices if it is connected, those two vertices have odd degrees, and all other vertices have even degrees 294.
- Corollary: A graph G has an Euler path from v to w ⟺ G is connected, deg(v) and deg(w) are odd, and deg(u) is even for all other vertices u∈V(G) 294.
40.5 Hamiltonian Circuits
A Hamiltonian circuit is a simple circuit that includes every vertex of a graph exactly once 294.
- Hamiltonian circuit: A simple circuit in which every vertex of G appears exactly once 294.
Examples of Hamiltonian circuits:
- For a given graph, one Hamiltonian circuit is a→b→d→e→f→c→g→h→a.
- Another possible Hamiltonian circuit for the same graph is a→b→c→d→e→f→g→h→a 294.
A graph with a Hamiltonian circuit must have a subgraph H with specific properties: H contains all vertices of G, is connected, has the same number of edges as vertices, and every vertex in H has a degree of 2 294.
- Proposition: If G has a Hamiltonian circuit, then G has a subgraph H such that:
- H contains every vertex of G.
- H is connected.
- H has ∣E(H)∣=∣V(H)∣.
- Every vertex of H has degree 2 294.
Consider a graph that does not have a Hamiltonian circuit:
- A graph with deg(c)=5 may not have a Hamiltonian circuit. Removing 3 edges from vertex c would reduce the degrees of adjacent vertices (b,g,f,d) to less than 2, violating the properties required for a Hamiltonian circuit 295.
41. Matrix Representation of Graphs
41.1 Matrix Definition and Properties
A matrix is a rectangular array of elements arranged in rows and columns. It is denoted as A=[aij]m×n, where m is the number of rows and n is the number of columns.
A square matrix has an equal number of rows and columns (m=n). The main diagonal of a square matrix consists of entries where the row index equals the column index (aii).
The transpose of a matrix A, denoted At, is obtained by interchanging its rows and columns. If A is an m×n matrix, At is an n×m matrix.
A symmetric matrix is a square matrix where At=A, meaning aij=aji for all i and j.
Matrix multiplication AB is defined only if the number of columns in matrix A equals the number of rows in matrix B. If A is m×p and B is p×n, their product AB is an m×n matrix where the entry cij is calculated as cij=∑k=1paikbkj 296 297 298.
41.2 Adjacency Matrix of a Graph
The adjacency matrix A of a graph G with ordered vertices v1,v2,…,vn is an n×n matrix where aij represents the number of edges connecting vertex vi and vertex vj. If aij=1 and aji=1, it signifies an edge between vi and vj.
Non-zero entries on the main diagonal (aii) indicate loops at vertex vi, and entries greater than 1 suggest parallel edges. For undirected graphs, the adjacency matrix is always symmetric 299.
The adjacency matrix for a directed graph (digraph) is defined similarly, where aij is the number of directed edges (arrows) from vertex vi to vertex vj. In a digraph, the adjacency matrix is not necessarily symmetric 300.
| Graph Type | Matrix Entry (a_ij) | Symmetry |
|---|---|---|
| Undirected Graph | Number of edges between v_i and v_j | Symmetric |
| Directed Graph (Digraph) | Number of directed edges from v_i to v_j | Not necessarily symmetric |
41.3 Walks and Adjacency Matrices
A fundamental theorem states that if A is the adjacency matrix of a graph G with vertices v1,…,vn, then the entry (i,j) of Ak (the matrix A multiplied by itself k times) equals the number of walks of length k from vertex vi to vertex vj 301.
Let A=112101210 be the adjacency matrix of graph G with vertices v1,v2,v3.
-
Number of walks of length 2 from v2 to v3: This is found by calculating A2. A2=A×A=112101210112101210=633322325. The entry at position (2,3) in A2 is 2, indicating there are 2 walks of length 2 from v2 to v3 301 302.
-
Number of walks of length 3 from v1 to v3: This is found by calculating A3. A3=A×A2=112101210633322325=159159581588. The entry at position (1,3) in A3 is 15, indicating there are 15 walks of length 3 from v1 to v3 302.
📝 For the graph with adjacency matrix A=112101210, the entry (2,3) of A2 is 2. This means there are exactly two distinct paths of length 2 from vertex v2 to vertex v3 301 302.
41.4 Incidence Matrix of a Simple Graph
The incidence matrix M of a simple graph G with n vertices (v1,…,vn) and m edges (e1,…,em) is an n×m matrix where mij=1 if vertex vi is incident on edge ej, and mij=0 otherwise. Multiple edges are represented by columns with identical entries, and loops are represented by a column with a single '1' entry corresponding to the incident vertex 302.
| Feature | Representation in Incidence Matrix |
|---|---|
| Vertex incidence on an edge | 1 if vertex v_i is incident on edge e_j, 0 otherwise |
| Multiple edges | Columns with identical entries |
| Loops | A column with a single '1' entry for the incident vertex |
42. Isomorphism of graphs
42.1 Isomorphism of graphs
Two graphs, G and G', are considered isomorphic if they are structurally identical, meaning there's a one-to-one correspondence between their vertices and edges that preserves adjacency. This structural identity is independent of how the vertices and edges are labeled.
The concept of isomorphism is crucial because it allows us to recognize that different representations can describe the same underlying graph structure 304.
42.2 Definition of isomorphic graphs
Let G and G' be graphs with vertex sets V(G) and V(G'), and edge sets E(G) and E(G'), respectively. G is isomorphic to G' if and only if there exist bijective functions g: V(G) → V(G') and h: E(G) → E(G') such that for every vertex v ∈ V(G) and every edge e ∈ E(G), v is an endpoint of e if and only if g(v) is an endpoint of h(e).
This condition ensures that the adjacency relationships between vertices and edges are preserved under the mapping 304.
42.3 Graph isomorphism as an equivalence relation
Graph isomorphism is an equivalence relation on the set of all graphs. This means it satisfies three properties:
- Reflexivity: Every graph is isomorphic to itself.
- Symmetry: If graph G is isomorphic to graph G', then G' is also isomorphic to G.
- Transitivity: If graph G is isomorphic to G', and G' is isomorphic to G'', then G is isomorphic to G'' 304.
42.4 Isomorphic invariants
An isomorphic invariant is a property of a graph that remains unchanged if the graph is isomorphic to another graph. If two graphs have different values for an isomorphic invariant, they cannot be isomorphic.
This concept is fundamental for proving that two graphs are not isomorphic 305.
42.5 Properties that are isomorphic invariants 305
Several graph properties serve as isomorphic invariants. If two graphs are isomorphic, they must share these properties.
| Property | Description |
|---|---|
| Number of vertices | An isomorphic graph must have the same number of vertices. |
| Number of edges | An isomorphic graph must have the same number of edges. |
| Vertex degree | If a graph has a vertex of degree k, any isomorphic graph must also have a vertex of degree k. This extends to having m vertices of degree k. |
| Circuit existence | The presence of circuits of a certain length (simple or otherwise) is an invariant. |
| Connectivity | Whether a graph is connected or not is an invariant. |
| Euler circuit | A graph having an Euler circuit implies any isomorphic graph also has one. |
| Hamiltonian circuit | Similarly, the existence of a Hamiltonian circuit is an invariant. |
📝 If two graphs are isomorphic, they must have the same number of vertices, the same number of edges, and the same vertex degrees 305.
42.6 Degree sequence
The degree sequence of a graph is a list of the degrees of all its vertices, arranged in non-increasing order. This sequence is an isomorphic invariant because if two graphs are isomorphic, their vertices must have corresponding degrees, resulting in identical degree sequences 305.
42.7 Example: Finding the degree sequence
Consider a graph with vertices labeled a, b, c, d, and e. The degrees are: degree(a) = 2, degree(b) = 3, degree(c) = 1, degree(d) = 2, and degree(e) = 0. Arranging these in non-increasing order gives the degree sequence: 3, 2, 2, 1, 0 305.
📝 For a graph with vertices a, b, c, d, and e having degrees 2, 3, 1, 2, and 0 respectively, the degree sequence in non-increasing order is 3, 2, 2, 1, 0 305.
42.8 Graph isomorphism for simple graphs
For simple graphs (graphs without loops or parallel edges), isomorphism can be defined by the existence of a bijective mapping between their vertex sets that preserves adjacency. That is, two vertices {u, v} form an edge in graph G if and only if their corresponding mapped vertices {g(u), g(v)} form an edge in graph G' 305.
42.9 Testing for non-isomorphism
While there is no efficient general algorithm to definitively prove isomorphism for all graphs, isomorphic invariants provide a practical way to prove that two graphs are not isomorphic. If any invariant differs between two graphs, they cannot be isomorphic 306.
42.10 Example: Non-isomorphic graphs due to edge count
Graph G has 5 vertices and 7 edges. Graph G' has 5 vertices but only 6 edges.
Since the number of edges differs, G and G' are not isomorphic 306.
42.11 Example: Non-isomorphic graphs due to vertex degrees
Graph G has 5 vertices and 7 edges. Graph G' also has 5 vertices and 7 edges.
However, G' has a vertex of degree 5, while G does not have any vertex with degree 5. Therefore, G and G' are not isomorphic 306.
42.12 Example: Non-isomorphic graphs due to connectivity
Graph G has vertices with degree 2, and the same number of vertices and edges as G'. However, G' is a connected graph, while G is not connected, consisting of two components.
Thus, G and G' are not isomorphic 307.
42.13 Example: Non-isomorphic graphs due to circuit length
Graphs G and G' have the same number of vertices and edges. G contains two simple circuits of length 3 (abca and defd).
G' has a simple circuit (uxwv) of length 4 but no simple circuit of length 3. Therefore, G and G' are not isomorphic 307.
42.14 Example: Non-isomorphic graphs due to circuit length (continued)
Graphs G and G' both have 8 vertices and 12 edges, and each vertex has a degree of 3. Graph G contains two simple circuits of length 5 (abcfea and cdhgfc). Graph G' does not have any simple circuit of length 5; its longest simple circuits have length 4 (e.g., tyxut).
Therefore, G and G' are not isomorphic 308.
42.15 Proving isomorphism
Proving that two graphs are isomorphic requires demonstrating a specific bijective mapping between their vertices and edges that preserves adjacency. This mapping is not always unique 308.
42.16 Example: Proving isomorphism with a bijective mapping
Consider two graphs G and G'. Both have four vertices of degree 2 and two vertices of degree 3. They also have circuits of length 4. A bijective function f: V(G) → V(G') can be defined, for instance, mapping a to u, b to v, c to y, d to x, e to w, and f to z. This mapping preserves edge endpoints, demonstrating that G and G' are isomorphic 308.
42.17 Non-isomorphic simple graphs
The number of non-isomorphic simple graphs with a small number of vertices is limited. For instance, there are four non-isomorphic simple graphs with three vertices 311.
42.18 Non-isomorphic connected simple graphs
When considering only connected simple graphs, the number of non-isomorphic structures decreases. There are two non-isomorphic connected simple graphs with three vertices.
For four vertices, there are six non-isomorphic connected simple graphs 311.
43. Planar graphs
43.1 Planar graphs and plane drawings
A graph is considered planar if it can be drawn on a flat surface without any of its edges crossing. This type of drawing, where no edges intersect, is called a plane drawing.
A graph's crossing number is zero if and only if it is planar 312.
- Complete graphs: Complete graphs with four or fewer vertices (Kn where n≤4) are planar 312.
- 3-cube graph (Q3): This graph, with 8 vertices and 12 edges, can be drawn without edge crossings, demonstrating its planarity 313.
- K3,3 graph: This complete bipartite graph is not planar. Although it can be redrawn to reduce crossings, it's impossible to eliminate them entirely.
- K5 graph: The complete graph with five vertices (K5) is also non-planar, as any attempt to draw it without edge crossings results in intersections 314.
43.2 Faces in a plane drawing
A plane drawing of a planar graph divides the plane into distinct regions. These regions are known as faces, and they include one unbounded region called the infinite face 315.
- Face count: The number of faces in a plane drawing depends on the specific drawing and the graph itself. For example, one graph has 6 faces, with one being the infinite face, while another has 8 faces, with one being infinite 315.
📝 In a plane drawing of a graph, one region is designated as the infinite face 315.
43.3 Euler's formula
Euler's formula provides a relationship between the number of vertices, edges, and faces in a connected planar simple graph. For such a graph with v vertices, e edges, and f faces in a plane drawing, the formula is f=e−v+2 315.
- Problem: If a connected planar simple graph has 30 edges and a plane drawing with 20 faces, it has 12 vertices 316.
43.4 Graph coloring and maps
Graph coloring is used to solve problems involving maps, where adjacent regions must be assigned different colors. The goal is to use the minimum number of colors possible 316.
- Map representation: Each region in a map can be represented as a vertex in a graph. Edges connect vertices if their corresponding regions share a common border. Regions touching at only a single point are not considered adjacent 316.
43.5 Vertex coloring and chromatic number
A coloring of a simple graph assigns a color to each vertex such that no two adjacent vertices share the same color. The chromatic number of a graph is the smallest number of colors required for such a coloring 317.
- Graph G: The chromatic number of graph G is 3. Vertices a, b, and c are mutually adjacent, requiring three distinct colors. Subsequent vertex coloring follows adjacency rules.
- Graph H: The chromatic number of graph H is 4. This is determined by the minimum colors needed to color its vertices without adjacent vertices having the same color 317.
43.6 The Four Color Theorem
The Four Color Theorem states that the chromatic number of any simple planar graph is at most four. This means any map drawn on a plane can be colored using no more than four colors such that no two adjacent regions share the same color 318.
43.7 Application of graph coloring
Graph coloring has practical applications, such as determining the minimum number of areas needed to store chemicals that react violently when in contact 318.
- Chemical storage problem: Five chemicals (a, b, c, d, e) need to be stored in separate areas if they react. A graph represents this, with vertices for chemicals and edges for reactive pairs. The chromatic number of this graph indicates the minimum number of areas required.
- Example: For a specific set of five chemicals and their reactive pairs, the graph requires 4 colors, meaning 4 areas are needed 318.
44. Trees
44.1 Tree definition and applications
A tree is a connected graph that contains no non-trivial circuits, meaning it is circuit-free. Trees are utilized across various disciplines, including computer science, for tasks such as efficient data searching, network construction, data compression, and modeling decision-making processes 319.
- Applications of trees:
- Constructing efficient algorithms for locating items in a list.
- Building networks with minimal cost to link distributed computers.
- Creating efficient codes for data storage and transmission.
- Modeling sequential decision-making procedures, valuable in sorting algorithm studies.
- Tree definition: A connected graph with no circuits.
- Non-trees: Graphs that are not trees include those with circuits or those that are disconnected 319.
44.2 Special trees and properties
Special types of trees include the trivial tree (a single vertex), the empty tree (no vertices or edges), and a forest (a circuit-free graph, where connected components are trees). Key properties relate the number of vertices and edges, connectivity, and the existence of unique paths 320 321.
- Trivial tree: A graph consisting of a single vertex.
- Empty tree: A tree with no vertices or edges.
- Forest: A circuit-free graph; its connected components are trees 320.
📝 A forest is a circuit-free graph, and its connected components are trees. For example, a graph with two separate trees, each with no circuits, would be considered a forest 320.
44.3 Properties of trees
- A tree with n vertices has n−1 edges (n≥0).
- A connected graph with n vertices and n−1 edges is a tree.
- Adding one edge to a tree (without adding a vertex) creates exactly one circuit.
- A tree is connected; removing any edge disconnects it.
- A tree with more than one vertex has at least two vertices of degree 1 320.
- A graph is a tree if and only if there is a unique path between any two of its vertices 321.
44.4 Non-isomorphic trees
The number and structure of non-isomorphic trees depend on the number of vertices. For a given number of vertices, the number of edges and the possible degree combinations for vertices can be determined 321.
- A tree with four vertices has three edges and a total degree of 6. Possible degree combinations for vertices are (1, 1, 1, 3) and (1, 1, 2, 2).
- There are three distinct non-isomorphic trees with five vertices, each having four edges. Degree combinations observed include (1, 2, 2, 2, 2), (1, 1, 1, 2, 3), and (1, 1, 1, 1, 4) 321.
44.5 Terminal and internal vertices
In a tree, a terminal vertex (or leaf) is a vertex with a degree of 1. An internal vertex (or branch vertex) is a vertex with a degree greater than 1 322.
44.6 Rooted trees
A rooted tree is a tree where one vertex is designated as the root. The level of a vertex is the number of edges on the unique path from the root to that vertex.
The height of a rooted tree is the maximum level of any vertex 322.
- Children: Vertices adjacent to an internal vertex v and one level farther from the root than v.
- Parent: If w is a child of v, then v is the parent of w.
- Siblings: Two vertices that share the same parent.
- Ancestor: If vertex v is on the unique path between vertex w and the root, v is an ancestor of w.
- Descendant: If vertex v is an ancestor of vertex w, then w is a descendant of v 322.
44.7 Rooted tree example
For a rooted tree with root v0, if v8 is at level 3, v0 is at level 0, and the height of the tree is 5, then v10 might have children v14,v15,v16. Siblings of v1 could be v3,v4,v5, and descendants of v12 might include v17,v18,v19 323.
44.8 Binary trees
A binary tree is a rooted tree where each internal vertex has at most two children, designated as either a left or right child. A full binary tree is a binary tree where every internal vertex has exactly two children 324.
44.9 Theorems about binary trees
- A full binary tree with k internal vertices has 2k+1 total vertices and k+1 terminal vertices.
- For a binary tree with t terminal vertices and height h, t≤2h 324.
44.10 Binary tree examples
- A full binary tree with seven vertices has 3 internal vertices and 4 terminal vertices.
- A binary tree with height 3 can have at most 23=8 terminal vertices. A binary tree with height 3 and 7 terminal vertices exists, implying 6 internal vertices 325.
44.11 Representation of algebraic expressions
Binary trees are used to represent algebraic expressions with nested parentheses. In these representations, terminal vertices typically represent variables, and internal vertices represent arithmetic operators 325 326.
- The expression a/b can be represented with '/' as the root, 'a' as the left child, and 'b' as the right child.
- The expression a/(c+d) has '/' as the root, 'a' as its left child, and the subtree for 'c+d' as its right child. In the 'c+d' subtree, '+' is the root, with 'c' and 'd' as its children.
- The expression a/(b−c⋅d) can be represented by a binary tree where the root is the division operator '/'. Its left child is the variable 'a'. Its right child is the subtraction operator '-', whose left child is 'b' and whose right child is the multiplication operator '⋅', with 'c' and 'd' as its left and right children, respectively 326.
45. Spanning Trees
45.1 Spanning trees
A spanning tree for a graph G is a subgraph that includes all vertices of G and is a tree, meaning it is connected and circuit-free. Developing a system of roads between cities, for example, might require finding a set of roads that connect all cities with the minimum number of connections 327.
- Definition: A spanning tree of a graph G is a subgraph of G that contains every vertex of G and is a tree.
- Existence: Every connected graph has at least one spanning tree.
- Uniqueness: A graph can have multiple spanning trees, but any two spanning trees for a given graph will always have the same number of edges.
- Tree as its own spanning tree: If a graph is already a tree, its only spanning tree is the graph itself 327.
To find a spanning tree for a connected graph with n vertices and e edges, you must remove e−(n−1) edges. This is achieved by identifying and deleting edges that form cycles until no cycles remain 328.
- Example: For a graph with 6 vertices and 9 edges, a spanning tree will have 9−(6−1)=4 fewer edges, resulting in 6−1=5 edges.
- Finding a spanning tree: This involves systematically deleting edges from cycles until the remaining subgraph is a tree 328.
📝 Consider a graph with 4 vertices and 5 edges. To find a spanning tree, we must delete 5−(4−1)=2 edges from cycles.
For instance, deleting edges v0v1 and v1v2 from a graph containing cycles v0−v1−v2−v0 and v1−v3−v2−v1 would result in a spanning tree 328 329.
- Complete bipartite graph: A complete bipartite graph K1,5 with 6 vertices and 5 edges is itself a tree and therefore its own spanning tree.
- Complete graph: For a complete graph K4 with 4 vertices and 6 edges, a spanning tree requires 6−(4−1)=3 fewer edges. Removing edges ab, bd, and cd from K4 yields a spanning tree 330.
45.2 Kirchhoff’s theorem (Matrix-Tree Theorem)
Kirchhoff's theorem provides a method to calculate the number of spanning trees in a connected graph using its adjacency matrix. It involves constructing a specific matrix M and then finding the value of any cofactor of M 331.
- Matrix M construction: Start with the adjacency matrix of the graph. Replace all 1s with -1s. Replace each diagonal 0 with the degree of the corresponding vertex.
- Number of spanning trees: The number of spanning trees of a connected graph G is equal to the value of any cofactor of the matrix M 331.
Example: For a graph with adjacency matrix A(G), the matrix M is constructed. The cofactor of the element at (1,1) in M is calculated by expanding the determinant of the submatrix obtained by removing the first row and first column 331 332.
- Calculation: Expanding the cofactor involves calculating a determinant. For the given example, the cofactor calculation results in 8.
- Non-isomorphic spanning trees: A graph can have multiple spanning trees that are structurally identical (isomorphic). The theorem counts all spanning trees, not just unique structural types 332.
45.3 Minimal spanning trees
A minimal spanning tree (MST) is a spanning tree for a weighted graph that has the smallest possible sum of edge weights among all possible spanning trees. This is crucial in applications like designing pipeline networks where minimizing construction costs is essential 332 333.
- Weighted graph: A graph where each edge is assigned a real number weight, representing cost, distance, or capacity.
- Total weight: The sum of the weights of all edges in a graph.
- Minimal spanning tree: A spanning tree with the least total weight 333.
Example: For a given weighted graph, several spanning trees can be identified. By summing the weights of the edges in each spanning tree, the one with the minimum total weight is determined to be the minimal spanning tree 333 334.
45.4 Kruskal’s algorithm
Kruskal's algorithm is a greedy algorithm used to find a minimal spanning tree for a weighted undirected graph. It works by iteratively adding the lowest-weight edge that does not form a cycle 334.
- Initialization: Start with a tree T containing all vertices of the graph but no edges.
- Edge selection: Consider all edges of the graph in increasing order of weight.
- Cycle prevention: Add an edge to T if and only if it connects two previously unconnected components, thus avoiding the creation of a cycle.
- Termination: The algorithm stops when n−1 edges have been added, where n is the number of vertices, forming the MST 334.
Example: Applying Kruskal's algorithm to a weighted graph involves selecting edges in ascending order of weight: {a,b} (weight 1), {e,f} (weight 2), {e,d} (weight 3), {c,d} (weight 3), {g,f} (weight 4), and {b,c} (weight 6). The resulting MST connects all vertices without cycles 334 335.
45.5 Prim’s algorithm
Prim's algorithm is another greedy algorithm for finding a minimal spanning tree. 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 335.
- Initialization: Select an arbitrary starting vertex and initialize the MST T with this vertex and no edges.
- Edge selection: In each step, find the edge with the minimum weight that connects a vertex already in T to a vertex not yet in T.
- Growth: Add this minimum-weight edge and the new vertex to T.
- Termination: Repeat until all vertices are included in T, resulting in an MST 335.
Example: Starting with vertex 'a', Prim's algorithm selects edges in the following order: {a,d} (weight 5), {d,c} (weight 7), {c,e} (weight 3), {c,b} (weight 6), and {e,f} (weight 8). This process builds the MST by progressively connecting new vertices to the growing tree 335 336 337.
- Multiple MSTs: For graphs with edges of equal weights, multiple minimal spanning trees can exist. Both Kruskal's and Prim's algorithms might produce different MSTs depending on the order in which equal-weight edges are considered 336.
© 2026 Maeve. All rights reserved. This content is protected by copyright.