# Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich.

## Presentation on theme: "Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich."— Presentation transcript:

Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

2 Full version of the paper Andreas Blass and Yuri Gurevich Program Termination, and Well Partial Orderings Tech report MSR-TR-2006-27, Microsoft Research, March 2006 #178 at YG s website

3 Agenda 1. Program termination and the covering question 2. Well partial orderings and a game 3. Stature P of a wpo set P, and reduction to the question what 1... n i s 4. More about the stature 5. 1... n = 1... n 6. Extra: Linearizations of an arbitrary well partial ordering 7. Related work

4 A (nondeterministic) program terminates the successor relation ySx (y succeeds x) on (possibly some abstraction of) states is well founded the transitive closure S + is well founded there is a ranking function for

5 Ranking functions A ranking function for is a function f from the states to ordinals that is monotone: ySx fy<fx. The ranking height of f is the smallest ordinal such that there is a ranking function f for with values <.

6 Covering observation A transitive relation covered by a finitely many well-founded relations is well- founded: if R U 1 U 2 … U n and U 1, U 2, …, U n are well-founded and R is transitive then R is well-founded. Ref: Geser, Podelski & Rybalchenko We learned it from Byron Cook. S + is often over-approximated by a disjunction of relations.

7 Program 1 if a < 1000 < b then choose between a,b:= a+1, b + 1/2 a,b:= a-1, b - 1 Use the covering observation where yUx is a x <a y <1000, yVx is 1000<b y <b x. Ranking height of is as 3b-2a > 1000 and decreases at every step.

8 Program 2 if a < 1000 < b then choose between a := a+1 a,b:= any int, b-1 By covering observation, 2 terminates. Ranking height is 2.

9 Program 3 In each state, some points (a,b,c) of N 3 may be "forbidden ; initially, none. Once forbidden a point remains so forever. As long as possible, chose a free point (a,b,c) and forbid points (a,b,c ) with a a & b & or c c. By covering observation, 3 terminates. What is the ranking height of 3?

10 Ordinal height Consider a well founded poset (or digraph) P and let x, y range over the elements of P. |x| = min { : > |y| for all y < x} |P| = min { : > |x| for all x}

11 Ranking height = ordinal height Suppose that terminates and consider the well founded poset P = (states, S + ). Ordinal height |x| is a ranking function, and |x| fx for any ranking function. Hence |P| is the ranking height of.

12 Covering question Suppose that U 1,..,U n are well founded and R U 1... U n is transitive. By covering observation, R is well founded. How to bound |R| in terms of |U 1 |,.., |U n |?

13 Well partially ordered sets Df. A sequence x 1,x 2,... in a poset P is bad if there are no i<j with x i x j. P is well partially ordered (wpo) if every bad sequence is finite. E.g. ordinals, strings with the (not necessarily contiguous) substring relation wpo well-founded, but not the other way round e.g. If P is wpo then, for every filter F, the set X = Min(F) is finite and F = {y: y some x in X}.

14 A frequently rediscovered concept (Kruskal 1972) The bad terminology harks back to Cantor s well ordered sets. Some alternatives: Finitely based posets (Higman, apparently the original discover, 1952) Tight posets (think boots, YG 1969)

15 Games (P,Q) P and Q are well-founded posets. Positions of P are elements of P plus the summit above P. Same for Q. Players 1, 2 play at P, Q resp. and move alternately; 1 moves first. Each player has a pebble, initially at the summit position. Move: put the pebble to a position lower than the old. Win/lose: if you can t move, you lose.

16 Game criterion for height comparison 1 wins (P,Q) |P| > |Q| 2 wins (P,Q) |P| |Q| here wins means has a winning strategy in.

17 Stature: Definition Let x, y be bad sequences. y is lower than x if x is a proper initial segment of y. Clearly BS(P) is well founded. The stature P of a wpo set P is the height |BS(P)| of the forest BS(P) of nonempty bad sequences of P.

18 Example Order componentwise. A sequence (x 1,y 1 ),(x 2,y 2 ),... without repetitions is bad iff there are no i<j with (x i,y i ) < (x j,y j ). BS( ) is the well-founded forest of nonempty bad sequences = |BS( )|

19 Let R and U i be as in the covering question, and let i =|U i |. Theorem. |R| = 1... n.

20 Upper bound Let R and U i be as in the covering question, and let i =|U i |. Proposition. |R| 1... n. Suffices to prove: 2 wins (R,BS)). Strategy: when 1 moves to a point x of the domain D, append ( 1, …, n ) to the existing bad sequence where i is the height of x in the poset (D,U i ).

21 The bound is tight 1.. n R,U 1,..,U n as in the question with |U i | n and |R|= 1... n. R is the lower relation of BS( 1... n ), and..., (x 1,..,x n ) U i..., (y 1,..,y n ) if x i < y i

22 New question What is 1... n ?

24 Ideals IDL(P) is the set of proper ideals of P ordered by inclusion. IDL is well founded. Pf. A descending sequence D 1,D 2,... of ideals gives rise to a bad sequence x 1,x 2,... where x i D i -D i+1.

25 Antichains Let ACH(P) be the set of nonempty antichains of a wpo set P ordered thus: A B if b in B a b in A. ACH is well founded. Pf. The mapping X P - Filter(X) is a poset isomorphism.

26 Pointed ideals A pointed ideal is a pair (D,x) where D is an ideal and x a max element of D. PI(P) is the set of pointed ideals of P ordered thus: (D,x) < (E,y) if D E – {y}. PI is well founded. Pf. A descending seq of pointed ideals gives a descending seq of ideals.

27 Equivalent defs of stature Proposition. |ACH(P)| = |IDL(P)| = |PI(P)| = P. Pf. 1 st equality by isomorphism. The rest by games. E.g. |PI| |IDL|. When 1 moves to (D,x), move to D - {x}.

28 Linearizations of wpo set P Every linearization A is well ordered and |A| P Pf. 2 wins (A,BS(P)): append the new position to the current bad sequence.

29 Natural sums and products 2 5 + 3 = 3 < 3 + 2 5 The last one is in Cantor s normal form. Natural sum: add as polynomials in. Natural product: multiply as polynomials in using natural sum for the exponents.

30 1... n = 1... n

31 1... n is small enough 1... n 1... n Pf. The length of any linearization of 1... n is 1... n. By induction on 1... n, construct a linearization of 1... n of length 1... n.

32 1... n is large enough 1... n 1... n Pf. Induction on 1... n.

33 Program 3, again As long as possible, chose a free (a,b,c) in N 3 and forbid all (a,b,c ) with a a & b & or c c. The ranking height is 3. Replace N 3 with the direct product of arbitrary wpo sets.

34 Extra: Linearizations of an arbitrary well partial ordering

35 Motivation Let P be an arbitrary wpo set, and let A range over linearizations of P. We know that |A| P. In the case P =, we have an A with |A| = P. What is the supremum of linearization lengths in general? Is the supremum attainable?

36 Theorem For every wpo set P, there is a linearization A of P such that |A| = P. Cor. The supremum of linearization lengths is P. Cor. The supremum is attainable.

37 The most relevant related work De Jongh and Parikh showed that 1. among the lengths of linearizations of a wpo set P there is always a largest one, and 2. in case P =, the largest length is.

Similar presentations