Monotone functions Monotone functions on CCPO’s Let ( D, ⊑ ) and ( D ′ , ⊑ ′ ) be ccpo’s and con- Lemma 4.30 sider a (total) function Let ( D, ⊑ ) and ( D ′ , ⊑ ′ ) be ccpo’s and let f : D → D ′ f : D → D ′ Then f is monotone if be a monotone function. If Y is a chain whenever d 1 ⊑ d 2 also f d 1 ⊑ ′ f d 2 in D then { f d | d ∈ Y } is a chain in D ′ . Furthermore, � Y ) � ′ { f d | d ∈ Y } ⊑ ′ f ( Examples f 1 , f 2 : P ( { a,b,c } ) → P ( { d,e } ) Proof of Lemma 4.30 X f 1 X f 2 X { a,b,c } { d,e } { d } If Y = ∅ then the result follows from { a,b } { d } { d } ⊥ ′ ⊑ ′ f ⊥ . { a,c } { d,e } { d } { b,c } { d,e } { e } If Y � = ∅ then there are two stages: { a } { d } { d } { b } { d } { e } • { f d | d ∈ Y } is a chain in D ′ { c } { e } { e } � Y ) � ′ { f d | d ∈ Y } ⊑ ′ f ( • ∅ ∅ { e } XIV.1 XIV.2
Example: Factorial program Monotonicity is not enough Example 4.31 f : P ( N ∪ { a } ) → P ( N ∪ { a } ) defined by S ds [ y := 1 ; while ¬ ( x = 1 ) do ( y := y ⋆ x ; x := x − 1 )] s if X is finite X f X = X ∪ { a } if X is infinite = (FIX F ) ( s [ y �→ 1] ) Then f is a monotone function. where � Y ) does not � ′ { f d | d ∈ Y } = f ( But ( F g ) s always hold. g ( s [ y �→ ( s y ⋆ s x )] [ x �→ ( s x ) − 1]) = if s x � = 1 Let Y = {{ 0 , 1 , · · · , n } | n ≥ 0 } . Then if s x = 1 s � Y = N � { f X | X ∈ Y } = Then F is monotone But � Y ) = f N = N ∪ { a } f ( XIV.3 XIV.4
Continuous functions Example: Factorial program Let ( D, ⊑ ) and ( D ′ , ⊑ ′ ) be ccpo’s and con- sider a (total) function f : D → D ′ . Then f is continuous if S ds [ y := 1 ; while ¬ ( x = 1 ) do • f is monotone ( y := y ⋆ x ; x := x − 1 )] s � Y ) � ′ { f d | d ∈ Y } = f ( • = (FIX F ) ( s [ y �→ 1] ) for all non-empty chains Y of D where Exercise 4.34 ( F g ) s g ( s [ y �→ ( s y ⋆ s x )] [ x �→ ( s x ) − 1]) Let ( D, ⊑ ) and ( D ′ , ⊑ ′ ) be ccpo’s and let = if s x � = 1 f : D → D ′ if s x = 1 s be a (total) function satisfying Then F is continuous � Y ) � ′ { f d | d ∈ Y } = f ( for all non-empty chains Y of D . Then f is monotone XIV.5 XIV.6
Fixed point theorem Example: Factorial program S ds [ y := 1 ; while ¬ ( x = 1 ) do Theorem 4.37 ( y := y ⋆ x ; x := x − 1 )] s Let f : D → D be a continuous function on the ccpo ( D, ⊑ ) with least element ⊥ . = (FIX F ) ( s [ y �→ 1] ) Then where � { f n ⊥ | n ≥ 0 } FIX f = ( F g ) s defines an element of D and this element g ( s [ y �→ ( s y ⋆ s x )] [ x �→ ( s x ) − 1]) is the least fixed point of f . if s x � = 1 = Notation: if s x = 1 s f 0 = id f n +1 = f ◦ f n for nǫ 0 We must ensure that Proof • (State ֒ → State, ⊑ ) is a ccpo 1. FIX f is well-defined Lemma 4.25 2. FIX f is a fixed point of f • F is a continuous function 3. FIX f is the least fixed point of f Then Theorem 4.37 can be applied XIV.7 XIV.8
Example: Factorial program ( F 0 ⊥ ) s = undef undef if s x � = 1 ( F 1 ⊥ ) s = if s x = 1 s ( F 2 ⊥ ) s undef if s x � = 1 and s x � = 2 s [ y �→ ( s y ) ⋆ 2][ x �→ 1] = if s x = 2 if s x = 1 s ( F n ⊥ ) s undef if s x < 1 or s x > n = s [ y �→ ( s y ) ⋆ j ⋆ . . . ⋆ 2 ⋆ 1][ x �→ 1] if s x = j and 1 ≤ j ≤ n (FIX F ) s undef if s x < 1 s [ y �→ ( s y ) ⋆ n ⋆ . . . ⋆ 2 ⋆ 1][ x �→ 1] = if s x = n and 1 ≤ n XIV.9
Recommend
More recommend