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

transfinite semantics in the form of greatest fixpoint
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 2

1 Transfinite semantics

2

Transfinite semantics

slide-3
SLIDE 3

1 Transfinite semantics

3

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.

slide-4
SLIDE 4

1 Transfinite semantics

4

Program slicing: example

0sum := 0 ; 1prod := 1 ; 2i := 0 ;

while

3i < n do

(

4i := i + 1 ; 5sum := sum + i ; 6prod := prod * i

) ;

7

− →

0sum := 0 ; 2i := 0 ;

while

3i < n do

(

4i := i + 1 ; 5sum := sum + i ;

) ;

7

Criterion: {(7, sum)}.

slide-5
SLIDE 5

1 Transfinite semantics

5

Semantic anomaly: example

If the original program loops then we might have slices which assign to interesting variables more times than the original program:

0while true do skip ; 1x := 0 ; 2

− →

1x := 0 2

Criterion: {(2, x)}.

slide-6
SLIDE 6

2 Greatest Fixpoint

6

Greatest Fixpoint

slide-7
SLIDE 7

2 Greatest Fixpoint

7

Goal: greatest fixpoint form

We represent transfinite semantics in the form of greatest fixpoint of a monotone operator on complete lattices.

slide-8
SLIDE 8

2 Greatest Fixpoint

8

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.
slide-9
SLIDE 9

2 Greatest Fixpoint

9

Epiphenomenons

  • Usual traces must be replaced by either fractional traces or trees.
  • Explicit determinism is lost.
slide-10
SLIDE 10

3 Fractional semantics

10

Fractional semantics

slide-11
SLIDE 11

3 Fractional semantics

11

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.
slide-12
SLIDE 12

3 Fractional semantics

12

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

1 2 3 4

   x → 1 y → 2 z → 0       x → 1 y → 2 z → 1       x → 2 y → 2 z → 1       x → 2 y → 1 z → 1   

slide-13
SLIDE 13

3 Fractional semantics

13

Example: infinite loops

If S1 = S2 = while true do skip S3 = x := 1 then the domain of the execution trace of statement S1 ; (S2 ; S3) is depicted in the following figure: 1

1 2 3 4

slide-14
SLIDE 14

4 Tree semantics

14

Tree semantics

slide-15
SLIDE 15

4 Tree semantics

15

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.

slide-16
SLIDE 16

4 Tree semantics

16

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 y → 2 z → 0 9 = ; → 8 < : x → 1 y → 2 z → 1 9 = ; 8 < : x → 1 y → 2 z → 1 9 = ; → 8 < : x → 2 y → 2 z → 1 9 = ; 8 < : x → 2 y → 2 z → 1 9 = ; → 8 < : x → 2 y → 1 z → 1 9 = ; 8 < : x → 1 y → 2 z → 1 9 = ; → 8 < : x → 2 y → 1 z → 1 9 = ; 8 < : x → 1 y → 2 z → 0 9 = ; → 8 < : x → 2 y → 1 z → 1 9 = ;

slide-17
SLIDE 17

4 Tree semantics

17

Example generalized

For any program of form S1 ; (S2 ; S3), the tree grows as follows: . . . s0 → s 1

2

. . . s 1

2 → s 3 4

. . . s 3

4 → s1

s 1

2 → s1

s0 → s1

slide-18
SLIDE 18

5 The framework and results

18

The framework and results

slide-19
SLIDE 19

5 The framework and results

19

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

slide-20
SLIDE 20

5 The framework and results

20

Kinds of semantics

We have considered the following kinds: Finite Standard Transfinite Integral trace − → + − → ω − → ∝ Fractional trace

  • +
  • ω

Tree

  • +
  • ω
slide-21
SLIDE 21

5 The framework and results

21

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.

slide-22
SLIDE 22

5 The framework and results

22

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κ Tk(M) = gfp(G k)(M)

slide-23
SLIDE 23

5 The framework and results

23

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!

slide-24
SLIDE 24

5 The framework and results

24

Example

Let procedure q be defined by proc q() is (call q() ; call q()) The iteration of its semantics goes as follows: 1

slide-25
SLIDE 25

6 Remarks

25

Remarks

slide-26
SLIDE 26

6 Remarks

26

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.

slide-27
SLIDE 27

6 Remarks

27

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.

slide-28
SLIDE 28

6 Remarks

28

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.