Definition · Greedy on an independence systemGiven an independence system (E, I) and non-negative weights w, sort E in decreasing weight and walk it once, adding each element when the set so far plus that element is still independent. The result is a maximal independent set; the question is whether it is a maximum-weight one.
Theorem · Rado and EdmondsLet (E, I) be an independence system. Greedy returns a maximum-weight independent set for every non-negative weight function w if and only if (E, I) is a matroid.
Suppose first that (E, I) is a matroid and let G be greedy's answer and O a maximum-weight independent set. Both are bases, so they have the same size r. List each in decreasing weight, g₁ ≥ g₂ ≥ … ≥ g_r and o₁ ≥ o₂ ≥ … ≥ o_r. The claim is that w(gᵢ) ≥ w(oᵢ) for every i, which gives w(G) ≥ w(O) at once.
Suppose not, and take the least i with w(gᵢ) < w(oᵢ). Let A = {g₁, …, g_(i−1)} and B = {o₁, …, oᵢ}, both independent by downward closure, with |A| < |B|. By the exchange property some x in B \ A has A ∪ {x} independent, and w(x) ≥ w(oᵢ) > w(gᵢ). But greedy, having chosen A, would have reached x before gᵢ and taken it. Contradiction.
For the converse, suppose the exchange property fails for some independent A and B with |A| < |B|, chosen with |A| as large as possible among failures, and write a = |A|. Give every element of A weight a + 2, every element of B \ A weight a + 1, and everything else weight 0. Greedy takes all of A first, then can add nothing from B \ A by assumption, so it collects at most a(a + 2) from the weighted elements; B alone is worth at least (a + 1)², which is larger. So greedy is not optimal for that weighting.
□
The converse is constructive, which is worth noticing: it does not merely assert that a bad weighting exists, it builds one out of the failing pair. On the matchings of a path with A = {B} and B = {A, C}, that recipe gives the middle edge weight 3 and the two ends weight 2 each, and greedy takes the middle for 3 against 4.
Which is exactly the weighting the lab ships as that family's default: 2 3 2. Greedy takes the middle edge, worth 3, and the best independent set is the pair of ends, worth 4. So the reader meets a counterexample before reading the proof that guarantees one, and the panel reports the gap as a measurement rather than as an illustration.
The search, and the number thirteen
The panel then does something the proof does not: it walks every weighting in {1, 2, 3}ⁿ in a fixed order and stops at the first one on which greedy is beaten. On the three-element family that space has 27 weightings, and the search stops after 13 of them, at 1 2 2. Greedy takes the middle edge for 2; the two ends are worth 3 together.
Thirteen is a fact about the enumeration order and nothing else. It is not a measure of how badly the family fails, not a property of matroids, and not stable under relabelling the elements. What is a fact about the family is that the search terminates at all, which the converse guarantees for every non-matroid, and that its answer is a concrete triple a reader can type back into the weights box.
The other direction, swept rather than sampled
On each of the three families that are matroids the panel walks the whole space: all 3⁵ = 243 weightings in {1, 2, 3}⁵, with greedy compared against the best member of the family on each. None of the 243 beats greedy on the uniform family, none on the graphic family, none on the partition family. The panel reports that it tried all of them, because “no counterexample found” and “the whole space was searched” are different sentences and only the second is worth printing.
It is still a sample. {1, 2, 3}ⁿ is 243 of the infinitely many weight functions on five elements, and a family could in principle survive all of them and fail on {1, 2, 4}. The theorem is what rules that out, and the sweep is what would catch an implementation that had drifted away from the theorem. Neither replaces the other.
One detail of the sweep is worth a sentence because it decides a tie. With weights 1 2 2 the two heaviest elements are tied, and greedy takes the middle edge rather than an end. Change the order in which ties are broken and greedy would take an end, then the other end, and reach 3 — the optimum. A counterexample to a greedy rule can depend on the tie-break, and the panel's is fixed, stated by the trace it prints, and part of the algorithm rather than an accident of it.
Measured on this page: 27 weightings in the space for the matchings family, 13 tried before one beat greedy, 1 2 2, giving 2 against 3; 243 weightings each for the three matroids, all tried, none beating greedy. Proved on this page: greedy is optimal for every non-negative weight function exactly when the family is a matroid. The sweep is 243 points and the theorem is every point, and this is the page on the course where that gap is smallest and still absolute.