Unfinished learning resource · Units 1–8 available · Whole-course validation unfinished

Unit 2. Structured counting and unavoidable repetition

Unfinished learning resource · TMP-SCI-074. Units 1–8 are available. All eight planned units have manuscripts; whole-course validation remains unfinished. This is provisional noncredit self-study, not a completed semester, registered course, degree credit or accreditation. Workload and formative rubrics are unpiloted. Specialist, learner and accessibility validation remain outstanding. All examples are fictional finite models; no account, private data, installation, purchase or programming is required.

Study route

Unit 1 established that counts need objects, equality, coverage and controlled multiplicity. Here we use those checks when several classes or restrictions interact. We also separate two questions: “How many configurations exist?” and “What feature must every configuration have?” A large count does not answer the second question.

Preparation: Unit 1's subsets, ordered selections, binomial coefficients, disjoint cases, complements, bijections, constant fibres and two-set inclusion–exclusion. Readiness tasks below identify what to revisit. No probability, calculus, binomial theorem, recurrence-solving or graph theory is assumed. In this unit “or” is inclusive unless explicitly qualified.

Proposed weeks-3–4 allocation: 16 hours, comprising five teaching/guided, three independent practice/correction, two proof homework, two quiz/delayed work and four project. These are design estimates, not observed times or credit hours. Attempt tasks before consulting the explained answers; keep first attempts beside corrections. Written, typed or spoken-plus-transcript explanations are acceptable. Diagram descriptions are complete text alternatives, and no colour-dependent interpretation is required.

Outcomes

Readiness

R1. Compute C(6,2), C(4,2) and 6!/(2!2!2!). Why does obtaining an integer not yet identify what the expression counts?

R2. For |U|=20, |X|=8, |Y|=7 and |X∩Y|=3, count X∪Y, exactly one of X,Y and neither. State the universe assumption.

R3. A surjective map has 24 sources and exactly four preimages per target. Count targets. What fails if some targets have two preimages and others four?

R4. Construct a distribution of 12 objects among four labelled boxes with no box containing more than three. Explain why this example does not prove that every distribution has that property.

Session A. More than two classes

A1. Labelled allocations have a controlled denominator

Let n distinct objects be assigned to r labelled classes, where r≥1 and prescribed nonnegative sizes k₁,…,k_r sum to n. Every object must enter exactly one class. Choose k₁ objects for class 1, then k₂ from the remaining objects, and continue. The product is

C(n,k₁) C(n−k₁,k₂) … = n!/(k₁! k₂! … k_r!).

This is a multinomial count. The name does not replace its meaning: the classes have specified labels, there is no order within a class, and the sizes are fixed. An alternative proof orders all n objects, cuts that order into consecutive blocks of the prescribed sizes and forgets the order within each block. Every target allocation has exactly k₁!⋯k_r! source orderings. Surjectivity and constant fibres justify division.

For seven distinct cards allocated to labelled lanes X,Y,Z with sizes 3,2,2, the count is C(7,3)C(4,2)C(2,2)=35·6·1=210. Equivalently 7!/(3!2!2!)=210. A zero-size class contributes 0!=1; it does not erase an allocation. If n=0 and all sizes are zero, the single allocation has every class empty. If sizes are negative or their sum is wrong, the model is invalid; do not force the formula to answer a different question.

Diagram A, text equivalent. A row of seven distinct cards is cut after positions 3 and 5. The first block enters X, the next Y and the last Z. Rearranging the three cards within X and the two within each other block gives 3!·2!·2!=24 descriptions of the same allocation. Exchanging the names X and Y generally changes the allocation rather than creating a duplicate description.

A2. Repeated symbols are not distinct hidden objects

A word using two A symbols, two B symbols and one C symbol has five ordered positions but identical copies of each letter. Choose the A positions, then the B positions: C(5,2)C(3,2)=30 words. Equivalently temporarily distinguish A₁,A₂,B₁,B₂,C, then erase subscripts. Each resulting word has 2!2! preimages, giving 5!/(2!2!)=30. Equal letters, not positions, become indistinguishable.

To forbid adjacent A symbols, count the complement. Treat AA as one block: arranging that block, B,B,C gives 4!/2!=12 words. Thus 18 of the 30 avoid AA. This block argument is bijective because there are exactly two A symbols and therefore one AA block in each forbidden word. With three A symbols, different adjacent-pair choices could overlap; an unexplained “one block per bad word” claim would require repair.

A3. Removing class names is a new map

Six distinct objects allocated to three labelled classes of size two give 6!/(2!2!2!)=90 allocations. Forget the three class names, retaining a collection of three disjoint pairs. Each target has 3!=6 labellings of its three nonempty pairs, giving 15 unlabelled pairings.

Do not divide by r! automatically. With four objects in three labelled boxes of sizes 2,2,0 in any order, a target is two nonempty pairs and an empty box. There are six distinct assignments of those three distinguishable blocks to box names. With two objects in three boxes of sizes 2,0,0 in any order, a target has just one nonempty pair and two indistinguishable empty blocks: only three distinct labelled allocations, not six. Restrictions tied to a particular name can also change the fibre size. Analyze the actual forgetful map each time.

G1. Allocate eight distinct labels to X,Y,Z with prescribed sizes 3,3,2. Count by successive choices and by a uniform-fibre argument. Does swapping X and Y preserve the same labelled allocation?

G2. Count words using exactly A,A,B,B,C. Count those avoiding adjacent A symbols and justify why the AA-block encoding is reversible in this case.

G3. Count allocations of six distinct labels to three labelled pairs, then unlabelled pairings. Now put two labels together in one of three labelled boxes with the others empty. Explain why the second model cannot use the same six-to-one quotient argument.

Session B. Overlap among several forbidden conditions

B1. Three-set inclusion–exclusion

For finite subsets A,B,C of a common universe U,

|A∪B∪C| = |A|+|B|+|C| − |A∩B|−|A∩C|−|B∩C| + |A∩B∩C|.

Check one object at a time. An object in exactly one set contributes 1. In exactly two sets it contributes 2−1=1. In all three it contributes 3−3+1=1. An object outside all sets contributes 0. This proves the formula because summing these contributions counts precisely the union. Pairwise intersections include the triple intersection; they are not “exactly two” regions.

If the sets are forbidden conditions, subtract that union from |U|. If instead the question says “exactly one,” use different contribution weights. Write S₁ for the sum of the three single-set counts, S₂ for the sum of their three pair-intersection counts and S₃ for the triple count. Then:

exactly one = S₁−2S₂+3S₃;
exactly two = S₂−3S₃;
at least two = S₂−2S₃.

Each formula can be checked for an object with zero, one, two or three memberships. These formulas are for three conditions; do not carry them unchanged to four conditions.

Worked example: in U={1,…,60}, let A,B,C mean divisibility by 2,3,5. Single counts are 30,20,12. Pair intersections mean divisibility by 6,10,15, with counts 10,6,4. The triple means divisibility by 30 and has count 2. Thus the union has 62−20+2=44 elements. Exactly one has 62−40+6=28; exactly two has 20−6=14; all three has 2; neither has 16. The disjoint counts 28+14+2+16 recover 60. Zero is not in this universe.

Diagram B, text equivalent. Three membership conditions create eight disjoint membership regions, described by bits ABC. Regions 000,100,010,001,110,101,011,111 mean neither; A only; B only; C only; A/B only; A/C only; B/C only; all three. An object in 111 appears in three single counts, three pair counts and one triple count. The signed contribution 3−3+1 leaves one copy, while exactly-one weighting 3−6+3 leaves none.

G4. For the divisibility example, list the actual triple-intersection values. Derive the exactly-two formula by explaining contributions rather than memorizing coefficients.

G5. Count permutations of {1,2,3} in which no label occupies its own numbered position. Define three forbidden sets, calculate all intersection levels and list the surviving permutations as a check.

B2. Many-set inclusion–exclusion without a hidden theorem

For m finite forbidden subsets A₁,…,A_m, add the sizes of single sets, subtract all pair intersections, add all triple intersections, and continue with alternating signs through the intersection of all m. Every intersection is indexed by a nonempty selection of set names. If one object lies in q≥1 of the sets, its total contribution is the sum of +1 for odd-sized selections of those q names and −1 for even-sized selections, excluding the empty selection.

Here is a proof that this contribution is one, without assuming the binomial theorem. Select one fixed name among the q names. Pair every subset of those names with the subset obtained by toggling whether the fixed name is present. This operation reverses itself and switches even and odd subset sizes. Across all subsets the odd/even signed total is zero. The empty subset is even and contributes −1; deleting it leaves signed total +1. An object in no forbidden set has no nonempty selections and contributes zero. Summing over objects proves the finite general formula.

The proof is short; evaluating all intersections may be long. There are 2^m−1 nonempty selections of m names. Symmetry can group intersections of equal size, but only if you justify why their sizes match. “All intersections of the same order are equal” is not true for arbitrary sets.

Worked example: five labelled records choose one of three labelled queues. There are 3⁵ assignments. To require all queues nonempty, forbid a queue being empty. Each single-empty condition leaves 2⁵ assignments; each pair-empty condition leaves 1⁵; all three empty leaves zero because five records still require destinations. Hence 3⁵−3·2⁵+3·1⁵=150. This counts onto functions, not equal queue sizes. For zero records, there is one empty function to the three queues, but it is not onto. Handle that case directly rather than silently substituting an unexplained 0⁰ into a formula.

G6. Count length-four strings from {A,B,C} using every symbol. Use inclusion–exclusion and check by the possible multiplicity pattern 2,1,1. State why the repeated symbol and its positions must both be chosen.

Session C. What every distribution must contain

C1. Pigeonhole arguments prove a forced feature

Suppose N distinct objects each enter exactly one of k labelled boxes, where N≥0 and k≥1 are integers. Let r≥1 be an integer target occupancy. If every box held at most r−1 objects, their total would be at most k(r−1). Consequently N>k(r−1) forces some box to hold at least r objects. This is the generalized pigeonhole principle. It makes no claim about which box, the number of qualifying boxes or how likely a distribution is.

For N≥1, some box contains at least ceil(N/k), where ceil(x) is the smallest integer at least x. If all counts were smaller than that integer, their sum would be too small. For 17 records and five queues, some queue has at least four records. Five is not guaranteed: counts 4,4,3,3,3 are possible. The lower bound is sharp when arbitrary assignments are allowed. Write N=kq+s with 0≤s<k; assign q+1 objects to s boxes and q to the others. This construction achieves maximum ceil(N/k). For N=0 the zero bound is trivial. For k=0 and N>0 there is no assignment; do not divide by zero.

The least N forcing at least r objects in some one of k boxes is k(r−1)+1, for k,r≥1, if arbitrary assignments are allowed. Prove both halves: above the threshold avoidance is impossible; at N=k(r−1) the distribution r−1 in each box avoids the feature. Without the second half you have a sufficient bound, not proof of the least threshold.

C2. Unequal capacities and feasibility

If box i is allowed at most c_i objects, with nonnegative integer capacities, every capacity-respecting assignment has total at most c₁+⋯+c_k. One more object forces some capacity to be exceeded. When objects can go to any box, filling each box to capacity constructs a capacity-respecting assignment of exactly that total, so the bound is sharp.

For capacities 2,4,1, a total of eight forces an overflow; seven can be placed as 2,4,1. Extra restrictions can make fewer objects infeasible. If every object is allowed only in the first box, three objects already violate the capacity-2 limit despite total capacity seven. Total capacity is then only a necessary condition, not a sufficient feasibility test. Later graph structures can describe richer assignment restrictions; no general assignment theorem is claimed here.

Diagram C, text equivalent. Three labelled boxes display capacities 2,4,1 and occupancy 2,4,1. Their seven spaces are full. An eighth object must raise one occupancy beyond its capacity, regardless of which box receives it. If arrows from every object lead only to the first box, the unused spaces in the other two boxes cannot help. The allowed destinations are part of the model.

G7. What is the least number of objects forcing at least five in one of four boxes? Give an avoiding distribution one below your threshold and explain both parts of minimality.

G8. For capacities 2,4,1, prove the overflow threshold when every object may use any box. Then give a restriction under which the total-capacity bound no longer guarantees feasibility, and demonstrate the failure on explicit object counts.

Independent practice

I1. Allocate eight distinct cards to labelled groups of sizes 3,3,2. Now require specified card A in the first group and specified different card B in the third. Count both models and give the residual sizes in the constrained one.

I2. Count words using A,A,A,B,B,C. Count those with no adjacent A symbols by first arranging B,B,C and choosing gaps for the A symbols. Explain why each gap may contain at most one A and why this does not require a correction for hidden A labels.

I3. In U={1,…,90}, count integers divisible by at least one of 2,3,5; exactly one; exactly two; and none. Show all intersection levels and a disjoint-total check.

I4. Count length-five strings from four labelled symbols using all four. Recount by the possible symbol multiplicities. Explain why counting onto assignments is different from prescribing equal class sizes.

I5. Count permutations of four labels having no label in its own numbered position. Derive the intersection sizes before using inclusion–exclusion. Explain why a triple of fixed positions forces the fourth position fixed too, without making the triple intersection empty.

I6. Among 26 objects assigned to six boxes, what lower bound on the largest occupancy is guaranteed? Give a distribution proving the bound cannot be improved. Then give the least number guaranteeing at least six in a box, with a one-below witness.

I7. Boxes have capacities 1,3,4,2 and every object may enter any box. Give the least number forcing some capacity violation and a sharpness witness. Can a particular named box be guaranteed to overflow? Explain the quantifier difference.

I8. Someone reports |A|=8, |B|=7, |C|=6, |A∩B|=4, |A∩C|=3, |B∩C|=2 and |A∩B∩C|=3. They substitute into inclusion–exclusion and report a union count. Decide whether any such finite sets can exist; identify a concrete containment or region contradiction before trusting the arithmetic.

Homework: proofs and limits

H1. Prove the multinomial allocation formula in two ways: successive choices and forgetting internal order after cutting a full ordering into labelled blocks. State integer/domain conditions, handle a zero-sized class and the all-empty case, and explain why erasing class names requires a separate proof.

H2. Prove inclusion–exclusion for any finite number of finite sets using the subset-toggle argument. Define the pairing, show it is its own inverse and changes parity, and explain the omitted empty subset's sign. Separately derive the exactly-one formula for three sets by membership multiplicities; do not assert it unchanged for four.

H3. Prove the least uniform occupancy threshold k(r−1)+1 for k,r≥1 and unrestricted destinations. Include a below-threshold construction. Prove the unequal-capacity version, then give an explicit allowed-destination counterexample to the converse “total capacity is enough.”

H4. Critique “there are 90 assignments, so at least one box has three objects.” Give a precisely specified model with 90 assignments in which that conclusion is false for every assignment. State a corrected pigeonhole inference for that model and distinguish number of assignments from number of objects per assignment.

Formative quiz: 32 points

Q1 (8). Count words using A,A,B,B,C,C. Count those whose first letter is A and whose last is not A in two ways. Explain the distinct-object interpretation behind any factorial denominator.

Q2 (8). Count length-five strings over four labelled symbols using every symbol. Give an inclusion–exclusion derivation with every intersection level, and a second count by multiplicity pattern. Explain the positive-length all-empty boundary.

Q3 (8). State the best guaranteed lower bound for the largest occupancy when 17 objects enter five boxes, and give a sharpness witness. Then for three boxes of capacities 2,4,5 give the least object count forcing overflow and a one-below witness, assuming unrestricted destinations. Explain why neither argument selects a specific overflowing box.

Q4 (8). In a universe of 20 elements, suppose single-set counts for A,B,C are 12,10,9; pair-intersection counts AB,AC,BC are 7,5,4; and triple count is 3. Compute all eight disjoint membership-region counts, the union and exactly-one count. Decide whether these data are feasible by giving a region-based construction. Explain why merely changing the triple count to 5 while retaining the other numbers would fail.

Project: queues, capacities and forgotten names, 40 points

Six distinct records A,B,C,D,E,F each choose exactly one labelled queue X,Y,Z. Every queue must be nonempty, and A and B must enter different queues. An assignment specifies a destination for each named record; there is no ordering within a queue. No probabilities or real queueing performance are assumed.

P1 (10). Count the assignments in two ways. First fix the distinct destinations of A and B and make the remaining queue nonempty. Then count all onto assignments and subtract those in which A and B share a queue, explaining the collapsed-block encoding. Identify why the restriction does not prescribe equal queue sizes.

P2 (10). Add capacity three to each queue. Count the assignments removed and those retained. Explain why removed assignments must have occupancy pattern 4,1,1, then split according to whether the four-record queue contains exactly one of A,B or neither. Independently classify the retained assignments by patterns 3,2,1 and 2,2,2 and recover the same total; justify all label/multiplicity factors.

P3 (10). For the capacity-three model, forget queue names but retain its collection of three record sets. Count these targets and prove the fibre size. Then add the name-specific restriction “A enters X.” Count remaining named assignments and targets, explaining reachability and the new fibre size. Is dividing this restricted source count by six still justified? Recheck rather than carrying over a prior denominator.

P4 (10). For the original six-record model, prove the best guaranteed lower bound on maximum occupancy and give a valid assignment meeting it. Is occupancy at least three forced? For a changed model with nine distinct records including A,B, keep three nonempty capacity-three queues and A/B separation. Construct a feasible assignment. Explain why ten records are impossible under those capacities. Finish with an audit distinguishing exact enumeration checks, universal proofs, modelling assumptions and unavailable performance/probability evidence.

Delayed follow-through

D1. After a pause, count length-four strings from {A,B,C} using every symbol and satisfying first≠second. Use a fixed-first-two method and a second method subtracting the equal-first-two family from all onto strings. Name the inverse behind any collapsed-block argument.

D2. Correct one unjustified division, overlap count or threshold claim from your work and test the repaired rule on changed data. If none occurred, critique “15 objects in five boxes force four in one.” Give a counterexample, the correct guaranteed occupancy and the least count that actually forces four; justify both threshold directions. This records revision, not certified mastery.

Feedback and next step

Compare the earliest unsupported step, not only the final total. Ask whether classes are labelled, whether intersections include deeper overlaps, whether a stated threshold was proved minimal, and whether a restriction changes all fibres equally. A valid alternate derivation is welcome; an accidentally correct number is not a model or proof.

Unit 3's recurrences and finite recursive constructions are available in this reader. Full-semester assessment and measured learner outcomes are unfinished. This unit does not claim a general algorithm for capacity-constrained assignment, graph-theoretic matching, advanced generating functions or probabilistic queue performance. Specialist review, learner attempts/timing, rendered navigation and device/assistive-technology checks remain necessary.

Source and original-material note

The exposition, fictional models, text-described diagrams, tasks and keys are original. Optional primary topic reference: MIT OpenCourseWare, Lecture 17: Counting Rules II, checked 4 November 2026. The source's terms and license apply to its material. No external exercise, passage, image, transcript or video is reproduced. No affiliation, endorsement, institutional equivalence or closing of the full-course source gap is implied.