- Learn
- Mathematics
- University Math
- Discrete Mathematics
- Sets and Functions
Sets and Functions
Sets, Functions and Cardinality
BeginnerLesson 2 of 10 in Discrete Mathematics Course
What you will learn
- Write sets by listing their elements or stating a property, compare sets with the subset relation, and form power sets, Cartesian products, unions, intersections, differences and complements.
- Write sets in roster and set-builder notationDescribe a set by listing its elements or by a defining property, decide membership, and use the empty set, the standard number sets and the size of a finite set.
- Compare sets with subsets and power setsDecide and prove when one set is contained in another, tell membership apart from containment, and list and count the subsets of a finite set.
- Form ordered pairs, tuples and Cartesian productsUse ordered pairs and n-tuples, build Cartesian products of sets, and count their elements.
- Combine sets with union, intersection, difference and complementApply the basic set operations, show them in Venn diagrams and with bit strings, and count the elements of a union of two finite sets.
- Write sets in roster and set-builder notation
- Use Venn diagrams and the standard set identities to see when two set expressions are equal, then prove identities with element arguments, membership tables and chains of laws, and disprove false ones with counterexamples.
- Use Venn diagrams and the standard set identitiesKnow the laws of set algebra, connect them with the logical equivalences behind them, and check identities and non-identities with Venn diagrams and small examples.
- Prove set identities and subset statementsWrite complete proofs that two sets are equal or that one contains the other, using element arguments, set-builder chains, membership tables and the laws of set algebra.
- Use Venn diagrams and the standard set identities
- Define functions precisely, find ranges, images and preimages, classify functions as injective, surjective or bijective, combine them by composition, find inverses, and use floor, ceiling and other functions common in computing.
- Define functions, their domains, codomains and rangesDecide whether a rule is a function, and find its range, the image of a subset and the preimage of a subset.
- Classify functions as injective, surjective or bijectiveProve or disprove that a function is one-to-one, onto or a one-to-one correspondence, and see how the answer depends on the domain and codomain.
- Compose functions and find inverse functionsForm and evaluate compositions, decide when a function has an inverse, find inverses, and use how composition interacts with injectivity, surjectivity and inverses.
- Use floor, ceiling and other functions common in computingEvaluate and reason with the floor and ceiling functions, prove simple statements about them, and use characteristic functions and logarithms in counting problems.
- Define functions, their domains, codomains and ranges
- Describe sequences by formulas and by rules that build each term from earlier ones, read and transform summation notation, and evaluate sums with closed formulas.
- Describe sequences with formulas and recurrence relationsWrite terms of arithmetic, geometric and recursively defined sequences, find a formula from a pattern, and treat strings as finite sequences.
- Read and transform summation notationExpand and evaluate sums written with sigma notation, and rewrite them by splitting, shifting the index, using linearity and working with double sums and products.
- Evaluate sums with closed formulasUse the formulas for arithmetic and geometric sums, sums of squares and cubes, telescoping sums and infinite geometric series, and combine them with splitting and linearity.
- Describe sequences with formulas and recurrence relations
- Use functions to compare cardinalities, prove that sets such as the integers and the rational numbers are countable, and prove with diagonal arguments that the real numbers and the power set of the natural numbers are uncountable and that every set is strictly smaller than its power set.
- Compare cardinalities with bijections and injectionsDefine equal and smaller cardinality with functions, build bijections between infinite sets, and use the Schröder–Bernstein theorem.
- Prove that a set is countableShow that a set is countable by listing its elements or by building a bijection or injection, including the integers, pairs of integers, the rational numbers and the set of all strings.
- Prove that a set is uncountable with diagonal argumentsUse Cantor's diagonal argument for the real numbers and Cantor's theorem for power sets, and draw the consequences for irrational numbers and for functions that no program computes.
- Compare cardinalities with bijections and injections
Sets and Functions study guide
1Sets, subsets and set operations
Sets give a precise way to describe collections, from valid inputs to records in a database. The braces and symbols distinguish an element from a set containing that element, and an unordered collection from an ordered pair. You will write sets, compare what they contain, and build new sets with products and operations. These descriptions also have useful visual forms: regions in a Venn diagram and bits in a string.
1.1 Elements and ways to describe a set
A set is an unordered collection of distinct objects. Its objects are called elements or members. The statement says that 4 belongs to the set; says that 5 does not.
List the elements or give a rule
Roster notation puts the elements inside braces. Order does not matter, and writing an element again adds nothing: . All three descriptions give the same set with three elements. An ellipsis is useful when its pattern is clear, such as .
Set-builder notation gives the allowed objects and a property they must satisfy. Read as “all elements of for which is true.” A colon sometimes replaces the vertical bar. For example,
The inequality allows integers from −4 through 4. The other inequality removes 0. Negative integers belong because their squares are positive; considering only positive square roots would miss half the elements.
Know the number sets
The natural numbers here are . The positive integers are , and also includes negative integers. The rational numbers are numbers expressible as with integer numerator and nonzero integer denominator. The real numbers include the rationals and irrationals. Many texts start the natural numbers at 1, so the definition of matters.
Intervals specify real numbers between endpoints. Thus includes its endpoints, while excludes them. A universal set fixes the objects under consideration, such as all integers or all students in a course.
Count elements at the outer level
Two sets are equal exactly when they have the same elements. Their descriptions can differ: .
The empty set , also written , has no elements. For example, no real number has square −1. There is only one empty set, regardless of the impossible property used to describe it.
The cardinality of a finite set counts its distinct elements. A set can itself be an element: has three elements. Here , but ; the inner braces make a single object. Similarly, but .
A set is finite if it has exactly some nonnegative integer number of elements, and infinite otherwise. Programming set types also store each value at most once, although whether they preserve insertion order depends on the language.
Key Takeaways
- Order and repetition do not change a set.
- Set-builder notation specifies both the allowed objects and their required property.
- has no elements; has one.
- Cardinality counts distinct elements, including a nested set as one element.
1.2 Subsets and power sets
A subset contains only elements of another set. Write when every element of belongs to . This permits equality: every set is a subset of itself.
Prove containment with an arbitrary element
Let be the integers divisible by 6 and the even integers. Take any . There is an integer with , so is even. Therefore and . The argument covers every element because was arbitrary.
To disprove a subset claim, one element is enough. The integer 2 is in but not in , so . The standard number sets give a chain of containments: .
The empty set is a subset of every set. The statement “every element of the empty set belongs to ” cannot fail: there is no element to provide a counterexample. This is called vacuous truth. It does not assert that the empty set is an element of every set.
A proper subset satisfies and . We write . For example, . Textbooks vary in their use of : some mean proper subset and others permit equality.
Separate membership from containment
| Statement | What it checks |
|---|---|
| Is the object one of the elements of ? | |
| Is every element of the set also in ? |
For , both and are true, but . The set's listed elements are numbers, not the singleton set. With , however, and are both true. The first checks a listed element; the second checks that 1 belongs to .
Double inclusion proves equality: exactly when and . One inclusion alone permits the larger set to have extra elements.
Build the set of all subsets
The power set has every subset of as an element. For a two-element set,
Include both the empty set and the full set. In particular, , because the empty set has exactly one subset: itself.
If has elements, then . Each element has two independent choices: include it or leave it out. Three elements give 8 subsets; ten give 1,024. With in that order, the bit string 1010 represents , and 0000 represents the empty set. Each bit records one inclusion choice.
Key Takeaways
- means every element of belongs to .
- Every set contains the empty set as a subset; membership is a separate question.
- Proper containment adds the requirement that the two sets differ.
- Equality requires both inclusions.
- The power set contains all subsets and has elements when the original set has .
1.3 Ordered pairs and Cartesian products
An ordered pair records a first entry and a second entry. Two pairs are equal exactly when their corresponding entries are equal: means and . In particular, , although .
Build a product one coordinate at a time
The Cartesian product is the set of all pairs with and . For and , fix the first entry and run through every second entry:
There are three pairs starting with 1 and three starting with 2. For finite sets, this gives . The product is a set; the expression between cardinality bars is its number of elements. A product with an empty factor has no pairs, because a required coordinate cannot be chosen: .
Reversing the factors changes which entries may occupy each position. The pair belongs to but not to , whose first entry must be a letter. The two products have the same size when finite, but need not be the same set. If both factors are nonempty, holds only when . Empty factors are an exception: both products are empty even if the other factor is nonempty.
Extend pairs to tuples
An ordered n-tuple has one entry for each position. Repetition is allowed, as in . The product contains tuples with each . Repeated factors are abbreviated as .
The set is the coordinate plane. The set consists of all 8-bit strings and has elements. A table row with columns for student number, course code and grade is a triple from the product of the three column sets. Swapping columns changes the role of an entry even if the same values remain present.
Combine products with set operations
Products distribute across union and intersection in a factor:
For the intersection identity, a pair on either side must have its first entry in and its second entry in both and . That coordinate test explains why the identity holds for all such sets.
A subset of can record selected links from first entries to second entries. The graph of a function is a special such subset: every element of appears as a first entry exactly once. This turns the product from a list of all possible pairs into the setting for assigning outputs to inputs.
Key Takeaways
- Pairs and tuples preserve position and allow repeated entries.
- contains every allowed first-and-second-coordinate combination.
- For finite sets, ; an empty factor makes the product empty.
1.4 Union, intersection and membership bits
Set operations describe which elements survive a membership test. Let and . The overlap matters because an element may belong to both sets.
Choose the matching operation
| Operation | Membership rule | Result for these sets |
|---|---|---|
| Union | In at least one set | |
| Intersection | In both sets | |
| Difference | In and outside | |
| Symmetric difference | In exactly one set |
Union uses inclusive “or,” so it keeps the overlap. Symmetric difference uses exclusive “or,” so it removes the overlap. Its alternative notation is , and its definition is . Difference, also written , depends on order: here . Sets are disjoint when their intersection is empty.
The complement keeps all elements of a stated universal set outside . It is also written or . With , the complement is ; with it also contains 0 and every integer greater than 10. Difference can be rewritten as relative to a common universe.
Read regions and counts
A Venn diagram shows the universe as a rectangle and the sets as regions inside it. Two overlapping circles separate four membership cases: only the first set, only the second, both, and neither. Three circles separate eight cases. Shade the part inside but outside for ; shade outside both circles for .
For finite sets,
The sum of the separate sizes counts each shared element twice; subtracting the intersection keeps one copy. In a group of 40 students, 25 take programming, 18 take statistics and 7 take both. The union has students, leaving taking neither. Disjoint sets have no double count, so their sizes add directly.
Work with families and bits
For a family of sets, contains elements in at least one set, while contains elements in every set. If , their union is and their intersection is . Over all positive integer indices, the union is and the intersection remains .
A finite universe in a fixed order lets each subset be stored as a bit string: 1 means membership and 0 means absence. Combine strings position by position. Union uses OR, intersection AND, symmetric difference XOR, and complement flips each bit. For , the odd members have string 1010101010 and has 1111100000. Their OR is 1111101010, representing ; their AND is 1010100000, representing . Changing the universe's order changes the encoding, so the order must stay fixed while the operations are performed.
Key Takeaways
- Union means at least one set; intersection means both; symmetric difference means exactly one.
- Complement depends on the chosen universe.
- Difference keeps elements of the first set that are absent from the second.
- For finite sets, subtract the overlap once when counting a union.
- Generalized union means at least one set in the family; generalized intersection means every set.
- In a fixed finite universe, set operations act on membership bits position by position.
2Set laws and complete proofs
A set equation claims that two descriptions pick out exactly the same objects. Testing a few collections can reveal a false claim, but a proof must account for arbitrary elements or every possible membership case. Set laws connect this work to familiar logical equivalences. You will use those laws to simplify expressions, compare regions, and write arguments that establish both directions of an equality.
2.1 The laws of set operations
A set identity holds for all sets in the stated universe. Its symbols translate into logic: union means “or,” intersection means “and,” and complement means “not.” This connection explains the laws and helps keep their conditions straight.
Laws that simplify an expression
The identity laws are and : neither operation changes membership. The domination laws are and . The universe admits every possible element in a union; an empty intersection factor admits none.
The idempotent laws are and . Repeating a membership condition does not change it. The complement laws are and . Every object in the universe is either in or outside it, and cannot be both. Double complement gives .
Both union and intersection are commutative, so their two inputs can be reversed. They are also associative: changing the grouping in or leaves membership unchanged.
Distribution and absorption
Both distributive laws are valid:
For the second law, an element in passes both conditions on the right. If it is outside , it must belong to both and . Ordinary addition does not distribute over multiplication, so an arithmetic analogy alone would miss this law.
The absorption laws are and . The intersection adds no elements to , while membership in already guarantees membership in .
Move a complement through an expression
De Morgan's laws change the operation as well as complementing the sets:
For , and , the complement of their union is . Their separate complements are and . Intersecting gives ; taking their union would incorrectly include 1, 2 and 4.
Check a claim or simplify it
A complete two-set Venn diagram displays all four membership cases; a three-set diagram displays all eight. Matching shaded regions check an identity because every case is present. Four or more circles cannot display every case, so a membership table or written argument is more useful there.
One counterexample disproves a universal identity. The claim fails for and : its left side is . It holds exactly when .
For a true simplification, factor the shared set:
The steps use distribution, the complement law and the identity law.
Key Takeaways
- Set identities express logical equivalences about membership.
- Both union and intersection distribute over the other operation.
- De Morgan changes union to intersection, or intersection to union, while complementing each set.
- One counterexample disproves an identity; matching particular examples do not prove it.
2.2 Element arguments, tables and chains of laws
A proof of equality must show that neither set has an element missing from the other. Three useful methods are an element argument, a membership table and an algebraic chain of established laws.
Follow an arbitrary element
To prove , take an arbitrary . Then
Each step is an equivalence, using the definition of complement, De Morgan's law in logic, and the definition of union. Reading forward proves one inclusion; reading backward proves the other. A forward implication alone would prove only a subset statement.
The same reasoning can be expressed as a set-builder chain, beginning with and replacing its condition by the equivalent condition . Both descriptions select precisely the same elements.
Use a hypothesis where it is needed
Suppose . To prove , first note that . For the reverse inclusion, let . If , the conclusion is immediate. If , the hypothesis gives . Every case reaches , proving .
Union gives two possible cases, not two simultaneous facts. Replacing its “or” with “and” would make the argument assume more than membership in the union supplies.
Check every membership combination
A membership table uses 1 for membership and 0 for absence. With three sets there are eight rows. To compare and , evaluate each subexpression in each row:
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 |
The final columns agree in every row, so the identity is proved. A table omitting one combination would leave that case unchecked.
Name the law at each step
An algebraic proof transforms one side into the other. For example,
Each equality is De Morgan's law. Commutativity can then reorder the intersection or the union. The law used must already be established; using the claim itself would be circular.
For Cartesian products, start with a pair. Membership of in means , and . These are exactly the conditions for membership in both and . The equivalence proves the product identity in both directions without listing particular elements.
Key Takeaways
- An arbitrary-element proof covers every element, not just selected examples.
- Two inclusions prove equality; a reversible equivalence chain proves both at once.
- A complete membership table checks every combination.
- In a conditional proof, state where the hypothesis supplies the needed membership.
- An algebraic proof justifies each equality with an established law.
3Functions, inverses and computing
A function pairs every allowed input with exactly one output. Its domain and codomain are part of its meaning, so the same formula can behave differently when those sets change. You will distinguish outputs that repeat from outputs that are missed, combine functions in a specified order, and decide when an assignment can be undone. Floor, ceiling and characteristic functions then put these ideas to work in discrete computing problems.
3.1 Inputs, outputs, images and preimages
A function assigns every element of exactly one element of . The set is its domain, and is its codomain. The value is the image of the input .
Check that the assignment is a function
A formula, table, list of pairs, arrow diagram or program can specify a function. In each representation, every domain element needs one output, and that output must belong to the codomain. Two different inputs may share an output.
The rule is not a function from to because it gives no value at 0. Removing 0 from the domain repairs that problem. The rule does not define a function , since 3 would have the noninteger output . The proposed assignment “” gives two outputs at 4, so it also fails. A partial function permits some inputs to have no value; a total function requires a value at each input.
The graph of is . Every domain element occurs exactly once as a first coordinate. For a real-variable graph, a vertical line can therefore meet it at most once.
Separate codomain and range
The range is the set of values actually reached. It lies inside the codomain and can be smaller. For , , the codomain is all integers, but the range is . A negative integer is an allowed target but never an output.
The image of a subset is . If , squaring gives . Repeated outputs appear only once because an image is a set.
The preimage of a subset is . It collects inputs, not outputs. For the same integer-square function, . Both signs square to 4 and no integer squares to 5. Also . A preimage exists as a set even when there is no inverse function.
| Construction | Starts with | Returns |
|---|---|---|
| Image | A subset of the domain | The outputs reached from it |
| Preimage | A subset of the codomain | All inputs landing in it |
Compare and combine functions
Two functions are equal when they have the same domain, codomain and value at every input. Thus squaring as a function differs from squaring as a function , even though the output formula agrees.
Real-valued functions can be added and multiplied pointwise: and . For and , these give and .
For finite sets, there are functions . Each input independently chooses one codomain element. Three inputs and two possible outputs give functions. An empty domain has exactly one function, the empty assignment, even into an empty codomain; the counting convention is . A nonempty domain has no function into an empty codomain.
Key Takeaways
- A function assigns every domain element exactly one value in the codomain.
- The range is the set of reached values and can be smaller than the codomain.
- An image collects outputs; a preimage collects all matching inputs.
- Preimages do not require invertibility.
- Function equality includes the domain and codomain.
- For finite sets, there are assignments .
3.2 One-to-one, onto and bijective functions
Being a function answers whether each input has exactly one output. Injectivity and surjectivity ask different questions about how the outputs are used.
Two tests for a function
| Property | Requirement | Evidence that it fails |
|---|---|---|
| Injective, or one-to-one | Different inputs have different outputs | Two distinct inputs share a value |
| Surjective, or onto | Every codomain element is reached | A codomain element has no preimage |
| Bijective | Both requirements hold | Either requirement fails |
In a finite arrow diagram, injectivity means no target receives two arrows. Surjectivity means every target receives at least one. A bijection gives every target exactly one incoming arrow. For example, the assignments , , , from to are surjective but not injective.
Prove each requirement
To prove injectivity of on , assume . Then . Subtracting 2 and dividing by 3 gives . Equal outputs can come only from equal inputs.
For surjectivity onto , take any real target . Solving gives . This input is real and maps to , so every target is reached. The function is bijective.
The same formula remains injective, but is not onto. Reaching 0 would require , outside its domain. Solving an equation is not enough for surjectivity unless the solution is an allowed input.
Domain and codomain change the answer
Squaring illustrates both kinds of restriction:
| Domain | Codomain | Properties of |
|---|---|---|
| Neither: opposite signs collide and negatives are missed | ||
| Onto, but not one-to-one | ||
| One-to-one, but not onto | ||
| Bijective |
A strictly increasing real function is injective: if one input is larger, its output must be larger. Strictly decreasing functions are injective for the same reason with the inequality reversed. Weakly increasing functions need not be injective, because equal outputs are permitted; a constant function is an example.
The identity is bijective on . A constant function on at least two inputs is not injective. With a nonempty domain it is onto exactly when its codomain consists of that one output.
Use finite sizes carefully
For finite sets, an injection requires , a surjection requires , and a bijection requires equality. If the finite sets have equal size, injectivity and surjectivity are equivalent: using distinct targets leaves none unused.
This last equivalence fails for infinite sets. The function from to itself is injective but misses 0. Infinitely many distinct outputs do not guarantee that every target is reached.
Key Takeaways
- Injectivity rules out collisions; surjectivity rules out missed targets.
- A bijection reaches each codomain element exactly once.
- Prove injectivity from equal outputs; prove surjectivity by finding an allowed input for an arbitrary target.
- Always classify the function with its stated domain and codomain.
- Equal finite domain and codomain sizes make injectivity and surjectivity equivalent.
3.3 Composition and undoing a function
Composition feeds one function's output into another. For and , the composition satisfies . The function on the right acts first.
Follow the order and the allowed inputs
Let and on the integers. Then
At 1 the outputs are 13 and 17. Composition is not commutative: the order can change the answer.
Composition also requires compatible sets: every value of the inner function must lie in the outer function's domain. For , , and , , , the composition sends to . The reverse composition is undefined because does not accept the outputs 1, 2 and 3.
Composition is associative: . Both apply , then , then . Identity functions leave an assignment unchanged: and for .
When can the assignment be reversed?
An inverse function assigns each output its unique original input. It exists exactly when is bijective. Injectivity provides uniqueness; surjectivity ensures every element of gets an inverse value. The checks are
To find an inverse of on the reals, write and solve: . Thus . Substitution gives , and .
Squaring has no inverse on all reals because opposite inputs collide. Restricting both domain and codomain to gives the inverse .
The inverse is not the reciprocal: for , , while . Nor does the preimage notation imply invertibility; it collects all inputs landing in a set.
Properties under composition
Composing two injections gives an injection: equality of final outputs first forces equality after the inner function, then equality of inputs. Composing two surjections gives a surjection: each final target has an intermediate preimage, which has an original preimage. Two bijections therefore compose to a bijection.
Undoing reverses the order: . If and , undo by dividing by 2 and then subtracting 3.
Some converses are weaker. If is injective, must be injective; if it is onto, must be onto. The other conclusions fail: take with and the constant . Their composition is bijective even though misses 2 and merges its inputs.
Key Takeaways
- applies first and requires its outputs to be valid inputs to .
- Composition is associative but generally not commutative.
- A function has an inverse on its full codomain exactly when it is bijective.
- An inverse undoes an assignment; a reciprocal divides 1 by a value.
- The inverse of a composition reverses the order of its factors.
- Injectivity of a composition forces injectivity of the first-applied function; surjectivity forces surjectivity of the last-applied function.
3.4 Floor, ceiling, indicators and binary length
Discrete tasks often turn a real quantity into an integer. The direction of that change matters, especially for negative inputs and partially filled containers.
Floor and ceiling are directed rounding
The floor is the greatest integer at most . The ceiling is the least integer at least . Thus , , and . At an integer, both return that integer.
For integer , exactly when , while exactly when . Dropping the decimal digits of a negative number gives the ceiling, not the floor. Ceiling is not nearest-integer rounding: .
Adding an integer shifts either result by that integer: and . Negation reverses the direction, so . The difference is 0 at integers and 1 elsewhere. Floor does not distribute over arbitrary addition: , whereas .
Count full containers and required containers
Storing 100 bits in 8-bit bytes requires bytes. Only are full. Similarly, sending 500 bytes in packets holding at most 64 bytes takes packets. The final partly filled container still counts.
As a function , floor is onto: an integer maps to itself. It is not injective because . Likewise, on the positive integers is onto but merges inputs 1 and 2.
Prove a floor identity by cases
Write , where and . To prove
split at . Below that point, , so the left side is and . At or above it, , so the left side is and the shifted floor is . The equality holds in both cases, including the boundary.
Encode membership and count binary digits
The characteristic function is 1 on members of and 0 elsewhere. Every subset gives one such function, and each such function identifies its subset of 1-valued inputs. For a finite universe in a fixed order, these values form its membership bit string.
The exponential function maps bijectively onto ; its inverse is . A positive integer has binary digits. Indeed, means the highest binary place is , so positions 0 through require digits. For 100, the logarithm is about 6.64, giving 7 digits: .
Key Takeaways
- Floor rounds toward the smaller integer; ceiling toward the larger integer.
- Use ceiling for containers required and floor for completely filled containers.
- Integer shifts commute with floor and ceiling; arbitrary real additions do not.
- Floor proofs can split the fractional part into intervals.
- A characteristic function encodes membership as 0 or 1.
- A positive integer has binary digits.
4Sequences and sums
A sequence records values in a specified order, and a sum combines selected terms. The starting index controls which value comes first and how many terms are included. You will move between formulas and recurrences, read sigma notation as repeated addition, and choose a formula that matches the pattern of a sum. Pairing and cancellation explain why several useful formulas work and make boundary errors easier to spot.
4.1 Terms, formulas and recurrence rules
A sequence is a function whose inputs are consecutive integers, usually starting at 0 or 1. The index names a position, and is the value at that position. For with , the first terms are .
Add a difference or multiply by a ratio
An arithmetic progression adds a fixed difference . With first term at index 0, its formula is . With and , it starts . If the first term instead has index 1, write . Substituting the starting index should always give the stated first term.
A geometric progression multiplies by a fixed ratio . Starting at index 0, . For and , the terms are . The ratio may be negative: and give . A constant difference identifies arithmetic behavior; a constant ratio between nonzero consecutive terms identifies geometric behavior.
Build terms from earlier terms
A recurrence relation specifies later terms using earlier ones. It needs initial conditions to fix the starting values. The rule could start from any number. Adding fixes the sequence .
Its closed formula is , which gives the value without computing the preceding terms. Check the initial condition: . Check the recurrence: . These checks show that the formula obeys both parts of the definition.
A second-order rule needs two starting terms. The Fibonacci sequence has , and for . It begins .
A culture starting with 1,000 cells and doubling each hour satisfies and . Therefore , giving after five hours.
Recognize a pattern without assuming uniqueness
Differences, ratios and familiar powers help suggest formulas. Squares suggest ; the terms suggest for . A finite prefix does not determine an infinite sequence, however. Starting with , the rule gives 8 next, while gives 7. A pattern-based guess remains a conjecture until it follows from the definition, often by induction.
Treat strings as finite sequences
A string over an alphabet is a finite sequence of symbols from it. The bit string 0110 has length 4 over . Order and repetition matter: 0110 differs from 0101, and its two 1s occupy different positions.
The empty string has length 0; another common symbol is . The set contains every finite string over the alphabet, including the empty one. A string is one ordered object; a set of strings is a collection of such objects.
Key Takeaways
- An index gives a position; the term is its value.
- Arithmetic progressions add a fixed difference; geometric progressions multiply by a fixed ratio.
- A recurrence needs enough initial conditions to determine its terms.
- A closed formula must match both the starting values and the recurrence.
- A finite prefix can fit more than one rule.
- Strings are finite sequences, including the empty string of length 0.
4.2 Reading and rewriting sigma notation
The notation means add the terms . The lower and upper limits are included. When , there are terms.
Expand before calculating
For example, . The index is a placeholder: using or instead leaves the sum unchanged if every occurrence is renamed. It has no assigned value outside the sum.
Limits may start at 0 or a negative integer. An empty sum, whose lower limit exceeds its upper limit, is 0. This is the neutral starting value for repeated addition, like a running total before any items are added. From 3 through 10 there are 8 indices, not 7: both endpoints contribute.
Split and combine sums
Linearity permits constants to move outside and sums to split termwise:
A constant added times gives . Products do not separate in the same way. For , , whereas multiplying the two separate sums gives because it includes cross terms.
A split must include each term once:
To keep the squares from 50 through 100, subtract only those through 49:
Subtracting through 50 would remove the first wanted term.
Shift the expression and both limits
With , the sum becomes . At the first index, both expressions contribute 1. At the last, both contribute 25. Changing only the limits or only the expression would describe different terms.
Read nested sums and products
In a double sum, evaluate the inner sum for each outer index. For
the inner sum is . Summing over the outer index gives . If the inner upper limit is , the number of terms changes with the outer index: . This counts the number of inner-loop executions in a triangular nested loop.
A sum can also run over a set. For , . Product notation replaces addition with multiplication: . Thus and . An empty product is 1, the neutral value for multiplication; in particular, .
Key Takeaways
- Inclusive limits from through give terms.
- An empty sum is 0 and an empty product is 1.
- Linearity separates added terms and constant factors, not arbitrary products.
- When shifting an index, change the expression and both endpoints together.
- A double sum evaluates its inner sum for each outer index.
4.3 Closed formulas and cancellation
A useful sum formula depends on the pattern and on the number of terms. First identify whether the terms grow by addition, multiplication or a difference that cancels.
Arithmetic sums and powers
The first positive integers satisfy . To see why, write the sum forward and backward. Each paired position adds to , and there are pairs. Twice the sum is therefore . For , the sum is 5,050.
Any arithmetic series equals the number of terms times the average of its endpoints. For , the step is 3, so there are terms. The sum is .
Two other standard formulas are
For , they give 385 and 3,025. These formulas sum powers of individual terms; cubing a sum is a different operation.
Linearity and subtraction extend the formulas. For example, . Also . The subtracted part stops at 10, preserving the term 11.
Geometric sums
For ,
To derive it, call the sum and multiply by . Subtract from . All middle terms cancel, leaving . Dividing by gives the formula. The exponent is the number of terms because the indices start at 0. If , division would fail; each term is simply , giving .
Thus and .
Telescoping sums
A telescoping sum cancels adjacent terms. In , every middle value appears once positively and once negatively, leaving .
Since ,
For the result is . Writing the first and last terms makes the surviving endpoints visible.
Infinite geometric series
When , the term tends to 0, giving . For example, . If and , there is no finite sum.
Repeating decimals can be evaluated with this idea: . Similarly, , which explains why a real number can have two decimal expansions.
A few successful numerical checks support a formula but do not prove it for all indices. Pairing and cancellation are direct proofs; many other sum formulas are proved by induction.
Key Takeaways
- An arithmetic sum is its term count times the mean of its endpoint terms.
- The finite geometric formula needs ; when , count the equal terms.
- Sums of squares and cubes have different closed formulas.
- Telescoping leaves the uncanceled boundary terms.
- An infinite geometric series with nonzero first term has a finite sum exactly when .
- Checking finitely many cases is not a proof for every index.
5Comparing infinite sizes
For finite sets, counting elements decides their size. Infinite sets require a different test: can their elements be matched without repeats or omissions? Some sets that seem much larger still admit such a matching, including the integers and rationals. Other sets defeat every proposed list. You will build complete enumerations and then use diagonal arguments to show why no enumeration can reach every real number or every subset of the natural numbers.
5.1 Match elements to compare cardinalities
Sets have the same cardinality when a bijection matches their elements. For finite sets this agrees with counting. For infinite sets it gives a precise meaning to “same size” without finishing a count.
Use the right function test
Write when some bijection exists. Its inverse gives a bijection back, and composing bijections shows that equal cardinality passes through an intermediate set.
The statement means there is an injection . It fits distinct elements of into distinct places in , possibly leaving places unused. Strict inequality additionally requires that no bijection exists. For instance, inclusion gives an injection , but that alone does not prove strict inequality.
An infinite set can match a proper subset
The function bijects with its even elements. Distinct inputs remain distinct, and every even natural number is reached by . The odd numbers left outside the target subset do not prevent this matching.
Hilbert's hotel makes the same idea visible. Its rooms are numbered and all are occupied. Move the guest in room to room . Every old guest still has a room, no two collide, and room 1 becomes free. There is no final room whose guest would be pushed out.
A shift bijects with . The integers can also be matched with by
The outputs are . Every nonnegative integer comes from an even input, and every negative integer from an odd input, with no repetitions.
Intervals need not differ in cardinality
The map bijects with . More generally, bijects with for . The inverse is . Length and cardinality measure different features.
Even the whole real line has the same cardinality as : is a bijection. The inner expression runs through , where tangent is strictly increasing and reaches every real value.
Two injections can replace one explicit bijection
The Schröder–Bernstein theorem says that injections and imply . Neither injection must be onto.
For example, inclusion injects into . In the reverse direction, injects into , with image . The theorem establishes equal cardinality without an explicit bijection.
Failure of one proposed map does not establish different sizes. Inclusion misses the negatives, yet the alternating-sign construction succeeds. Conversely, being infinite does not by itself guarantee equal cardinality: a proof still needs an appropriate matching or theorem.
Key Takeaways
- Equal cardinality means that some bijection exists.
- An injection establishes a non-strict cardinality comparison.
- An infinite set can match a proper subset of itself.
- Injections in both directions establish equal size by Schröder–Bernstein.
- One failed bijection candidate does not rule out every bijection.
5.2 Complete lists of countable sets
A set is countable when it is finite or can be matched bijectively with . An infinite countable set is countably infinite, with cardinality , read “aleph null.” A set that is not countable is uncountable. Some texts reserve “countable” for the infinite case; here finite sets are included.
Every element needs a finite position
An infinite set is countable exactly when its elements can be listed as with every element appearing at a finite position. Repetitions may be skipped to obtain a bijective list.
The integers have the list . Listing all nonnegative integers “and then the negatives” fails: the first part never ends. The odd positive integers also form a complete list through the bijection from .
Visit a grid by finite diagonals
For positive integer pairs, list by increasing :
Every diagonal is finite, and a pair lies on the diagonal with sum . Only finitely many pairs precede it. Listing an entire infinite row first would never reach the second row.
An explicit alternative is the Cantor pairing function on nonnegative integers:
For , its outputs run from through , one for each value of . The next diagonal starts at , exactly one more than the previous endpoint. Thus the diagonals fill the natural numbers without gaps or collisions.
Enumerate fractions and strings
A positive rational can be represented as with positive integers . Visit the pair grid by diagonals and skip fractions not in lowest terms. The list begins . Every rational's reduced pair appears at a finite point, and skipping duplicates preserves that fact. Include 0 and alternate positive and negative entries to list all of .
The set of finite strings over a finite alphabet is countable too. Order strings by length, then alphabetically within each length. For binary strings this gives . Each length contributes finitely many strings, so any specified finite string is reached. Pure alphabetical order can get stuck at and never reach 1. Programs are finite strings over finite alphabets, so there are countably many possible programs in a programming language.
Reuse countability results
Every subset of a countable set is countable. Two countable lists can be interleaved to list their union, skipping duplicates. Two countable factors give a countable Cartesian product by diagonal traversal. A countable union of countable sets is countable as well: arrange their lists in rows and visit entries diagonally. Skip positions beyond the end of a finite row and every position in an empty row.
The rationals are dense—another rational lies between any two distinct rationals—yet countable. Density concerns gaps in an ordering; countability concerns the existence of a complete list.
Key Takeaways
- Countable includes finite sets; countably infinite means cardinality .
- A valid infinite list reaches each element after finitely many positions.
- Finite diagonals enumerate pairs without becoming trapped in one row.
- Reduced fractions and length-ordered finite strings admit complete lists.
- Subsets, finite products and countable unions preserve countability.
- Density does not imply uncountability.
5.3 Diagonal arguments and larger infinities
A diagonal proof defeats an arbitrary proposed complete list by constructing an object that it misses. The constructed object must belong to the very set the list claims to cover.
A real number outside every proposed list
Suppose all reals in could be listed as . Write their decimal digits as . Construct by choosing if and if .
The new number is in . For every row , it differs from at digit . Therefore it is absent from the entire list, contradicting completeness. Since the proposed list was arbitrary, no list works: and hence are uncountable.
For example, diagonal digits produce the prefix . The full construction continues through every row; the first four digits alone do not determine the missing number.
Choosing only 4 and 5 avoids an important decimal issue. Numbers such as have two expansions. A number with only 4s and 5s has a unique expansion, so the digit differences really establish unequal numbers. A careless “add 1” rule can also produce an invalid digit at 9.
Why the same claim fails for rationals
Diagonalizing against a list of rational numbers still constructs a real number, but need not construct a rational one. Being absent from that list would then be expected, not contradictory. For positive integers, an endless digit string need not be an integer at all. Checking that the constructed object stays in the target set is essential.
The irrationals are uncountable. Otherwise their union with the countable rationals would make countable, contradicting the diagonal proof.
Every power set is larger than its set
Cantor's theorem states for every set . The singleton map is injective, giving the non-strict comparison. To rule out surjectivity of any , define
This is a subset of , so an onto function would have for some . If , its defining rule says . If , that rule says . Both possibilities contradict themselves. Thus no function of this form is onto, and no bijection exists.
For finite sets the theorem agrees with . For the naturals it proves that is uncountable. Repeating the construction gives .
Finite programs and infinite output choices
Every subset of corresponds to its characteristic function , an infinite bit string. Flipping bit of row constructs an infinite bit string absent from any proposed list. These functions are therefore uncountable.
Programs, however, form a countable set of finite strings. Each program computes at most one total function of this kind. Consequently, some functions are uncomputable: no program computes them. This is an existence argument, not a claim that a particular displayed function is uncomputable.
Key Takeaways
- A diagonal argument constructs an object missing from an arbitrary proposed complete list.
- The constructed object must belong to the target set.
- The 4-or-5 digit rule avoids duplicate decimal representations.
- Cantor proves that every set has strictly smaller cardinality than its power set.
- The reals, irrationals and infinite binary strings are uncountable.
- Countably many finite programs cannot compute all uncountably many binary-valued functions.
Sets and Functions examples
1Build and combine sets
15 steps
- 1IntroductionDecide which objects belong
A set gives a precise membership test: an object either belongs or does not. We will start by reading its elements, then build subsets and ordered pairs before combining collections.
Keep track of the kind of object each expression describes. A number, a singleton containing that number, and a pair using it in one coordinate play different roles even when the same symbol appears.
- 2ExplanationRead the outer braces
In , the outer elements are 2, the set containing 2 and 6, and the empty set. Thus .
The inner set counts as one object. It does not place 6 directly in , so . Likewise, adding a repeated 2 to the roster would not add a new element. Sets preserve distinct membership, not the number of written entries.
- 3ExampleTurn a property into a roster
Consider . The allowed integers run from −3 to 3 because but .
Therefore . Include both signs because they give the same square. Include 0 because the inequality allows its square; the domain determines that we list integers, not all real values between the endpoints.
- 4ChallengeCount nested objects
Let . What is its cardinality, and does belong to it?
---reveal---
because its distinct elements are 5, the singleton containing 5, and the empty set. Yes, : that entire set is explicitly listed as an element. Repeating the number 5 does not create a fourth element.
- 5ExplanationTest all elements of a subset
The statement checks every element of against membership in . For and , both checks pass, so the inclusion holds.
It is proper because 4 belongs to but not to . Equality is allowed by ; proper containment additionally requires a difference. Membership, such as , checks a single object instead.
- 6ExampleList every subset once
For , each element can be included or excluded. The four resulting subsets are , , and .
These four sets are the elements of . Notice that while . The empty subset must be included: choosing neither original element is one valid choice.
- 7ChallengeSeparate an element from a subset
Let . Are and both true?
---reveal---
Yes. The first statement is true because the singleton is listed as an outer element. The second is true because its only element, 1, also belongs to . The same two symbols can satisfy both relations, but the reasons come from different membership checks.
- 8ExampleChoose the two coordinates
Let and . Fix a first coordinate and try every allowed second coordinate:
The product has elements. Each pair has a letter first and a number second. Reversing the factors produces pairs with a number first, so equal counts do not imply equal product sets.
- 9ChallengeCount a product after an intersection
Let , and . What is ?
---reveal---
The second coordinate must be 4, the sole member of . The product is with three elements. Multiplying the sizes of and all of would include pairs whose second coordinates fail the intersection condition.
- 10ExplanationChoose an overlap rule
For and , union gives and intersection gives .
The union keeps the overlap because its “or” means at least one set. The symmetric difference removes that overlap, leaving . In a two-circle Venn diagram, these are respectively all of both circles, only their shared lens, and the two nonoverlapping parts.
- 11ExampleFind the complement inside a universe
Fix and . The complement is .
A complement scans the whole stated universe and keeps the elements outside the set. Difference scans only the first set: if , then . Thus , while can contain many elements outside .
- 12ConnectionRead operations as bit tests
In universe order , let have string 1010 and string 0110. Bitwise OR gives 1110 for the union; AND gives 0010 for the intersection.
XOR gives 1100 for membership in exactly one set. Flipping 1010 gives 0101 for the complement of . Each position has a fixed meaning, so the universe order must stay unchanged across both input strings and the result.
- 13ExampleRemove a double count
In a group of 48, there are 28 members in , 23 in and 9 in both. Adding the separate totals gives 51 because the nine shared members appear twice.
Subtract one copy of the overlap: . The number outside both is then . These are two different regions: first find the union, then subtract it from the universe.
- 14ChallengeCombine subsets with counts
A universe has 64 elements. Sets and have sizes 35 and 27, and their intersection has 11 elements. How many elements are in exactly one set, and how many subsets does that collection have?
---reveal---
The union has elements. Remove its shared part to keep exactly-one membership: . This subset therefore has subsets. Union counts the shared elements once; symmetric difference removes them entirely.
- 15RecapKeep the object and the test clear
Read braces at the outer level before counting elements. Subset statements test every element of the first set, while power sets collect all possible subsets. Products preserve coordinate roles.
For operations, decide whether the condition is “at least one,” “both,” “first only,” or “exactly one.” A stated universe completes a complement test. The same tests work on Venn regions and fixed-order membership bits.
2Prove a set equation
10 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionAn equation about every element
- 2ExampleFactor a shared set
- 3Key InsightComplement reverses the connective
- 4ChallengeSimplify a nested complement
- 5ExplanationWrite a reversible membership chain
- 6ExampleUse a hypothesis at the decisive step
- 7TipTest every membership row
- 8ChallengeFind the error in a proof
- 9ChallengeProve a conditional equality
- 10RecapChoose evidence that covers the claim
3Follow inputs through functions
18 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionTrack inputs and allowed targets
- 2ExplanationA function needs one value per input
- 3ExampleFollow a subset backward
- 4ChallengeCheck a proposed target set
- 5ExplanationLook for collisions and missed values
- 6ExampleProve a linear map is one-to-one
- 7ExampleFind an input for an arbitrary target
- 8ChallengeChange the input set
- 9ExampleCompose without reversing order
- 10ExplanationUndo the whole assignment
- 11Key InsightReverse the order when undoing
- 12ChallengeRestrict a domain before inverting
- 13ExplanationUse the number line for floor
- 14ExampleInclude the partly filled block
- 15ConnectionEncode a subset as a function
- 16ChallengeCount positions in a binary representation
- 17ChallengeA bijection through a smaller image
- 18RecapCheck the sets before the formula
4Read sequences and evaluate sums
15 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionKeep the index and value separate
- 2ExplanationChoose the starting exponent
- 3ExampleGenerate terms from a recurrence
- 4ChallengeTest an index convention
- 5ExampleExpand all included indices
- 6TipShift expression and endpoints together
- 7ChallengeRead a nested loop as a sum
- 8ExamplePair the first and last terms
- 9ExplanationCancel a shifted geometric sum
- 10ExampleKeep only the boundary terms
- 11Key InsightAn infinite sum needs a shrinking tail
- 12ChallengeChoose the formula that matches the series
- 13ConnectionSubtract the unwanted prefix
- 14ChallengeCombine linearity with range subtraction
- 15RecapMatch the formula to the pattern
5Build lists and defeat lists
16 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionSize without finishing a count
- 2ExampleMatch naturals with a proper subset
- 3AnalogyMove every guest one room
- 4ChallengeCompare intervals with two injections
- 5ExplanationA list must reach every element
- 6ExampleVisit pairs on finite diagonals
- 7ConnectionFractions inherit the pair listing
- 8ChallengeList strings without getting stuck
- 9ExplanationAssume a real-number list is complete
- 10ExampleChange the diagonal digits
- 11ChallengeKeep the constructed object in the set
- 12ExplanationConstruct a subset an onto map misses
- 13Key InsightPower sets give strictly larger sizes
- 14ConnectionFinite descriptions versus infinite strings
- 15ChallengeRemove a countable part
- 16RecapConstruct a matching or defeat every list
Sets and Functions practice questions
Set 1: Changing domains and following formulas10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
Show answerHide answer
Question 3 of 10
Show answerHide answer
Question 4 of 10
Show answerHide answer
Question 5 of 10
Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
Show answerHide answer
Question 10 of 10
Show answerHide answer
Set 2: Elements, assignments and first calculations10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 3: Membership proofs and complete enumerations10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 4: Boundary cases and several-step reasoning10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 5: Transfer across sets, functions and infinity10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
A
Absorption law
Algebraic proof
Arithmetic progression
Arithmetic series
Associativity
B
Base-2 logarithm
Bijective function
Bit string
C
Cantor pairing function
Cantor's theorem
Cardinality
Cartesian product
Ceiling
Characteristic function
Closed formula
Codomain
Complement
Composition
Constant function
Coordinate
Countable set
Countably infinite set
Counterexample
D
De Morgan's law
Density
Diagonal argument
Disjoint sets
Distributive law
Domain
Double inclusion
Double sum
E
Element
Element argument
Empty set
Empty sum
Enumeration
F
Floor
Function
G
Geometric progression
Geometric series
Graph
H
Hilbert's hotel
I
Idempotent law
Identity function
Image
Index shift
Infinite geometric series
Initial condition
Injective function
Intersection
Inverse function
Invertible function
L
Linearity
M
Membership table
O
One-to-one correspondence
Ordered pair
P
Partial function
Power set
Preimage
Product notation
Proper subset
R
Range
Recurrence relation
Roster notation
S
Schröder–Bernstein theorem
Sequence
Set
Set difference
Set identity
Set-builder notation
Strictly increasing function
String
Subset
Summation index
Surjective function
Symmetric difference
T
Telescoping sum
Tuple
U
Uncomputable function
Uncountable set
Union
Universal set
V
Vacuous truth
Venn diagram
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.