Proofs: Size-change termination
These are the human proofs of Size-change termination, at full length.
The closure algorithm decides size-change termination full
This proof shows: correctness.
We use the definitions and the pseudocode of the page. is a finite set of size-change graphs, each graph has at most one arc between each pair of parameters, and is defined when and . A walk is a nonempty sequence of graphs of with , and . A path through from to is a sequence of parameters with an arc in for each ; it is strict if one of these arcs is strict.
Lemma 1 (composition). has an arc iff there is a path through from to , and the arc is strict iff some such path is strict. In particular composition is associative, and whenever is a walk.
Proof. By induction on . For a path is one arc of . For write . By definition has an arc iff some has an arc in and in , which by induction holds iff there is a path through from to followed by an arc of , that is, a path through from to . The arc is strict iff for some such one of the two parts is strict, which by induction holds iff some path through from to is strict. Since paths through are paths through followed by paths through , the same description gives , and associativity follows.
Lemma 2 (the closure). Lines L1 to L6 stop, and afterwards .
Proof. A graph is determined by its endpoints and by the state of each of the at most pairs of parameters: no arc, a non-strict arc or a strict arc. So there are at most graphs. A graph enters only when it enters , and never leaves , so at most that many graphs enter ; each iteration of L2 removes one, so the loop stops.
Every graph put into is some : this holds for the graphs of at L1, and line L5 forms by Lemma 1, where is a walk since starts at the end of .
Conversely, let be a walk; we show by induction on its length. Walks of length 1 are put into at L1. For , by induction . Every graph of entered when it entered , and the loop runs until is empty, so is removed at L3 at some time. Then L4 considers , which starts where ends, and L5 and L6 ensure .
Lemma 3 (Ramsey). If every idempotent in has a strict arc , then every multipath has an infinitely descending thread.
Proof. Let be a multipath, with . For times let , a graph of by Lemma 2. This colors the pairs of positive integers with finitely many colors, so by the infinite Ramsey theorem there are times and a graph with for all . Then and , so and for . By Lemma 1, , so is idempotent. By assumption it has a strict arc , and by Lemma 1, for each there is a strict path from to through . These paths join into a thread from time that has a strict arc in each segment, so it is infinitely descending.
Lemma 4 (the witness). If is idempotent and has no strict arc , then the multipath has no infinitely descending thread.
Proof. The multipath is well formed, since starts and ends at . Suppose a thread from some time has infinitely many strict arcs. Let the period boundaries after be the times at which a copy of starts, and let be the parameter of the thread at . There are finitely many parameters and infinitely many strict arcs, so there are with and a strict arc of the thread between and . That part of the thread is a strict path from to through , so by Lemma 1 the graph has a strict arc . Since is idempotent, , which has no strict arc , a contradiction.
Theorem. SIZE-CHANGE-TERMINATES stops, and it returns "SCT" iff is size-change terminating; when it returns "not SCT" with witness , the multipath has no infinitely descending thread.
Proof. The closure stops by Lemma 2, and lines L7 to L9 make one finite pass over . Line L8 tests for graphs , that is, idempotence, and L9 tests for a strict self arc. If the algorithm returns "SCT" at L10, every idempotent in has a strict self arc, so is SCT by Lemma 3. If it returns "not SCT" at L9 with , then for a walk by Lemma 2, recorded by the implementation, and by Lemma 4 the multipath has no infinitely descending thread, so is not SCT.