transfinite semantics in the form of greatest fixpoint
play

Transfinite Semantics in the form of Greatest Fixpoint Hrmel Nestra - PDF document

1 Transfinite Semantics in the form of Greatest Fixpoint Hrmel Nestra Institute of Computer Science University of Tartu e-mail: harmel.nestra@ut.ee 2 1 Transfinite semantics Transfinite semantics 3 1 Transfinite semantics Transfinite


  1. 1 Transfinite Semantics in the form of Greatest Fixpoint Härmel Nestra Institute of Computer Science University of Tartu e-mail: harmel.nestra@ut.ee

  2. 2 1 Transfinite semantics Transfinite semantics

  3. 3 1 Transfinite semantics Transfinite semantics Transfinite semantics : program execution can continue after com- pleting an infinite subcomputation. – Studied during the last decade. – Can entail: ∗ transfinite traces of execution steps in the case of iteration; ∗ fractal traces of execution steps in the case of recursion. – Useful in formalizing program slicing to avoid semantic anomaly .

  4. 4 1 Transfinite semantics Program slicing: example 0 sum := 0 ; 0 sum := 0 ; 1 prod := 1 ; 2 i := 0 ; 2 i := 0 ; while 3 i < n do while 3 i < n do ( ( − → 4 i := i + 1 ; 4 i := i + 1 ; 5 sum := sum + i ; 5 sum := sum + i ; 6 prod := prod * i ) ; ) ; 7 7 Criterion: { (7 , sum ) } .

  5. 5 1 Transfinite semantics Semantic anomaly: example If the original program loops then we might have slices which assign to interesting variables more times than the original program: 0 while true do skip ; 1 x := 0 ; 1 x := 0 − → 2 2 Criterion: { (2 , x ) } .

  6. 6 2 Greatest Fixpoint Greatest Fixpoint

  7. 7 2 Greatest Fixpoint Goal: greatest fixpoint form We represent transfinite semantics in the form of greatest fixpoint of a monotone operator on complete lattices.

  8. 8 2 Greatest Fixpoint Subgoals • Express transfinite semantics in a standard framework. – Express both transfinite and standard semantics in a uniform algebraic way. • Provide an exhaustive definition of infinitely deep recursion seman- tics. • As a plan for future: build a Cousot’s hierarchy.

  9. 9 2 Greatest Fixpoint Epiphenomenons • Usual traces must be replaced by either fractional traces or trees. • Explicit determinism is lost.

  10. 10 3 Fractional semantics Fractional semantics

  11. 11 3 Fractional semantics Fractional traces In the case of fractional traces, computation steps are indexed by ratio- nal numbers from a fixed interval. • The interval of rationals within which an execution of a state- ment of the program falls does not depend on the initial state. • Traces grow into depth rather than into length.

  12. 12 3 Fractional semantics Example: swap The fractional trace of the execution of program z := x ; ( x := y ; y := z ) at initial state   x �→ 1   y �→ 2   z �→ 0 is 1 3 0 1 2 4         x �→ 1 x �→ 1 x �→ 2 x �→ 2         y �→ 2 y �→ 2 y �→ 2 y �→ 1         z �→ 0 z �→ 1 z �→ 1 z �→ 1

  13. 13 3 Fractional semantics Example: infinite loops If S 1 = S 2 = while true do skip S 3 = x := 1 then the domain of the execution trace of statement S 1 ; ( S 2 ; S 3 ) is depicted in the following figure: 1 3 0 1 4 2

  14. 14 4 Tree semantics Tree semantics

  15. 15 4 Tree semantics Trees In tree semantics, an execution is depicted in the form of tree. – The tree structure reflects the proof of that execution within a deduction system.

  16. 16 4 Tree semantics Example: swap Here is the tree of the execution of the swap program z := x ; ( x := y ; y := z ) at the same initial state as before: 8 x �→ 1 9 8 x �→ 2 9 8 x �→ 2 9 8 x �→ 2 9 < = < = < = < = y �→ 2 y �→ 2 y �→ 2 y �→ 1 ; → ; → z �→ 1 z �→ 1 z �→ 1 z �→ 1 : : ; : : ; x �→ 1 x �→ 1 x �→ 1 x �→ 2 8 9 8 9 8 9 8 9 < = < = < = < = y �→ 2 y �→ 2 y �→ 2 y �→ 1 ; → ; → z �→ 0 z �→ 1 z �→ 1 z �→ 1 : : ; : : ; x �→ 1 x �→ 2 8 9 8 9 < = < = y �→ 2 y �→ 1 ; → z �→ 0 z �→ 1 : : ;

  17. 17 4 Tree semantics Example generalized For any program of form S 1 ; ( S 2 ; S 3 ) , the tree grows as follows: . . . . . . . 2 → s 3 4 → s 1 s 1 s 3 . . 4 s 0 → s 1 2 → s 1 s 1 2 s 0 → s 1

  18. 18 5 The framework and results The framework and results

  19. 19 5 The framework and results Language • Statements: Stmt → Var := Expr | Stmt ; Stmt | if Expr then Stmt else Stmt | while Expr do Stmt | call Proc ( Var , . . . , Var ) • Modules: Module → proc Proc ( Var , . . . , Var ) is Stmt | Module ; Module

  20. 20 5 The framework and results Kinds of semantics We have considered the following kinds: Finite Standard Transfinite − → → − − → + ∝ Integral trace ω � � ∝ Fractional trace + � ω + � � ∝ � Tree ω

  21. 21 5 The framework and results Domains Val the set of values State = Var → Val Dom κ the set of individual semantic objects (traces, trees etc.) Env κ = Proc → (State → Val ∗ ) → ℘ (Dom κ ) The semantic domains ℘ (Dom κ ) are equipped with inclusion order, lifted componentwise to functions.

  22. 22 5 The framework and results Signatures • Statement level. F κ ∈ Env κ → ( Stmt → ℘ (Dom κ )) → ( Stmt → ℘ (Dom κ )) S κ ∈ Env κ → ( Stmt → ℘ (Dom κ )) S κ ( S )( e ) = gfp( F κ ( e ))( S ) • Module level. G κ ∈ ( Module → Env κ ) → ( Module → Env κ ) T κ ∈ Module → Env κ T k ( M ) = gfp( G k )( M )

  23. 23 5 The framework and results Correctness • The functions F κ ( e ) and G κ are monotone. – By Tarski’s theorem, the greatest fixpoint always exists and the definition is correct. • The functions F κ ( e ) and G κ are Scott-cocontinuous for κ = � ∝ , κ = ∝ . � ∗ By Kleene’s theorem, the greatest fixpoint of the transfinite se- mantics can be obtained by an iteration which is not transfinite!

  24. 24 5 The framework and results Example Let procedure q be defined by proc q() is ( call q() ; call q() ) The iteration of its semantics goes as follows: 0 1

  25. 25 6 Remarks Remarks

  26. 26 6 Remarks The choice of the kind of semantics Why do we need the fractional traces or trees? Why couldn’t we use transfinite sequences? • It is not possible to express fractal structures that arise in the case of infinitely deep recursion using transfinite sequences. • Even in the case of infinite iteration only, the greatest fixpoint of our function would contain too many traces. – Besides the desired traces, all traces having a desired trace as a prefix would be included. – But in fractional semantics, the interval [0; 1] is wholly dis- tributed between all statements occurring in the program and no space is left for garbage.

  27. 27 6 Remarks Connection between different kind of semantics Fractional traces reflect the deduction tree structure within a linear or- der. They have both trace and tree properties. This way, fractional semantics is an intermediate level between trace and tree semantics.

  28. 28 6 Remarks Non-determinism The price we pay in this approach is that explicit determinism is lost. – It is not clear whether the execution trace of a program at an initial state is unique. – It is not clear whether there exists an execution trace after all! ∗ What would the absence of execution traces mean? Under some natural restrictions, it can be proven that non-determinism can be introduced by infinitely deep recursion only.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend