<<

Partially Ordered Sets Background for Program Analysis

Wednesday, November 14, 2007 1

Partial ordering

• A partial ordering is a : : L L true, false ! × → { } • that is: reflexive: l : l l • ∀ " transitive: l1, l2, l3 : l1 l2 l2 l3 l1 l3 • ∀ " ∧ " ⇒ " anti-symmetric: l1, l2 : l1 l2 l2 l1 l1 = l2 • ∀ " ∧ " ⇒

Wednesday, November 14, 2007 2

A partially ordered set (L, ) • ! is a set L equipped with a partial ordering ! l2 l1 l1 l2 • ! ≡ # l l l l l = l • 1 ! 2 ≡ 1 " 2 ∧ 1 $ 2

Wednesday, November 14, 2007 3

Bounds

Y L has l L as an upper bound if • ⊆ ∈ l! Y : l! l ∀ ∈ # and l L as a lower bound if ∈ l! Y : l! l ∀ ∈ #

Wednesday, November 14, 2007 4 Least upper bound

• A least upper bound l of Y is an upper bound of Y that satisfies l l 0 whenever l 0 ! is another upper bound of Y • A Y need not have a least upper bound but if one exists then it is unique (since is anti-symmetric) ! • The least upper bound of Y is written Y l l l , l ! • 1 ! 2 ≡ { 1 2} !

Wednesday, November 14, 2007 5

Greatest lower bound

• A greatest lower bound l of Y is a lower bound of Y that satisfies l0 l whenever l 0 ! is another lower bound of Y • A subset Y need not have a greatest lower bound but if one exists then it is unique (since is anti-symmetric) ! • The greatest lower bound of Y is written Y l l l , l ! • 1 ! 2 ≡ { 1 2} !

Wednesday, November 14, 2007 6 Complete

A complete lattice L = ( L , ) = ( L , , , , , ) • ! ! ⊥ # is a partially ordered set ( L , ) where all ! ! ! have an lub and a glb = = L is the least element • ⊥ ∅ = ! = ! L is the greatest element • ! ∅ ! !

Wednesday, November 14, 2007 7

Example

• For some set S ! ≡ ⊆ Y = Y L = ( (S), ) ! Y = " Y P ⊆ ⇒ ! = # ⊥ ∅ = S &

! ≡ ⊇ Y = Y L = ( (S), ) ! Y = " Y P ⊇ ⇒ ! = #S ⊥ = % ∅ both are complete lattices

Wednesday, November 14, 2007 8 Example 1

S = 1, 2, 3 { } 1, 2, 3 { } ∅ 1, 2 1, 3 2, 3 1 2 3 { } { } { } { } { } { }

1 2 3 1, 2 1, 3 2, 3 { } { } { } { } { } { } 1, 2, 3 ∅ { } L = ( (S), ) L = ( (S), ) P ⊆ P ⊇

Wednesday, November 14, 2007 9

Lemma 2

For a partially ordered set L = ( L , ) the claims: ! (i) L is a complete lattice (ii) every subset of L has a lub (iii) every subset of L has a glb are equivalent

Wednesday, November 14, 2007 10 Proof

Clearly, (i) implies (ii) and (iii). To show that (ii) implies (i) let Y L and define ⊆ Y = l L l! Y : l l! { ∈ | ∀ ∈ # } Now, pro!ve this! defines a glb: RHS set elements are all lbs so the equation defines a lb. Since any lb will be in the set it follows that the equation defines the glb.

Similarly, for Y = l L l! Y : l! l { ∈ | ∀ ∈ # } Wednesday, November 14, 2007 ! ! 11

Moore family

• A Moore family is a subset Y of a complete lattice L = ( L , ) that is closed under glbs: ! Y ! Y : Y ! Y ∀ ⊆ ∈ • Thus, a Moore family! always contains a least element, Y , and a greatest element, , ∅ which equals the greatest element, , from L ! ! ! • A Moore family is never empty

Wednesday, November 14, 2007 12 Example 3 Consider the complete lattice L = ( (S), ) P ⊆ S = 1, 2, 3 { } 1, 2, 3 2 , 1, 2 , 2, 3 , 1, 2, 3 { } {{ } { } { } { }} , 1, 2, 3 1, 2 1, 3 2, 3 {∅ { }} { } { } { } are both Moore families

1 , 2 1 2 3 {{ } { }} { } { } { } , 1 , 2 , 1, 2 {∅ { } { } { }} are not Moore families ∅

Wednesday, November 14, 2007 13

Properties of functions

A function f : L L between posets • 1 → 2 L = ( L , ) and L = (L , ) 1 1 !1 2 2 !2 is onto if l2 L2 : l1 L1 : f(l1) = l2 • ∀ ∈ ∃ ∈

is 1-1 if l, l! L : f(l) = f(l!) l = l! • ∀ ∈ 1 ⇒ is monotone if l, l! L : l l! f(l) f(l!) • ∀ ∈ 1 #1 ⇒ #2 is additive if l , l L : f(l l ) = f(l ) f(l ) • ∀ 1 2 ∈ 1 1 # 2 1 # 2 is multiplicative if • l , l L : f(l l ) = f(l ) f(l ) ∀ 1 2 ∈ 1 1 # 2 1 # 2 Wednesday, November 14, 2007 14 Properties of functions

• The function f is completely additive if for all Y L : ⊆ 1 f ( Y ) = f ( l ! ) l! Y 1 2{ | ∈ } ! ! whenever 1 Y exists It is completely! multiplicative if for all Y L : • ⊆ 1 f( Y ) = f(l!) l! Y 1 2{ | ∈ } ! ! whenever 1 Y exists !

Wednesday, November 14, 2007 15

Properties of functions

Y • Clearly 1 and 1 Y exist when L 1 is a complete lattice ! ! • When L 2 is not a complete lattice the above statements also require the appropriate lubs and glbs to exist in L2 The function is affine if for all Y L , Y = • ⊆ 1 " ∅ f( Y ) = f(l!) l! Y 1 2{ | ∈ } whenever! Y exists! (and Y = ) 1 ! ∅

Wednesday, November 14, 2007 ! 16 Properties of functions

The function is affine if for all Y L , Y = • ⊆ 1 " ∅ f( Y ) = f(l!) l! Y 1 2{ | ∈ } whenever! Y exists! (and Y = ) 1 ! ∅ The function! is strict if f( 1) = 2 • ⊥ ⊥ • Note that a function is completely additive iff it is both affine and strict

Wednesday, November 14, 2007 17

Lemma 4

If L = ( L , , , , , ) and M = ( M , , , , , ) ! " # ⊥ % ! " # ⊥ % are complete lattices and M is finite then the three conditions: (i) γ : M L is monotone → (ii) γ ( ) = , and ! ! (iii) γ ( m 1 m 2 ) = γ ( m 1 ) γ ( m 2 ) whenever ! ! m m m m 1 !" 2 ∧ 2 !" 1 are jointly equivalent to γ : M L being completely multiplicative →

Wednesday, November 14, 2007 18 Proof

First note that if γ is completely multiplicative then all three conditions hold. For the converse note that by monotonicity of γ we have γ ( m 1 m 2 ) = γ ( m 1 ) γ ( m 2 ) also when m m m ! m ! 1 ! 2 ∨ 2 ! 1 By induction on the (finite) of M ! M ⊆ we prove that γ( M !) = γ(m) m M ! { | ∈ } ! !

Wednesday, November 14, 2007 19

If the cardinality of M !is 0 then the equation follows from (ii). If the cardinality of M !is larger than 0 then we write M ! = M !! m !! where m ! ! M !! ∪ { } !∈ to ensure that the cardinality of M !! is strictly less than that of M ! ; hence:

γ( M !) = γ(( M !!) m!!) ! ! = γ( !M !!) γ(m!!) ! = ( !γ(m) m M !! ) γ(m!!) { | ∈ } ! = !γ(m) m M ! { | ∈ }

Wednesday, November 14, 2007 20 Lemma 5

A function f : ( ( D ) , ) ( ( E ) , ) is affine iff P ⊆ → P ⊆ there exists a function ϕ : D ( E ) and an → P element ϕ ( E ) such that ∅ ∈ P f(Y ) = ϕ(d) d Y ϕ { | ∈ } ∪ ∅ ! The function f is completely additive iff additionally ϕ = ∅ ∅

Wednesday, November 14, 2007 21

Proof

Suppose f is as displayed and assume = ; then Y ! ∅ f(Y ) Y = ϕ(d) d Y ϕ Y { | ∈ Y} { { | ∈ } ∪ ∅ | ∈ Y} ! = ! ! ϕ(d) d Y Y ϕ { { | ∈ } | ∈ Y} ∪ ∅ = ! ϕ!(d) d ϕ { | ∈ Y} ∪ ∅ = f!( ) ! Y ! showing that f is affine.

Wednesday, November 14, 2007 22 Next, suppose that f is affine and define ϕ ( d ) = f ( d ) { } and ϕ = f ( ) . For Y ( D ) let = d d Y ∅ ∅ ∈ P Y {{ } | ∈ } ∪ {∅} and note that Y = and = . Then Y Y ! ∅ f(Y ) = f( ! ) Y = !( f( d ) d Y f( ) ) { { } | ∈ } ∪ { ∅ } = !( ϕ(d) d Y ϕ ) { | ∈ } ∪ { ∅} = ! ϕ(d) d Y ϕ { | ∈ } ∪ ∅ ! so f can be written in the required form. Completely additive follows straightforwardly.

Wednesday, November 14, 2007 23

Isomorphism

An isomorphism from a poset ( L 1 , 1 ) to a ! poset ( L , ) is a monotone function θ : L L 2 !2 1 2 such that there exists a (necessarily unique)→ 1 1 monotone function θ − : L 2 L 1 with θ θ − = i d 2 1 → ◦ and θ − θ = i d (where i d i is the identity ◦ 1 function over L i , i = 1 , 2 .

Wednesday, November 14, 2007 24 Construction of Complete Lattices

• Complete lattices can be combined to construct new complete lattices. • Cartesian product • Total function space • Monotone function space

Wednesday, November 14, 2007 25

Cartesian Product

Let L = ( L , ) and L = ( L , ) be posets. 1 1 !1 2 2 !2 Define L = ( L , ) = L L by ! 1 × 2 L = (l1, l2) l1 L1 l2 L2 and (l , l ) {(l , l |) iff∈l ∧ l ∈ l } l 11 21 ! 12 22 11 ! 12 ∧ 21 ! 22 It is then straightforward to verify that L is a poset. If additionally each L = ( L , , , , , ) i i !i "i #i ⊥i %i is a complete lattice then so is L = ( L , , , , , ) ! " # ⊥ % and furthermore Y = ( l l : (l , l ) Y , l l : (l , l ) Y ) 1{ 1 | ∃ 2 1 2 ∈ } 2{ 2 | ∃ 1 1 2 ∈ } ! ! ! and = ( 1 , 2 ) and similarly for Y and . Wednesday, November 14, 20⊥07 ⊥ ⊥ ! ! 26 Total function space

Let L = ( L , ) be a poset and let S be a set. 1 1 !1 Define L = ( L , ) = S L by ! → 1 L = f : S L f is a total function and { → 1 | } f f ! iff s S : f(s) f !(s) ! ∀ ∈ !1 It is then straightforward to verify that L is a poset. If additionally L 1 = ( L 1 , 1 , 1 , 1 , 1 , 1 ) ! " # ⊥ % is a complete lattice then so is L = ( L , , , , , ) ! " # ⊥ % and furthermore Y = λ s . f ( s ) f Y 1{ | ∈ } and = λ s . and similarly for Y and . ⊥ ⊥1 ! ! ! !

Wednesday, November 14, 2007 27 Monotone function space Let L = ( L , ) and L = ( L , ) be posets. 1 1 !1 2 2 !2 Define L = ( L , ) = L L by ! 1 → 2 L = f : L L f is a monotone function and { 1 → 2 | } f f ! iff l1 L1 : f(l1) 2 f !(l1) It is then !straightf∀orwar∈ d to verify! that L is a poset. If additionally each L = ( L , , , , , ) i i !i "i #i ⊥i %i is a complete lattice then so is L = ( L , , , , , ) ! " # ⊥ % and furthermore Y = λl . f(l ) f Y 1 2{ 1 | ∈ } ! ! and = λ l 1 . 2 and similarly for Y and . Wednesday, November 14, 200⊥7 ⊥ ! ! 28 Chains

A subset Y L of a poset L = ( L , ) is a chain if ⊆ ! l , l Y : (l l ) (l l ) ∀ 1 2 ∈ 1 # 2 ∨ 2 # 1 Thus a chain is a (possibly empty) subset of L that is totally ordered. It is a finite chain if it is a finite subset of L .

A sequence ( l n ) n = ( l n ) n of elements in L is ∈N an ascending chain if n m l l ≤ ⇒ n # m Writing ( l n ) n also for l n n N it is clear that { | ∈ } an ascending chain is also a chain.

Wednesday, November 14, 2007 29

Similarly, a sequence ( l n ) n is a descending chain if n m l l ≤ ⇒ n # m and clearly a descending chain is also a chain.

A sequence ( l n ) n eventually stabilizes iff

n0 N : n N : n n0 ln = l0 ∃ ∈ ∀ ∈ ≥ ⇒ For ( l n ) n we write n l n for l n n N { | ∈ } ! ! and similarly we write n l n for ln n N { | ∈ } ! !

Wednesday, November 14, 2007 30 Ascending Chain and Descending Chain Conditions • A poset L = ( L , ) has finite height iff all chains are finite. ! • It has finite height at most h if all chains contain at most h+1 elements; it has finite height h if additionally there is a chain with h+1 elements. • The poset satisfies the Ascending Chain Condition iff all ascending chains eventually stabilize. Similarly, it satisfies the Descending Chain Condition iff all descending chains eventually stabilize.

Wednesday, November 14, 2007 31

Lemma 6

A poset L = ( L , ) has finite height iff it satisfies ! both the Ascending and Descending Chain Conditions.

Wednesday, November 14, 2007 32 Proof

First assume that L has finite height. If ( l n ) n is an ascending chain then it must be a finite chain and hence eventually stabilize; thus L satisfies the Ascending Chain Condition. Similarly for the Descending Chain Condition.

Wednesday, November 14, 2007 33

Next assume that L satisfies both the Ascending and Descending Chain Conditions, and consider a chain Y L . We prove that Y is a finite chain. ⊆ This is obvious if Y is empty so assume it is not. Then also ( Y , ) is a non-empty poset satisfying ! the Ascending and Descending Chain Conditions.

Wednesday, November 14, 2007 34 As an auxiliary result we now show that

each non-empty Y ! Y contains a least ⊆ element

Construct a descending chain ( l n! ) n in Y ! as

follows: first let l 0! be an arbitrary element of Y !. For the inductive step let l n! + 1 = l n! if l n! is the least element of Y !; otherwise we can find l ! Y ! such that l ! l ! l ! = l ! . n+1 ∈ n+1 ! n ∧ n+1 # n Clearly ( l n! ) n is a descending chain in Y ; since Y satisfies the Descending Chain Condition the chain will eventually stabilize:

i.e. n 0! : n n 0! : l n! = l n! and the construction ∃ ∀ ≥ 0! is such that l ! is the least element of Y !. n0!

Wednesday, November 14, 2007 35

Back to the main proof: construct an ascending chain ( l n ) n in Y . Using the side result each l n is chosen as the least element of the

set Y l 0 , . . . , l n 1 as long as the latter set is \ { − } non-empty, and this yields l n 1 l n l n 1 = ln ; − ! ∧ − # when Y l 0 , . . . , l n 1 is l n = l n 1 , and \ { − } − since Y = we know that n > 0 . Thus we have ! ∅ an ascending chain in Y and using the Ascending Chain Condition we have n : n n : l = l . ∃ 0 ∀ ≥ 0 n n0 But this means that Y l , . . . , l = since this \ { 0 n0 } ∅ is the only way that we can achieve l n 0 + 1 = l n 0. It follows that Y is finite.

Wednesday, November 14, 2007 36 Example 7

• 0 • ! . • –1 . • –2 • 2 . . • 1 • –! • 0 Ascending Chain but does not Descending Chain but does have finite height not have finite height

Wednesday, November 14, 2007 37

Preservation

• If L 1 and L 2 each satisfy one of the conditions finite height, ascending chain,

descending chain then L 1 L 2 also satisfies that condition. ×

If S is finite then S L preserves the • → conditions of L . L L does not in general preserve the • 1 → 2 conditions.

Wednesday, November 14, 2007 38 Lemma 8

For a poset L = ( L , ) the conditions ! (i) L is a complete lattice satisfying the Ascending Chain Condition, and (ii) L has a least element, , and binary lubs and ⊥ satisfies the Ascending Chain Condition are equivalent.

Wednesday, November 14, 2007 39

Proof

It is immediate that (i) implies (ii) so we prove that (ii) implies (i). Using Lemma 2 it suffices to prove that all subsets Y of L have a lub Y . If Y is empty clearly Y = . If Y is finite and non- ⊥ ! empty then we can write Y = y , . . . , y for n 1 ! { 1 n} ≥ and it follows that Y = ( . . . ( y 1 y 2 ) . . . ) y n . ! ! ! !

Wednesday, November 14, 2007 40 If Y is infinite then construct ( l n ) n of elements of L : let l 0 be an arbitrary element y 0 of Y and given l take l n + 1 = l n in the case y Y : y ln n ∀ ∈ # and take l = l y in the case where n+1 n ! n+1 some y Y satisfies y l . Clearly this n+1 ∈ n+1 !" n sequence is an ascending chain. Since L satisfies the Ascending Chain Condition it follows that the chain eventually stabilizes: i.e., n : l = l + 1 = . . . ∃ n n This means that y Y : y l because if y l n ∀ ∈ # n !" then l = l y for a contradiction. So we have n ! n " constructed an upper bound for Y . Since it is the lub for y , . . . , y Y it is also the lub for Y . { 0 n} ⊆

Wednesday, November 14, 2007 41

Lemma 9

For a complete lattice L = ( L , ) satisfying the ! Ascending Chain Condition and a total function f : L L , the conditions → (i) f is additive i.e. l , l : f ( l l ) = f ( l ) f ( l ), and ∀ 1 2 1 " 2 1 " 2 (ii) f is affine i.e. Y L, Y = : f( Y ) = f(l) l Y ∀ ⊆ # ∅ { | ∈ } are equivalent and in !both cases! f is a monotone function.

Wednesday, November 14, 2007 42 Proof

It is immediate that (ii) implies (i): take Y = l , l { 1 2} Also, (i) implies that f is monotone since l l 1 ! 2 is equivalent to l l = l . 1 ! 2 2 Next, suppose that f satisfies (i) and prove (ii). If Y is finite write Y = y , . . . , y for n 1 and { 1 n} ≥ f( Y ) = f(y . . . y ) = f(y ) . . . f(y ) 1 ! ! n 1 ! ! n ! f(l) l Y " { | ∈ } !

Wednesday, November 14, 2007 43

If Y is infinite then the construction of the proof of Lemma 8 gives Y = l and l n = y n . . . y0 n ! ! for some y i Y and 0 i n . Then ∈ ≤ !≤ f( Y ) = f(l ) = f(y . . . y ) n n ! ! 0 ! = f(y ) . . . f(y ) n ! ! 0 f(l) l Y " { | ∈ } Furthermore ! f( Y ) f(l) l Y ! { | ∈ } follows from the! monotonicity! of f . This completes the proof.

Wednesday, November 14, 2007 44 Fixed points

Consider a monotone function f : L L on • → a complete lattice L = ( L , , , , , ) . A ! " # ⊥ % fixed point of f is an element l L : f ( l ) = l . ∈ Write F i x ( f ) = l f ( l ) = l for the set of { | } fixed points. f is reductive at l iff f ( l ) l . • ! Write R e d ( f ) = l f ( l ) l for the set of { | ! } elements on which f is reductive, and say that f itself is reductive if R e d ( f ) = L .

Wednesday, November 14, 2007 45

Similarly, f is extensive at l iff f ( l ) l . • ! Write E x t ( f ) = l f ( l ) l for the set of { | ! } elements on which f is extensive, and say that f itself is extensive if E x t ( f ) = L .

• Since L is a complete lattice it is always the case that F i x ( f ) will have a glb in L : lfp(f) = Fix(f) Similarly, F i x ( f ) will! have a lub in L : gfp(f) = Fix(f) • Tarski’s Fixed Point Theor! em establishes that l f p ( f ) is the least fixed point of f and that gfp(f) is the greatest fixed point of f .

Wednesday, November 14, 2007 46 Proposition 10 Tarski’s Fixed Point Theorem Let L = ( L , , , , , ) be a complete lattice. ! " # ⊥ % If f : L L is a monotone function then lfp(f) → and g f p ( f ) satisfy: lfp(f) = Red(f) Fix(f) ∈ gfp(f) = ! Ext(f) Fix(f) ∈ !

Wednesday, November 14, 2007 47

Proof

For l f p ( f ) define l 0 = R e d ( f ) . First show that f ( l 0 ) l 0 so that l R e d ( f ) . Since l0 l l Red(f) ! 0 ∈! ! ∀ ∈ and f is monotone we have f(l ) f(l) l, l Red 0 ! ! ∀ ∈ and hence f ( l ) l . 0 ! 0 To prove l f ( l ) observe thatf(f(l )) f(l ) 0 ! 0 0 ! 0 showing that f ( l ) R e d ( f ) and hence l f(l ) 0 ∈ 0 ! 0 by definition of l 0 . Together this shows that l 0 is a fixed point of f and so l F i x ( f ). To see that 0 ∈ l is least in F i x ( f ) note that F i x ( f ) R e d ( f ) so 0 ⊆ l f p ( f ) = l 0 . Similarly for g f p ( f ) . Wednesday, November 14, 2007 48 Iteration

Iterating to the lfp by taking the lub of the sequence ( f n ( ) ) implies need for continuity of ⊥ n f (i.e. f ( n l n ) = n ( f ( l n ) ) for all ascending chains ( l! n ) n ), and !similarly for the glb. One can show that f ( ) f ( ) lfp(f) ⊥ " n ⊥ " n n ⊥ " ! gfp(f) f n( ) f n( ) " " n # " # " # However, if L satisfies the Ascending! Chain Condition then n : f n ( ) = f n + 1 ( ) and hence ∃ ⊥ ⊥ lf p = f n ( ) . Similarly for g f p ( f ) . ⊥

Wednesday, November 14, 2007 49

! f n( ) !

f n( ) n ! Red(f) ! gfp(f)

Fix(f)

lfp(f) Ext(f) f n( ) n ⊥ ! f n( ) ⊥

Wednesday, November 14, 2007 50