Proofs: Little's algorithm
These are the human proofs of Little's algorithm, at full length.
Little's algorithm returns a shortest tour full
This proof shows: correctness, termination.
We use the pseudocode of the page. A tour is a set of arcs that forms one cycle through all cities, and , which is if has a forbidden arc. Let be the least cost of a tour, or if every tour has a forbidden arc. For a node , let and be the rows and columns of : the cities with no arc of out of them, and the cities with no arc of into them. The node stands for the set of tours with and for every .
Claim 1 (cost identity). For every node that the algorithm makes and every , , and for all entries.
Proof. Before line L1 reduces it, with on the diagonal, and , ; the identity holds, as no tour uses a diagonal arc. We show that each operation keeps the identity and , for every tour that the node still stands for after the operation.
- Row reduction by , the smallest entry of row . A tour in the set uses exactly one arc out of , and since it is not in , so its end is a column in . The sum in the identity loses and gains . The new row has smallest entry 0. If , the set is empty, and REDUCE returns .
- Column reduction. The same, with arcs into a city of .
- Setting an entry to (lines L10 and L12). The set of tours shrinks; the identity holds for the tours that remain, as the other entries do not change.
- Fixing with (line L11). For a tour , the term moves from the sum to , and the other terms of lie in rows and columns , which keeps.
Each node is made from its parent by these operations, so the claim holds by induction.
Claim 2 (bound and leaves). For every node, every has . If at line L6, then is a tour and .
Proof. The first part follows from Claim 1, as . For the second, arcs are added only at line L11, with and , so has at most one arc out of each city and at most one into each city. If has no cycle, it is a set of disjoint paths, where a city with no arc of counts as a path with no arcs. The end of a path has no arc out, so , and its start has no arc in, so .
We show the invariant: for every path of with fewer than arcs, . For a path with no arcs this is the diagonal entry, which line L1 sets to . Reductions do not change entries equal to , and line L10 only adds one, so the invariant passes to the exclude child. In the include child, is the end of its path and the start of its path, and these two paths join into the path through , for which line L12 sets when it has fewer than arcs. Every other path keeps its ends, which are not and not , so its entry is in a row and a column that keeps.
Now suppose that adding at line L11 closes a cycle. Then is the start and the end of the same path , and the cycle has arcs. If , the invariant gives , so is not a zero, a contradiction. So the only cycle can contain has arcs and is a tour. When , the arcs with one out of each city and one into each city cannot all lie on paths, so is this tour; it lies in with an empty sum, and Claim 1 gives .
Claim 3 (children split the parent). Let a node with be split at lines L8 to L14 on . Every lies in the set of the exclude child or of the include child , with the bounds and that lines L10 and L13 compute, whether or not the child is inserted.
Proof. If , then uses no arc with , so ; the reduction of row subtracts , since and the other entries of row are those of , and then column has smallest entry , so the bound is . If , then . If , the arc of line L12 together with the path of makes a cycle of fewer than arcs, which cannot contain, so does not use and .
Claim 4 (invariant). At the start of each iteration of line L3, every tour with lies in the set of some live node.
Proof. At the start, the root stands for all tours of finite cost, and it is inserted unless its bound is , in which case no tour has finite cost. Suppose that the claim holds at the start of an iteration that takes and does not break, and let at the end of the iteration. As only decreases, held at the start, and was in the set of a live node. If that node is not , it is still live. If it is and , then and line L7 sets , which contradicts . Otherwise, by Claim 3, is in the set of a child with bound by Claim 2; then the test at line L9 or line L14 passes and the child is inserted.
Claim 5 (termination). The loop runs finitely often. Proof. Each child either has one more arc in (include) or one more entry equal to among the entries of its rows and columns (exclude, since becomes ). Along any path of the tree, the number of fixed arcs is at most , and between two include steps the number of finite entries, at most , falls by at least one at each exclude step. So every path has length at most , the tree is binary, and it is finite.
Theorem. LITTLE returns for a tour of cost if , and otherwise.
Proof. By Claim 5 the loop ends. By Claim 2, is or the cost of the tour , so . When the loop ends, either is empty, or the node taken has and, as is a min-priority queue, every live node has bound at least . In both cases, Claim 4 and Claim 2 show that no tour has cost below : such a tour would lie in a live node with bound at most its cost, below . So , hence . If , then is a tour of cost ; if , line L7 never runs, since a leaf has finite bound only if its tour has finite cost, and inserted nodes have bound below ; so .