Algorithm Search⌘K

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. G\mathcal{G} is a finite set of size-change graphs, each graph G:f→gG : f \to g has at most one arc between each pair of parameters, and G;HG ; H is defined when G:f→gG : f \to g and H:g→hH : g \to h. A walk is a nonempty sequence w=H1⋯Hnw = H_1 \cdots H_n of graphs of G\mathcal{G} with Ht:ft→ft+1H_t : f_t \to f_{t+1}, and Gw=H1;⋯ ;Hn:f1→fn+1G_w = H_1 ; \cdots ; H_n : f_1 \to f_{n+1}. A path through ww from ii to jj is a sequence of parameters x1=i,x2,…,xn+1=jx_1 = i, x_2, \ldots, x_{n+1} = j with an arc xt→xt+1x_t \to x_{t+1} in HtH_t for each tt; it is strict if one of these arcs is strict.

Lemma 1 (composition). GwG_w has an arc i→ji \to j iff there is a path through ww from ii to jj, and the arc is strict iff some such path is strict. In particular composition is associative, and Gw;Gv=GwvG_{w} ; G_{v} = G_{wv} whenever wvwv is a walk.

Proof. By induction on nn. For n=1n = 1 a path is one arc of H1H_1. For n>1n > 1 write w=w′Hnw = w' H_n. By definition Gw′;HnG_{w'} ; H_n has an arc i→ji \to j iff some kk has an arc i→ki \to k in Gw′G_{w'} and k→jk \to j in HnH_n, which by induction holds iff there is a path through w′w' from ii to kk followed by an arc k→jk \to j of HnH_n, that is, a path through ww from ii to jj. The arc is strict iff for some such kk one of the two parts is strict, which by induction holds iff some path through ww from ii to jj is strict. Since paths through wvwv are paths through ww followed by paths through vv, the same description gives Gw;Gv=GwvG_w ; G_v = G_{wv}, and associativity follows. □\square

Lemma 2 (the closure). Lines L1 to L6 stop, and afterwards S={Gw:w a walk}S = \{G_w : w \text{ a walk}\}.

Proof. A graph f→gf \to g is determined by its endpoints and by the state of each of the at most p2p^2 pairs of parameters: no arc, a non-strict arc or a strict arc. So there are at most F2⋅3p2F^2 \cdot 3^{p^2} graphs. A graph enters WW only when it enters SS, and never leaves SS, so at most that many graphs enter WW; each iteration of L2 removes one, so the loop stops.

Every graph put into SS is some GwG_w: this holds for the graphs of G\mathcal{G} at L1, and line L5 forms Gw;H=GwHG_w ; H = G_{wH} by Lemma 1, where wHwH is a walk since HH starts at the end of GwG_w.

Conversely, let ww be a walk; we show Gw∈SG_w \in S by induction on its length. Walks of length 1 are put into SS at L1. For w=w′Hw = w' H, by induction Gw′∈SG_{w'} \in S. Every graph of SS entered WW when it entered SS, and the loop runs until WW is empty, so Gw′G_{w'} is removed at L3 at some time. Then L4 considers HH, which starts where Gw′G_{w'} ends, and L5 and L6 ensure Gw′;H=Gw∈SG_{w'} ; H = G_w \in S. □\square

Lemma 3 (Ramsey). If every idempotent G:f→fG : f \to f in SS has a strict arc x→xx \to x, then every multipath has an infinitely descending thread.

Proof. Let H1H2⋯H_1 H_2 \cdots be a multipath, with Ht:ft→ft+1H_t : f_t \to f_{t+1}. For times s<ts < t let c(s,t)=GHs⋯Ht−1c(s, t) = G_{H_s \cdots H_{t-1}}, a graph of SS by Lemma 2. This colors the pairs of positive integers with finitely many colors, so by the infinite Ramsey theorem there are times t0<t1<t2<⋯t_0 < t_1 < t_2 < \cdots and a graph GG with c(ta,tb)=Gc(t_a, t_b) = G for all a<ba < b. Then G:ft0→ft1G : f_{t_0} \to f_{t_1} and G:ft1→ft2G : f_{t_1} \to f_{t_2}, so ft0=ft1f_{t_0} = f_{t_1} and G:f→fG : f \to f for f=ft0f = f_{t_0}. By Lemma 1, G;G=c(t0,t1);c(t1,t2)=c(t0,t2)=GG ; G = c(t_0, t_1) ; c(t_1, t_2) = c(t_0, t_2) = G, so GG is idempotent. By assumption it has a strict arc x→xx \to x, and by Lemma 1, for each aa there is a strict path from xx to xx through Hta⋯Hta+1−1H_{t_a} \cdots H_{t_{a+1} - 1}. These paths join into a thread from time t0t_0 that has a strict arc in each segment, so it is infinitely descending. □\square

Lemma 4 (the witness). If G=Gw:f→fG = G_w : f \to f is idempotent and has no strict arc x→xx \to x, then the multipath www⋯w w w \cdots has no infinitely descending thread.

Proof. The multipath is well formed, since ww starts and ends at ff. Suppose a thread from some time ss has infinitely many strict arcs. Let the period boundaries after ss be the times b0<b1<⋯b_0 < b_1 < \cdots at which a copy of ww starts, and let ymy_m be the parameter of the thread at bmb_m. There are finitely many parameters and infinitely many strict arcs, so there are m<m′m < m' with ym=ym′=xy_m = y_{m'} = x and a strict arc of the thread between bmb_m and bm′b_{m'}. That part of the thread is a strict path from xx to xx through wm′−mw^{m' - m}, so by Lemma 1 the graph Gwm′−m=Gm′−mG_{w^{m'-m}} = G^{m'-m} has a strict arc x→xx \to x. Since GG is idempotent, Gm′−m=GG^{m'-m} = G, which has no strict arc x→xx \to x, a contradiction. □\square

Theorem. SIZE-CHANGE-TERMINATES stops, and it returns "SCT" iff G\mathcal{G} is size-change terminating; when it returns "not SCT" with witness G=GwG = G_w, the multipath www⋯w w w \cdots has no infinitely descending thread.

Proof. The closure stops by Lemma 2, and lines L7 to L9 make one finite pass over SS. Line L8 tests G;G=GG ; G = G for graphs f→ff \to f, that is, idempotence, and L9 tests for a strict self arc. If the algorithm returns "SCT" at L10, every idempotent G:f→fG : f \to f in SS has a strict self arc, so G\mathcal{G} is SCT by Lemma 3. If it returns "not SCT" at L9 with GG, then G=GwG = G_w for a walk ww by Lemma 2, recorded by the implementation, and by Lemma 4 the multipath www⋯w w w \cdots has no infinitely descending thread, so G\mathcal{G} is not SCT. ■\blacksquare

Back to Size-change termination