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

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

Embed Size (px)

Citation preview

Page 1: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

Program Termination,and

Well Partial Orderings

Andreas Blass and Yuri Gurevich

Page 2: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

2

Full version of the paper

Andreas Blass and Yuri GurevichProgram Termination, and Well Partial OrderingsTech report MSR-TR-2006-27, Microsoft Research, March 2006#178 at YG’s website

Page 3: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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

Page 4: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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 < .

Page 5: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

6

Covering observation

A transitive relation covered by a finitely many well-founded relations is well-founded: if R U1 U2 … Un

and U1, U2,…, Un are well-founded and R is transitive then R is well-founded.Ref: Geser, Podelski & RybalchenkoWe learned it from Byron Cook.S+ is often over-approximated by a disjunction of relations.

Page 6: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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 whereyUx is ax<ay<1000, yVx is 1000<by<bx .

Ranking height of is as 3b-2a > 1000 and decreases at every step.

Page 7: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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.

Page 8: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

9

Program 3

In each state, some points (a,b,c) of N3 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?

Page 9: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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}

Page 10: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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 .

Page 11: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

12

Covering question

Suppose that U1,..,Un are well

founded and R U1 ... Un is transitive.By covering observation, R is well founded. How to bound |R| in terms of |U1|,.., |Un|?

Page 12: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

13

Well partially ordered sets

Df. A sequence x1,x2,... in a poset P is bad if there are no i<j with xi xj. 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}.

Page 13: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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)

Page 14: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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.

Page 15: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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”.

Page 16: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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.

Page 17: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

18

Example

Order componentwise.

A sequence (x1,y1),(x2,y2),... without repetitions is bad iff there are no i<j with (xi,yi) < (xj,yj).

BS() is the well-founded forest of nonempty bad sequences

∥∥ = |BS()|

Page 18: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

19

Let R and Ui be as in the covering

question, and let i=|Ui|.

Theorem. |R| = ∥1...n∥.

Page 19: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

20

Upper bound

Let R and Ui be as in the covering question, and let i=|Ui|.

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,Ui).

Page 20: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

21

The bound is tight

1..n R,U1,..,Un as in the

question with |Ui|n and |R|=

∥1...n∥.

R is the “lower” relation of BS(1...n), and

...,(x1,..,xn) Ui ...,(y1,..,yn) if xi < yi

Page 21: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

22

New question

What is ∥1...n∥?

Page 22: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

23

More about the stature

Page 23: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

24

Ideals

IDL(P) is the set of proper ideals of P ordered by inclusion. IDL is well founded.Pf. A descending sequence D1,D2,... of ideals gives rise to a

bad sequence x1,x2,... where

xiDi-Di+1.

Page 24: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

25

Antichains

Let ACH(P) be the set of nonempty antichains of a wpo set P ordered thus:AB if b in B a b in A.ACH is well founded.

Pf. The mapping X ↦ P - Filter(X) is a poset isomorphism.

Page 25: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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.

Page 26: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

27

Equivalent defs of stature

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

Page 27: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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.

Page 28: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

29

Natural sums and products

2 5 + 3 = 3 < 3 + 2 5The 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.

Page 29: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

30

∥1...n∥ = 1...n

Page 30: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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.

Page 31: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

32

1...n is large enough

1...n ∥1...n∥

Pf. Induction on 1...n.

Page 32: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

33

Program 3, again

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

Page 33: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

34

Extra: Linearizations of an arbitrary well partial

ordering

Page 34: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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?

Page 35: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

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.

Page 36: Program Termination, and Well Partial Orderings Andreas Blass and Yuri Gurevich

37

The most relevant related work

De Jongh and Parikh showed that1. 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 .