ISRN

SICS-R

SE

SICS

Research

Report

ISSN

On

the

Computation

of

Fixpoints

in

Static

Program

Analysis

with

an

Application

to

Analysis

of

AKL

Erik

Sch?on

Report

ISRN

SICS-R

SE

ISSN

On

the

Computation

of

Fixpoints

in

Static

Program

Analysis

with

an

Application

to

Analysis

of

AKL

by

Erik

Sch?on

October

eriks@sics.se

Programming

Systems

Group

Swedish

Institute

of

Computer

Science

Box

KISTA

Sweden

Abstract

This

report

features

an

introduction

to

lattice

and

fixpoint

theory

and

a

survey

of

methods

and

recent

results

for

fixpoint

computations

in

static

program

analysis

As

the

number

of

equations

in

static

program

analysis

tend

to

be

very

large

it

is

extremely

important

to

avoid

unnecessary

computations

and

hence

to

find

an

optimal

order

in

which

to

compute

the

functions

It

is

also

important

to

have

an

efficient

method

for

detecting

stability

An

algorithm

satisfying

these

two

requirements

is

Bourdoncle

's

algorithm

-LSB-

-RSB-

for

finding

a

weak

topological

ordering

of

a

directed

graph

which

may

contain

cycles

This

algorithm

is

a

generalization

of

Tarjan

's

algorithm

for

finding

the

strongly

connected

components

of

a

directed

graph

This

report

presents

results

from

experiments

with

a

fixpoint

solver

in

the

analysis

framework

for

AKL

-LRB-

Agents

Kernel

Language

a

concurrent

constraint

language

developed

at

SICS

-RRB-

using

the

above

ideas

showing

that

a

considerable

speed-up

-LRB-

up

to

-RRB-

can

be

achieved

compared

to

that

of

a

fixpoint

solver

based

on

strongly

connected

components

This

is

explained

by

showing

how

weak

topological

orders

computed

by

Bourdoncle

's

algorithm

incorporate

many

intuitively

good

heuristics

The

report

also

introduces

partially

argument

independent

functions

a

class

of

functions

particularly

suited

to

the

repetitive

scheme

of

computations

that

arise

in

fixpoint

computations

A

function

of

this

type

needs

to

be

re-evaluated

only

with

respect

to

those

of

its

arguments

which

have

changed

since

its

latest

evaluation

This

work

was

partly

supported

by

the

ESPRIT

BRA

project

ParForce

Project

No.

i

Acknowledgments

There

are

some

people

without

whom

this

M.Sc

Thesis

would

not

have

existed

First

and

foremost

many

thanks

go

to

Dan

Sahlin

my

supervisor

at

SICS

who

inspiringly

guided

me

into

the

wondrous

world

of

program

analysis

providing

insights

into

everything

from

lattices

to

formulating

definitions

I

would

like

to

thank

all

the

members

of

the

Programming

Systems

Group

at

SICS

for

creating

a

stimulating

research

environment

to

work

in

The

following

deserves

special

mentioning

Thomas

Sj?oland

Mats

Carlsson

Joakim

Hirsch

Khaled

Shalaan

Kent

Boortz

Johan

Montelius

and

Per

Brand

I

am

also

very

grateful

to

Bj?orn

Lisper

of

the

Department

of

Teleinformatics

-LRB-

IT

-RRB-

at

the

Royal

Institute

of

Technology

-LRB-

KTH

-RRB-

who

accepted

my

M.Sc

degree

project

proposal

and

has

served

as

examiner

and

to

my

supervisor

at

IT

Karl-Filip

Fax?en

Last

but

by

no

means

least

I

would

like

to

thank

my

parents

Gerd

and

Erkki

who

sparked

my

interest

in

computers

and

programming

by

giving

me

an

exciting

present

way

back

in

the

early

eighties

a

BASIC

programming

course

on

the

computer

This

M.Sc

degree

project

was

conducted

in

and

funded

by

the

Programming

Systems

Group

at

the

Swedish

Institute

of

Computer

Science

-LRB-

SICS

-RRB-

SICS

is

a

non-profit

research

foundation

sponsored

by

the

Swedish

Board

for

Industrial

and

Technical

Development

-LRB-

NUTEK

-RRB-

CelsiusTech

Systems

AB

Ellemtel

Utvecklings

AB

Ericsson

FMV

-LRB-

Defense

Materials

Administration

-RRB-

IBM

Svenska

AB

SUN

Microsystems

and

Telia

AB

ii

Contents

Introduction

Background

Purpose

Contributions

Overview

Preliminaries

Logic

Sets

Relations

Functions

I

Foundations

of

Fixpoint

Computations

Lattice

Theory

and

Fixpoints

Ordered

Sets

Lattices

and

Complete

Lattices

Complete

Partial

Orders

Fixpoints

Summary

Graph

Theory

Basic

Concepts

Reducible

Graphs

Orders

on

Graphs

II

Fixpoint

Computations

in

Static

Program

Analysis

Program

Analysis

Basic

Concepts

Static

Program

Analysis

Abstract

Interpretation

Analysis

of

AKL

iii

iv

CONTENTS

A

Survey

of

Fixpoint

Computations

The

Problem

Basic

Concepts

A

Declarative

View

Iteration

Strategies

Static

Dependencies

Worklists

Topological

Sorting

Dynamic

Dependencies

The

Operational

Approach

The

Denotational

Approach

Optimizations

Based

on

Properties

of

Functions

Characterization

of

Frameworks

III

Towards

Efficient

Fixpoint

Computations

Practical

Iteration

Strategies

Strongly

Connected

Components

Weak

Topological

Orders

Basic

Concepts

Bourdoncle

's

Algorithm

Iteration

Strategies

Implementation

of

the

Algorithms

Experimental

Results

Presentation

of

Results

Analysis

of

Results

Related

Work

Properties

of

Functions

Argument-change

dependence

Partial

argument-independence

Application

Conclusion

Summary

Future

Work

A

AKL

A.

Overview

A.

Syntax

A.

Semantics

B

Benchmarks

List

of

Figures

Every

possible

ordered

set

generated

from

the

set

containing

a

b

c.

A

lattice

The

directed

graph

G

fhi

ji

j

i

jgi

Chains

in

a

directed

graph

An

irreducible

directed

graph

A

directed

graph

which

consists

of

a

single

strongly

connected

component

Abstract

interpretation

and

the

Galois

connection

Illustrating

the

youngest

vertex

first

heuristic

-LRB-

-RRB-

Illustrating

the

depth

first

heuristic

-LRB-

-RRB-

and

the

direct

dependency

heuristic

-LRB-

-RRB-

Illustrating

the

direct

dependency

heuristic

-LRB-

-RRB-

Tarjan

's

algorithm

for

finding

the

SCC

's

of

a

directed

graph

Bourdoncle

's

algorithm

for

finding

a

WTO

of

a

directed

graph

Relationships

SCC

WTO

Tarjan

's

algorithm

and

Bourdoncle

's

algorithm

Static

dependency

graph

Comparison

recursive

-LCB-

old

strategy

Comparison

iterative

-LCB-

old

strategy

Comparison

recursive

-LCB-

iterative

strategy

Comparison

execution

time

vs

number

of

equations

number

of

heads

and

maximum

depth

respectively

Comparison

number

of

applications

vs

number

of

equations

number

of

heads

and

maximum

depth

respectively

Number

of

applications

and

execution

time

vs

the

intrinsic

complexity

of

the

dependency

graph

v

vi

LIST

OF

FIGURES

List

of

Tables

Logical

connectives

and

quantifiers

Iteration

bounds

for

fixpoints

of

functionals

How

the

different

chaotic

iteration

strategies

compare

A.

Statement

Syntax

A.

Clausal

Syntax

B.

Program

descriptions

B.

Benchmarks

vii

viii

LIST

OF

TABLES

Chapter

Introduction

In

this

chapter

the

purpose

and

contribution

of

the

thesis

is

given

It

also

includes

some

background

information

and

an

overview

Background

The

declarative

programming

languages

eg

Lisp

and

Prolog

represent

a

paradigm

shift

in

that

they

make

the

programmer

focus

on

stating

the

problem

instead

of

specifying

how

to

solve

it

in

minute

detail

Ideally

this

leads

to

shorter

development

times

and

fewer

programming

errors

On

the

negative

side

the

increased

level

of

abstraction

also

leads

to

slower

less

memory

efficient

programs

Thus

to

summarize

the

problem

in

one

sentence

What

is

stated

declaratively

must

at

some

point

somehow

be

computed

efficiently

Static

program

analysis

is

a

way

to

bridge

the

gap

between

the

declarative

and

the

operational

sides

of

programming

and

hence

to

have

the

best

of

both

worlds

by

performing

static

program

analysis

global

information

on

properties

of

the

program

in

question

can

be

found

which

can

then

be

used

by

a

compiler

to

generate

faster

and

less

memory

consuming

code

or

by

a

debugger

to

help

the

programmer

find

faults

and

inconsistencies

Fixpoint

computations

lie

at

the

heart

of

almost

all

frameworks

for

static

program

analysis

In

order

to

find

the

properties

of

interest

an

equation

system

is

set

up

and

the

solution

is

usually

found

be

performing

an

iterative

computation

leading

to

the

least

fixpoint

of

the

system

AKL

-LRB-

Agents

Kernel

Language

-RRB-

is

a

declarative

multi-paradigm

programming

language

which

can

benefit

greatly

from

static

program

analysis

A

framework

for

static

program

analysis

of

AKL

the

goal

of

which

is

to

support

the

AKL

compiler

has

been

developed

A

major

bottle-neck

in

the

framework

is

the

execution

speed

and

one

way

of

overcoming

this

problem

is

to

optimize

the

fixpoint

solver

Purpose

The

purpose

of

this

thesis

is

to

investigate

the

methods

used

in

computing

the

fixpoints

that

arise

when

solving

the

equation

systems

generated

in

static

program

analysis

A

more

specific

goal

is

to

enhance

the

fixpoint

solver

in

the

static

program

analysis

framework

for

AKL

Contributions

The

main

contributions

are

the

following

ffl

A

survey

of

methods

used

in

fixpoint

computations

in

static

program

analysis

ffl

The

first

major

experimental

evaluation

of

iteration

strategies

for

fixpoint

computations

based

on

weak

topological

orders

found

by

Bourdoncle

's

algorithm

showing

behaviour

which

contradicts

some

of

Bourdoncle

's

claims

ffl

An

average

speed-up

of

and

in

some

cases

up

to

in

the

fixpoint

computation

part

of

the

analysis

framework

for

AKL

when

weak

topological

orders

are

used

ffl

The

introduction

of

the

concept

of

partially

argument-independent

functions

which

decreases

the

cost

of

function

applications

Overview

The

intention

is

for

the

thesis

to

be

self-contained

hence

Chapter

defines

the

basic

concepts

and

notation

to

be

used

whereas

Part

I

deals

with

the

theoretical

foundations

of

fixpoint

computations

Chapter

gives

a

brief

introduction

to

lattice

theory

including

fixpoints

and

the

following

chapters

depend

rather

heavily

on

the

concepts

and

results

presented

here

Chapter

presents

some

results

from

graph

theory

relevant

in

this

context

Readers

familiar

with

discrete

mathematics

can

skip

these

chapters

Part

II

relates

static

program

analysis

to

fixpoint

computations

Chapter

shows

how

static

program

analysis

gives

rise

to

an

equation

system

which

can

be

solved

by

means

of

a

fixpoint

procedure

and

how

the

AKL

analysis

framework

is

set

up

In

Chapter

the

problem

of

fixpoint

computation

in

static

program

analysis

is

defined

and

a

survey

of

methods

for

solving

it

is

presented

The

last

part

is

dedicated

to

fixpoint

computations

in

practice

Two

strategies

for

computing

fixpoints

strongly

connected

components

and

weak

topological

orders

are

presented

and

compared

in

Chapter

whereas

Chapter

singles

out

the

class

of

functions

which

do

not

need

the

values

of

all

their

arguments

when

evaluated

Finally

the

two

appendices

present

AKL

-LRB-

Agents

Kernel

Language

-RRB-

and

the

full

benchmark

results

respectively

Chapter

Preliminaries

This

chapter

defines

the

meaning

of

the

basic

symbols

and

modes

of

expression

used

throughout

the

text

and

is

thus

to

be

used

as

a

reference

Logic

The

logical

symbols

and

their

meanings

are

given

in

Table

An

arbitrary

sequence

of

variables

is

denoted

x

A

definition

of

a

symbol

is

written

A

B

where

A

is

the

definiendum

-LRB-

what

is

to

be

defined

-RRB-

and

B

is

the

definiens

-LRB-

the

actual

definition

-RRB-

An

assignment

of

the

value

a

to

the

variable

x

is

denoted

thus

x

a

A

-RRB-

B

expresses

the

fact

that

statement

B

follows

from

statement

A

The

expression

A

B

or

sometimes

A

iff

B

is

defined

by

A

B

A

-RRB-

B

B

-RRB-

A.

Sets

A

set

is

a

collection

of

objects

without

repetition

An

member

of

a

set

is

one

of

the

objects

The

finite

set

A

consisting

of

members

an

is

denoted

ang

and

that

is

a

member

of

A

is

denoted

A

A

set

former

is

a

specification

of

the

type

fx

j

P

-LRB-

x

-RRB-

g

or

fx

A

j

P

-LRB-

x

-RRB-

g

where

the

first

is

read

the

set

of

objects

x

such

that

P

-LRB-

x

-RRB-

is

true

and

the

second

is

read

the

set

of

objects

x

in

the

set

A

such

that

P

-LRB-

x

-RRB-

is

true

Symbol

Description

negation

conjunction

disjunction

implication

equivalence

universal

quantification

for

all

existential

quantification

at

least

one

existential

quantification

exactly

one

Table

Logical

connectives

and

quantifiers

The

symbol

denotes

the

set

fx

j

x

xg

i.e.

the

empty

set

A

is

a

subset

of

B

denoted

A

B

if

x

A

x

B

The

power

set

of

B

is

defined

by

-RCB-

-LRB-

B

-RRB-

fA

j

A

Bg

i.e.

the

set

of

all

subsets

of

B

The

union

and

intersection

of

A

and

B

is

defined

by

A

-LSB-

B

fx

j

x

A

x

Bg

and

A

B

fx

j

x

A

x

Bg

respectively

Relations

An

ordered

n-tuple

of

objects

an

is

defined

by

ani

f

fanggg

A

pair

is

an

ordered

The

cartesian

product

of

A

and

B

is

defined

by

A

B

fha

bi

j

a

A

b

Bg

A

relation

from

A

to

B

is

a

set

of

pairs

R

such

that

R

A

B

A

relation

R

is

on

the

set

A

if

R

A

A

The

fact

ha

bi

R

is

written

aRb

A

relation

R

A

A

is

reflexive

if

aRa

A

transitive

if

aRb

bRc

aRc

b

c

A

symmetric

if

aRb

bRa

b

A

and

anti-symmetric

if

aRb

bRa

a

b

b

A.

Let

be

a

relation

from

A

to

B

and

let

be

a

relation

from

B

to

C

the

composition

of

and

is

defined

by

ffi

fha

ci

j

a

A

c

C

B

The

transitive

closure

of

a

relation

R

is

defined

by

R

R

-LSB-

-LSB-

-LSB-

where

Rn

RnffiR

and

R

The

reflexive

and

transitive

closure

of

a

relation

R

on

the

set

A

is

defined

by

R

-LSB-

fha

ai

j

a

Ag

A

relation

R

on

a

set

A

is

an

equivalence

relation

if

R

is

reflexive

symmetric

and

transitive

For

any

a

A

the

equivalence

class

of

a

is

defined

by

-LSB-

a

-RSB-

A

j

where

R

is

an

equivalence

relation

An

equivalence

relation

R

on

a

set

A

partitions

A

into

a

number

of

disjoint

non-empty

equivalence

classes

Functions

A

relation

from

a

set

X

to

a

set

Y

is

a

function

denoted

f

X

Y

if

X

y

Y

xfy

The

set

X

is

the

domain

and

Y

is

the

range

of

the

function

f

The

relation

xfy

where

f

is

a

function

is

written

y

f

-LRB-

x

-RRB-

Functions

are

sometimes

called

maps

or

mappings

Definition

-LRB-

abstraction

-RRB-

If

E

is

an

expression

taking

values

in

a

domain

D

then

xn

E

denotes

the

function

f

D

such

that

f

-LRB-

xn

-RRB-

for

any

xi

may

be

obtained

by

evaluating

E

using

the

values

for

xn

The

extension

by

of

a

function

f

X

Y

is

defined

by

f

-LSB-

-RSB-

x

if

x

then

else

f

-LRB-

x

-RRB-

The

restriction

of

the

function

f

X

Y

to

values

in

a

certain

domain

is

defined

by

f

f

-LRB-

-RRB-

i

j

ae

Xg

The

composition

of

two

functions

f

X

Y

and

g

Y

Z

is

the

function

from

X

to

Z

defined

by

-LRB-

f

ffi

g

-RRB-

-LRB-

x

-RRB-

g

-LRB-

f

-LRB-

x

-RRB-

-RRB-

x

X

g

-LRB-

f

-LRB-

x

-RRB-

-RRB-

Z

A

relation

from

a

set

X

to

a

set

Y

is

a

functional

denoted

f

X

Y

if

X

and

Y

are

sets

of

functions

A

function

f

X

X

Y

is

commutative

if

f

-LRB-

x

-RRB-

f

-LRB-

x

-RRB-

X

associative

if

f

-LRB-

x

f

-LRB-

-RRB-

-RRB-

f

-LRB-

f

-LRB-

x

-RRB-

-RRB-

X

A

function

f

X

X

is

idempotent

if

f

-LRB-

f

-LRB-

x

-RRB-

-RRB-

f

-LRB-

x

-RRB-

X.

Definition

-LRB-

order

of

magnitude

-RRB-

Let

f

g

be

functions

of

xn

f

is

of

the

same

order

of

magnitude

as

g

denoted

f

-LRB-

xn

-RRB-

O

-LRB-

g

-LRB-

xn

-RRB-

-RRB-

if

jf

-LRB-

xn

-RRB-

j

-LRB-

xn

-RRB-

j

xn

A

function

f

-LRB-

x

-RRB-

is

linear

if

f

-LRB-

x

-RRB-

O

-LRB-

x

-RRB-

quadratic

if

f

-LRB-

x

-RRB-

O

-LRB-

-RRB-

and

cubic

if

f

-LRB-

x

-RRB-

O

-LRB-

-RRB-

Part

I

Foundations

of

Fixpoint

Computations

Chapter

Lattice

Theory

and

Fixpoints

This

chapter

gives

a

very

brief

introduction

to

the

theory

of

ordered

sets

lattices

and

fixpoints

The

material

is

well-known

and

the

presentation

relies

heavily

on

Chapters

-LCB-

of

-LSB-

-RSB-

and

to

some

extent

on

Chapter

of

-LSB-

-RSB-

Further

information

can

be

found

in

-LSB-

-RSB-

which

is

a

modern

textbook

or

in

the

more

advanced

treatment

-LSB-

-RSB-

Ordered

Sets

In

lattice

theory

the

first

objective

is

to

impose

a

certain

structure

on

sets

This

is

done

by

means

of

a

binary

relation

relating

elements

to

each

other

Definition

-LRB-

order

ordered

set

-RRB-

Let

P

be

a

set

A

relation

v

is

an

order

on

P

if

v

P

P

is

reflexive

anti-symmetric

and

transitive

A

set

P

is

an

ordered

set

ordered

by

v

denoted

hP

vi

if

v

is

an

order

on

P

An

order

and

an

ordered

set

is

sometimes

called

a

partial

order

and

a

partially

ordered

set

or

poset

respectively

Example

-LRB-

Order

and

ordered

set

-RRB-

Let

X

be

a

set

and

form

the

powerset

-RCB-

-LRB-

X

-RRB-

then

the

set

inclusion-operator

is

easily

seen

to

be

an

order

on

-RCB-

-LRB-

X

-RRB-

and

the

ordered

set

is

thus

h

-RCB-

-LRB-

X

-RRB-

i.

Two

elements

x

y

P

are

incomparable

symbolically

xky

if

neither

x

v

y

nor

y

v

x.

Incomparable

elements

are

sometimes

said

to

be

unrelated

Let

hP

vi

be

an

ordered

set

and

let

Q

be

a

subset

of

P

Then

Q

can

inherit

the

order

relation

v

from

P

given

x

y

Q

x

v

y

in

Q

iff

x

v

y

in

P

A

new

ordered

set

hQ

vi

is

thus

induced

from

P

The

following

definition

gives

two

quite

special

kinds

of

ordered

sets

the

first

in

which

any

two

elements

are

comparable

and

the

second

in

which

no

two

elements

are

comparable

Definition

-LRB-

chain

anti-chain

-RRB-

The

ordered

set

hP

vi

is

a

chain

if

y

P

either

x

v

y

or

y

v

x

The

ordered

set

hP

vi

is

an

anti-chain

if

y

P

x

v

y

iff

x

y.

Two

alternative

names

for

a

chain

are

linearly

ordered

set

and

totally

ordered

set

e

e

e

e

e

e

e

e

e

e

e

e

e

e

e

-LRB-

i

-RRB-

-LRB-

ii

-RRB-

-LRB-

iii

-RRB-

-LRB-

iv

-RRB-

-LRB-

v

-RRB-

a

b

c

c

b

a

a

b

c

a

b

c

a

b

c

Figure

Every

possible

ordered

set

generated

from

the

set

containing

a

b

c.

Example

-LRB-

Chain

-RRB-

The

set

of

natural

numbers

g

endowed

with

the

order

in

which

becomes

the

chain

i

The

order

relation

v

on

P

gives

rise

to

the

more

strict

order

relation

x

y

in

P

iff

x

v

y

and

x

y

The

cartesian

product

Pn

Pn

of

the

ordered

sets

Pn

can

be

made

into

an

ordered

set

by

imposing

the

coordinatewise

ordering

defined

by

xni

v

yni

-LRB-

-RRB-

ng

xi

v

yi

in

Pi

The

notion

of

order

is

generalized

to

sets

of

maps

in

the

following

way

An

order

on

the

set

of

maps

Y

X

fOE

j

OE

X

Y

g

is

given

by

putting

OE

v

in

Y

X

iff

OE

-LRB-

x

-RRB-

v

-LRB-

x

-RRB-

in

Y

X

When

X

is

a

set

of

n

elements

then

Y

X

collapses

into

Y

n.

Definition

-LRB-

covering

-RRB-

Let

hP

vi

be

an

ordered

set

and

let

x

y

P

y

covers

x

if

x

y

and

there

is

no

a

P

such

that

x

a

y

It

is

often

useful

to

visualize

ordered

sets

as

-LRB-

Hasse

-RRB-

diagrams

The

diagram

of

an

ordered

set

hP

vi

represents

the

elements

by

small

circles

Two

elements

x

y

P

are

connected

by

a

straight

line

if

one

covers

the

other

if

x

covers

y

then

the

circle

representing

x

is

higher

than

the

circle

representing

y

Example

-LRB-

Diagrams

-RRB-

In

Figure

diagrams

every

possible

ordered

set

generated

from

fa

b

cg

-LRB-

modulo

renaming

-RRB-

are

given

Diagram

-LRB-

i

-RRB-

shows

the

chain

a

v

b

v

c

in

-LRB-

ii

-RRB-

the

order

a

v

c

b

v

c

akb

is

shown

-LRB-

iii

-RRB-

represents

a

v

b

a

v

c

bkc

-LRB-

iv

-RRB-

shows

how

a

v

b

while

cka

ckb

and

the

anti-chain

akb

akc

bkc

is

depicted

in

diagram

-LRB-

v

-RRB-

Some

elements

in

an

ordered

set

are

more

important

than

others

and

therefore

require

special

consideration

Definition

-LRB-

maximal

element

minimal

element

-RRB-

Let

hP

vi

be

an

ordered

set

and

let

S

P

Then

x

S

is

a

maximal

element

of

S

if

x

v

y

S

implies

x

y

x

S

is

a

minimal

element

of

S

if

x

w

y

S

implies

x

y

Definition

-LRB-

greatest

element

least

element

-RRB-

Let

hP

vi

be

an

ordered

set

and

let

S

P

Then

x

S

is

the

greatest

element

of

S

denoted

x

maxS

if

x

w

y

S.

x

S

is

the

least

element

of

S

denoted

x

min

S

if

x

v

y

S

Note

that

an

ordered

set

may

have

several

maximal

-LRB-

minimal

-RRB-

elements

without

having

a

greatest

-LRB-

least

-RRB-

element

that

S

has

a

greatest

-LRB-

least

-RRB-

element

iff

it

has

precisely

one

maximal

-LRB-

minimal

-RRB-

element

and

that

this

element

is

unique

-LRB-

if

it

exists

-RRB-

e

e

e

e

e

e

e

e

l

l

l

l

l

l

l

l

l

l

l

l

l

l

l

l

fa

bg

fb

cgf

a

cg

fa

b

cg

fag

fbg

fcg

Figure

A

lattice

Definition

-LRB-

top

bottom

-RRB-

Let

hP

vi

be

an

ordered

set

The

greatest

element

of

P

if

it

exists

is

called

the

top

element

of

P

and

is

denoted

The

least

element

of

P

if

such

an

element

exists

is

called

the

bottom

element

and

it

is

denoted

Example

-LRB-

Top

and

bottom

-RRB-

In

h

-RCB-

-LRB-

X

-RRB-

i

X

and

which

is

shown

in

Figure

with

X

fa

b

cg

Lattices

and

Complete

Lattices

Many

important

properties

an

ordered

set

hP

vi

can

be

expressed

in

terms

of

the

existence

of

certain

upper

or

lower

bounds

of

subsets

of

P

Lattices

and

complete

lattices

are

two

classes

of

ordered

sets

characterized

in

this

way

Definition

-LRB-

upper

bound

lower

bound

-RRB-

Let

hP

vi

be

an

ordered

set

and

let

S

P

An

element

x

P

is

an

upper

bound

of

S

if

s

v

x

S

An

element

x

P

is

a

lower

bound

of

S

if

s

w

x

S.

Su

fx

P

j

S

s

v

xg

is

the

set

of

all

upper

bound

of

S

and

Sl

fx

P

j

S

s

w

xg

is

the

set

of

all

lower

bounds

of

S

The

difference

between

maximal

-LRB-

minimal

-RRB-

elements

and

upper

-LRB-

lower

-RRB-

bounds

of

a

set

S

P

is

that

the

former

elements

are

members

of

S

while

the

latter

elements

are

members

of

P

and

hence

not

necessarily

members

of

S.

Definition

-LRB-

least

upper

bound

greatest

lower

bound

-RRB-

Let

hP

vi

be

an

ordered

set

and

let

S

P

An

element

x

P

is

the

least

upper

bound

of

S

denoted

lubS

if

x

is

an

upper

bound

of

S

and

x

v

y

for

all

upper

bounds

y

of

S

An

element

x

P

is

the

greatest

lower

bound

of

S

denoted

glb

S

if

x

is

an

lower

bound

of

S

and

x

w

y

for

all

lower

bounds

y

of

S

The

least

upper

bound

of

S

is

also

called

the

supremum

of

S

and

is

denoted

by

supS

the

greatest

lower

bound

of

S

is

sometimes

called

the

infimum

of

S

denoted

inf

S

As

a

notational

convention

we

define

x

t

y

lubfx

yg

x

u

y

glbfx

yg

G

S

lubS

S

glbS

when

the

objects

referred

to

by

the

right-hand-side

of

the

definitions

exist

Example

-LRB-

Least

upper

bound

and

greatest

lower

bound

-RRB-

In

h

-RCB-

-LRB-

X

-RRB-

i

the

least

upper

bound

of

a

collection

of

subsets

of

X

is

their

union

-LRB-

-LSB-

-RRB-

and

the

greatest

lower

bound

is

their

intersection

-LRB-

-RRB-

See

Figure

Definition

-LRB-

lattice

complete

lattice

-RRB-

Let

hP

vi

be

an

ordered

set

where

P

is

non-empty

hP

vi

is

a

lattice

if

x

t

y

and

x

u

y

exist

for

all

x

y

P

hP

vi

is

a

complete

lattice

if

FS

and

S

exist

for

all

S

P

hP

vi

is

a

lattice

if

x

t

y

and

x

u

y

exist

in

P

for

all

incomparable

pairs

x

y

P

It

is

also

a

fact

that

every

finite

lattice

is

complete

as

both

the

least

upper

bound

and

the

greatest

lower

bound

then

always

can

be

found

for

every

subset

The

difference

between

a

lattice

and

a

complete

lattice

is

that

a

lattice

may

have

certain

gaps

in

it

Example

-LRB-

Incomplete

lattices

-RRB-

Every

chain

is

a

lattice

with

x

t

y

maxfx

yg

and

x

u

y

minfx

yg

Thus

i

is

a

lattice

It

is

not

complete

however

as

it

lacks

a

top

element

Example

-LRB-

Complete

lattices

-RRB-

h

-RCB-

-LRB-

X

-RRB-

vi

is

a

complete

lattice

as

the

least

upper

bound

-LRB-

-LSB-

-RRB-

and

the

greatest

lower

bound

-LRB-

-RRB-

of

every

subset

of

-RCB-

-LRB-

X

-RRB-

always

exist

See

Figure

The

following

theorem

shows

how

to

find

the

complete

lattices

among

the

ordered

sets

Theorem

-LRB-

Characterization

of

complete

lattices

-RRB-

Let

hP

vi

be

an

ordered

set

where

P

is

non-empty

Then

the

following

statements

are

equivalent

-LRB-

i

-RRB-

P

is

a

complete

lattice

-LRB-

ii

-RRB-

S

exists

in

P

for

every

subset

S

of

P

-LRB-

iii

-RRB-

P

has

a

top

element

and

S

exists

in

P

for

every

non-empty

subset

S

of

P

Proof

-LSB-

-RSB-

Definition

-LRB-

join-irreducible

-RRB-

Let

hL

vi

be

a

complete

lattice

An

element

x

L

is

join-irreducible

if

x

and

x

a

t

b

implies

x

a

or

x

b

for

all

a

b

L

The

set

of

join-irreducible

elements

of

L

is

denoted

J

-LRB-

L

-RRB-

Example

-LRB-

Join-irreducible

elements

-RRB-

In

a

chain

every

element

except

is

joinirreducible

Definition

-LRB-

distributive

-RRB-

A

complete

lattice

hL

vi

is

distributive

if

x

u

-LRB-

y

t

z

-RRB-

-LRB-

x

u

y

-RRB-

t

-LRB-

x

u

z

-RRB-

for

all

x

y

z

L.

Example

-LRB-

Distributive

lattices

-RRB-

h

-RCB-

-LRB-

X

-RRB-

vi

and

ordinary

chains

are

examples

of

distributive

lattices

The

concepts

below

are

defined

in

order

to

capture

the

notions

of

size

and

finiteness

in

ordered

sets

and

lattices

Definition

-LRB-

length

finite

length

noetherian

-RRB-

Let

hP

vi

be

an

ordered

set

-LRB-

i

-RRB-

If

C

cng

is

a

finite

chain

with

jCj

n

then

the

length

of

C

is

n.

-LRB-

ii

-RRB-

P

has

length

n

denoted

-LRB-

P

-RRB-

n

if

the

length

of

the

longest

chain

in

P

is

n.

-LRB-

iii

-RRB-

P

has

height

h

if

the

length

of

the

longest

chain

starting

from

is

h.

-LRB-

iv

-RRB-

hP

vi

is

of

finite

length

if

it

has

length

n

for

some

n

-LRB-

v

-RRB-

P

is

noetherian

if

every

chain

in

P

is

finite

Note

that

there

are

lattices

which

are

noetherian

without

being

of

finite

length

Definition

-LRB-

ascending

chain

condition

-LRB-

ACC

-RRB-

-RRB-

Let

hP

vi

be

an

ordered

set

P

satisfies

the

ascending

chain

condition

-LRB-

ACC

-RRB-

if

given

any

sequence

v

v

v

xn

v

of

elements

of

P

there

exists

k

N

such

that

xk

xk

Definition

-LRB-

descending

chain

condition

-LRB-

DCC

-RRB-

-RRB-

Let

hP

vi

be

an

ordered

set

P

satisfies

the

descending

chain

condition

-LRB-

DCC

-RRB-

if

any

sequence

w

w

w

xn

w

of

elements

of

P

is

such

that

there

exists

k

N

such

that

xk

xk

From

the

above

definitions

it

is

clear

that

a

lattice

of

finite

length

is

noetherian

and

hence

satisfies

both

-LRB-

ACC

-RRB-

and

-LRB-

DCC

-RRB-

The

theorems

below

characterize

noetherian

ordered

sets

Theorem

-LRB-

Infinite

chain

condition

-RRB-

An

ordered

set

is

noetherian

iff

it

satisfies

both

-LRB-

ACC

-RRB-

and

-LRB-

DCC

-RRB-

Proof

-LSB-

-RSB-

Theorem

-LRB-

Completeness

of

noetherian

ordered

sets

-RRB-

A

lattice

which

is

noetherian

is

complete

Proof

-LSB-

-RSB-

Complete

Partial

Orders

It

is

sometimes

important

to

realize

an

element

in

an

ordered

set

as

the

join

of

a

set

of

approximating

elements

below

it

The

concept

of

complete

partial

order

is

defined

in

order

to

guarantee

that

such

an

element

can

be

consistently

found

Definition

-LRB-

directed

consistent

-RRB-

Let

S

be

a

non-empty

subset

of

an

ordered

set

hP

vi

S

is

directed

if

for

every

finite

subset

F

of

S

there

exists

z

S

such

that

z

Fu

S

is

consistent

if

for

every

finite

subset

F

of

S

there

exists

z

P

such

that

z

Fu

Non-consistency

arises

only

in

ordered

sets

without

the

top

element

A

directed

set

is

of

course

consistent

Example

-LRB-

Directed

sets

-RRB-

In

an

ordered

set

every

non-empty

chain

is

directed

and

every

subset

with

a

greatest

element

is

directed

The

simplest

example

of

a

directed

set

is

a

chain

Definition

-LRB-

complete

partially

ordered

set

-LRB-

CPO

-RRB-

pre-CPO

-RRB-

An

ordered

set

hP

vi

is

a

complete

partially

ordered

set

-LRB-

CPO

-RRB-

if

-LRB-

i

-RRB-

P

has

a

bottom

element

and

-LRB-

ii

-RRB-

FD

exists

for

every

directed

subset

D

of

P

hP

vi

is

a

pre-CPO

if

it

only

satisfies

requirement

-LRB-

ii

-RRB-

Example

-LRB-

CPO

s

-RRB-

Every

complete

lattice

is

a

CPO

Fixpoints

In

order

to

guarantee

the

existence

of

fixpoints

certain

properties

of

maps

between

ordered

sets

are

needed

Definition

-LRB-

monotone

continuous

strict

additive

completely

additive

-RRB-

Let

hP

vP

i

and

hQ

vQi

be

ordered

sets

A

map

OE

P

Q

is

monotone

if

x

vP

y

implies

OE

-LRB-

x

-RRB-

vQ

OE

-LRB-

y

-RRB-

The

map

is

continuous

if

for

every

directed

set

D

in

P

OE

-LRB-

F

D

-RRB-

F

OE

-LRB-

D

-RRB-

where

F

OE

-LRB-

D

-RRB-

FfOE

-LRB-

x

-RRB-

j

x

Dg

The

map

is

strict

if

OE

-LRB-

-RRB-

The

map

is

additive

if

OE

-LRB-

x

t

y

-RRB-

OE

-LRB-

x

-RRB-

t

OE

-LRB-

y

-RRB-

for

all

x

y

P

The

map

is

completely

additive

if

OE

-LRB-

F

S

-RRB-

F

fOE

-LRB-

x

-RRB-

j

x

Sg

where

S

P

A

monotone

map

is

sometimes

called

order-preserving

or

isotone

For

complete

and

finite

lattices

a

strict

additive

map

is

also

completely

additive

As

monotonicity

of

maps

is

a

desirable

property

a

definition

of

a

monotonic

version

of

an

arbitrary

map

is

sometimes

needed

Definition

-LRB-

monotonic

closure

-RRB-

Let

hP

vP

i

be

an

ordered

set

and

let

OE

P

Q

be

a

map

The

monotonic

closure

of

OE

is

defined

by

OE

mon

j

OE

v

and

is

monotonic

g

The

intuition

of

monotone

maps

is

that

where

the

order

represents

e.g.

is

less

defined

than

or

is

a

worse

approximation

than

a

monotone

map

OE

is

one

which

is

such

that

the

better

the

input

x

the

better

the

output

OE

-LRB-

x

-RRB-

The

n-fold

composite

n

of

a

map

P

P

is

defined

as

follows

n

is

the

identity

map

if

n

and

n

ffi

n

for

n

If

is

monotone

so

is

n.

Theorem

Every

continuous

map

is

monotone

Proof

-LSB-

-RSB-

Let

OE

P

Q

be

a

continuous

map

which

implies

that

for

every

directed

set

D

in

P

G

OE

-LRB-

D

-RRB-

vQ

OE

-LRB-

G

D

-RRB-

Now

choose

x

y

P

such

that

x

vP

y

Then

D

fx

yg

is

directed

with

FD

y

by

definition

Hence

OE

-LRB-

x

-RRB-

vQ

OE

-LRB-

x

-RRB-

t

OE

-LRB-

y

-RRB-

G

OE

-LRB-

D

-RRB-

vQ

OE

-LRB-

G

D

-RRB-

OE

-LRB-

y

-RRB-

whence

OE

P

Q

is

monotone

Note

however

that

there

are

monotone

maps

which

are

not

continuous

Definition

-LRB-

fixpoint

equation

fixpoint

least

fixpoint

-RRB-

Let

hP

vi

be

an

ordered

set

and

let

P

P

be

a

map

A

fixpoint

equation

is

an

equation

of

the

form

-LRB-

x

-RRB-

x

in

which

x

P

is

a

fixpoint

of

The

set

of

all

fixpoints

of

is

defined

by

fix

-LRB-

-RRB-

fx

P

j

-LRB-

x

-RRB-

xg

The

least

fixpoint

of

is

defined

by

-LRB-

-RRB-

min

fix

-LRB-

-RRB-

when

min

fix

-LRB-

-RRB-

exists

Theorem

-LRB-

CPO

Fixpoint

I

-RRB-

Let

hP

vi

be

a

CPO

let

P

P

be

a

monotone

map

and

define

F

n

n

-LRB-

-RRB-

-LRB-

i

-RRB-

If

fix

-LRB-

-RRB-

then

-LRB-

-RRB-

-LRB-

ii

-RRB-

If

is

continuous

then

-LRB-

-RRB-

Proof

-LSB-

-RSB-

-LRB-

i

-RRB-

Certainly

v

-LRB-

-RRB-

whence

n

-LRB-

-RRB-

v

n

-LRB-

-RRB-

by

monotonicity

of

n.

Hence

there

is

a

chain

v

-LRB-

-RRB-

v

n

-LRB-

-RRB-

v

n

-LRB-

-RRB-

v

in

P

Since

P

is

a

CPO

F

n

n

-LRB-

-RRB-

exists

Let

fix

-LRB-

-RRB-

By

induction

n

-LRB-

-RRB-

for

all

n

As

v

n

-LRB-

-RRB-

v

n

-LRB-

-RRB-

by

monotonicity

of

n

The

definition

of

forces

v

which

means

that

if

fix

-LRB-

-RRB-

then

-LRB-

-RRB-

-LRB-

ii

-RRB-

It

suffices

to

show

that

fix

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

G

n

n

-LRB-

-RRB-

-RRB-

G

n

-LRB-

n

-LRB-

-RRB-

-RRB-

since

is

continuous

Then

G

n

-LRB-

n

-LRB-

-RRB-

-RRB-

G

n

n

-LRB-

-RRB-

G

n

n

-LRB-

-RRB-

since

v

n

-LRB-

-RRB-

for

all

n

The

following

theorems

are

important

for

the

clues

they

provide

to

a

systematic

search

for

fixpoints

Theorem

-LRB-

Knaster-Tarski

-RRB-

If

hL

vi

is

a

complete

lattice

and

L

L

is

a

monotone

map

then

F

fx

L

j

x

v

-LRB-

x

-RRB-

g

fix

-LRB-

-RRB-

Proof

-LSB-

-RSB-

Put

G

fx

L

j

x

v

-LRB-

x

-RRB-

g

and

g

FG

By

definition

x

v

g

G

so

x

v

-LRB-

x

-RRB-

v

-LRB-

g

-RRB-

by

monotonicity

of

Thus

-LRB-

g

-RRB-

Gu

whence

g

v

-LRB-

g

-RRB-

Since

is

monotone

-LRB-

g

-RRB-

v

-LRB-

-LRB-

g

-RRB-

-RRB-

hence

-LRB-

g

-RRB-

G

so

-LRB-

g

-RRB-

v

g.

This

together

with

the

fact

that

g

v

-LRB-

g

-RRB-

says

that

g

-LRB-

g

-RRB-

so

g

fix

-LRB-

-RRB-

Theorem

-LRB-

Tarski

-RRB-

If

hL

vi

is

a

complete

lattice

and

L

L

is

a

monotone

map

then

has

a

least

fixpoint

-LRB-

-RRB-

fx

j

-LRB-

x

-RRB-

xg

fx

j

-LRB-

x

-RRB-

v

xg

Proof

-LSB-

-RSB-

Let

G

fx

L

j

-LRB-

x

-RRB-

v

xg

g

G

and

similarly

let

fix

-LRB-

-RRB-

fx

L

j

-LRB-

x

-RRB-

xg

and

As

hL

vi

is

a

complete

lattice

both

g

and

exists

Three

steps

are

necessary

in

order

to

show

that

g

is

the

least

fixpoint

of

g

G

g

-LRB-

g

-RRB-

and

g

Now

g

v

x

G

by

definition

of

greatest

lower

bound

hence

by

monotonicity

of

-LRB-

g

-RRB-

v

-LRB-

x

-RRB-

G.

Thus

-LRB-

g

-RRB-

v

x

G

so

by

definition

of

glb

-LRB-

g

-RRB-

v

g

which

means

that

g

G.

To

show

that

g

fix

-LRB-

-RRB-

it

remains

to

be

shown

that

g

v

-LRB-

g

-RRB-

since

it

is

known

from

above

that

-LRB-

g

-RRB-

v

g.

From

-LRB-

g

-RRB-

v

g

it

follows

by

monotonicity

of

that

-LRB-

-LRB-

g

-RRB-

-RRB-

v

-LRB-

g

-RRB-

which

implies

that

-LRB-

g

-RRB-

G.

Hence

g

v

-LRB-

g

-RRB-

so

that

g

fix

-LRB-

-RRB-

Since

g

fix

-LRB-

-RRB-

it

is

known

that

v

g.

On

the

other

hand

G

so

g

v

Thus

g

Theorem

-LRB-

CPO

Fixpoint

II

-RRB-

If

hP

vi

is

a

CPO

and

P

P

is

a

map

such

that

x

v

-LRB-

x

-RRB-

for

all

x

P

then

has

a

fixpoint

Proof

-LSB-

-RSB-

-LRB-

hard

-RRB-

Theorem

-LRB-

CPO

Fixpoint

III

-RRB-

If

hP

vi

is

a

CPO

and

P

P

is

a

monotone

map

then

has

a

least

fixpoint

Proof

-LSB-

-RSB-

Summary

To

summarize

the

existence

of

a

least

fixpoint

is

guaranteed

when

the

ordered

set

is

a

CPO

and

the

map

is

continuous

or

monotone

or

when

the

ordered

set

is

a

complete

lattice

and

the

map

is

monotone

Noetherian

ordered

sets

and

finite

ordered

sets

are

complete

lattices

and

complete

lattices

are

CPO

s.

Chapter

Graph

Theory

Graph

theory

is

very

important

in

fixpoint

computations

as

relations

between

equations

can

be

described

by

a

certain

kind

of

directed

graphs

called

dependency

graphs

-LRB-

Section

-RRB-

Hence

in

this

chapter

basic

material

from

graph

theory

is

presented

A

modern

textbook

where

a

good

treatment

of

graph

theory

can

be

found

is

-LSB-

-RSB-

Basic

Concepts

Intuitively

a

directed

graph

is

just

a

generalization

of

an

ordered

set

in

the

sense

that

the

only

requirement

on

the

relation

holding

between

objects

in

a

directed

graph

is

that

it

should

have

a

direction

i.e.

the

members

of

the

relation

should

be

ordered

pairs

Definition

-LRB-

directed

graph

vertices

edges

-RRB-

Let

V

vng

and

let

E

fhvi

vji

j

i

n

j

ng

V

V

G

hV

Ei

is

a

directed

graph

on

V

where

V

is

the

set

of

vertices

and

E

is

its

set

of

edges

Directed

graphs

vertices

and

edges

are

sometimes

called

digraphs

nodes

and

arcs

respectively

An

edge

between

vertices

v

and

w

is

sometimes

denoted

v

w.

Definition

-LRB-

path

-RRB-

A

sequence

of

vertices

vn

vng

in

a

directed

graph

G

hV

Ei

is

a

path

between

vertices

and

vn

if

hvn

vnig

is

a

set

of

edges

Note

that

an

empty

sequence

of

vertices

is

allowed

by

the

definition

Definition

-LRB-

reachable

-RRB-

Let

G

hV

Ei

be

a

directed

graph

A

vertex

w

V

is

reachable

from

a

vertex

v

V

if

there

is

a

path

between

v

and

w.

Definition

-LRB-

cycle

-RRB-

Let

G

hV

Ei

be

a

directed

graph

A

path

between

vertices

and

vn

is

a

cycle

if

vn

Example

-LRB-

Paths

cycles

and

reachability

-RRB-

In

Figure

there

are

two

paths

connecting

vertices

and

and

but

there

is

no

cycle

Every

vertex

is

connected

to

itself

by

an

empty

path

Vertex

is

reachable

from

every

other

vertex

whereas

vertex

is

unreachable

In

Figure

there

are

two

cycles

and

moreover

every

vertex

is

reachable

from

every

other

vertex

l

l

l

l

Figure

The

directed

graph

G

fhi

ji

j

i

jgi

l

l

l

l

l

l

l

l

l

R

R

oe

Figure

Chains

in

a

directed

graph

A

chain

in

a

directed

graph

-LSB-

-RSB-

consists

of

sequence

of

connected

vertices

where

each

vertex

has

only

one

in-going

and

one

outgoing

edge

with

the

exception

of

the

starting

vertex

which

may

have

several

in-going

edges

and

the

end

vertex

which

may

have

several

outgoing

edges

Chains

in

graph

theory

should

not

be

confused

with

chains

in

lattice

theory

Definition

-LRB-

chain

-RRB-

Let

G

hV

Ei

be

a

directed

graph

A

path

vn

vng

between

vertices

and

vn

is

a

chain

if

i

n

-LRB-

v

hv

vii

E

-RRB-

i

n

-LRB-

w

hvi

wi

E

-RRB-

Example

-LRB-

Chains

-RRB-

In

Figure

the

only

chains

are

and

Reducible

Graphs

The

following

concepts

lead

to

the

definition

of

reducible

graphs

which

are

often

used

as

flow-charts

when

modeling

inter-procedural

execution

of

languages

without

the

goto

construct

-LSB-

-RSB-

Definition

-LRB-

head

tail

initial

vertex

-RRB-

Let

G

hV

Ei

be

a

directed

graph

and

let

e

hv

wi

be

an

edge

in

G

The

head

of

e

is

v

and

the

tail

of

e

is

w

A

vertex

u

V

is

the

initial

vertex

of

G

if

u

V

ui

E.

Definition

-LRB-

domination

-RRB-

Let

G

hV

Ei

be

a

directed

graph

A

vertex

v

dominates

vertex

w

if

every

path

between

the

initial

vertex

of

G

and

w

contains

v.

Definition

-LRB-

forward

edges

back

edges

reducible

-RRB-

Let

G

hV

Ei

be

a

directed

graph

The

set

F

E

is

the

set

of

forward

edges

in

G

if

hV

F

i

forms

an

acyclic

subgraph

of

G

in

which

every

vertex

can

be

reached

from

the

initial

vertex

of

l

l

l

R

oe

Figure

An

irreducible

directed

graph

ll

l

l

QQQQs

QQQQs

Figure

A

directed

graph

which

consists

of

a

single

strongly

connected

component

G

The

set

B

E

is

the

set

of

back

edges

in

G

if

every

edge

in

B

has

a

head

which

dominates

its

tail

G

is

reducible

if

E

F

-LSB-

B

F

B

The

most

simple

example

of

an

irreducible

directed

graph

is

given

in

Figure

Orders

on

Graphs

In

the

context

of

fixpoint

computations

the

ordering

of

the

vertices

of

a

directed

graph

is

crucial

as

such

an

order

-LRB-

when

possible

-RRB-

provides

the

fixpoint

solver

with

a

very

good

order

of

computation

Definition

-LRB-

topological

order

-RRB-

Let

G

hV

Ei

be

a

directed

graph

An

linear

order

relation

on

G

is

a

topological

order

if

G

is

acyclic

and

hv

wi

E

-RRB-

v

w.

From

the

above

definition

it

is

clear

that

a

large

number

of

directed

graphs

are

impossible

to

order

topologically

these

are

the

graphs

containing

cycles

Strongly

connected

components

-LRB-

SCC

-RRB-

of

a

directed

graph

are

subgraphs

where

every

vertex

is

reachable

from

any

other

vertex

Definition

-LRB-

path

equivalence

strongly

connected

component

-LRB-

SCC

-RRB-

-RRB-

Let

G

hV

Ei

be

a

directed

graph

Two

vertices

v

and

w

are

path

equivalent

symbolically

vRw

if

there

is

a

path

from

v

to

w

and

a

path

from

w

to

v

The

distinct

equivalence

classes

formed

by

the

path

equivalence

relation

R

are

Vi

i

n

The

subgraph

Gi

hVi

Eii

is

a

strongly

connected

component

of

G

if

Ei

fhv

wi

E

j

v

w

Vig

As

every

vertex

is

reachable

from

the

other

vertices

in

Figure

this

graph

is

strongly

connected

If

the

edges

are

thought

of

as

representing

dependencies

-LRB-

Definition

-RRB-

a

strongly

connected

component

is

a

subgraph

where

a

change

in

a

vertex

may

affect

the

whole

component

Part

II

Fixpoint

Computations

in

Static

Program

Analysis

Chapter

Program

Analysis

The

purpose

of

this

chapter

is

to

establish

the

connection

between

-LRB-

static

-RRB-

program

analysis

and

the

computation

of

fixpoints

and

to

introduce

the

analysis

framework

for

AKL

Good

introductions

to

static

program

analysis

and

analysis

of

AKL

are

-LSB-

-RSB-

and

-LSB-

-RSB-

respectively

Basic

Concepts

Program

analysis

is

a

way

of

extracting

semantic

information

from

a

program

static

program

analysis

is

a

method

for

discovering

-LRB-

approximate

-RRB-

global

properties

of

the

runtime

behaviour

of

a

program

on

arbitrary

input

data

without

actually

running

it

whereas

dynamic

program

analysis

is

a

way

of

analyzing

a

program

by

running

it

on

various

sets

of

input

data

collecting

statistics

and

extrapolate

the

behaviour

on

other

data

sets

from

these

facts

The

syntax

of

a

programming

language

deals

with

the

structure

of

expressions

whereas

the

semantics

gives

an

interpretation

by

way

of

supplying

a

meaning

to

each

expression

in

the

language

An

operational

semantics

is

a

description

of

how

the

expressions

of

a

programming

language

behaves

in

an

operational

sense

in

terms

of

an

abstract

machine

defined

by

its

state

instructions

and

transition

rules

A

denotational

semantics

on

the

other

hand

is

a

set

of

functions

mapping

syntactic

structures

-LRB-

representing

expressions

-RRB-

in

a

programming

language

to

the

abstract

values

which

they

denote

The

operational

approach

is

thus

to

give

a

notion

of

what

a

program

does

in

terms

of

an

execution

mechanism

and

the

denotational

approach

is

to

provide

an

explanation

of

what

the

program

mean

independent

of

any

execution

mechanism

Static

Program

Analysis

Static

program

analysis

is

a

tool

for

discovering

properties

of

the

run-time

behaviour

of

program

without

actually

running

it

taking

both

control

flow

and

data

flow

into

account

Whereas

the

actual

execution

of

a

program

produces

one

sequence

of

states

the

data

and

control

pass

through

static

program

analysis

produces

a

static

semantics

defined

as

follows

for

each

control

point

in

the

program

a

finite

description

of

the

set

of

A

gives

a

brief

introduction

to

the

Agents

Kernel

Language

-LRB-

AKL

-RRB-

-LSB-

-RSB-

for

a

textbook

on

semantics

in

general

and

denotational

semantics

in

particular

data

states

the

program

could

be

in

when

any

conceivable

execution

passes

through

that

point

is

given

The

goal

is

thus

to

produce

descriptions

of

certain

program

properties

which

applies

to

all

possible

executions

of

the

program

for

arbitrary

input

values

and

the

idea

is

to

use

the

information

found

when

ffl

compiling

programs

giving

smaller

faster

less

memory

consuming

code

ffl

debugging

programs

finding

dead

code

and

type

incorrect

calls

Normally

analysis

is

global

which

means

that

no

part

of

the

program

being

analyzed

is

investigated

in

isolation

The

descriptions

of

program

properties

must

be

approximate

since

Rice

's

theorem

-LSB-

-RSB-

says

that

all

interesting

extensional

properties

of

programs

are

undecidable

Examples

of

interesting

-LRB-

and

thus

undecidable

-RRB-

program

properties

are

The

program

terminates

and

Variables

x

and

y

must

be

aliased

at

some

point

during

the

program

execution

The

descriptions

must

therefore

be

approximate

in

the

sense

that

they

can

not

provide

full

information

not

in

the

sense

that

they

may

be

wrong

Other

examples

of

program

properties

which

may

be

of

interest

include

call/exit-patterns

of

procedures

reachable/non-reachable

code

and

memory

usage

The

main

building

blocks

of

static

program

analysis

are

ffl

the

program

properties

of

interest

ffl

the

program

points

which

probe

the

program

structure

ffl

the

program

functions

modeling

an

approximate

execution

by

relating

program

properties

and

program

points

Typical

program

properties

of

interest

include

possible

values

of

variables

at

run-time

whereas

program

points

e.g.

could

be

located

between

statements

or

at

procedure

entry/return

in

the

program

to

be

analyzed

The

program

functions

can

model

concurrent

execution

of

statements

or

ordinary

procedure

calls

which

introduce

change

in

scope

These

intuitive

notions

are

captured

by

concepts

from

lattice

theory

Program

properties

are

modeled

by

a

complete

lattice

or

a

complete

partial

order

L

thus

an

order

relation

holding

between

the

program

properties

must

exist

If

the

program

property

investigated

is

the

possible

values

of

variables

the

top

and

bottom

element

of

the

lattice

may

represent

that

the

variable

in

question

can

be

bound

to

arbitrary

values

and

that

the

corresponding

program

point

is

not

reachable

respectively

whereas

an

intermediate

value

indicate

that

a

variable

may

be

bound

to

certain

ranges

or

types

A

set

of

variables

xi

ranging

over

program

properties

is

used

to

hold

information

about

these

properties

at

certain

program

points

Every

program

point

i

then

has

an

associated

function

OEi

which

computes

the

program

property

valid

at

this

point

All

this

leads

to

an

equation

system

xi

OEi

-LRB-

xn

-RRB-

xi

L

i

n

which

must

be

solved

either

symbolically

or

iteratively

The

engine

for

solving

this

equation

system

is

thus

the

heart

of

static

program

analysis

the

vehicle

which

performs

the

approximate

execution

In

this

thesis

the

method

used

by

the

engine

is

based

on

finding

the

fixpoint

of

the

equation

system

by

means

of

iteration

extensional

program

property

is

a

property

which

depends

only

the

input/output

behaviour

of

a

program

An

interesting

property

is

any

property

except

the

two

trivial

properties

true

which

holds

for

every

program

and

false

which

holds

for

no

program

concrete

indata

concrete

execution

concrete

outdata

abstraction

concretization

concrete

domain

Galois

connection

abstract

domain

abstract

indata

abstract

abstract

execution

outdata

Figure

Abstract

interpretation

and

the

Galois

connection

Abstract

Interpretation

The

theory

of

abstract

interpretation

-LSB-

-RSB-

facilitates

a

systematic

approach

to

the

problem

of

extracting

properties

from

programs

in

order

to

provide

provably

correct

answers

to

questions

about

their

run-time

behaviour

These

properties

are

properties

of

some

semantic

function

which

characterizes

certain

aspects

of

the

program

The

domain

of

the

semantic

function

consists

of

the

program

properties

of

interest

There

are

two

ways

of

understanding

abstract

interpretation

-LRB-

i

-RRB-

to

design

hierarchies

of

interrelated

semantics

specifying

the

behaviour

of

programs

in

various

levels

of

detail

hence

to

understand

the

program

in

certain

specific

ways

-LRB-

ii

-RRB-

to

design

automatic

static

program

analysis

tools

for

determining

dynamic

properties

of

programs

hence

to

execute

the

program

on

a

non-standard

domain

of

values

and

operators

The

first

way

interprets

-LRB-

-RRB-

interpretation

as

understanding

while

the

second

emphasizes

execution

The

first

aspect

of

abstract

interpretation

can

thus

be

used

in

formalizing

the

notion

of

approximate

program

properties

in

static

program

analysis

by

relating

the

concrete

semantics

to

an

abstract

semantics

modeling

certain

interesting

properties

of

the

program

and

its

execution

This

relationship

between

concrete

and

abstract

is

provided

by

a

Galois

connection

-LRB-

Figure

-RRB-

which

guarantees

that

the

approximate

program

properties

are

correct

In

short

the

main

idea

of

static

program

analysis

is

to

project

the

infinite

concrete

domain

of

the

original

program

onto

a

finite

abstract

domain

where

it

is

possible

to

execute

the

program

completely

the

guarantee

that

this

approximation

is

correct

is

then

given

by

abstract

interpretation

based

on

the

Galois

connection

Analysis

of

AKL

The

purpose

of

analyzing

AKL

-LSB-

-RSB-

is

to

provide

the

compiler

with

information

which

facilitates

optimization

of

guard

computations

leading

to

faster

program

execution

and

less

memory

consumption

The

analyzer

provides

the

compiler

with

ffl

Alias

information

two

variables

are

definitely

not

aliased

at

program

point

i

ffl

Type

information

a

variable

has

type

T

at

program

point

i

how

the

AKL

compiler

can

be

enhanced

by

using

global

static

program

analysis

is

described

in

-LSB-

-RSB-

The

interesting

program

properties

alias

and

type

are

modeled

by

a

complete

lattice

called

the

AT-domain

The

value

of

a

program

property

is

of

the

form

hAliased

Typesi

where

Aliased

is

a

set

of

variables

which

may

be

aliased

i.e.

refer

to

the

same

value

and

Types

is

a

set

consisting

of

descriptions

of

the

structures

-LRB-

name

arity

arguments

-RRB-

the

variables

in

Aliased

may

be

bound

to

The

bottom

value

of

the

lattice

is

a

dead

code

indicator

and

other

values

facilitates

the

decision

whether

two

variables

are

unaliased

at

a

certain

program

point

in

every

possible

execution

and

that

a

variable

is

always

bound

to

e.g.

a

list

hence

providing

type

information

The

two

sets

Aliased

and

Types

are

implemented

by

bit

vectors

represented

as

large

integers

-LRB-

BigNums

-RRB-

and

the

set

operations

are

thus

implemented

as

boolean

functions

on

bit

vectors

The

use

of

bit

vectors

instead

of

lists

for

implementing

sets

speeds

up

execution

Each

construct

in

a

normalized

AKL

program

has

a

corresponding

program

point

which

consists

of

a

pair

hpre

parti

where

the

intuition

is

that

a

value

of

a

pre-point

depends

on

all

the

program

points

leading

to

this

pre-point

and

that

the

value

of

a

part-point

reflects

a

state

of

partial

computation

e.g.

suspended

processes

and

parallel

execution

of

non-atomic

processes

The

result

of

possibly

concurrent

processes

is

modeled

by

the

function

conc

and

alternative

computations

are

modeled

by

the

function

lub

These

are

the

two

most

important

program

functions

in

the

AKL

analysis

framework

Change

in

scope

during

execution

is

modeled

by

the

functions

call

and

return

built-in

AKL-functions

are

handled

by

builtin

One

of

the

merits

of

the

analyzer

framework

written

in

AKL

is

that

it

is

modular

it

separates

ffl

the

setting

up

of

the

equation

system

ffl

the

implementation

of

program

functions

ffl

the

fixpoint

computation

procedure

facilitating

experimentation

with

and

optimization

of

each

module

separately

This

fact

is

used

in

Chapter

where

different

fixpoint

solvers

are

compared

Chapter

A

Survey

of

Fixpoint

Computations

The

most

time-consuming

part

in

static

program

analysis

is

spent

in

the

fixpoint

solver

Sadly

enough

this

area

has

been

much

neglected

in

the

past

but

if

static

program

analysis

is

to

be

a

usable

tool

in

software

development

the

execution

times

for

analyzing

programs

must

be

considerably

shorter

than

they

are

today

In

recent

years

however

more

effort

has

been

put

into

research

in

the

area

and

this

chapter

features

a

survey

of

fixpoint

computations

in

static

program

analysis

Chapter

six

in

Nilsson

's

thesis

-LSB-

-RSB-

and

the

paper

by

Vergauwen

et

al.

-LSB-

-RSB-

are

two

highly

readable

accounts

of

fixpoint

computations

The

Problem

In

static

program

analysis

the

program

properties

program

points

and

program

functions

add

up

to

give

an

equation

system

x

OE

-LRB-

x

-RRB-

which

can

be

written

as

xi

OEi

-LRB-

xn

-RRB-

i

n

using

the

notation

x

xni

OE

-LRB-

x

-RRB-

-LRB-

x

-RRB-

-LRB-

x

-RRB-

OEn

-LRB-

x

-RRB-

i

where

each

xi

belong

to

a

CPO

or

complete

lattice

hP

vi

and

the

functions

are

monotone

or

continuous

These

last

requirements

are

needed

in

order

to

guarantee

that

the

system

has

a

solution

The

problem

is

to

find

a

solution

to

this

equation

system

as

efficiently

as

possible

This

is

done

by

finding

the

-LRB-

least

-RRB-

fixpoint

of

the

system

Hence

the

goal

is

to

find

an

algorithm

for

computing

the

desired

fixpoint

which

minimizes

the

total

execution

time

The

total

execution

time

is

minimized

by

decreasing

ffl

the

number

of

function

evaluations

ffl

the

cost

of

comparisons

ffl

the

number

of

comparisons

needed

to

detect

stability

ffl

the

cost

of

computing

a

new

value

of

a

function

Basic

Concepts

At

this

point

some

terminology

must

be

introduced

A

fixpoint

computation

is

local

if

the

arguments

to

a

fixpoint

found

are

restricted

to

some

subspace

of

the

argument

space

of

the

functional

for

which

it

is

sought

global

if

no

restriction

is

placed

on

the

argument

space

of

the

fixpoint

of

a

functional

An

equation

is

stable

if

an

evaluation

of

the

function

does

not

lead

to

a

new

value

Granularity

Le

Charlier

and

Van

Hentenryck

introduce

the

following

terminology

concerning

granularity

for

comparing

static

program

analysis

frameworks

The

granularity

is

finer

if

more

program

points

are

considered

coarser

otherwise

-LSB-

-RSB-

By

analogy

with

partial

evaluation

the

granularity

is

polyvariant

if

the

analysis

deals

with

multiple

abstract

descriptions

for

each

object

in

the

program

depending

on

the

context

in

which

these

objects

are

used

and

monovariant

when

only

one

abstract

description

for

each

object

in

the

program

is

considered

An

example

of

polyvariance

is

analysis

of

logic

programs

where

the

resulting

fixpoint

is

a

map

of

predicate

inputs

to

predicate

outputs

Finer

polyvariant

granularity

is

likely

to

giver

better

results

at

the

price

of

a

higher

computation

cost

compared

to

coarser

monovariant

granularity

Dependencies

How

are

the

equations

in

the

equation

system

related

to

each

other

There

are

in

fact

certain

dependencies

-LSB-

-RSB-

between

the

equations

say

that

if

function

i

needs

the

value

of

function

j

-LRB-

j

is

one

of

its

arguments

-RRB-

then

function

i

depends

on

function

j

and

function

j

should

perhaps

be

evaluated

before

function

i

The

answer

is

thus

to

use

these

dependencies

in

the

following

way

a

function

which

depends

on

values

of

other

functions

should

be

reevaluated

only

when

the

values

the

functions

on

which

it

depends

have

changed

The

formal

definition

of

these

concepts

is

this

Definition

-LRB-

dependencies

dependency

graph

-RRB-

Let

xi

OEi

-LRB-

xn

-RRB-

i

n

be

an

equation

system

An

equation

j

depends

on

equation

i

denoted

hi

ji

if

xj

OEj

-LRB-

xi

:-RRB-

A

directed

graph

is

a

dependency

graph

if

its

vertices

represent

the

dependencies

of

an

equation

system

A

dependency

graph

is

dynamic

if

the

dependencies

are

changing

with

time

and

static

otherwise

As

higher-order

languages

do

not

have

static

flow

graphs

-LRB-

since

higherorder

programs

treat

procedures

and

functions

as

values

leading

to

an

intertwined

controland

data

flow

-RRB-

analysis

of

such

languages

leads

dynamic

dependency

graphs

as

do

polyvariant

granularity

When

speaking

of

dependency

graphs

-LRB-

where

each

vertex

has

an

associated

equation

-RRB-

to

visit

to

a

vertex

means

to

evaluate

the

function

in

the

equation

and

to

traverse

the

graph

in

a

certain

order

means

to

evaluate

the

functions

in

this

order

In

order

to

formulate

computation

strategies

a

stabilization

operator

denoted

-LSB-

-RSB-

is

sometimes

needed

Applied

to

a

sequence

of

vertices

it

works

by

computing

the

equations

represented

by

the

vertices

in

the

order

given

repeating

this

procedure

until

every

equation

in

the

sequence

is

stable

Optimizations

In

order

to

classify

various

optimizations

Sahlin

and

Sj?oland

-LSB-

-RSB-

have

introduced

the

following

terminology

Optimizations

which

guarantee

an

improvement

are

algorithmic

those

giving

an

improvement

in

practice

are

heuristic

The

dependency

on

a

certain

domain

or

on

specific

properties

of

functions

in

the

equation

system

is

expressed

by

saying

that

the

optimizations

are

either

domain

-LRB-

function

-RRB-

dependent

or

domain

-LRB-

function

-RRB-

independent

A

Declarative

View

In

order

to

illustrate

the

above

concepts

this

section

follows

-LSB-

-RSB-

in

giving

a

declarative

view

on

how

to

solve

the

problem

The

equation

system

is

defined

by

xi

OEi

i

n

where

OEi

V

X

V

X

xng

An

element

is

a

solution

of

the

above

equation

system

iff

-LRB-

xi

-RRB-

OEi

-LRB-

-RRB-

X

A

data

structure

val

X

V

is

used

in

the

algorithm

to

store

the

current

values

of

the

variables

In

the

naive

scheme

in

each

iteration

a

variable

xi

X

is

chosen

and

val

-LRB-

xi

-RRB-

is

updated

by

a

call

to

the

function

EvalRHS

-LRB-

xi

val

-RRB-

which

returns

OEi

-LRB-

val

-RRB-

In

order

to

minimize

the

number

of

evaluations

a

computation

ordering

which

avoids

selecting

equations

that

are

currently

stable

should

be

used

If

a

workset

ws

X

is

known

to

contain

only

variables

which

are

potentially

unstable

then

only

variables

in

ws

should

be

selected

for

re-evaluation

An

invariant

expressing

the

condition

on

ws

is

-LRB-

Iws

-RRB-

ws

OEi

-LRB-

val

-RRB-

val

-LRB-

xi

-RRB-

i.e.

all

variables

outside

ws

are

stable

Now

-LRB-

i

-RRB-

Iws

should

be

invariant

and

-LRB-

ii

-RRB-

the

size

of

ws

as

small

as

possible

This

is

achieved

by

a

call

to

the

procedure

Restore

-LRB-

xi

ws

-RRB-

whenever

the

value

of

variable

xi

changes

The

simplest

implementation

of

Restore

-LRB-

xi

ws

-RRB-

is

to

schedule

all

variables

for

reevaluation

i.e.

ws

X

but

this

breaks

requirement

-LRB-

ii

-RRB-

The

solution

to

this

is

to

keep

track

of

dependencies

between

variables

and

right

hand

sides

of

equations

Monovariance

Define

Arg

-LRB-

OEi

-RRB-

as

the

set

of

argument

variables

needed

in

order

to

evaluate

OEi

When

modifying

val

-LRB-

xi

-RRB-

only

variables

that

depend

on

xi

are

affected

and

hence

may

become

unstable

Therefore

Restore

-LRB-

xi

ws

-RRB-

-LSB-

ws

ws

-LSB-

mathitDep

-LRB-

xi

-RRB-

-RSB-

where

Dep

X

-RCB-

-LRB-

X

-RRB-

Dep

-LRB-

xi

-RRB-

fxj

X

j

xi

Arg

-LRB-

OEj

-RRB-

g

Polyvariance

Take

into

account

that

the

context

val

is

changing

and

that

this

may

affect

dependencies

Define

arg

-LRB-

xi

-RRB-

as

the

set

of

variables

that

xi

currently

depends

on

Introduce

the

predicate

Suff

-LRB-

OE

A

-RRB-

which

holds

iff

the

variables

in

A

are

sufficient

to

evaluate

OE

in

context

and

the

new

invariant

-LRB-

Idep

-RRB-

ws

Suff

-LRB-

OEi

val

arg

-LRB-

xi

-RRB-

-RRB-

The

function

EvalRHS

-LRB-

xi

val

-RRB-

is

extended

so

as

to

return

an

additional

set

A

consisting

of

variables

needed

in

evaluating

OEi

-LRB-

val

-RRB-

i.e.

A

Arg

-LRB-

fi

-RRB-

and

Suff

-LRB-

fi

val

A

-RRB-

Assuming

invariance

of

Idep

Restore

-LRB-

xi

ws

-RRB-

-LSB-

ws

ws

-LSB-

dep

-LRB-

xi

-RRB-

-RSB-

where

dep

X

-RCB-

-LRB-

X

-RRB-

dep

-LRB-

xi

-RRB-

fxj

ws

j

xi

arg

-LRB-

OEj

-RRB-

g

Dynamic

dependencies

are

more

interesting

when

the

right

hand

sides

of

the

equations

are

sparse

A

function

OE

is

sparse

if

for

most

contexts

only

a

small

part

of

is

needed

in

order

to

evaluate

OE

-LRB-

-RRB-

as

for

example

in

boolean

contexts

Local

Local

algorithms

try

to

compute

a

certain

part

of

-LRB-

OE

-RRB-

by

investigating

only

a

small

fragment

of

the

equation

system

Instead

of

stabilizing

all

variables

as

in

the

global

algorithm

the

local

algorithm

tries

to

construct

S

a

stable

subset

of

variables

called

the

search

space

In

addition

to

being

stable

this

set

of

variables

should

also

be

complete

which

means

that

variables

in

S

do

not

depend

on

values

of

variables

outside

S

The

goal

is

thus

to

construct

a

search

space

S

fxg

such

that

Stable

-LRB-

S

val

-RRB-

Complete

-LRB-

S

val

-RRB-

where

Stable

-LRB-

S

val

-RRB-

-LSB-

S

val

-LRB-

xi

-RRB-

OEi

-LRB-

val

-RRB-

-RSB-

and

Complete

-LRB-

S

val

-RRB-

-LSB-

S

Suff

-LRB-

OEi

val

S

-RRB-

-RSB-

which

means

that

S

-LRB-

OE

-RRB-

-LRB-

xi

-RRB-

val

-LRB-

xi

-RRB-

To

achieve

this

the

procedures

Update

and

Expand

are

defined

Update

Variables

of

S

that

are

in

ws

are

potentially

unstable

and

must

be

reevaluated

and

updated

-LRB-

by

Restore

-RRB-

just

as

in

the

global

algorithm

Expand

S

is

extended

when

there

are

stable

variables

in

S

which

depend

on

variables

outside

S

The

search

space

should

be

kept

small

as

variables

which

were

added

to

S

may

cease

to

be

needed

but

can

still

cause

further

useless

expansions

of

the

search

space

Such

variables

-LRB-

or

in

some

cases

calls

-RRB-

are

called

spurious

-LSB-

-RSB-

To

keep

the

search

space

small

the

procedure

Update

should

be

given

priority

over

Expand

Another

search

space

reduction

technique

is

to

remove

all

variables

in

S

that

are

no

longer

directly

or

indirectly

reachable

from

x.

Iteration

Strategies

An

iteration

strategy

is

a

heuristic

for

choosing

the

order

in

which

the

functions

in

the

system

of

equations

should

be

evaluated

This

approach

is

a

way

of

minimizing

the

number

of

evaluations

necessary

to

find

the

least

fixpoint

of

the

system

As

the

number

of

equations

typically

is

very

large

-LRB-

-RRB-

this

idea

is

crucial

The

Jacobi

iteration

strategy

has

its

origin

in

numerical

analysis

where

it

is

used

in

finding

a

solution

to

a

set

of

linear

equations

If

xk

denotes

the

value

of

x

in

iteration

step

k

then

the

Jacobi

iteration

strategy

amounts

to

the

following

sequence

of

successive

approximations

xk

-LRB-

xkn

xkn

-RRB-

xk

-LRB-

xkn

xkn

-RRB-

xk

n

OEn

-LRB-

xkn

xkn

-RRB-

The

Gauss-Seidel

iteration

strategy

is

an

improvement

to

the

previous

scheme

which

uses

those

values

already

computed

in

iteration

k

when

computing

the

new

values

xk

i

xk

-LRB-

xkn

xkn

-RRB-

xk

-LRB-

xk

xkn

xkn

-RRB-

xk

n

OEn

-LRB-

xk

xk

xk

n

xkn

-RRB-

The

above

two

iteration

strategies

are

special

cases

of

the

chaotic

iteration

strategy

-LSB-

-RSB-

which

intuitively

states

that

in

each

step

in

the

sequence

of

iterations

an

arbitrary

equation

i

may

be

chosen

as

long

as

no

equation

is

forgotten

indefinitely

-LRB-

fairness

-RRB-

To

capture

this

notion

the

following

two

concepts

are

needed

Definition

-LRB-

weak

fairness

-RRB-

Let

J

-RCB-

-LRB-

ng

-RRB-

A

sequence

of

such

subsets

Jk

k

is

weakly

fair

if

ng

i

Jk

l.

Definition

-LRB-

ascending

sequence

of

chaotic

iterations

-RRB-

Let

OEJ

be

the

map

defined

by

OEJ

-LRB-

xn

-RRB-

yni

where

for

i

ng

yi

ae

OEi

-LRB-

xn

-RRB-

if

i

J

xi

if

i

J

Let

hPn

vi

be

an

ordered

set

A

sequence

xk

of

vectors

in

Pn

is

an

ascending

sequence

of

chaotic

iterations

for

F

if

xk

ae

h

i

if

k

OEJk

-LRB-

xk

-RRB-

if

k

where

the

sequence

Jk

is

weakly

fair

Different

chaotic

iteration

strategies

can

thus

be

obtained

by

varying

the

specification

of

the

choice

sequence

Jk

which

guides

the

computation

Example

-LRB-

Jacobi

and

Gauss-Seidel

as

chaotic

iteration

strategies

-RRB-

First

note

that

OEfig

OEi

and

ng

OE

by

Definition

The

Jacobi

iteration

strategy

is

obtained

by

choosing

Jk

ng

whereas

the

choice

Jk

f

-LRB-

k

mod

n

-RRB-

corresponds

to

the

Gauss-Seidel

iteration

strategy

If

it

is

known

that

an

iteration

strategy

results

in

an

ascending

sequence

of

chaotic

iterations

this

fixpoint

computation

is

guaranteed

to

converge

in

a

finite

number

of

steps

Theorem

-LRB-

Convergence

of

ascending

sequences

of

chaotic

iterations

-RRB-

Let

hPn

vi

be

a

CPO

or

a

complete

lattice

If

xk

is

an

ascending

sequence

of

chaotic

iterations

for

the

map

OE

Pn

Pn

then

-LRB-

OE

-RRB-

F

k

xk

Proof

-LSB-

-RSB-

The

proof

consists

of

four

steps

-LRB-

i

-RRB-

Let

x

v

OE

-LRB-

x

-RRB-

v

-LRB-

OE

-RRB-

Now

xi

v

OEi

-LRB-

x

-RRB-

i

n

therefore

if

i

J

then

xi

v

OEi

-LRB-

x

-RRB-

OEJ

-LRB-

x

-RRB-

-LSB-

i

-RSB-

otherwise

xi

v

OEJ

-LRB-

x

-RRB-

-LSB-

i

-RSB-

v

OEi

-LRB-

x

-RRB-

where

OEi

-LRB-

x

-RRB-

OE

-LRB-

x

-RRB-

-LSB-

i

-RSB-

In

both

cases

xi

v

OEJ

-LRB-

x

-RRB-

-LSB-

i

-RSB-

hence

x

v

OE

-LRB-

x

-RRB-

v

-LRB-

OE

-RRB-

-RRB-

ng

x

v

OEJ

-LRB-

x

-RRB-

v

OE

-LRB-

x

-RRB-

v

-LRB-

OE

-RRB-

-LRB-

-RRB-

-LRB-

ii

-RRB-

Prove

that

xk

v

xk

OEJk

-LRB-

xk

-RRB-

v

OE

-LRB-

xk

-RRB-

v

-LRB-

OE

-RRB-

-LRB-

-RRB-

Induction

k

for

v

-LRB-

OE

-RRB-

v

OE

-LRB-

-RRB-

v

OE

-LRB-

-LRB-

OE

-RRB-

-RRB-

-LRB-

OE

-RRB-

by

monotonicity

of

OE

and

the

definition

of

fixpoints

hence

v

-LRB-

-RRB-

v

OE

-LRB-

-RRB-

v

-LRB-

OE

-RRB-

by

Equation

For

the

induction

step

k

assume

that

xk

v

xk

OEJk

-LRB-

xk

-RRB-

v

OE

-LRB-

xk

-RRB-

v

-LRB-

OE

-RRB-

If

i

Jk

then

xk

i

OEi

-LRB-

xk

-RRB-

v

OEi

-LRB-

xk

-RRB-

v

-LRB-

OEi

-RRB-

since

xk

v

xk

v

-LRB-

OE

-RRB-

and

OEi

is

monotone

Otherwise

i

Jk

and

xk

i

v

xki

v

OEi

-LRB-

xk

-RRB-

v

-LRB-

OEi

-RRB-

by

the

induction

hypothesis

so

that

xki

OEi

-LRB-

xk

-RRB-

v

OEi

-LRB-

xk

-RRB-

v

-LRB-

OEi

-RRB-

by

monotonicity

of

OEi

In

both

cases

xki

OEi

-LRB-

xk

-RRB-

v

-LRB-

OEi

-RRB-

for

i

n

therefore

xk

v

OE

-LRB-

xk

-RRB-

v

-LRB-

OE

-RRB-

which

proves

that

xk

v

xk

OEJk

-LRB-

xk

-RRB-

v

OE

-LRB-

xk

-RRB-

v

-LRB-

OE

-RRB-

-LRB-

iii

-RRB-

If

i

n

and

k

then

by

weak

fairness

-LRB-

Definition

-RRB-

-LRB-

i

-RRB-

i

Jk

-LRB-

i

-RRB-

This

implies

that

xk

-LRB-

i

-RRB-

i

OEi

-LRB-

xk

-LRB-

i

-RRB-

-RRB-

Now

by

induction

using

-LRB-

-RRB-

above

xk

v

xk

-LRB-

i

-RRB-

so

that

by

monotonicity

OEi

-LRB-

xk

-RRB-

v

xk

-LRB-

i

-RRB-

i

v

xmi

where

m

is

the

maximum

of

-LRB-

i

-RRB-

for

i

n.

Whence

k

OE

-LRB-

xk

-RRB-

v

xm

-LRB-

-RRB-

-LRB-

iv

-RRB-

Let

x

F

k

xk

By

-LRB-

-RRB-

definition

of

least

upper

bounds

and

continuity

x

v

F

k

OE

-LRB-

xk

-RRB-

OE

-LRB-

x

-RRB-

By

-LRB-

-RRB-

OE

-LRB-

xk

-RRB-

v

F

m

xm

which

means

that

OE

-LRB-

x

-RRB-

F

k

OE

-LRB-

xk

-RRB-

v

x

Hence

x

fix

-LRB-

OE

-RRB-

and

by

-LRB-

-RRB-

x

v

-LRB-

OE

-RRB-

whence

x

-LRB-

OE

-RRB-

by

definition

of

fixpoints

Theorem

-LRB-

Termination

of

ascending

sequences

of

chaotic

iterations

-RRB-

Let

hPn

vi

be

a

CPO

or

a

complete

lattice

with

-LRB-

Pn

-RRB-

l

and

let

xk

be

an

ascending

sequence

of

chaotic

iterations

for

the

map

OE

Pn

Pn

If

the

number

of

steps

necessary

for

every

component

to

evolve

in

chaotic

iteration

xk

is

bounded

by

m

then

-LRB-

OE

-RRB-

xl?m

Proof

-LSB-

-RSB-

From

-LRB-

-RRB-

and

-LRB-

-RRB-

in

the

proof

of

convergence

of

an

ascending

sequence

of

chaotic

iterations

it

is

known

that

xk

v

OE

-LRB-

xk

-RRB-

v

xk

m

The

case

xk

xk

m

is

impossible

since

it

contradicts

the

fact

-LRB-

Pn

-RRB-

l.

Hence

pick

the

least

k

such

that

xk

xk

m

which

means

that

xk

-LRB-

OE

-RRB-

and

xi

m

i

k

is

a

strictly

increasing

chain

such

that

k

l

When

a

fixpoint

is

reached

-LRB-

OE

-RRB-

xl?m

Static

Dependencies

The

idea

is

that

the

structure

given

to

the

equation

system

by

finding

the

static

dependencies

facilitates

a

good

iteration

strategy

Worklists

In

strategies

based

on

worklists

the

function

to

be

evaluated

is

chosen

from

a

worklist

containing

functions

which

should

be

evaluated

This

worklist

initially

contains

all

functions

and

if

the

value

of

function

i

picked

-LRB-

and

removed

-RRB-

from

the

worklist

changes

then

all

those

functions

depending

on

function

i

are

added

to

the

worklist

A

fixpoint

is

found

when

the

worklist

is

empty

Workstacks

One

way

of

choosing

functions

from

a

worklist

is

to

see

it

as

a

stack

Thus

in

a

workstack

approach

the

functions

are

added

to

and

removed

from

the

worklist

in

a

LIFO-manner

i.e.

pushed

and

popped

until

the

stack

is

empty

-LSB-

-RSB-

Priority-Queues

According

to

the

priority-queue

method

-LSB-

-RSB-

the

vertices

in

the

worklist

should

be

ordered

in

reverse

postorder

Topological

Sorting

When

the

static

dependency

graph

is

acyclic

the

problem

of

finding

an

optimal

chaotic

iteration

strategy

is

easy

just

sort

the

graph

topologically

and

evaluated

the

functions

at

vertices

in

the

order

given

Unfortunately

global

static

program

analysis

normally

generates

equation

systems

with

cyclic

dependency

graphs

hence

this

method

is

not

immediately

applicable

Strongly

Connected

Components

One

way

of

overcoming

the

problem

of

cyclic

dependency

graphs

is

to

topologically

sort

the

strongly

connected

components

-LRB-

found

by

Tarjan

's

algorithm

-RRB-

in

the

graph

and

then

visit

the

SCCs

in

this

order

employing

various

function

and

domain

independent

optimizations

inside

each

SCC

e.g.

ffl

Following

chains

and

worklist

Identify

the

chains

of

the

dependency

graph

prior

to

the

fixpoint

computation

Then

use

a

workstack

except

when

the

value

of

the

first

vertex

in

a

chain

has

changed

then

all

the

vertices

in

the

chain

should

be

recomputed

This

is

an

algorithmic

optimization

used

in

the

AKL

analysis

framework

-LSB-

-RSB-

k

l

l

l

oe

Figure

Illustrating

the

youngest

vertex

first

heuristic

-LRB-

-RRB-

ffl

Reverse

postorder

Perform

a

reverse

postorder

traversal

-LSB-

-RSB-

ffl

Reverse

postorder

and

worklist

The

vertices

are

picked

in

reverse

postorder

from

the

worklist

-LSB-

-RSB-

The

following

optimizations

are

all

based

on

a

workstack

adding

various

heuristics

ffl

Youngest

vertex

first

When

choosing

between

two

vertices

the

youngest

-LRB-

the

one

which

has

been

evaluated

a

smaller

number

of

times

of

the

two

-RRB-

should

be

evaluated

first

This

captures

the

requirement

of

fairness

in

chaotic

iteration

strategies

that

no

equation

should

be

forgotten

indefinitely

-LSB-

-RSB-

In

Figure

this

means

that

the

order

of

evaluation

should

be

ffl

Depth

first

Perform

a

depth

first

traversal

of

the

spanning

tree

of

the

SCC

-LSB-

-RSB-

The

vertices

in

Figure

should

then

be

visited

in

the

order

ffl

Direct

dependency

If

vertices

A

and

B

are

put

on

the

workstack

for

reevaluation

and

B

depends

on

A

then

A

should

be

visited

first

-LSB-

-RSB-

In

Figure

the

vertices

should

be

visited

in

the

order

whereas

in

Figure

the

visiting

sequence

should

be

ffl

Indirect

dependency

If

vertices

A

and

B

need

to

be

evaluated

and

the

paths

from

A

to

B

do

not

contain

vertices

in

need

of

evaluation

then

vertex

A

should

be

visited

first

-LSB-

-RSB-

ffl

Prefer

global

effects

The

vertex

with

the

largest

number

of

edges

should

be

chosen

first

-LSB-

-RSB-

Weak

Topological

Orders

The

concept

of

a

weak

topological

order

is

a

generalization

of

a

topological

order

of

a

directed

graph

possibly

containing

cycles

Its

major

advantage

is

that

it

both

subsumes

a

topological

sort

of

the

strongly

connected

components

of

a

directed

graph

and

automatically

i.e.

without

using

dynamic

heuristics

-LRB-

cf.

above

-RRB-

orders

the

the

vertices

inside

each

SCC

in

an

ingenious

way

-LSB-

-RSB-

Bourdoncle

's

algorithm

for

finding

a

weak

topological

order

makes

a

hierarchical

decomposition

of

a

directed

graph

into

strongly

connected

components

and

subcomponents

by

recursively

applying

Tarjan

's

algorithm

to

each

non-trivial

component

after

having

removed

w

-LRB-

the

head

of

the

component

-RRB-

and

every

back-edge

v

w.

For

an

experimental

comparison

of

weak

topological

orders

and

strongly

connected

components

in

fixpoint

computations

see

Chapter

oe

oe

l

l

l

l

l

AE

J

J

JJ

AE

J

J

JJ

oe

Figure

Illustrating

the

depth

first

heuristic

-LRB-

-RRB-

and

the

direct

dependency

heuristic

-LRB-

-RRB-

l

l

l

k

k

AE

J

J

JJ

J

J

JJ

AE

J

J

JJ

Figure

Illustrating

the

direct

dependency

heuristic

-LRB-

-RRB-

Dynamic

Dependencies

Dynamic

dependencies

arise

when

analyzing

higher-order

programs

or

when

the

analysis

is

polyvariant

In

these

two

cases

the

dependency

graph

is

not

known

before

the

analysis

starts

and

it

changes

dynamically

during

analysis

The

solving

of

the

corresponding

equations

system

is

different

in

that

the

goal

is

to

find

the

fixpoint

of

a

monotone

functional

instead

of

the

fixpoint

of

a

function

The

main

idea

is

to

use

a

dependency

relation

in

the

style

of

-LSB-

-RSB-

and

to

transfer

it

from

an

ordinary

system

of

equations

to

the

more

expressive

system

of

functional

equations

fi

-LRB-

xk

-RRB-

Ei

-LRB-

fn

xk

-RRB-

j

n

The

Operational

Approach

Le

Charlier

and

Van

Hentenryck

-LSB-

-RSB-

describe

a

universal

algorithm

which

finds

the

local

least

fixpoint

of

a

monotone

functional

on

a

noetherian

CPO

The

actual

computation

is

top-down

in

the

sense

that

it

is

viewed

as

a

generalization

of

computing

the

values

of

a

function

from

its

recursive

definition

The

starting

point

is

a

monotone

functional

OE

-LRB-

A

-RRB-

-LRB-

A

-RRB-

and

its

high-level

procedural

representation

phi

-LRB-

f

A

A

-RRB-

where

A

are

noetherian

CPOs

Given

OE

and

A

the

algorithm

computes

a

local

version

of

the

least

fixpoint

-LRB-

OE

-RRB-

thus

avoiding

to

compute

the

entire

table

of

-LRB-

OE

-RRB-

The

result

is

partial

function

f

-LRB-

represented

as

a

partial

table

pt

-RRB-

such

that

f

-LRB-

-RRB-

-LRB-

OE

-RRB-

ff

Simulate

the

execution

of

-LRB-

a

procedure

representing

OE

-RRB-

on

argument

when

f

is

applied

to

another

element

suspend

the

simulation

of

f

on

and

start

a

sub-simulation

of

f

on

The

sub-simulation

provides

new

values

for

the

partial

table

-LRB-

pt

-RRB-

of

f

and

these

values

are

used

when

the

initial

simulation

is

resumed

The

sub-simulation

proceeds

in

much

the

same

way

as

the

initial

simulation

the

only

difference

being

that

when

f

is

simulated

on

no

new

sub-simulation

is

started

instead

the

current

value

of

as

found

in

the

partial

table

is

used

Note

that

this

means

that

depends

on

and

that

whenever

the

value

of

is

refined

the

sub-simulation

on

has

to

be

redone

To

avoid

unnecessary

computations

the

algorithm

uses

a

dynamic

dependency

graph

Intuitively

the

set

dg

-LRB-

-RRB-

represents

the

elements

on

which

depend

and

dg

-LRB-

-RRB-

represents

the

reflexive

and

transitive

closure

of

dg

i.e.

all

the

elements

that

directly

or

indirectly

depend

on

If

any

of

the

elements

in

the

set

dg

-LRB-

-RRB-

is

refined

then

has

to

be

refined

If

depends

on

a

set

of

elements

which

have

not

been

refined

no

further

refinement

of

is

possible

at

this

moment

This

is

also

the

case

when

a

sub-computation

for

already

has

been

started

In

all

other

cases

is

a

new

sub-computation

and

a

local

fixpoint

for

is

computed

in

the

following

way

repeatedly

adjust

the

partial

table

by

calling

the

procedure

phi

When

calling

phi

it

may

happen

that

the

dependency

graph

of

is

extended

-LRB-

i.e.

depends

on

some

values

-RRB-

and

if

the

new

value

computed

by

phi

leads

to

an

adjustment

of

the

partial

table

all

dependency

graphs

with

elements

which

directly

or

indirectly

depend

on

elements

which

have

been

modified

are

removed

The

repetition

terminates

and

a

local

fixpoint

is

found

when

depends

on

some

elements

which

have

not

been

refined

-LRB-

i.e.

there

is

a

dependency

graph

left

after

removing

those

with

modified

elements

hence

the

elements

on

which

depend

have

not

been

refined

-RRB-

Note

that

phi

may

trigger

sub-simulations

and

extend

dependency

graphs

In

-LSB-

-RSB-

an

instance

of

the

above

universal

top-down

algorithm

for

Prolog

along

with

caching

of

operations

is

described

Optimizations

Chen

-LSB-

-RSB-

expresses

an

analysis

problem

as

the

least

fixpoint

of

an

abstract

semantic

functional

over

abstract

domains

The

monotone

function

-LRB-

the

abstract

interpreter

-RRB-

is

I

oe

P

P

where

oe

is

the

set

of

expressions

in

a

program

P

and

P

are

sets

of

prestates

and

poststates

of

expressions

respectively

The

functional

is

F

-LRB-

oe

P

P

-RRB-

-LRB-

oe

P

P

-RRB-

Next

a

relationship

called

entailment

is

introduced

Definition

-LRB-

entailment

-RRB-

Let

F

X

Y

X

Y

be

a

map

and

let

x

X.

x

entails

under

F

and

f

denoted

x

F

f

if

f

-LRB-

-RRB-

F

-LRB-

f

-LSB-

y

-RSB-

-RRB-

x

Ffx

The

intuition

of

this

definition

is

that

F

-LRB-

f

-RRB-

x

somehow

depends

on

the

value

of

f

-LRB-

-RRB-

hence

x

depends

on

On

the

other

hand

if

x

disentails

-LRB-

does

not

entail

-RRB-

then

F

-LRB-

f

-LSB-

y

-RSB-

-RRB-

x

Ffx

The

basic

fixpoint

computation

uses

the

following

four

equations

-LRB-

-RRB-

x

j

-LRB-

-RRB-

-LRB-

-RRB-

fi

fhx

F

-LRB-

fi

jXi

-RRB-

xi

j

x

Xig

-LRB-

-RRB-

Xi

Xi

-LSB-

j

x

F

fijXi

Xig

-LRB-

-RRB-

says

that

a

new

approximation

of

the

least

fixpoint

is

found

by

applying

F

to

the

current

approximation

restricted

to

those

elements

that

are

currently

entailed

-LRB-

Xi

-RRB-

-LRB-

-RRB-

makes

sure

that

the

vertices

entailed

under

F

and

fi

jXi

are

added

to

the

set

of

entailed

vertices

Note

that

fi

does

not

differ

from

fi

on

all

elements

in

Xi

The

differences

can

be

divided

into

two

subsets

-LRB-

-RRB-

Vertices

that

are

newly

entailed

-LRB-

-RRB-

Vertices

entailing

old

vertices

that

are

improved

i.e.

vertices

that

depend

on

other

vertices

which

have

been

refined

We

thus

get

-LRB-

-RRB-

x

j

-LRB-

-RRB-

-LRB-

-RRB-

fi

fhx

F

-LRB-

fi

jXi

-RRB-

xi

j

x

Wig

-LRB-

-RRB-

Wi

j

x

F

fijXi

x

Wig

-LSB-

fx

j

x

F

-LRB-

fi

jXi

-RRB-

-LRB-

fi

jXi

-RRB-

x

Xi

Wig

The

next

concept

introduced

is

the

entailment

graph

G

if

x

entails

there

is

a

directed

edge

hx

in

the

entailment

graph

This

graph

will

be

constructed

dynamically

during

the

fixpoint

computation

It

is

generally

impossible

to

compute

the

entailment

relation

precisely

and

therefore

a

safe

approximation

is

computed

by

adding

an

edge

ha

bi

to

G

if

the

value

f

-LRB-

b

-RRB-

is

used

during

the

computation

of

F

-LRB-

f

-RRB-

a

as

a

then

depends

on

b

It

is

easy

to

show

that

superfluous

edges

do

not

affect

the

correctness

of

the

fixpoint

Basic

Entailment

Algorithm

The

algorithm

uses

two

tables

TP

oe

P

and

TP

oe

P

for

keeping

track

of

the

prestate

and

poststate

of

each

expression

in

the

program

Figuratively

speaking

prestates

flow

forward

in

the

entailment

graph

and

poststates

flow

backwards

The

main

iteration

retrieves

vertices

from

a

workstack

W

finishing

when

W

is

empty

If

the

evaluation

of

a

vertex

w

leads

to

an

improved

value

all

the

vertices

that

entail

w

are

put

on

the

workstack

-LRB-

i.e.

those

that

depend

on

w

-RRB-

In

the

evaluation

procedure

if

a

prestate

value

has

been

refined

the

vertex

that

w

entails

is

put

onto

the

workstack

Regardless

of

the

result

of

the

evaluation

the

evaluation

procedure

adds

the

edge

hw

to

the

entailment

graph

Guided

Entailment

Algorithm

Local

knowledge

of

the

entailment

graph

at

each

vertex

is

used

to

dynamically

order

the

evaluations

necessary

for

finding

the

least

fixpoint

The

strategies

are

ffl

Waiting

for

all

successors

There

is

no

need

to

compute

a

new

poststate

value

unless

the

values

of

every

successor

vertex

is

known

ffl

Leading

vertex

first

Compute

a

new

poststate

of

every

vertex

that

has

an

improved

prestate

-LRB-

a

leading

vertex

-RRB-

before

considering

retreating

vertices

ie

those

vertices

added

to

the

workstack

because

one

of

its

successor

vertices

has

been

improved

ffl

Suspended

evaluation

Perform

only

a

minimum

amount

of

evaluation

of

a

vertex

v

in

order

to

supply

its

successor

vertices

with

sufficient

prestate

information

then

put

the

successor

vertices

on

the

workstack

suspend

evaluation

of

vertex

v

evaluate

the

successor

vertices

and

finally

resume

execution

of

vertex

v

This

may

however

lead

to

problems

when

there

is

an

internal

entailment

between

the

successor

vertices

such

that

the

entailment

graph

is

cyclic

ffl

Back

edge

first

This

strategy

deals

with

the

above

problem

If

a

vertex

entails

one

of

its

ancestors

there

is

a

back

edge

in

the

dependency

graph

-LRB-

a

loop

-RRB-

and

new

poststates

should

always

propagate

along

a

back

edge

first

-LRB-

if

there

is

one

-RRB-

until

the

loop

is

stable

In

the

algorithm

vertices

are

seen

as

objects

receiving

messages

The

messages

are

activate

which

computes

a

new

value

of

the

vertex

by

activating

its

successor

vertices

according

to

the

above

strategies

The

computation

is

thus

driven

forward

along

the

entailment

edges

At

the

end

of

an

activate

session

propagate

is

used

to

pass

information

backwards

to

predecessor

vertices

The

method

propagate

also

deals

with

propagating

new

values

along

back

edges

until

the

loop

is

stable

Context

Projections

A

large

context

-LRB-

the

current

state

of

the

computation

-RRB-

is

often

propagated

during

the

fixpoint

computation

A

solution

is

to

use

a

projected

context

i.e.

the

part

of

a

context

which

is

needed

for

evaluation

and

which

makes

it

possible

to

say

whether

the

vertex

should

be

reevaluated

or

not

The

prestate

of

a

vertex

v

is

split

into

a

projected

part

needed

in

the

evaluation

of

the

vertex

and

the

part

unnecessary

at

this

point

i.e.

ae

-LSB-

where

P

roject

-LRB-

ae

n

-RRB-

If

the

projected

context

has

changed

since

the

last

time

the

vertex

was

evaluated

the

vertex

must

be

reevaluated

in

this

new

context

The

goal

is

now

to

find

a

function

P

roject

such

that

P

roject

-LRB-

ae

-RRB-

is

as

small

as

possible

The

Denotational

Approach

The

papers

by

Rosendahl

-LSB-

-RSB-

and

Jorgensen

-LSB-

-RSB-

approach

the

problem

of

finding

fixpoints

of

functionals

from

a

denotational

semantics

perspective

Starting

with

a

domain

D

and

a

language

of

expressions

L

a

corresponding

evaluation

function

is

defined

E

L

-LRB-

Dk

D

-RRB-

Dk

D

The

syntactic

equation

f

-LRB-

xi

xk

-RRB-

E

now

induces

a

semantic

functional

E

-LSB-

E

-RSB-

and

its

least

fixpoint

-LRB-

E

-RRB-

-LSB-

E

-RSB-

The

dependency

-LRB-

or

sometimes

neededness

-RRB-

relation

is

expressed

by

the

neededness

function

N

which

can

be

used

to

infer

that

certain

applications

of

the

induced

functional

E

-LSB-

E

-RSB-

may

safely

be

omitted

as

these

applications

will

not

change

the

current

fixpoint

approximation

The

neededness

function

is

defined

by

N

L

-LRB-

Dk

D

-RRB-

Dk

-RCB-

-LRB-

Dk

-RRB-

N

-LSB-

E

-RSB-

OE

-LSB-

f

-LRB-

ei

-RRB-

fh

E

-LSB-

ei

-RSB-

OE

ig

where

RE

is

the

set

of

recursive

calls

to

f

in

E

RE

ff

-LRB-

ei

:-RRB-

j

f

-LRB-

ei

:-RRB-

is

a

sub-expression

of

Eg

The

intuition

is

that

the

neededness

set

consists

of

the

argument

tuples

need

needed

in

the

computation

of

the

functional

relative

to

the

current

approximation

OE

This

means

that

the

information

is

dynamic

in

nature

and

hence

can

not

be

computed

prior

to

the

fixpoint

iteration

The

algorithm

uses

the

functions

OE

and

N

-LRB-

think

of

them

as

tables

being

gradually

extended

-RRB-

mapping

Dk

to

its

currently

approximated

fixpoint

and

to

its

neededness

set

respectively

In

addition

to

this

there

is

a

workset

W

Dk

which

contains

all

those

tuples

that

must

be

processed

in

some

subsequent

iteration

The

algorithm

is

global

in

the

sense

that

the

initial

workset

W

contains

the

whole

of

Dk

which

means

that

every

tuple

is

processed

at

least

once

The

initial

fixpoint

approximation

maps

all

tuples

to

and

the

function

maps

every

tuple

to

the

empty

set

In

each

iteration

step

hOEn

Nn

Wni

is

used

to

compute

hOEn

Nn

Wn

i

finishing

with

the

result

OE

OEs

when

the

workset

W

is

empty

The

argument

tuple

n

is

arbitrarily

-LRB-

-RRB-

chosen

from

the

workset

and

is

used

to

extend

the

approximate

functional

of

the

previous

iteration

OEn

OEn

-LSB-

n

E

-LSB-

E

-RSB-

OEn?n

-RSB-

mon

The

monotonic

closure

operation

speeds

up

convergence

as

some

tuples

are

assigned

larger

values

without

being

processed

When

for

some

argument

tuple

there

is

no

need

to

re-compute

the

fixpoint

approximation

there

is

no

need

to

update

the

neededness

information

either

The

new

neededness

set

is

given

by

Nn

Nn

-LSB-

n

N

-LSB-

E

-RSB-

OEn?n

-RSB-

Note

that

the

set

of

tuples

N

-LSB-

E

-RSB-

OEn?n

is

already

computed

during

the

evaluation

of

E

-LSB-

E

-RSB-

OEn?n

and

that

no

other

neededness

sets

are

modified

The

new

workset

is

Wn

-LRB-

Wn

n

f?n

g

-RRB-

-LSB-

An

where

An

f

Dk

j

need

-LRB-

Nn

-RRB-

OEn?need

OEn

needg

Hence

the

workset

is

extended

with

all

those

tuples

with

neededness

sets

having

members

need

which

are

mapped

to

strictly

larger

values

under

the

new

approximation

OEn

The

main

difference

compared

to

-LSB-

-RSB-

is

that

the

neededness

analysis

of

Jorgensen

's

algorithm

is

more

shallow

i.e.

it

cares

only

about

direct

needs

whereas

the

algorithm

in

-LSB-

-RSB-

also

deals

with

indirect

needs

by

performing

a

transitive

closure

operation

Jorgensen

's

algorithm

is

also

more

iterative

as

each

iteration

corresponds

to

the

processing

of

a

single

element

Dk

during

which

all

needs

need

are

treated

by

look-ups

in

the

table

holding

the

previous

fixpoint

approximation

whereas

the

depthfirst

strategy

of

-LSB-

-RSB-

sometimes

suspends

the

processing

of

an

element

in

order

to

improve

the

approximating

value

for

a

need

This

can

be

generalized

to

a

system

of

m

functional

equations

where

two

twodimensional

tables

are

used

OEmi

with

OE

Dk

D

for

the

fixpoint

approximation

and

N

Nmi

for

the

neededness

information

where

Ni

-RCB-

-LRB-

fmg

Dk

-RRB-

i.e.

the

first

argument

is

the

function

of

the

subexpression

that

gives

rise

to

the

need

in

question

Now

in

iteration

step

n

choose

a

pair

hj

n

i

from

the

workset

Wn

which

means

that

n

should

be

given

as

input

to

equation

j

If

equation

j

contains

a

call

to

the

r

th

function

fr

then

a

pair

hfr

needi

will

be

placed

in

the

neededness

set

Nn

j

-LRB-

-RRB-

As

in

the

single

equation

case

every

tuple

with

a

neededness

set

which

contains

tuples

that

lead

to

better

functional

approximations

OEn

is

included

in

the

new

workset

Instead

of

trying

to

find

a

global

fixpoint

it

should

be

less

expensive

to

find

a

local

fixpoint

i.e.

a

functional

fixpoint

only

defined

for

a

subset

of

the

domain

OE

-LRB-

E

-LSB-

E

-RSB-

-RRB-

where

Dk

is

the

set

of

tuples

for

which

fixpoint

values

are

sought

-LRB-

cf.

-LSB-

-RSB-

-RRB-

The

idea

is

to

select

tuples

from

the

workset

according

to

the

following

scheme

n

Wn

Seenn

where

Seenn

Seenn

-LSB-

N

-LSB-

E

-RSB-

OEn?n

Seen

thus

accumulates

neededness

information

Example

An

instantiation

of

the

above

scheme

can

be

found

in

-LSB-

-RSB-

which

maintains

a

distinction

between

the

different

ways

in

which

a

Prolog

predicate

can

be

called

-LRB-

the

running

example

is

groundness

analysis

-RRB-

The

dynamics

of

algorithm

is

due

to

the

following

definition

Given

a

tuple

hC

i

where

C

is

a

Prolog

clause

and

is

a

specific

call

pattern

of

C

this

tuple

depends

on

if

has

been

computed

as

a

call

pattern

for

an

atom

in

the

body

of

C

during

the

most

recent

evaluation

of

against

C

This

means

that

the

dependency

relation

is

dynamic

i.e.

changing

from

one

iteration

to

the

next

Optimizations

Based

on

Properties

of

Functions

To

minimize

the

cost

of

computing

a

new

value

of

a

function

a

number

of

algorithmic

function

dependent

optimizations

have

been

proposed

ffl

Simplifying

argument

lists

For

an

associative

commutative

and

idempotent

operator

all

duplicate

arguments

may

be

removed

leading

to

a

shorter

evaluation

time

-LSB-

-RSB-

ffl

Simplifying

single

equations

The

lub-function

has

certain

nice

properties

facilitating

simplification

-LSB-

-RSB-

The

n

argument

equation

xi

lub

-LRB-

xi

xn

-RRB-

can

be

replaced

by

the

n

argument

equation

xi

lub

-LRB-

xi

xi

xn

-RRB-

as

minxi

lub

-LRB-

xi

xi

xn

-RRB-

ffl

Strongly

connected

subcomponents

The

type

T

of

a

vertex

is

determined

by

its

associated

function

and

a

strongly

connected

subcomponent

is

a

subgraph

where

all

vertices

have

the

same

type

Now

the

vertices

in

a

strongly

connected

subgraph

of

type

lub

can

be

collapsed

into

a

single

vertex

as

they

will

all

get

the

same

value

-LSB-

-RSB-

ffl

Incremental

computation

on

totally

ordered

domains

The

method

in

-LSB-

-RSB-

essentially

uses

the

old

value

of

a

vertex

when

computing

the

new

value

instead

of

computing

every

new

value

from

scratch

This

is

possible

when

the

domain

is

a

chain

and

the

functions

are

monotone

The

question

is

whether

this

idea

could

be

extended

to

domains

which

are

ordered

sets

framework

Xw

k

total

or

monotone

A

jAj

-LRB-

B

-RRB-

completely

additive

fx

A

j

x

J

-LRB-

A

-RRB-

g

jJ

-LRB-

A

-RRB-

j

-LRB-

B

-RRB-

iterative

scheme

fwg

-LRB-

A

-RRB-

Table

Iteration

bounds

for

fixpoints

of

functionals

Characterization

of

Frameworks

In

-LSB-

-RSB-

Nielson

and

Nielson

conducts

a

theoretical

study

of

various

frameworks

for

fixpoint

computations

To

each

program

the

analysis

associates

an

element

d

of

a

complete

lattice

hD

vi

of

abstract

values

The

value

d

is

determined

as

the

least

fixpoint

-LRB-

H

-RRB-

of

a

continuous

functional

H

D

D

possibly

parameterized

by

the

argument

w

which

the

resulting

fixpoint

is

to

be

evaluated

on

Furthermore

it

is

assumed

that

the

lattice

D

has

the

form

A

B

where

A

and

B

are

finite

complete

lattices

which

guarantees

termination

of

the

standard

iteration

procedure

for

finding

the

least

fixpoint

The

goal

is

to

give

bounds

to

size

of

the

set

Xw

in

if

Hk?v

Hk

Xw

then

fix

-LRB-

H

-RRB-

w

Hk?w

and

the

number

of

iterations

k

in

fix

-LRB-

H

-RRB-

w

Hk?w

The

three

frameworks

investigated

are

the

general

framework

where

the

functions

of

A

B

are

only

required

to

be

total

the

monotone

framework

where

the

functions

A

B

must

be

monotone

the

completely

additive

framework

where

the

functions

of

A

B

must

be

strict

and

additive

-LRB-

or

distributive

-RRB-

and

finally

the

case

where

H

is

in

iterative

form

H

is

on

iterative

form

if

it

is

of

the

form

H

h

f

t

-LRB-

h

ffi

g

-RRB-

The

bounds

on

the

number

of

iterations

k

needed

to

compute

the

fixpoint

of

the

functional

H

are

presented

in

Table

If

furthermore

f

and

g

are

strict

and

additive

it

is

shown

that

the

dependence

of

k

on

p

is

at

most

linear

and

that

the

fixpoint

can

be

computed

pointwise

In

the

setting

where

A

B

Cp

p

-LRB-

which

incorporates

imperative

programs

with

roughly

p

variables

-RRB-

the

above

results

yield

that

the

dependence

of

k

on

p

is

at

most

exponential

in

the

general

and

monotone

frameworks

quadratic

in

the

completely

additive

framework

Part

III

Towards

Efficient

Fixpoint

Computations

Chapter

Practical

Iteration

Strategies

This

chapter

describes

and

compares

two

methods

for

solving

to

the

equation

systems

that

arise

in

the

framework

for

analyzing

AKL-programs

As

the

dependency

graphs

are

static

in

this

particular

case

both

methods

work

by

basing

their

respective

chaotic

iteration

strategies

on

a

topological

sort

of

the

already

given

graph

Strongly

Connected

Components

The

current

AKL

analysis

framework

sets

up

a

system

of

semantic

functions

whose

dependencies

are

modeled

by

a

directed

graph

containing

cycles

Because

of

the

cycles

an

ordinary

topological

sort

of

the

graph

is

impossible

Instead

the

strongly

connected

components

of

the

graph

are

topologically

sorted

-LRB-

Section

-RRB-

Although

this

method

imposes

a

certain

structure

on

the

graph

it

is

by

no

means

enough

inside

each

strongly

connected

component

there

is

still

no

order

guiding

the

fixpoint

computation

and

various

optimizations

apart

from

the

workstack-approach

must

be

used

One

optimization

is

based

on

chains

in

graphs

-LRB-

Definition

-RRB-

This

algorithmic

optimization

works

by

reevaluating

every

member

of

a

chain

as

soon

as

the

first

vertex

in

this

chain

has

been

reevaluated

As

a

chain

in

a

graph

is

isolated

from

the

rest

of

the

graph

no

other

vertices

are

affected

by

this

procedure

In

order

to

find

the

strongly

connected

components

of

the

graph

Tarjan

's

is

used

This

algorithm

described

in

Figure

is

basically

a

depth

first

traversal

of

the

dependency

graph

where

each

visited

vertex

is

given

a

depth-first

number

-LRB-

dfn

-RRB-

and

is

stored

on

a

stack

The

time

complexity

of

Tarjan

's

algorithm

is

linear

in

the

number

of

edges

Weak

Topological

Orders

When

surveying

the

field

of

fixpoint

computations

the

method

based

on

a

weak

topological

order

-LRB-

WTO

-RRB-

-LSB-

-RSB-

of

the

static

dependency

graph

seemed

to

be

the

best

way

of

improving

the

execution

speed

of

the

fixpoint

solver

in

the

AKL

analysis

original

idea

was

first

published

by

Tarjan

in

-LSB-

-RSB-

the

papers

-LSB-

-RSB-

and

-LSB-

-RSB-

are

recent

enhancements

pseudo

code

loosely

resembles

Pascal

the

modifications

being

that

arguments

to

functions

may

be

labeled

in

out

or

inout

signifying

how

values

of

the

arguments

are

passed

through

the

function

interface

The

symbol

denotes

list

concatenation

func

Partition

-LRB-

in

G

-RRB-

var

vertex

partition

num

begin

foreach

vertex

verticesG

do

dfn

-LSB-

vertex

-RSB-

num

partition

V

isit

-LRB-

rootG

partition

-RRB-

return

partition

end

func

V

isit

-LRB-

in

vertex

inout

partition

-RRB-

var

head

min

succ

element

component

begin

push

-LRB-

vertex

-RRB-

head

dfn

-LSB-

vertex

-RSB-

num

num

foreach

succ

succG

-LSB-

vertex

-RSB-

do

if

dfn

-LSB-

succ

-RSB-

then

min

V

isit

-LRB-

succ

partition

-RRB-

else

min

dfn

-LSB-

succ

-RSB-

if

min

head

then

head

min

if

head

dfn

-LSB-

vertex

-RSB-

then

component

repeat

pop

-LRB-

element

-RRB-

dfn

-LRB-

element

-RRB-

component

element

component

until

element

vertex

partition

component

partition

return

head

end

Figure

Tarjan

's

algorithm

for

finding

the

SCC

's

of

a

directed

graph

framework

as

it

is

a

natural

generalization

of

the

current

approach

based

on

strongly

connected

components

Another

reason

for

this

choice

is

that

the

weak

topological

order

approach

is

relatively

new

-LRB-

-RRB-

and

that

it

would

be

interesting

to

compare

it

to

other

related

methods

To

the

author

's

knowledge

this

is

the

first

major

experimental

evaluation

of

WTOs

in

fixpoint

computations

The

main

idea

is

to

find

the

structure

inside

the

strongly

connected

components

and

the

approach

is

to

generalize

the

concept

of

topological

order

to

work

with

directed

graphs

containing

cycles

This

generalized

order-relation

between

equations

-LRB-

vertices

-RRB-

then

facilitates

at

least

two

efficient

chaotic

iteration

strategies

Basic

Concepts

In

contrast

to

the

approach

using

work

stacks

where

checking

for

stability

is

a

constant

operation

-LRB-

is

the

stack

empty

-RRB-

more

work

is

required

in

approaches

based

on

following

a

directed

graph

containing

cycles

In

order

to

detect

stability

of

a

fixpoint

computation

every

vertex

-LRB-

representing

a

function

in

the

system

of

equations

-RRB-

of

the

dependency

graph

must

be

examined

in

the

worst

case

When

the

dependency

graph

is

cyclic

however

there

exist

smaller

sets

of

vertices

which

it

is

sufficient

to

check

The

definition

follows

Definition

-LRB-

feedback

vertex

set

-RRB-

A

set

of

vertices

V

in

a

directed

graph

G

hV

Ei

is

a

feedback

vertex

set

if

every

cycle

in

G

contains

at

least

one

element

of

V

Thus

it

is

of

great

interest

to

find

the

minimal

feedback

vertex

set

as

this

will

reduce

the

time

spent

checking

whether

the

equation

system

is

stable

or

not

Finding

this

set

is

a

classical

problem

which

unfortunately

is

NP-complete

-LSB-

-RSB-

and

the

time

complexity

of

the

naive

algorithm

is

quadratic

in

the

number

of

vertices

Bourdoncle

is

the

first

author

to

investigate

the

possibility

of

combining

the

order

of

computation

and

the

checking

for

stability

The

answer

proposed

is

based

on

a

weaker

form

of

topological

order

of

a

directed

graph

and

an

algorithm

-LRB-

generalizing

Tarjan

's

algorithm

-RRB-

for

sorting

the

graph

according

to

this

order

Definition

-LRB-

hierarchical

order

component

component-head

-RRB-

A

hierarchical

order

on

a

set

A

is

a

well-parenthesized

permutation

of

A

without

two

consecutive

-LRB-

A

set

C

akg

A

is

a

component

where

is

its

component-head

if

the

elements

of

C

are

placed

between

two

matching

parentheses

The

sets

of

component-heads

of

all

nested

components

containing

a

A

is

denoted

-LRB-

a

-RRB-

and

the

set

of

all

component-heads

is

denoted

H

The

depth

of

a

is

defined

by

ffi

-LRB-

a

-RRB-

j

-LRB-

a

-RRB-

j.

Theorem

A

hierarchical

order

on

the

set

A

defines

a

chain

hA

i

The

concept

of

a

weak

topological

order

is

based

on

feedback

edges

a

feedback

edge

is

an

edge

hv

wi

such

that

w

v

in

the

chain

given

by

a

hierarchical

order

on

the

graph

Intuitively

in

a

weak

topological

order

the

head

w

of

a

feedback

edge

hv

wi

is

also

the

component-head

of

the

component

containing

its

tail

v

More

formally

Definition

-LRB-

weak

topological

order

-LRB-

WTO

-RRB-

-RRB-

Let

G

hV

Ei

be

a

directed

graph

A

hierarchical

order

W

hV

i

is

a

weak

topological

order

if

for

every

edge

hv

wi

E

-LRB-

v

OE

w

w

-LRB-

v

-RRB-

-RRB-

-LRB-

w

OE

v

w

-LRB-

v

-RRB-

-RRB-

Bourdoncle

's

Algorithm

A

generalization

of

Tarjan

's

algorithm

for

finding

the

strongly

connected

components

of

a

directed

graph

Bourdoncle

's

algorithm

-LRB-

Figure

-RRB-

finds

a

weak

topological

order

of

a

directed

graph

which

is

possibly

irreducible

and

contains

cycles

The

basic

idea

is

to

apply

Tarjan

's

algorithm

recursively

to

each

component

found

after

having

removed

the

component-head

h

and

every

feedback

edge

to

h

The

various

interrelationships

between

strongly

connected

components

weak

topological

order

Tarjan

's

algorithm

and

Bourdoncle

's

algorithm

are

depicted

in

Figure

where

the

arrows

indicate

logical

dependency

Bourdoncle

's

algorithm

is

correct

and

its

time

complexity

is

O

-LRB-

ffi

E

-RRB-

where

ffi

is

the

maximum

depth

of

the

graph

and

E

is

the

number

of

edges

-LRB-

-LSB-

-RSB-

Section

-RRB-

Example

-LRB-

Weak

topological

ordering

by

Bourdoncle

's

algorithm

-RRB-

The

weak

topological

order

of

the

directed

graph

in

Figure

as

given

by

Bourdoncle

's

algorithm

is

-LRB-

-LRB-

-RRB-

-RRB-

The

strongly

connected

components

as

found

by

Tarjan

's

algorithm

are

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

-LRB-

-RRB-

Iteration

Strategies

From

every

weak

topological

order

the

following

two

chaotic

iteration

strategies

can

be

derived

the

recursive

strategy

and

the

iterative

strategy

Both

these

strategies

are

based

on

the

stabilization

operator

which

uses

the

component-heads

of

the

weak

topological

order

to

check

for

stability

In

the

recursive

strategy

the

stabilization

operator

is

applied

recursively

to

the

nested

sequence

of

components

and

subcomponents

which

make

up

the

weak

topological

order

When

a

subcomponent

is

found

inside

a

component

the

stabilization

operator

is

applied

to

C

before

continuing

with

the

remaining

part

of

component

C

The

stability

of

a

component

is

detected

by

examining

its

component-head

Lemma

A

set

of

consecutive

vertices

of

depth

in

a

WTO

requires

only

one

iteration

Proof

-LSB-

-RSB-

Assume

that

ffi

-LRB-

v

-RRB-

Now

by

definition

of

a

WTO

hv

wi

-RRB-

v

OE

w

hence

hv

wi

stable

-LRB-

v

-RRB-

-RRB-

stable

-LRB-

w

-RRB-

-LRB-

-RRB-

As

there

are

no

feedback-edges

The

first

vertex

in

the

ordering

is

stable

after

one

evaluation

-LRB-

-RRB-

From

these

two

facts

it

follows

that

after

one

iteration

where

every

vertex

is

evaluated

once

every

v

is

stable

Theorem

-LRB-

Detection

of

stability

recursive

strategy

-RRB-

In

the

recursive

strategy

a

component

of

a

weak

topological

order

is

stable

if

its

component-head

is

stable

func

Partition

-LRB-

in

G

-RRB-

var

vertex

partition

num

begin

foreach

vertex

verticesG

do

dfn

-LSB-

vertex

-RSB-

num

partition

V

isit

-LRB-

rootG

partition

-RRB-

return

partition

end

func

Component

-LRB-

in

vertex

-RRB-

var

succ

partition

begin

partition

foreach

succ

succG

-LRB-

vertex

-RRB-

do

if

dfn

-LSB-

succ

-RSB-

then

V

isit

-LRB-

succ

partition

-RRB-

return

-LRB-

vertex

partition

-RRB-

end

func

V

isit

-LRB-

in

vertex

inout

partition

-RRB-

var

head

min

succ

element

loop

begin

push

-LRB-

vertex

-RRB-

head

dfn

-LSB-

vertex

-RSB-

num

num

loop

false

foreach

succ

succG

-LSB-

vertex

-RSB-

do

if

dfn

-LSB-

succ

-RSB-

then

min

V

isit

-LRB-

succ

partition

-RRB-

else

min

dfn

-LSB-

succ

-RSB-

if

min

head

then

head

min

loop

true

if

head

dfn

-LSB-

vertex

-RSB-

then

dfn

-LSB-

vertex

-RSB-

pop

-LRB-

element

-RRB-

if

loop

then

while

element

vertex

do

dfn

-LSB-

element

-RSB-

pop

-LRB-

element

-RRB-

partition

Component

-LRB-

vertex

-RRB-

partition

else

partition

vertex

partition

return

head

end

Figure

Bourdoncle

's

algorithm

for

finding

a

WTO

of

a

directed

graph

ss

S

S

SSw

Theory

Algorithm

SCC

Tarjan

WTO

Bourdoncle

Topological

sort

Figure

Relationships

SCC

WTO

Tarjan

's

algorithm

and

Bourdoncle

's

algorithm

l

l

l

l

l

l

l

l

oe

XXXXXXXXXz

oe

Figure

Static

dependency

graph

Proof

-LSB-

-RSB-

Without

loss

of

generality

suppose

that

the

WTO

consists

of

a

single

outermost

component

C

i.e.

a

SCC

Furthermore

assume

that

after

applying

all

the

equations

in

C

and

stabilizing

each

sub-component

recursively

the

value

of

the

component-head

of

C

remains

unchanged

Equation

in

the

proof

of

Lemma

then

shows

that

evaluation

of

the

vertices

once

more

is

unnecessary

as

no

vertex

inside

the

component

will

change

Hence

the

stability

of

a

component-head

imply

the

stability

of

the

entire

component

The

iterative

strategy

works

by

applying

the

stabilization

operator

to

every

outermost

component

of

a

weak

topological

order

-LRB-

aka

strongly

connected

component

-RRB-

thereby

removing

the

subcomponent

structure

without

loosing

the

order

structure

Once

again

the

stability

is

checked

by

investigating

component-heads

Theorem

-LRB-

Detection

of

stability

iterative

strategy

-RRB-

In

the

iterative

strategy

an

outermost

component

C

of

a

weak

topological

order

is

stable

if

all

component-heads

of

C

and

its

subcomponents

are

stable

Proof

-LSB-

-RSB-

Without

loss

of

generality

suppose

that

the

WTO

consists

of

a

single

outermost

component

C

i.e.

a

SCC

The

idea

is

to

prove

that

after

applying

the

equations

in

the

sequence

given

either

at

least

one

of

the

component-heads

of

C

and

its

subcomponents

have

changed

or

that

of

the

values

associated

with

vertices

in

W

have

changed

Suppose

that

the

contrary

holds

and

that

the

value

associated

with

a

vertex

w

W

has

changed

By

definition

of

a

WTO

every

edge

hv

wi

where

w

W

is

such

that

v

OE

w.

Hence

there

is

at

least

one

vertex

v

whose

value

has

changed

inducing

a

change

in

w.

Inductive

application

of

this

argument

shows

that

the

component-head

has

changed

which

contradicts

the

assumptions

Hence

either

at

least

one

of

the

component-heads

of

C

and

its

subcomponents

have

changed

or

that

of

the

values

associated

with

vertices

in

W

have

changed

This

is

equivalent

to

the

fact

that

if

all

component-heads

of

C

and

its

subcomponents

are

stable

then

C

is

stable

Theorem

-LRB-

Complexities

-RRB-

If

L

is

a

lattice

with

-LRB-

L

-RRB-

l

then

the

time

complexity

of

the

recursive

strategy

for

a

strongly

connected

graph

G

hV

Ei

is

O

-LRB-

l

X

ffi

-LRB-

v

-RRB-

-RRB-

and

the

time

complexity

of

the

iterative

strategy

is

O

-LRB-

l

jV

j

jHj

-RRB-

where

H

is

the

set

of

component-heads

Proof

-LSB-

-RSB-

Section

The

theoretical

upper

bound

of

the

recursive

strategy

is

always

better

than

that

of

the

iterative

strategy

since

ffi

-LRB-

v

-RRB-

jHj

V

Note

however

that

the

above

time

complexity

results

are

based

on

the

number

of

function

applications

The

assumption

is

that

every

function

application

regardless

of

the

number

of

arguments

and

the

size

of

the

arguments

executes

for

a

certain

constant

time

In

practice

this

is

not

the

case

Example

-LRB-

Strategies

based

on

weak

topological

orders

-RRB-

For

the

directed

graph

in

Figure

the

iterative

strategy

is

-LSB-

-RSB-

whereas

the

recursive

strategy

gives

the

following

order

of

evaluation

-LSB-

-LSB-

-RSB-

-RSB-

where

-LSB-

-RSB-

is

a

stabilization

operator

-LRB-

Section

-RRB-

Implementation

of

the

Algorithms

The

actual

implementation

is

done

in

AKL

-LRB-

Appendix

A

-RRB-

two

new

fixpoint

computation

modules

one

for

each

chaotic

iteration

strategy

are

written

and

incorporated

into

the

AKL

analysis

framework

-LRB-

Section

-RRB-

The

algorithms

are

coded

in

a

declarative

way

and

deterministic

execution

is

guaranteed

A

store

is

used

to

represent

the

equation

of

every

program

point

including

left

hand

side

variable

current

value

right

hand

side

function

arguments

and

the

equations

which

depend

on

the

equation

in

question

First

the

dependencies

of

the

equation

system

are

turned

into

a

dependency

graph

Secondly

Bourdoncle

's

algorithm

is

used

to

find

the

weak

topological

order

of

the

dependency

graph

The

equations

are

then

linked

together

according

to

the

weak

topological

order

before

the

fixpoint

computation

starts

This

link

information

is

also

placed

in

the

store

In

the

iterative

chaotic

iteration

strategy

the

vertices

representing

equations

in

a

strongly

connected

component

are

traversed

until

each

component

head

is

stable

During

the

traversal

only

those

equations

with

arguments

that

have

changed

are

evaluated

This

procedure

is

repeated

for

every

strongly

connected

component

Strategies

number

of

function

applications

execution

time

old/recursive

old/iterative

recursive/iterative

Table

How

the

different

chaotic

iteration

strategies

compare

In

the

recursive

chaotic

iteration

strategy

each

component

head

is

linked

to

two

vertices

-LRB-

-RRB-

the

vertex

following

the

component

head

inside

the

component

and

-LRB-

-RRB-

the

vertex

to

be

considered

when

the

current

component

is

stable

The

last

vertex

in

a

component

is

linked

back

to

the

head

of

the

component

which

after

a

traversal

of

the

component

is

checked

for

stability

If

unstable

route

-LRB-

-RRB-

is

taken

whereas

route

-LRB-

-RRB-

is

chosen

if

the

component

head

is

stable

Experimental

Results

The

different

performances

i.e.

execution

time

and

number

of

function

applications

of

three

different

fixpoint

solvers

in

the

analysis

framework

of

AKL

are

presented

and

compared

The

solvers

used

the

iteration

strategies

described

above

in

analyzing

programs

from

the

AKL

demo

directory

Below

when

speaking

about

strategies

recursive

and

iterative

refers

to

the

recursive

and

iterative

chaotic

iteration

strategy

respectively

where

both

strategies

are

based

on

weak

topological

orders

old

refers

to

the

chaotic

iteration

strategy

based

on

a

topological

sort

of

strongly

connected

components

and

the

chain

optimization

inside

strongly

connected

components

-LRB-

Section

-RRB-

Presentation

of

Results

In

Table

the

three

strategies

are

compared

The

results

shown

are

the

averages

of

comparing

the

number

of

applications

or

the

fixpoint

execution

time

i.e.

strategyA

strategyB

strategyAi

strategyBi

n

n

X

i

strategyAi

strategyBi

These

results

show

that

the

iterative

strategy

is

best

on

average

It

is

times

faster

than

the

old

strategy

and

times

faster

than

the

recursive

strategy

Comparisons

of

each

program

with

respect

to

the

different

strategies

are

given

in

Figures

and

Figures

and

show

how

execution

time

and

number

of

applications

vary

with

number

of

equations

number

of

heads

and

maximum

depth

Analysis

of

Results

The

reason

why

the

approach

based

on

a

weak

topological

order

of

the

dependency

graph

is

better

than

the

approach

based

on

strongly

connected

components

and

chains

more

information

about

the

experimental

setup

see

Appendix

B.

am

indebted

to

Mats

Carlsson

Dan

Sahlin

and

Thomas

Sj?oland

-LRB-

SICS

-RRB-

for

suggestions

on

how

to

present

the

results

graphically

10 100 1000 10000

Old

strategy

-LRB-

number

of

applications

-RRB-

Recursive

strategy

-LRB-

number

of

applications

-RRB-

Old

strategy

vs

recursive

strategy

number

of

applications

x

x

x

10 100 1000 10000

Old

strategy

-LRB-

secs

-RRB-

Recursive

strategy

-LRB-

secs

-RRB-

Old

strategy

vs

recursive

strategy

time

x

x

x

x

Figure

Comparison

recursive

-LCB-

old

strategy

10 100 1000 10000

Old

strategy

-LRB-

number

of

applications

-RRB-

Iterative

strategy

-LRB-

number

of

applications

-RRB-

Old

strategy

vs

iterative

strategy

number

of

applications

x

x

x

10 100 1000 10000

Old

strategy

-LRB-

secs

-RRB-

Iterative

strategy

-LRB-

secs

-RRB-

Old

strategy

vs

iterative

strategy

time

x

x

x

x

Figure

Comparison

iterative

-LCB-

old

strategy

10 100 1000 10000

Iterative

strategy

-LRB-

number

of

applications

-RRB-

Recursive

strategy

-LRB-

number

of

applications

-RRB-

Iterative

strategy

vs

recursive

strategy

number

of

applications

x

x

10 100 1000 10000

Iterative

strategy

-LRB-

secs

-RRB-

Recursive

strategy

-LRB-

secs

-RRB-

Iterative

strategy

vs

recursive

strategy

time

x

x

Figure

Comparison

recursive

-LCB-

iterative

strategy

10 100 1000 10000

Time

-LRB-

secs

-RRB-

Number

of

equations

Time

vs

number

of

equations

x

x

x

Old

Iterative

Recursive

10 100 1000 10000

Time

-LRB-

secs

-RRB-

Number

of

heads

Time

vs

number

of

heads

x

x

x

Old

Iterative

Recursive

10 100 1000 10000

Time

-LRB-

secs

-RRB-

Maximum

depth

Time

vs

maximum

depth

x

x

x

Old

Iterative

Recursive

Figure

Comparison

execution

time

vs

number

of

equations

number

of

heads

and

maximum

depth

respectively

10 100 1000 10000

Number

of

applications

Number

of

equations

Number

of

applications

vs

number

of

equations

x

x

x

Old

Iterative

Recursive

10 100 1000 10000

Number

of

applications

Number

of

heads

Number

of

applications

vs

number

of

heads

x

x

x

Old

Iterative

Recursive

10 100 1000 10000

Number

of

applications

Maximum

depth

Number

of

applications

vs

maximum

depth

x

x

x

Old

Iterative

Recursive

Figure

Comparison

number

of

applications

vs

number

of

equations

number

of

heads

and

maximum

depth

respectively

Number

of

applications

vs

problem

complexity

Old

strategy

Maximum

depth

Number

of

heads

Number

of

applications

Recursive

strategy

Iterative

strategy

Time

vs

problem

complexity

Old

strategy

Maximum

depth

Number

of

heads

Time

-LRB-

secs

-RRB-

Recursive

strategy

Iterative

strategy

Figure

Number

of

applications

and

execution

time

vs

the

intrinsic

complexity

of

the

dependency

graph

should

be

fairly

obvious

as

it

probes

the

dependency

graph

with

finer

granularity

a

specific

order

is

imposed

on

the

strongly

connected

components

What

makes

it

so

much

faster

is

that

the

heuristic

optimizations

strongly

connected

components

following

chains

and

worklist

youngest

vertex

first

depth

first

direct

dependency

and

indirect

dependency

-LRB-

Section

-RRB-

are

incorporated

automatically

into

the

weak

topological

order

hence

the

optimizations

are

taken

care

of

before

the

actual

fixpoint

computation

starts

Contrary

both

to

Bourdoncle

's

claim

that

the

recursive

strategy

is

almost

always

better

in

practice

-LRB-

-LSB-

-RSB-

p.

-RRB-

and

the

theoretical

worst-case

result

the

results

presented

here

show

that

this

is

heavily

application

dependent

in

analysis

of

AKL

the

iterative

strategy

is

approximately

faster

The

maximum

depth

of

the

dependency

graph

might

be

a

deciding

factor

in

choosing

which

iteration

strategy

to

use

in

a

specific

analysis

framework

as

a

large

maximum

depth

can

introduce

a

great

deal

of

overhead

in

unfavorable

cases

when

the

iterative

strategy

is

used

However

the

plots

indicate

that

the

speed-up

when

comparing

the

old

and

the

recursive

strategy

is

increasing

with

intrinsic

program

complexity

which

is

a

nice

phenomenon

probably

due

to

the

explicit

computation

order

given

to

each

SCC

An

interesting

fact

is

that

the

spread

in

the

measurements

is

always

greater

when

the

comparison

is

based

on

the

execution

time

instead

of

the

number

of

function

applications

This

indicates

that

a

measure

of

the

cost

of

each

function

application

and/or

the

number

of

comparisons

needed

in

order

to

detect

stability

of

a

-LRB-

sub

-RRB-

component

could

be

of

use

In

the

cases

where

the

old

strategy

outperforms

the

new

strategies

in

terms

of

execution

time

the

number

of

function

applications

is

still

larger

for

the

old

strategy

-LRB-

Figure

-RRB-

The

explanation

of

this

phenomenon

is

that

the

cost

of

function

applications

varies

between

different

equations

and

even

for

the

same

function

with

different

arguments

hence

fewer

more

costly

function

applications

may

take

longer

time

to

execute

than

a

larger

number

of

cheap

function

applications

What

should

be

minimized

is

not

the

number

of

function

applications

but

the

total

execution

time

Related

Work

One

way

of

sorting

a

directed

graph

is

to

partition

the

graph

into

disjoint

intervals

and

then

collapse

the

intervals

into

a

limit

flow

graph

-LSB-

-RSB-

A

limit

flow

graph

can

only

be

found

if

the

graph

is

reducible

A

method

for

overcoming

this

difficulty

is

using

node

splitting

but

this

is

rather

ad-hoc

There

are

two

reasons

why

the

weak

topological

order

approach

is

better

first

it

deals

with

non-reducible

graphs

automatically

and

secondly

it

gives

an

easy

way

of

checking

for

stability

Handling

non-reducible

graphs

is

very

important

as

almost

all

global

analyses

of

programming

languages

supporting

recursion

give

rise

to

this

kind

of

dependency

graphs

Chapter

Properties

of

Functions

The

repetitive

approach

in

fixpoint

computations

leads

to

many

evaluations

of

each

function

in

the

equations

system

hence

the

cost

of

a

function

evaluation

is

one

of

the

parameters

to

minimize

It

is

also

the

case

that

the

functions

in

static

program

analysis

frameworks

tend

to

have

many

arguments

Now

if

it

is

assumed

that

the

cost

of

evaluating

a

function

is

proportional

to

the

number

of

its

arguments

it

is

a

natural

step

to

investigate

the

functions

which

do

not

need

to

be

evaluated

with

respect

to

all

their

arguments

in

every

evaluation

The

following

theorem

guarantees

the

existence

of

certain

transformed

functions

that

do

not

need

all

of

their

arguments

Theorem

-LRB-

Kleene

-RRB-

If

ym

xn

OE

-LRB-

ym

xn

-RRB-

E

where

E

is

a

recursive

definition

then

for

fixed

arguments

ym

there

exists

a

function

Smn

such

that

xn

OE

-LRB-

ym

xn

-RRB-

Smn

-LRB-

E

ym

-RRB-

Proof

-LSB-

-RSB-

Theorem

XXIII

-LRB-

Kleene

's

s

m

n

theorem

-RRB-

Recursive

definitions

are

defined

in

-LSB-

-RSB-

Starting

from

this

theorem

the

goal

is

to

investigate

the

functions

Smn

-LRB-

E

ym

-RRB-

which

are

computationally

inexpensive

Argument-change

dependence

An

idea

of

Sahlin

-LSB-

-RSB-

is

to

compute

a

function

incrementally

which

means

that

the

old

value

of

a

function

is

used

when

computing

a

new

function

value

A

slightly

different

viewpoint

is

to

see

the

new

function

value

as

depending

on

the

changes

in

its

arguments

since

the

last

evaluation

This

could

be

interesting

from

a

memory

perspective

as

values

of

arguments

need

not

be

saved

what

is

important

is

the

current

value

of

the

function

and

the

changes

in

its

arguments

and

the

function

thus

depends

on

the

changes

in

its

arguments

Definition

-LRB-

argument-change

dependence

-RRB-

Let

OE

Ln

L

be

a

function

OE

is

argument-change

dependent

if

there

exists

a

function

F

and

an

operation

ffi

L

such

that

OE

-LRB-

-RRB-

ckg

-LRB-

OE

-LRB-

xn

-RRB-

ck

-RRB-

where

ae

xi

ffi

i

if

i

ckg

xi

otherwise

Thus

instead

of

performing

the

operator

twice

first

updating

the

arguments

in

question

and

then

updating

the

function

with

its

new

arguments

the

operator

is

just

used

once

for

updating

the

previous

value

with

respect

to

changes

Example

-LRB-

Argument-change

dependent

functions

-RRB-

An

example

of

a

function

with

this

property

is

addition

on

given

the

previous

function

value

and

the

change

in

-LRB-

some

of

-RRB-

its

arguments

a

new

function

value

is

computed

by

simply

adding

the

changes

to

the

previous

function

value

Thus

define

OE

-LRB-

xn

-RRB-

n

X

i

xi

ckg

-LRB-

OE

-LRB-

xn

-RRB-

ck

-RRB-

OE

-LRB-

xn

-RRB-

k

X

i

ci

which

gives

n

X

i

n

X

i

xi

k

X

i

ci

Partial

argument-independence

The

assumption

that

the

cost

of

evaluating

a

function

is

proportional

to

the

number

of

its

arguments

and

the

fact

that

functions

in

static

program

analysis

tend

to

have

many

arguments

point

to

the

class

of

functions

which

do

not

need

all

of

their

arguments

in

every

evaluation

as

a

particularly

interesting

one

Alas

the

basic

intuition

is

that

of

a

function

OE

which

in

an

iterative

computation

only

needs

to

be

evaluated

with

respect

to

those

arguments

which

have

changed

since

its

latest

evaluation

and

the

previous

value

of

the

function

The

function

is

thus

independent

of

some

of

its

arguments

A

more

formal

definition

is

the

following

Definition

-LRB-

partial

argument-independence

-RRB-

Let

OE

Ln

L

be

a

function

OE

is

partially

argument-independent

if

there

exists

a

function

F

such

that

OE

-LRB-

-RRB-

ckg

-LRB-

OE

-LRB-

xn

-RRB-

-RRB-

where

ng

i

ckg

xi

Example

-LRB-

Partially

argument-independent

functions

-RRB-

Constant

functions

are

trivial

examples

of

partial

argument-independence

On

a

lattice

the

lub-function

is

nontrivially

partially

argument-independent

to

specialize

further

the

max-function

on

IR

is

also

partially

argument-independent

Theorem

-LRB-

lub

is

partially

argument-independent

-RRB-

lub

-LRB-

-RRB-

lub

-LRB-

lub

-LRB-

xn

-RRB-

-RRB-

where

ng

i

ckg

xi

Proof

Follows

from

the

definition

with

ckg

lub

Application

All

this

suggests

that

argument-change

dependent

functions

as

well

as

partially

argumentindependent

functions

should

be

identified

and

used

more

in

static

program

analysis

of

course

bearing

in

mind

that

some

overhead

is

introduced

by

the

book-keeping

necessary

for

selecting

the

appropriate

arguments

in

every

function

evaluation

In

the

current

framework

for

analyzing

AKL

the

lub

functions

account

for

approximately

of

the

total

number

of

functions

in

the

equations

systems

generated

The

conc

functions

are

similar

to

lub

functions

and

these

two

types

can

therefore

be

merged

If

this

merger

is

done

functions

of

the

lub

type

account

for

more

than

of

the

total

number

of

functions

Chapter

Conclusion

This

final

chapter

summarizes

what

has

been

said

and

tells

what

lies

ahead

Summary

In

this

thesis

a

self-contained

presentation

of

fixpoint

computations

in

static

program

analysis

from

theory

to

application

has

been

presented

the

most

important

parts

of

which

are

an

introduction

to

lattice

theory

and

fixpoints

a

survey

of

methods

used

in

fixpoint

computations

in

static

program

analysis

the

first

major

experimental

evaluation

of

iteration

strategies

based

on

weak

topological

orders

found

by

Bourdoncle

's

algorithm

an

implementation

giving

a

speed-up

of

on

average

and

in

some

cases

up

to

in

the

analysis

framework

for

AKL

and

finally

the

concept

of

partially

argumentindependent

functions

which

decreases

the

cost

of

function

applications

Future

Work

In

the

spirit

of

topological

sorting

of

weighted

directed

graphs

it

would

be

very

interesting

to

try

to

generalize

the

concept

of

a

weak

topological

order

to

account

for

weighted

edges

each

weight

corresponding

to

the

computational

cost

of

the

corresponding

functions

The

experimental

results

where

a

small

number

of

applications

yet

lead

to

large

execution

times

in

some

of

the

examples

indicates

that

such

a

sorting

method

could

lead

to

further

speed-ups

Further

analyses

of

the

merits

of

the

iterative

and

recursive

WTO-strategies

in

relation

to

each

other

and

to

the

old

strategy

based

on

SCCs

and

chains

would

have

to

take

not

only

the

number

of

function

applications

and

the

execution

time

into

account

but

also

the

number

of

comparisons

needed

to

detect

stability

Dependency

graphs

are

often

dynamic

in

more

general

frameworks

A

natural

question

is

whether

it

would

be

computationally

feasible

to

use

Bourdoncle

's

algorithm

to

dynamically

sort

those

parts

of

the

dependency

graph

which

are

affected

by

the

dynamic

changes

-LRB-

new

edges

etc

-RRB-

With

respect

to

parallel

execution

it

would

be

interesting

to

see

if

Bourdoncle

's

algorithm

can

be

parallelized

This

could

be

quite

hard

as

the

algorithm

is

based

on

Tarjan

's

algorithm

which

deals

with

the

problem

of

finding

the

strongly

connected

components

of

a

directed

graph

a

problem

which

has

been

known

for

some

time

to

be

very

difficult

to

solve

in

parallel

On

the

other

hand

the

complexity

of

Tarjan

's

algorithm

is

already

linear

whereas

the

complexity

of

Bourdoncle

's

algorithm

is

a

function

of

the

complexity

of

the

graph

which

should

leave

room

for

improvement

in

the

case

of

a

parallel

algorithm

In

this

context

a

partial

order

on

SCCs

facilitating

parallel

evaluation

of

these

components

could

be

of

interest

In

order

to

see

if

there

are

any

practical

advantages

of

using

argument-change

dependent

functions

and

partially

argument-independent

functions

an

experimental

test

of

partially

argument-independent

functions

e.g.

lub

should

be

performed

This

test

will

show

if

the

reduction

in

time

for

function

applications

outweighs

the

loss

introduced

by

the

book-keeping

overhead

If

this

turns

out

to

be

the

case

conc

functions

should

be

merged

with

the

lub

functions

in

the

AKL-analysis

framework

leading

to

less

redundant

work

in

the

fixpoint

solver

A

spin-off

of

weak

topological

orderings

in

static

program

analysis

is

the

following

Given

a

static

program

analysis

and

the

resulting

equation

system

the

weak

topological

order

of

the

dependency

graph

can

be

used

as

a

way

of

automatically

measuring

the

complexity

-LRB-

or

perhaps

better

the

degree

of

intricacy

-RRB-

of

a

program

statically

-LSB-

-RSB-

This

measure

should

then

be

based

on

the

intrinsic

complexity

of

the

graph

as

given

by

the

weak

topological

order

e.g.

as

-LRB-

maxdepth

-RRB-

edges

or

as

the

sum

of

the

mean

values

of

depth

edges

in

every

strongly

connected

component

Finally

the

implementation

of

the

current

fixpoint

solver

in

the

AKL

analysis

framework

is

written

in

AKL

itself

What

would

the

speed

up

be

if

the

solver

was

written

in

an

imperative

language

like

C

Bibliography

-LSB-

-RSB-

Samson

Abramsky

and

Chris

Hankin

Abstract

Interpretation

of

Declarative

Languages

Ellis

Horwood

Chichester

-LSB-

-RSB-

Alfred

V.

Aho

Ravi

Sethi

and

Jeffrey

D.

Ullman

Compilers

Principles

Techniques

and

Tools

Addison-Wesley

Reading

Massachusetts

-LSB-

-RSB-

Dines

Bjorner

Manfred

Broy

and

Igor

V.

Pottosin

editors

Formal

Methods

in

Programming

and

Their

Applications

volume

of

Lecture

Notes

in

Computer

Science

Academgorodok

Novosibirsk

Russia

June/July

Springer-Verlag

-LSB-

-RSB-

Norman

L.

Biggs

Discrete

Mathematics

Oxford

University

Press

Oxford

-LSB-

-RSB-

Fran?cois

Bourdoncle

Abstract

interpretation

by

dynamic

partitioning

Technical

Report

DIGITAL

Paris

Research

Laboratory

March

-LSB-

-RSB-

Fran?cois

Bourdoncle

S?emantiques

des

langages

imp?eratifs

d'ordre

sup?erieur

et

interpr?etation

abstraite

PhD

thesis

Ecole

Polytechnique

-LSB-

-RSB-

Fran?cois

Bourdoncle

Efficient

chaotic

iteration

strategies

with

widenings

In

Bjorner

et

al.

-LSB-

-RSB-

pages

-LCB-

-LSB-

-RSB-

Maurice

Bruynooghe

and

Jaan

Penjam

editors

International

Symposium

on

Programming

Language

Implementation

and

Logic

Programming

PLILP

volume

of

Lecture

Notes

in

Computer

Science

Tallinn

Estonia

August

Springer-Verlag

-LSB-

-RSB-

Per

Brand

Enhancing

the

AKL

compiler

using

global

analysis

Deliverable

number

D.WP

of

the

ESPRIT

project

ParForce

ftp

Z

September

-LSB-

CAA

-RSB-

Mats

Carlsson

Johan

Andersson

Stefan

Andersson

Kent

Boortz

Hans

Nilsson

Thomas

Sj?oland

and

Johan

Wid?en

SICStus

Prolog

User

's

Manual

Version

SICS

Research

Report

April

-LSB-

-RSB-

Patrick

Cousot

and

Radhia

Cousot

Automatic

synthesis

of

optimal

invariant

assertions

Mathematical

foundations

SIGPLAN

Notices

-LRB-

-RRB-

-LCB-

BIBLIOGRAPHY

-LSB-

-RSB-

Patrick

Cousot

and

Radhia

Cousot

Abstract

interpretation

and

application

to

logic

programs

The

Journal

of

Logic

Programming

-LRB-

-RRB-

-LCB-

July

-LSB-

-RSB-

Patrick

Cousot

and

Radhia

Cousot

Abstract

interpretation

frameworks

Journal

of

Logic

and

Computation

-LRB-

-RRB-

-LCB-

August

-LSB-

-RSB-

Patrick

Cousot

Moreno

Falaschi

Gilberto

Fil?e

and

Antoine

Rauzy

editors

Third

International

Workshop

on

Static

Analysis

WSA

volume

of

Lecture

Notes

in

Computer

Science

Padova

Italy

September

Springer-Verlag

-LSB-

-RSB-

Li-Ling

Chen

Efficient

Computation

of

Fixpoints

that

Arise

in

Abstract

Interpretation

PhD

thesis

University

of

Illinois

at

Urbana-Champaign

-LSB-

-RSB-

Patrick

Cousot

Semantic

Foundations

of

Program

Analysis

chapter

In

-LSB-

-RSB-

-LSB-

-RSB-

Pierre

Deransart

and

Jan

Ma

luszy?nski

editors

International

Symposium

on

Programming

Language

Implementation

and

Logic

Programming

PLILP

volume

of

Lecture

Notes

in

Computer

Science

Link?oping

August

Springer-Verlag

-LSB-

-RSB-

B.A.

Davey

and

H.A.

Priesley

Introduction

to

Lattices

and

Order

Cambridge

University

Press

Cambridge

-LSB-

-RSB-

Peter

A.

Fritzson

editor

International

Conference

on

Compiler

Construction

CC

volume

of

Lecture

Notes

in

Computer

Science

Edinburgh

U.K.

April

Springer-Verlag

-LSB-

-RSB-

Michael

R.

Garey

and

David

S.

Johnson

Computers

and

Intractability

A

Guide

to

the

Theory

of

NP-completeness

W.

H.

Freeman

San

Francisco

-LSB-

-RSB-

George

Gr?atzer

General

Lattice

Theory

Birkh?auser

Verlag

Basel

-LSB-

-RSB-

Susan

Horowitz

Alan

Demers

and

Tim

Teitelbaum

An

efficient

general

iterative

algorithm

for

dataflow

analysis

Acta

Informatica

-LRB-

-RRB-

-LCB-

-LSB-

-RSB-

John

E.

Hopcroft

and

Jeffrey

D.

Ullman

Introduction

to

Automata

Theory

Languages

and

Computation

Addison-Wesley

Reading

Massachusetts

-LSB-

-RSB-

Sverker

Jansson

AKL

a

Multiparadigm

Programming

Language

Uppsala

Theses

in

Computing

Science

SICS

Dissertation

Series

-LSB-

-RSB-

Bin

Jiang

I/O

and

CPU-optimal

recognition

of

strongly

connected

components

Information

Processing

Letters

-LCB-

-LSB-

-RSB-

Niels

Jorgensen

Chaotic

fixpoint

iteration

guided

by

dynamic

dependency

In

Cousot

et

al.

-LSB-

-RSB-

pages

-LCB-

BIBLIOGRAPHY

-LSB-

-RSB-

Niels

Jorgensen

Finding

fixpoints

in

finite

function

spaces

using

neededness

analysis

and

chaotic

iteration

In

Le

Charlier

-LSB-

-RSB-

pages

-LCB-

-LSB-

-RSB-

Gerda

Janssens

and

Wim

Simoens

On

the

implementation

of

A.I

systems

for

-LRB-

constraint

-RRB-

logic

programs

In

Fritzson

-LSB-

-RSB-

pages

-LCB-

-LSB-

-RSB-

Stephen

C.

Kleene

Introduction

to

Metamathematics

D.

van

Nostrand

Princeton

New

Jersey

-LSB-

-RSB-

Jean-Louis

Lassez

editor

Fourth

International

Conference

of

Logic

Programming

ICLP

Melbourne

May

MIT

Press

-LSB-

-RSB-

Baudouin

Le

Charlier

editor

First

International

Static

Analysis

Symposium

SAS

volume

of

Lecture

Notes

in

Computer

Science

Namur

Belgium

September

Springer-Verlag

-LSB-

-RSB-

Baudouin

Le

Charlier

Olivier

Degimbe

Laurent

Michel

and

Pascal

Van

Hentenryck

Optimization

techniques

for

general

purpose

fixpoint

algorithms

Practical

efficiency

for

the

abstract

interpretation

of

Prolog

In

Cousot

et

al.

-LSB-

-RSB-

pages

-LCB-

-LSB-

-RSB-

Baudouin

Le

Charlier

and

Pascal

Van

Hentenryck

A

universal

top-down

fixpoint

algorithm

Technical

Report

Brown

University

Computer

Science

May

-LSB-

-RSB-

John

W.

Lloyd

Foundations

of

Logic

Programming

Springer-Verlag

Berlin

second

extended

edition

edition

-LSB-

-RSB-

Steven

S.

Muchnik

and

Neil

D.

Jones

Program

Flow

Analysis

Theory

and

Applications

Prentice-Hall

Englewood

Cliffs

New

Jersey

-LSB-

-RSB-

Ulf

Nilsson

Abstract

Interpretations

Abstract

Machines

PhD

thesis

Link?oping

University

-LSB-

-RSB-

Hanne

Riis

Nielson

and

Flemming

Nielson

Bounded

fixed-point

iteration

Journal

of

Logic

and

Computation

-LRB-

-RRB-

-LCB-

August

-LSB-

-RSB-

Esko

Nuutila

and

Eljas

Soisalon-Soininen

On

finding

the

strongly

connected

components

in

a

directed

graph

Information

Processing

Letters

-LRB-

-RRB-

-LCB-

-LSB-

-RSB-

Richard

A.

O'Keefe

Finite

fixed-point

problems

In

Lassez

-LSB-

-RSB-

pages

-LCB-

-LSB-

-RSB-

Mads

Rosendahl

Higher-order

chaotic

iteration

sequences

In

Bruynooghe

and

Penjam

-LSB-

-RSB-

pages

-LCB-

-LSB-

-RSB-

Dan

Sahlin

Finding

the

least

fixed

point

using

wait-declarations

in

Prolog

In

Deransart

and

Ma

luszy?nski

-LSB-

-RSB-

pages

-LCB-

-LSB-

-RSB-

Vijay

A.

Saraswat

Concurrent

Constraint

Programming

Logic

Programming

and

Doctoral

Dissertation

Award

MIT

Press

Cambridge

Massachusetts

-LSB-

-RSB-

Leon

Sterling

and

Ehud

Shapiro

The

Art

of

Prolog

MIT

Press

Cambridge

Massachusetts

BIBLIOGRAPHY

-LSB-

-RSB-

Dan

Sahlin

and

Thomas

Sj?oland

Towards

an

analysis

tool

for

AKL

Deliverable

number

D.WP

of

the

ESPRIT

project

ParForce

ftp

Z

July

-LSB-

-RSB-

Thomas

Sj?oland

and

Dan

Sahlin

Fixpoint

analysis

of

type

and

alias

in

AKL

programs

SICS

Research

Report

b

ftp

ftp.sics.se

pub/SICS-reports/Reports

SICS-R

SE.ps.Z

January

-LSB-

-RSB-

Joseph

E.

Stoy

Denotational

Semantics

The

Scott-Strachey

Approach

to

Programming

Language

Theory

MIT

Press

Cambridge

Massachusetts

-LSB-

-RSB-

Robert

E.

Tarjan

Depth-first

search

and

linear

graph

algorithms

SIAM

Journal

of

Computing

-LRB-

-RRB-

-LCB-

June

-LSB-

-RSB-

B.

Vergauwen

J.

Wauman

and

J.

Lewi

Efficient

fixpoint

computation

In

Le

Charlier

-LSB-

-RSB-

pages

-LCB-

-LSB-

-RSB-

Horst

Zuse

Software

Complexity

Measures

and

Methods

de

Gruyter

Berlin

Appendix

A

AKL

A.

Overview

AKL

-LRB-

Agents

Kernel

Language

also

known

as

Agents

-RRB-

-LSB-

-RSB-

is

a

multiparadigm

programming

language

based

on

a

concurrent

constraint

framework

-LRB-

CCP

-RRB-

-LSB-

-RSB-

Paradigms

supported

include

imperative

-LRB-

ability

to

mutate

data-objects

e.g.

Basic

-RRB-

procedural

-LRB-

operations

associated

with

certain

data-types

e.g.

Algol

-RRB-

object-oriented

-LRB-

types

of

data-objects

with

associated

operations

and

the

ability

to

define

new

types

based

on

existing

ones

e.g.

Smalltalk

-RRB-

functional

-LRB-

evaluations

of

recursive

expressions

e.g.

Lisp

-RRB-

logical

-LRB-

deductions

from

facts

and

relations

e.g.

Prolog

-RRB-

and

process-based

-LRB-

processes

which

communicate

by

message-passing

e.g.

Erlang

-RRB-

The

unifier

of

these

paradigms

is

the

notion

of

a

constraint

system

which

is

a

collection

of

constraints

i.e.

pieces

of

partial

information

about

the

values

that

variables

can

take

and

an

entailment

relation

which

specifies

what

can

be

deduced

from

a

set

of

constraints

Instead

of

equating

a

variable

with

a

value

in

a

store

a

variable

is

specified

-LRB-

by

various

constraints

-RRB-

to

be

in

a

certain

range

e.g.

X

X

The

execution

is

then

driven

by

constraints

information

about

a

variable

can

be

added

to

the

constraint

store

and

choices

can

be

made

based

on

what

is

known

-LRB-

or

follows

logically

from

what

is

known

-RRB-

about

certain

variables

The

language

incorporates

ideas

of

predicates

as

processes

-LRB-

concurrency

-RRB-

which

synchronize

through

guard

operators

and

conditions

on

variables

-LRB-

constraints

-RRB-

without

sacrificing

the

nondeterministic

search

capabilities

of

Prolog

It

can

be

seen

as

an

effort

to

generalize

Prolog

in

a

number

of

directions

the

constraint

solving

for

equality

on

Herbrand

terms

is

generalized

to

arbitrary

constraint

domains

the

cut-operator

is

abandoned

in

favour

of

other

guard

operators

with

more

well-defined

semantics

the

introduction

of

ports

which

enhances

I/O-capabilities

and

facilitates

object-oriented

programming

techniques

the

notions

of

encapsulation

and

stability

for

taming

the

computationally

expensive

non-determinism

to

name

but

a

few

is

reassuring

to

know

that

a

constraint

system

is

nothing

but

a

complete

lattice

of

simple

constraints

where

the

entailment

relation

c

d

-LRB-

d

follows

logically

from

c

-RRB-

imposes

an

order

on

the

constraints

-LSB-

-RSB-

for

an

advanced

textbook

on

Prolog

and

-LSB-

-RSB-

for

a

rigorous

treatment

of

logic

programming

in

general

APPENDIX

A.

AKL

P

A

agent

j

D

P

D

f

p

-LRB-

x

-RRB-

A

g

definition

A

c

-LRB-

x

-RRB-

constraint

j

p

-LRB-

x

-RRB-

call

j

A

A

composition

j

x

A

hiding

j

C

choice

j

bagof

-LRB-

x

A

y

-RRB-

aggregate

C

-LRB-

x

A

A

f

x

A

A

g

-RRB-

conditional

guard

j

j

commit

guard

j

wait

guard

Table

A.

Statement

Syntax

A.

Syntax

Programs

in

AKL

can

be

written

according

to

two

different

syntaxes

either

in

the

clausal

style

of

Prolog

where

a

number

of

clauses

consisting

of

a

head

followed

by

statements

make

up

the

definition

of

a

predicate

or

in

a

more

statement-like

style

where

a

predicate

is

defined

as

a

sequence

of

statements

In

fact

the

clausal

syntax

is

just

syntactic

for

the

statement

syntax

and

set

of

simple

transformation

rules

facilitates

a

translation

between

the

two

syntaxes

of

AKL

The

syntax

presented

in

Tables

A.

and

A.

uses

the

following

conventions

Assuming

a

set

of

variables

and

names

given

a

constraint

atom

is

an

expression

of

the

form

c

-LRB-

x

-RRB-

expressing

a

constraint

on

the

variables

x

where

c

is

a

name

a

program

atom

is

an

expression

of

the

form

p

-LRB-

x

-RRB-

where

p

is

a

name

Example

A.

-LRB-

Append

-RRB-

The

classical

append

predicate

could

be

written

in

the

following

way

using

the

statement

syntax

append

-LRB-

X

Y

Z

-RRB-

-LRB-

X

-LSB-

-RSB-

Z

Y

X

-LSB-

Head

Tail

-RSB-

append

-LRB-

Tail

Y

-RRB-

Z

-LSB-

Head

-RSB-

-RRB-

alternative

way

of

coding

which

is

more

succinct

or

more

like

some

familiar

notation

It

does

not

affect

the

expressiveness

of

the

formalism

A.

SEMANTICS

P

A

agent

j

D

P

D

f

p

-LRB-

x

-RRB-

A

A

g

clausal

definition

A

c

-LRB-

x

-RRB-

constraint

j

p

-LRB-

x

-RRB-

call

j

A

A

composition

j

x

A

hiding

j

bagof

-LRB-

x

A

y

-RRB-

aggregate

conditional

guard

j

j

commit

guard

j

wait

guard

Table

A.

Clausal

Syntax

When

using

clausal

syntax

it

takes

the

form

append

-LRB-

-LSB-

-RSB-

Y

Z

-RRB-

Y

Z.

append

-LRB-

X

Y

Z

-RRB-

X

-LSB-

Head

Tail

-RSB-

Z

-LSB-

Head

-RSB-

append

-LRB-

Tail

Y

-RRB-

A.

Semantics

The

defining

semantics

of

AKL

is

given

as

an

operational

semantics

It

is

formalized

by

the

computation

model

which

is

a

labeled

transition

system

on

configurations

with

a

set

of

rewrite

rules

defining

the

transition

relation

Each

of

the

computation

rules

correspond

to

an

actual

computation

step

and

an

AKL

execution

is

a

-LRB-

possibly

non-deterministic

and

possibly

infinite

-RRB-

sequence

of

configurations

An

actual

computation

proceeds

in

a

hierarchical

system

of

state

objects

-LRB-

and

choice

and

or-boxes

-RRB-

where

each

object

has

its

local

store

of

constraints

A

constraint

solver

used

together

with

the

rewrite

rules

determines

whether

a

constraint

or

a

set

of

constraints

are

entailed

or

not

with

respect

to

the

local

constraint

store

and

all

parent

constraint

stores

The

different

guard

operators

in

the

language

provide

three

different

kinds

of

choice

deterministic

-LRB-

always

the

same

choice

under

the

same

circumstances

-RRB-

do

n't

care

nondeterministic

-LRB-

possibly

different

choices

under

the

same

circumstances

-RRB-

and

do

n't

know

nondeterministic

-LRB-

different

time-separated

choices

possible

-RRB-

As

seen

in

the

syntax

definition

a

choice

statement

has

the

form

APPENDIX

A.

AKL

-LRB-

Gn

Bn

-RRB-

where

Gi

Bi

is

a

guarded

clause

with

Gi

as

guard

and

Bi

as

body

The

guard

operator

f

j

g

must

be

the

same

in

every

guarded

clause

The

conditional

guard

-LRB-

-RRB-

is

a

way

of

ensuring

a

deterministic

conditional

branching

as

the

guards

are

evaluated

in

textual

order

and

the

first

body

which

has

all

its

guard

goals

solved

and

the

resulting

constraints

are

entailed

by

the

surrounding

computation

is

chosen

The

commit

guard

-LRB-

j'

-RRB-

facilitates

do

n't

care

nondeterminism

as

any

body

which

all

its

guard

goals

solved

and

the

resulting

constraints

entailed

by

the

surrounding

computation

can

be

chosen

The

wait

guard

-LRB-

-RRB-

provides

do

n't

know

nondeterminism

execution

proceeds

in

all

bodies

with

all

its

guard

goals

solved

Note

that

there

is

no

requirement

that

the

resulting

constraints

must

be

entailed

by

the

surrounding

environment

instead

the

-LRB-

possibly

concurrent

-RRB-

execution

of

these

bodies

is

delayed

as

far

as

possible

An

interesting

aspect

of

AKL

is

that

it

has

deep

guards

which

means

that

any

agent

expression

may

appear

before

a

guard

operator

giving

the

possibility

of

local

computations

in

nested

guards

Usually

guards

are

required

to

contain

only

constraint

expressions

and/or

built-in

predicates

Composition

expresses

concurrency

i.e.

that

the

two

components

can

proceed

independently

Hiding

is

a

way

of

introducing

local

variables

and

aggregates

are

used

as

a

means

of

interaction

between

determinate

and

nondeterminate

code

Nondeterminism

inside

an

aggregate

is

not

propagated

outside

of

it

hence

the

term

encapsulation

Appendix

B

Benchmarks

programs

from

the

AKL

demo

directory

were

analyzed

by

the

AKL

analysis

framework

-LRB-

compiled

by

the

sequential

AGENTS

system

as

of

January

-RRB-

running

on

a

Sun

SPARCstation

-LRB-

MHz

-RRB-

with

MB

of

main

memory

A

very

brief

description

of

each

program

is

given

in

Table

B.

The

results

are

presented

in

Table

B.

sorted

by

number

of

equations

where

filename

is

the

name

of

the

AKL

source

program

size

its

size

in

bytes

eqs

is

the

number

of

equations

-LRB-

or

program

points

-RRB-

in

the

equation

system

provided

by

the

AKL

analysis

framework

scc

is

the

total

number

of

strongly

connected

components

-LRB-

including

strongly

connected

components

consisting

of

a

single

vertex

-RRB-

of

the

dependency

graph

of

the

equation

system

dp

and

hd

is

the

maximum

depth

i.e.

max

ffi

-LRB-

v

-RRB-

and

the

total

number

of

heads

given

by

the

weak

topological

order

of

the

dependency

graph

respectively

Rec

-LRB-

WTO

-RRB-

and

Iter

-LRB-

WTO

-RRB-

denotes

the

recursive

and

iterative

strategy

respectively

where

both

strategies

are

based

on

a

weak

topological

order

of

the

dependency

graph

Old

-LRB-

SCC

-RRB-

denotes

the

old

iteration

strategy

based

on

strongly

connected

components

and

chains

finally

the

sub-columns

show

the

total

number

of

applications

-LRB-

appls

-RRB-

and

the

total

execution

time

in

seconds

of

the

fixpoint

solver

-LRB-

time

-RRB-

for

the

three

different

iteration

strategies

compared

A

rough

estimation

of

the

execution

time

of

AGENTS

compared

to

Prolog

and

C

is

given

by

the

following

argument

For

a

small

program

like

naive

reverse

SICStus

Prolog

-LSB-

CAA

-RSB-

running

native

code

is

about

faster

than

AGENTS

for

emulated

code

it

is

approximately

faster

The

execution

speed

of

C

is

reported

to

be

about

times

faster

than

that

of

Prolog

due

to

the

semantic

gap

between

C

and

Prolog

-LSB-

-RSB-

This

indicates

that

programs

compiled

by

the

AGENTS

system

is

in

the

order

of

to

times

slower

than

comparable

programs

compiled

by

a

standard

C

compiler

Note

however

that

it

is

notoriously

difficult

to

compare

the

implementation

of

a

declarative

language

to

an

implementation

of

an

imperative

language

as

the

comparison

pertains

to

both

language

implementation

and

the

implementation

of

the

programs

on

which

the

comparison

is

based

Montelius

-LRB-

SICS

-RRB-

personal

communication

APPENDIX

B.

BENCHMARKS

Filename

description

Solves

an

equations

system

with

unknowns

by

finite

domain

constraints

Solves

an

equations

system

with

unknowns

by

finite

domain

constraints

fd-alpha

Finite

domain

constructs

are

used

to

solve

the

alpha

cipher

fd-sendmm

Finite

domain

constructs

for

solving

SEND

MORE

MONEY

merge

The

standard

merge

predicate

proc

An

example

for

monitoring

processes

fd-five

Solves

the

five-puzzle

by

using

finite

domain

constraints

sublist

Illustrates

how

the

sublist

predicate

can

be

written

efficiently

orp

An

or-parallel

Prolog

interpreter

originally

for

Concurrent

Prolog

fd-cars

A

finite

domain

constraint

version

of

the

car

puzzle

mwmerge

An

illustration

of

the

unordered

bagof

by

means

of

merging

of

streams

ancestors

Simple

facts-relations

example

fd-magic

Finds

magic

series

by

using

finite

domain

constraints

prove

A

meta-interpreter

for

AKL

lookup

Modeling

Prolog

's

lookup

predicate

in

AKL

showing

quit/noisy

guards

kkqueen

Solves

the

N-Queens

puzzle

using

the

candidates/non-candidates

fd-suudoku

A

finite

domain

constraint

version

of

the

Japanese

game

lsqueens

Solves

the

N-Queens

puzzle

using

layered

streams

fd-queens

The

N

queens

puzzle

using

finite

domain

constraints

cube

Tick

's

Instant

insanity

program

pascal

Computes

Pascal

's

Triangle

klife

Conway

's

Game

of

Life

mastermind

Naive

generate

and

test

implementation

of

the

classical

game

life

Conway

's

Game

of

Life

turtles

Tick

's

turtle

puzzle

ghcexamples

Six

GHC

sample

programs

zebra

A

version

of

the

houses

-LRB-

zebra

-RRB-

program

by

Van

Hentenryck

puzzle

The

puzzle

program

by

Tick

waves

The

waves

program

by

Foster

knights

Solves

the

knights

tour

puzzle

queens

A

program

for

solving

the

N-queens

puzzle

semigroup

A

filter

for

unbalanced

binary

trees

money

The

classical

cryptarithmetic

puzzle

in

standard

AKL

triangle

A

hand-optimized

version

of

source

code

written

by

Okimura

cipher

Decoding

simple

substitution

ciphers

Table

B.

Program

descriptions

Filename

size

eqs

scc

dp

hd

Rec

-LRB-

WTO

-RRB-

Iter

-LRB-

WTO

-RRB-

Old

-LRB-

SCC

-RRB-

appls

time

appls

time

appls

time

fd-alpha

fd-sendmm

merge

proc

fd-five

sublist

orp

24 602 147 750

178 1576 201

fd-cars

385 242 385 241

mwmerge

ancestors

fd-magic

prove

lookup

kkqueen

fd-suudoku

50 1113 590 1686

488 3243 111

lsqueen

fd-queens

cube

2565 91 6262 249

pascal

2783 60 4942 131

klife

15 81 2835 175

mastermind

16 25 102 5227

230 4625 155 13687

life

2929 73 4590 144

turtles

109 6040 556 4219

ghcexamples

51 16 128 5365

4442 69 8476 168

zebra

35 13 124 3104

3380 67 7179 216

puzzle

13 19 118 19965

3658 5574 1150 65749

waves

16 28 121 8167

929 6710 660 17090

knights

queens

28 19 158 3210

75 7045 157

semigroup

10 41 173 17329

2327 8873 5837 36953

money

34 18 181 6068

89 5636 134 11721

triangle

22 11 167 12644

2234 7227 1063 11558

cipher

35 17 456 12202

Table

B.

Benchmarks

dependency graphs
fixpoint computations
static program analysis
strongly connected components
topological sorting
weak topological orders