analyzing recursive probabilistic programs - informatik 2 · pdf file1 introduction 2...

171
Analyzing recursive probabilistic Programs Justin Winkens 30. June 2016 Justin Winkens | 29. Juni 2016 0/42 Justin Winkens | 30. June 2016 1/42

Upload: dangtruc

Post on 07-Feb-2018

218 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Analyzing recursive probabilisticProgramsJustin Winkens

30. June 2016

Justin Winkens | 29. Juni 2016 0/42Justin Winkens | 30. June 2016 1/42

Page 2: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 Introduction

2 Preliminaries

3 Translating pGCL to pPDA

4 Analyzing Probabilistic Pushdown Automata

Table of contents

Justin Winkens | 30. June 2016 2/42

Page 3: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 Introduction

2 Preliminaries

3 Translating pGCL to pPDA

4 Analyzing Probabilistic Pushdown Automata

Introduction

Justin Winkens | 30. June 2016 3/42

Page 4: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Input ProbabilisticProgram

Output

Introduction

Probabilistic Programs

Justin Winkens | 30. June 2016 4/42

Page 5: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Input ProbabilisticProgram

Output

Introduction

Probabilistic Programs

Justin Winkens | 30. June 2016 4/42

Page 6: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Input ProbabilisticProgram

Output

TrueSkillTM

Introduction

Probabilistic Programs

Justin Winkens | 30. June 2016 4/42

Page 7: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Input ProbabilisticProgram

Output

TrueSkillTM self-testing/correcting

Introduction

Probabilistic Programs

Justin Winkens | 30. June 2016 4/42

Page 8: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Input ProbabilisticProgram

Output

TrueSkillTM self-testing/correcting

biology

Introduction

Probabilistic Programs

Justin Winkens | 30. June 2016 4/42

Page 9: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Input ProbabilisticProgram

Output

TrueSkillTM self-testing/correcting

biology networks

Introduction

Probabilistic Programs

Justin Winkens | 30. June 2016 4/42

Page 10: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Input ProbabilisticProgram

Output

TrueSkillTM self-testing/correcting

biology networks Picture

Introduction

Probabilistic Programs

Justin Winkens | 30. June 2016 4/42

Page 11: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 algorithm quicksort(A) is

2 list less , equal , greater

3 if length(A) <= 1

4 return A

5 pivot := A[length(A)]

6 for x in A

7 if x < pivot then append x to less

8 if x = pivot then append x to equal

9 if x > pivot then append x to greater

10 return concat(quicksort(less), equal ,quicksort(greater ))

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 5/42

Page 12: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 algorithm quicksort(A) is

2 list less , equal , greater

3 if length(A) <= 1

4 return A

5 pivot := A[length(A)]

6 for x in A

7 if x < pivot then append x to less

8 if x = pivot then append x to equal

9 if x > pivot then append x to greater

10 return concat(quicksort(less), equal ,quicksort(greater ))

) Average case complexity O(n log n)

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 5/42

Page 13: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 algorithm quicksort(A) is

2 list less , equal , greater

3 if length(A) <= 1

4 return A

5 pivot := A[length(A)]

6 for x in A

7 if x < pivot then append x to less

8 if x = pivot then append x to equal

9 if x > pivot then append x to greater

10 return concat(quicksort(less), equal ,quicksort(greater ))

) Average case complexity O(n log n)) Worst case complexity O(n2

)

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 5/42

Page 14: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 algorithm quicksort(A) is

2 list less , equal , greater

3 if length(A) <= 1

4 return A

5 pivot := uniformSel(A)

6 for x in A

7 if x < pivot then append x to less

8 if x = pivot then append x to equal

9 if x > pivot then append x to greater

10 return concat(quicksort(less), equal ,quicksort(greater ))

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 5/42

Page 15: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 algorithm quicksort(A) is

2 list less , equal , greater

3 if length(A) <= 1

4 return A

5 pivot := uniformSel(A)

6 for x in A

7 if x < pivot then append x to less

8 if x = pivot then append x to equal

9 if x > pivot then append x to greater

10 return concat(quicksort(less), equal ,quicksort(greater ))

) Worst case far less likely!

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 5/42

Page 16: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We wish to...

I ...reason about a programs behaviorI ...estimate expected outcomes and runtimesI ...quantify probabilities

I Recursive programs written in the probabilistic Guarded CommandLanguage

I Analysis by using probabilistic pushdown automata

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 6/42

Page 17: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We wish to...I ...reason about a programs behavior

I ...estimate expected outcomes and runtimesI ...quantify probabilities

I Recursive programs written in the probabilistic Guarded CommandLanguage

I Analysis by using probabilistic pushdown automata

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 6/42

Page 18: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We wish to...I ...reason about a programs behaviorI ...estimate expected outcomes and runtimes

I ...quantify probabilitiesI Recursive programs written in the probabilistic Guarded Command

LanguageI Analysis by using probabilistic pushdown automata

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 6/42

Page 19: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We wish to...I ...reason about a programs behaviorI ...estimate expected outcomes and runtimesI ...quantify probabilities

I Recursive programs written in the probabilistic Guarded CommandLanguage

I Analysis by using probabilistic pushdown automata

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 6/42

Page 20: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We wish to...I ...reason about a programs behaviorI ...estimate expected outcomes and runtimesI ...quantify probabilities

I Recursive programs written in the probabilistic Guarded CommandLanguage

I Analysis by using probabilistic pushdown automata

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 6/42

Page 21: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We wish to...I ...reason about a programs behaviorI ...estimate expected outcomes and runtimesI ...quantify probabilities

I Recursive programs written in the probabilistic Guarded CommandLanguage

I Analysis by using probabilistic pushdown automata

Introduction

Recursive Probabilistic Programs

Justin Winkens | 30. June 2016 6/42

Page 22: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 Introduction

2 Preliminaries

3 Translating pGCL to pPDA

4 Analyzing Probabilistic Pushdown Automata

Preliminaries

Justin Winkens | 30. June 2016 7/42

Page 23: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

ControlUnit

p

... a b a d ...

Input tape

c

a

f...

h

a

b

Stack

Preliminaries Probabilistic Pushdown Automata

Pushdown Automata

Justin Winkens | 30. June 2016 8/42

Page 24: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined as

I Q is a finite set of states.I

� is a finite stack alphabet.I ,!✓ (Q⇥ �)⇥ (Q⇥ �

⇤) is a set of transitions such that

I for every pX 2 Q⇥ � there is at least one transition of the formpX ,! q↵

I for every transition pX ,! q↵ we have that |↵| 2.

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 9/42

Page 25: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI Q is a finite set of states.

I� is a finite stack alphabet.

I ,!✓ (Q⇥ �)⇥ (Q⇥ �

⇤) is a set of transitions such that

I for every pX 2 Q⇥ � there is at least one transition of the formpX ,! q↵

I for every transition pX ,! q↵ we have that |↵| 2.

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 9/42

Page 26: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI Q is a finite set of states.I

� is a finite stack alphabet.

I ,!✓ (Q⇥ �)⇥ (Q⇥ �

⇤) is a set of transitions such that

I for every pX 2 Q⇥ � there is at least one transition of the formpX ,! q↵

I for every transition pX ,! q↵ we have that |↵| 2.

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 9/42

Page 27: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI Q is a finite set of states.I

� is a finite stack alphabet.I ,!✓ (Q⇥ �)⇥ (Q⇥ �

⇤) is a set of transitions such that

I for every pX 2 Q⇥ � there is at least one transition of the formpX ,! q↵

I for every transition pX ,! q↵ we have that |↵| 2.

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 9/42

Page 28: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI Q is a finite set of states.I

� is a finite stack alphabet.I ,!✓ (Q⇥ �)⇥ (Q⇥ �

⇤) is a set of transitions such that

I for every pX 2 Q⇥ � there is at least one transition of the formpX ,! q↵

I for every transition pX ,! q↵ we have that |↵| 2.

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 9/42

Page 29: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI Q is a finite set of states.I

� is a finite stack alphabet.I ,!✓ (Q⇥ �)⇥ (Q⇥ �

⇤) is a set of transitions such that

I for every pX 2 Q⇥ � there is at least one transition of the formpX ,! q↵

I for every transition pX ,! q↵ we have that |↵| 2.

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 9/42

Page 30: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI P is a function which assigns probabilities to transitions

I P(pX ,! q↵) 2 [0, 1]

IP

pX,!q↵

P(pX ,! q↵) = 1

I We write pXx

,! q↵ instead of P(pX ,! q↵) = x

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 10/42

Page 31: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI P is a function which assigns probabilities to transitions

I P(pX ,! q↵) 2 [0, 1]

IP

pX,!q↵

P(pX ,! q↵) = 1

I We write pXx

,! q↵ instead of P(pX ,! q↵) = x

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 10/42

Page 32: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI P is a function which assigns probabilities to transitions

I P(pX ,! q↵) 2 [0, 1]

IP

pX,!q↵

P(pX ,! q↵) = 1

I We write pXx

,! q↵ instead of P(pX ,! q↵) = x

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 10/42

Page 33: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Probabilistic Pushdown Automaton (pPDA)

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI P is a function which assigns probabilities to transitions

I P(pX ,! q↵) 2 [0, 1]

IP

pX,!q↵

P(pX ,! q↵) = 1

I We write pXx

,! q↵ instead of P(pX ,! q↵) = x

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 10/42

Page 34: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Example pPDA

A pPDA � is given by:I Q = {q}I

� = {I}I qI

0.5,! qII , qI

0.5,! q✏

Preliminaries Probabilistic Pushdown Automata

Example pPDA

Justin Winkens | 30. June 2016 11/42

Page 35: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Example pPDA

A pPDA � is given by:I Q = {q}I

� = {I}I qI

0.5,! qII , qI

0.5,! q✏

What does this pPDA represent?

Preliminaries Probabilistic Pushdown Automata

Example pPDA

Justin Winkens | 30. June 2016 11/42

Page 36: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Example pPDA

A pPDA � is given by:I Q = {q}I

� = {I}I qI

0.5,! qII , qI

0.5,! q✏

q"

qI

qII qIII qIIII ...

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

Preliminaries Probabilistic Pushdown Automata

Example pPDA

Justin Winkens | 30. June 2016 11/42

Page 37: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Example pPDA

A pPDA � is given by:I Q = {q}I

� = {I}I qI

0.5,! qII , qI

0.5,! q✏

q" qI qII

qIII qIIII ...

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

Preliminaries Probabilistic Pushdown Automata

Example pPDA

Justin Winkens | 30. June 2016 11/42

Page 38: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Example pPDA

A pPDA � is given by:I Q = {q}I

� = {I}I qI

0.5,! qII , qI

0.5,! q✏

q" qI qII qIII

qIIII ...

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

Preliminaries Probabilistic Pushdown Automata

Example pPDA

Justin Winkens | 30. June 2016 11/42

Page 39: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Example pPDA

A pPDA � is given by:I Q = {q}I

� = {I}I qI

0.5,! qII , qI

0.5,! q✏

q" qI qII qIII qIIII ...

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

Preliminaries Probabilistic Pushdown Automata

Example pPDA

Justin Winkens | 30. June 2016 11/42

Page 40: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Example pPDA

A pPDA � is given by:I Q = {q}I

� = {I}I qI

0.5,! qII , qI

0.5,! q✏

q" qI qII qIII qIIII ...

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

0.5

) Termination on empty stack!

Preliminaries Probabilistic Pushdown Automata

Example pPDA

Justin Winkens | 30. June 2016 11/42

Page 41: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Example pPDA

A pPDA � is given by:I Q = {q}I

� = {I}I qI

0.5,! qII , qI

0.5,! q✏

What could an unbounded random walk look like?

Preliminaries Probabilistic Pushdown Automata

Example pPDA

Justin Winkens | 30. June 2016 11/42

Page 42: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Regular Configurations

Let � = (Q,�, ,!,P) be a pPDA and C ✓ Q⇥�

⇤ a set of configurations.

We call C regular if p↵ 2 C iff the reversed stack of p↵ is accepted by adeterministic finite-state automaton (DFA) A.

We call C simple if there exists a set H ✓ Q⇥ � such that p↵ 2 C iff↵ 6= " and head(p↵) 2 H.

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 12/42

Page 43: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Regular Configurations

Let � = (Q,�, ,!,P) be a pPDA and C ✓ Q⇥�

⇤ a set of configurations.

We call C regular if p↵ 2 C iff the reversed stack of p↵ is accepted by adeterministic finite-state automaton (DFA) A.

We call C simple if there exists a set H ✓ Q⇥ � such that p↵ 2 C iff↵ 6= " and head(p↵) 2 H.

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 12/42

Page 44: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Regular Configurations

Let � = (Q,�, ,!,P) be a pPDA and C ✓ Q⇥�

⇤ a set of configurations.

We call C regular if p↵ 2 C iff the reversed stack of p↵ is accepted by adeterministic finite-state automaton (DFA) A.

We call C simple if there exists a set H ✓ Q⇥ � such that p↵ 2 C iff↵ 6= " and head(p↵) 2 H.

Preliminaries Probabilistic Pushdown Automata

Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 12/42

Page 45: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Paths and RunsLet S be a set of states and !✓ S⇥S a binary and total relation andP = (S,!).

I A path is a word w such that w(i) ! w(i+ 1) for everyi 2 {0, . . . , |w|� 1}

I A state t is reachable from s if there is a finite path w with w(0) = sand w(|w|� 1) = t.

I A run is an infinite path.I Runs(P,w) = set of all runs in P that start with w

Preliminaries Notions

Paths, Runs

Justin Winkens | 30. June 2016 13/42

Page 46: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Paths and RunsLet S be a set of states and !✓ S⇥S a binary and total relation andP = (S,!).I A path is a word w such that w(i) ! w(i+ 1) for every

i 2 {0, . . . , |w|� 1}

I A state t is reachable from s if there is a finite path w with w(0) = sand w(|w|� 1) = t.

I A run is an infinite path.I Runs(P,w) = set of all runs in P that start with w

Preliminaries Notions

Paths, Runs

Justin Winkens | 30. June 2016 13/42

Page 47: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Paths and RunsLet S be a set of states and !✓ S⇥S a binary and total relation andP = (S,!).I A path is a word w such that w(i) ! w(i+ 1) for every

i 2 {0, . . . , |w|� 1}I A state t is reachable from s if there is a finite path w with w(0) = s

and w(|w|� 1) = t.

I A run is an infinite path.I Runs(P,w) = set of all runs in P that start with w

Preliminaries Notions

Paths, Runs

Justin Winkens | 30. June 2016 13/42

Page 48: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Paths and RunsLet S be a set of states and !✓ S⇥S a binary and total relation andP = (S,!).I A path is a word w such that w(i) ! w(i+ 1) for every

i 2 {0, . . . , |w|� 1}I A state t is reachable from s if there is a finite path w with w(0) = s

and w(|w|� 1) = t.I A run is an infinite path.

I Runs(P,w) = set of all runs in P that start with w

Preliminaries Notions

Paths, Runs

Justin Winkens | 30. June 2016 13/42

Page 49: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Paths and RunsLet S be a set of states and !✓ S⇥S a binary and total relation andP = (S,!).I A path is a word w such that w(i) ! w(i+ 1) for every

i 2 {0, . . . , |w|� 1}I A state t is reachable from s if there is a finite path w with w(0) = s

and w(|w|� 1) = t.I A run is an infinite path.I Runs(P,w) = set of all runs in P that start with w

Preliminaries Notions

Paths, Runs

Justin Winkens | 30. June 2016 13/42

Page 50: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Reachability

Let � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand C ✓ Q⇥ �

⇤ a set of target configurations.

I Reach(pX, C) set of all runs r 2 Runs(�, pX) with r(i) 2 C, i 2 N0

I P(Reach(pX, C))

Preliminaries Notions

Reachability

Justin Winkens | 30. June 2016 14/42

Page 51: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Reachability

Let � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand C ✓ Q⇥ �

⇤ a set of target configurations.

I Reach(pX, C) set of all runs r 2 Runs(�, pX) with r(i) 2 C, i 2 N0

I P(Reach(pX, C))

Preliminaries Notions

Reachability

Justin Winkens | 30. June 2016 14/42

Page 52: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Reachability

Let � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand C ✓ Q⇥ �

⇤ a set of target configurations.

I Reach(pX, C) set of all runs r 2 Runs(�, pX) with r(i) 2 C, i 2 N0

I P(Reach(pX, C))

Preliminaries Notions

Reachability

Justin Winkens | 30. June 2016 14/42

Page 53: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: TerminationLet � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand q 2 Q a (final) state.

I Reach(pX, {q"}) set of all runs r 2 Runs(�, pX) with r(i) = q",i 2 N0.

I P(Reach(pX, {q"})).

Preliminaries Notions

Termination

Justin Winkens | 30. June 2016 15/42

Page 54: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: TerminationLet � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand q 2 Q a (final) state.

I Reach(pX, {q"}) set of all runs r 2 Runs(�, pX) with r(i) = q",i 2 N0.

I P(Reach(pX, {q"})).

Preliminaries Notions

Termination

Justin Winkens | 30. June 2016 15/42

Page 55: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: TerminationLet � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand q 2 Q a (final) state.

I Reach(pX, {q"}) set of all runs r 2 Runs(�, pX) with r(i) = q",i 2 N0.

I P(Reach(pX, {q"})).

Preliminaries Notions

Termination

Justin Winkens | 30. June 2016 15/42

Page 56: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Qualitative/Quantitative Reachability/Termination

Let � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand C ✓ Q⇥ �

⇤ a set of target configurations.

I Qualitative reachability/termination: P(Reach(pX,C)) = 1?I Quantitative reachability/termination: P(Reach(pX,C)) d for a

constant d 2 (0, 1)?

Preliminaries Notions

Qualitative/Quantitative Reachability/Termination

Justin Winkens | 30. June 2016 16/42

Page 57: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Qualitative/Quantitative Reachability/Termination

Let � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand C ✓ Q⇥ �

⇤ a set of target configurations.I Qualitative reachability/termination: P(Reach(pX,C)) = 1?

I Quantitative reachability/termination: P(Reach(pX,C)) d for aconstant d 2 (0, 1)?

Preliminaries Notions

Qualitative/Quantitative Reachability/Termination

Justin Winkens | 30. June 2016 16/42

Page 58: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Qualitative/Quantitative Reachability/Termination

Let � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand C ✓ Q⇥ �

⇤ a set of target configurations.I Qualitative reachability/termination: P(Reach(pX,C)) = 1?I Quantitative reachability/termination: P(Reach(pX,C)) d for a

constant d 2 (0, 1)?

Preliminaries Notions

Qualitative/Quantitative Reachability/Termination

Justin Winkens | 30. June 2016 16/42

Page 59: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

skip | abort | var x | x:=E | Q;R | {Q}[ ]{R} | {Q}[p]{R}if(G){Q}else{R} | while(G){Q}

Preliminaries Probabilistic Guarded Command Language

Probabilistic Guarded Command Language

Justin Winkens | 30. June 2016 17/42

Page 60: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

skip | abort | var x | x:=E | Q;R | {Q}[ ]{R} | {Q}[p]{R}if(G){Q}else{R} | while(G){Q}

Preliminaries Probabilistic Guarded Command Language

Probabilistic Guarded Command Language

Justin Winkens | 30. June 2016 17/42

Page 61: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

skip | abort | var x | x:=E | Q;R | {Q}[ ]{R} | {Q}[p]{R}if(G){Q}else{R} | while(G){Q}

1 var flip := true;

2 flip (){

3 while(flip){

4 {skip ;}[0.5]{ flip = false;}

5 }

6 }

Preliminaries Probabilistic Guarded Command Language

Probabilistic Guarded Command Language

Justin Winkens | 30. June 2016 17/42

Page 62: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

skip | abort | var x | x:=E | Q;R | {Q}[ ]{R} | {Q}[p]{R}if(G){Q}else{R} | while(G){Q}

1 var flip := true;

2 flip (){

3 while(flip){

4 {skip ;}[0.5]{ flip = false;}

5 }

6 }

We allow function calls!

Preliminaries Probabilistic Guarded Command Language

Probabilistic Guarded Command Language

Justin Winkens | 30. June 2016 17/42

Page 63: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Preliminaries Probabilistic Guarded Command Language

Dueling Cowboys

Justin Winkens | 30. June 2016 18/42

Page 64: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 var cowboy := A;

2 var duel:= true;

3

4 {cowboy := A;}[p]{ cowboy := B;}

5

6 while(duel){

7 if(cowboy = A){

8 {duel := false ;}[a]{ cowboy := B;}

9 }else{

10 {duel := false ;}[b]{ cowboy := A;}

11 }

12 }

Preliminaries Probabilistic Guarded Command Language

Dueling Cowboys (Orig.)

Justin Winkens | 30. June 2016 19/42

Page 65: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

1 kill (){ //k02

3 }

How do we analyze this?

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

Preliminaries Probabilistic Guarded Command Language

Dueling Cowboys (Rec.)

Justin Winkens | 30. June 2016 20/42

Page 66: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

1 kill (){ //k02

3 }

How do we analyze this?

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

Preliminaries Probabilistic Guarded Command Language

Dueling Cowboys (Rec.)

Justin Winkens | 30. June 2016 20/42

Page 67: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

1 kill (){ //k02

3 }

How do we analyze this?

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

Preliminaries Probabilistic Guarded Command Language

Dueling Cowboys (Rec.)

Justin Winkens | 30. June 2016 20/42

Page 68: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

1 kill (){ //k02

3 }

How do we analyze this?

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

Preliminaries Probabilistic Guarded Command Language

Dueling Cowboys (Rec.)

Justin Winkens | 30. June 2016 20/42

Page 69: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 Introduction

2 Preliminaries

3 Translating pGCL to pPDA

4 Analyzing Probabilistic Pushdown Automata

Translating pGCL to pPDA

Justin Winkens | 30. June 2016 21/42

Page 70: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

2 Steps:

1. Translate pGCL program to control flow graph2. Translate control flow graph to pPDA

Translating pGCL to pPDA

Translating pGCL to pPDA

Justin Winkens | 30. June 2016 22/42

Page 71: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

2 Steps:1. Translate pGCL program to control flow graph

2. Translate control flow graph to pPDA

Translating pGCL to pPDA

Translating pGCL to pPDA

Justin Winkens | 30. June 2016 22/42

Page 72: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

2 Steps:1. Translate pGCL program to control flow graph2. Translate control flow graph to pPDA

Translating pGCL to pPDA

Translating pGCL to pPDA

Justin Winkens | 30. June 2016 22/42

Page 73: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Pick control points (k0,d0,d1,s0,...,s6) as nodes

I Connect nodes by edges if control flows from one node to the nextI Label edges with statements and transition probability (if 6= 1)

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 23/42

Page 74: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Pick control points (k0,d0,d1,s0,...,s6) as nodesI Connect nodes by edges if control flows from one node to the next

I Label edges with statements and transition probability (if 6= 1)

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 23/42

Page 75: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Pick control points (k0,d0,d1,s0,...,s6) as nodesI Connect nodes by edges if control flows from one node to the nextI Label edges with statements and transition probability (if 6= 1)

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 23/42

Page 76: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Pick control points (k0,d0,d1,s0,...,s6) as nodesI Connect nodes by edges if control flows from one node to the nextI Label edges with statements and transition probability (if 6= 1)

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 23/42

Page 77: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Pick control points (k0,d0,d1,s0,...,s6) as nodesI Connect nodes by edges if control flows from one node to the nextI Label edges with statements and transition probability (if 6= 1)

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 23/42

Page 78: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Pick control points (k0,d0,d1,s0,...,s6) as nodesI Connect nodes by edges if control flows from one node to the nextI Label edges with statements and transition probability (if 6= 1)

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 23/42

Page 79: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Pick control points (k0,d0,d1,s0,...,s6) as nodesI Connect nodes by edges if control flows from one node to the nextI Label edges with statements and transition probability (if 6= 1)

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 23/42

Page 80: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Pick control points (k0,d0,d1,s0,...,s6) as nodesI Connect nodes by edges if control flows from one node to the nextI Label edges with statements and transition probability (if 6= 1)

1 var player := A;

2 duel (){ //d03 {player :=A;}[p]{ player :=B;}

4 shoot (); //d15 }

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 23/42

Page 81: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

s0

s1 s2

s3 s4 s5 s6

if else if

skill()

1� splayer := B

shoot()

tkill()

1� tplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 24/42

Page 82: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

s0

s1 s2

s3 s4 s5 s6

if else if

skill()

1� splayer := B

shoot()

tkill()

1� tplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 24/42

Page 83: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

s0

s1 s2

s3 s4 s5 s6

if else if

skill()

1� splayer := B

shoot()

tkill()

1� tplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 24/42

Page 84: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

s0

s1 s2

s3 s4

s5 s6

if else if

skill()

1� splayer := B

shoot()

tkill()

1� tplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 24/42

Page 85: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

s0

s1 s2

s3 s4 s5 s6

if else if

skill()

1� splayer := B

shoot()

tkill()

1� tplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 24/42

Page 86: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 shoot (){ //s02 if(player == A){ //s13 {

4 kill (); //s35 }

6 [s]

7 {

8 player := B;

9 shoot (); //s410 }

11 }

12 else if(player == B){//s213 {

14 kill (); //s515 }

16 [t]

17 {

18 player := A;

19 shoot (); //s620 }

21 }

22 }

s0

s1 s2

s3 s4 s5 s6

if else if

skill()

1� splayer := B

shoot()

tkill()

1� tplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 24/42

Page 87: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 kill (){ //k02

3 }

k0

Why do we have this method?I It yields an “easy” head (pk0) for analysisI All configuration with head pk0 terminate) Picking good control points and methods is key!

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 25/42

Page 88: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 kill (){ //k02

3 }

k0

Why do we have this method?I It yields an “easy” head (pk0) for analysisI All configuration with head pk0 terminate) Picking good control points and methods is key!

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 25/42

Page 89: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 kill (){ //k02

3 }

k0

Why do we have this method?

I It yields an “easy” head (pk0) for analysisI All configuration with head pk0 terminate) Picking good control points and methods is key!

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 25/42

Page 90: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 kill (){ //k02

3 }

k0

Why do we have this method?I It yields an “easy” head (pk0) for analysis

I All configuration with head pk0 terminate) Picking good control points and methods is key!

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 25/42

Page 91: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 kill (){ //k02

3 }

k0

Why do we have this method?I It yields an “easy” head (pk0) for analysisI All configuration with head pk0 terminate

) Picking good control points and methods is key!

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 25/42

Page 92: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 kill (){ //k02

3 }

k0

Why do we have this method?I It yields an “easy” head (pk0) for analysisI All configuration with head pk0 terminate) Picking good control points and methods is key!

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 25/42

Page 93: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

k0

s0

s1 s2

s3 s4 s5 s6

if else if

skill()

1� splayer := B

shoot()

tkill()

1� tplayer := A

shoot()

Translating pGCL to pPDA

pGCL ! Control Flow Graph

Justin Winkens | 30. June 2016 26/42

Page 94: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Reminder: pPDA

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI Q is a finite set of states.I

� is a finite stack alphabet.I ,!✓ (Q⇥ �)⇥ (Q⇥ �

⇤) is a set of transitions

I P is a function which assigns probabilities to transitions

How does this relate to control flow graphs?

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 27/42

Page 95: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Reminder: pPDA

A probabilistic pushdown automaton (pPDA) is a tuple � = (Q,�, ,!,P)

defined asI Q is a finite set of states.I

� is a finite stack alphabet.I ,!✓ (Q⇥ �)⇥ (Q⇥ �

⇤) is a set of transitions

I P is a function which assigns probabilities to transitions

How does this relate to control flow graphs?

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 27/42

Page 96: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 28/42

Page 97: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Q: Variable assignments

I�: Nodes in the graph

I P: Probabilities of the edgesI ,!: ???

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 29/42

Page 98: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Q: Variable assignmentsI

�: Nodes in the graph

I P: Probabilities of the edgesI ,!: ???

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 29/42

Page 99: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Q: Variable assignmentsI

�: Nodes in the graphI P: Probabilities of the edges

I ,!: ???

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 29/42

Page 100: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I Q: Variable assignmentsI

�: Nodes in the graphI P: Probabilities of the edgesI ,!: ???

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 29/42

Page 101: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I construct every pair Q⇥ �

I for each pair hq, �i 2 Q⇥ � consider edges of the control flow graph:I hq, �i ,! hq0, �0i if no function call between � and �0

I hq, �i ,! hq0,'�0i if function call between � and �0

I �0 return addressI ' entry point of function call

I hq, �i ,! hq0, "i if function call terminates

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 30/42

Page 102: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I construct every pair Q⇥ �

I for each pair hq, �i 2 Q⇥ � consider edges of the control flow graph:

I hq, �i ,! hq0, �0i if no function call between � and �0

I hq, �i ,! hq0,'�0i if function call between � and �0

I �0 return addressI ' entry point of function call

I hq, �i ,! hq0, "i if function call terminates

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 30/42

Page 103: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I construct every pair Q⇥ �

I for each pair hq, �i 2 Q⇥ � consider edges of the control flow graph:I hq, �i ,! hq0, �0i if no function call between � and �0

I hq, �i ,! hq0,'�0i if function call between � and �0

I �0 return addressI ' entry point of function call

I hq, �i ,! hq0, "i if function call terminates

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 30/42

Page 104: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I construct every pair Q⇥ �

I for each pair hq, �i 2 Q⇥ � consider edges of the control flow graph:I hq, �i ,! hq0, �0i if no function call between � and �0

I hq, �i ,! hq0,'�0i if function call between � and �0

I �0 return addressI ' entry point of function call

I hq, �i ,! hq0, "i if function call terminates

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 30/42

Page 105: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I construct every pair Q⇥ �

I for each pair hq, �i 2 Q⇥ � consider edges of the control flow graph:I hq, �i ,! hq0, �0i if no function call between � and �0

I hq, �i ,! hq0,'�0i if function call between � and �0

I �0 return addressI ' entry point of function call

I hq, �i ,! hq0, "i if function call terminates

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 30/42

Page 106: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I construct every pair Q⇥ �

I for each pair hq, �i 2 Q⇥ � consider edges of the control flow graph:I hq, �i ,! hq0, �0i if no function call between � and �0

I hq, �i ,! hq0,'�0i if function call between � and �0

I �0 return addressI ' entry point of function call

I hq, �i ,! hq0, "i if function call terminates

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 30/42

Page 107: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

k0

hAk0i 1,! hA"i

hBk0i 1,! hB"i

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 31/42

Page 108: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

k0 hAk0i 1,! hA"i

hBk0i 1,! hB"i

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 31/42

Page 109: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

hAd0i p,! hAs0d1i

hAd0i 1�p,! hBs0d1i

hAd1i 1,! hA"i

hBd1i 1,! hB"i

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 32/42

Page 110: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

d0

d1

1� pplayer := B

shoot()

pplayer := A

shoot()

hAd0i p,! hAs0d1i

hAd0i 1�p,! hBs0d1i

hAd1i 1,! hA"i

hBd1i 1,! hB"i

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 32/42

Page 111: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

s0

s1 s2

s3 s4 s5 s6

if else if

skill()

1� splayer := B

shoot()

tkill()

1� tplayer := A

shoot()

hAs0i 1,! hAs1i

hBs0i 1,! hBs2i

hAs1i s,! hAk0s3i

hAs1i 1�s,! hBs0s4i

hAs3i 1,! hA"i

hAs4i 1,! hA"i

hBs4i 1,! hB"i

hBs2i t,! hBk0s5i

hBs2i 1�t,! hAs0s6i

hBs5i 1,! hB"i

hBs6i 1,! hB"i

hAs6i 1,! hA"i

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 33/42

Page 112: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

s0

s1 s2

s3 s4 s5 s6

if else if

skill()

1� splayer := B

shoot()

tkill()

1� tplayer := A

shoot()

hAs0i 1,! hAs1i

hBs0i 1,! hBs2i

hAs1i s,! hAk0s3i

hAs1i 1�s,! hBs0s4i

hAs3i 1,! hA"i

hAs4i 1,! hA"i

hBs4i 1,! hB"i

hBs2i t,! hBk0s5i

hBs2i 1�t,! hAs0s6i

hBs5i 1,! hB"i

hBs6i 1,! hB"i

hAs6i 1,! hA"i

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 33/42

Page 113: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

hAd0i p,! hAs0d1i

hAd0i 1�p,! hBs0d1i

hAd1i 1,! hA"i

hBd1i 1,! hB"i

hAs0i 1,! hAs1i

hBs0i 1,! hBs2i

hAs1i s,! hAk0s3i

hAs1i 1�s,! hBs0s4i

hAs3i 1,! hA"i

hAs4i 1,! hA"i

hBs4i 1,! hB"i

hBs2i t,! hBk0s5i

hBs2i 1�t,! hAs0s6i

hBs5i 1,! hB"i

hBs6i 1,! hB"i

hAs6i 1,! hA"i

hAk0i 1,! hA"i

hBk0i 1,! hB"i

Translating pGCL to pPDA

Control Flow Graph ! pPDA

Justin Winkens | 30. June 2016 34/42

Page 114: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

1 Introduction

2 Preliminaries

3 Translating pGCL to pPDA

4 Analyzing Probabilistic Pushdown Automata

Analyzing Probabilistic Pushdown Automata

Justin Winkens | 30. June 2016 35/42

Page 115: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Properties of pPDA

Let � = (Q,�, ,!,P) be a pPDA, pX 2 Q⇥ � an initial configurationand C ✓ Q⇥ �

⇤ a set of target configurations.I Qualitative reachability/termination: P(Reach(pX,C)) = 1?I Quantitative reachability/termination: P(Reach(pX,C)) d for a

constant d 2 (0, 1)?

Analyzing Probabilistic Pushdown Automata

Reminder: Properties of pPDA

Justin Winkens | 30. June 2016 36/42

Page 116: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

We solve this problem for a simple set of target configurations.

) Extensible to regular sets of target configurations

NotationLet � = (Q,�, ,!,P) be a pPDA, C ✓ Q⇥ �

⇤ a simple set of targetconfigurations and H be the associated set of heads.

I[pX•] = P(Reach(pX, C))

I[pXq] = probability of all r 2 Reach(pX, {q"}) that do not visit C

For pX 2 H:I

[pX•] = 1

I[pXq] = 0

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 37/42

Page 117: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

We solve this problem for a simple set of target configurations.) Extensible to regular sets of target configurations

NotationLet � = (Q,�, ,!,P) be a pPDA, C ✓ Q⇥ �

⇤ a simple set of targetconfigurations and H be the associated set of heads.

I[pX•] = P(Reach(pX, C))

I[pXq] = probability of all r 2 Reach(pX, {q"}) that do not visit C

For pX 2 H:I

[pX•] = 1

I[pXq] = 0

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 37/42

Page 118: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

We solve this problem for a simple set of target configurations.) Extensible to regular sets of target configurations

NotationLet � = (Q,�, ,!,P) be a pPDA, C ✓ Q⇥ �

⇤ a simple set of targetconfigurations and H be the associated set of heads.

I[pX•] = P(Reach(pX, C))

I[pXq] = probability of all r 2 Reach(pX, {q"}) that do not visit C

For pX 2 H:I

[pX•] = 1

I[pXq] = 0

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 37/42

Page 119: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

We solve this problem for a simple set of target configurations.) Extensible to regular sets of target configurations

NotationLet � = (Q,�, ,!,P) be a pPDA, C ✓ Q⇥ �

⇤ a simple set of targetconfigurations and H be the associated set of heads.

I[pX•] = P(Reach(pX, C))

I[pXq] = probability of all r 2 Reach(pX, {q"}) that do not visit C

For pX 2 H:I

[pX•] = 1

I[pXq] = 0

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 37/42

Page 120: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

We solve this problem for a simple set of target configurations.) Extensible to regular sets of target configurations

NotationLet � = (Q,�, ,!,P) be a pPDA, C ✓ Q⇥ �

⇤ a simple set of targetconfigurations and H be the associated set of heads.

I[pX•] = P(Reach(pX, C))

I[pXq] = probability of all r 2 Reach(pX, {q"}) that do not visit C

For pX 2 H:I

[pX•] = 1

I[pXq] = 0

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 37/42

Page 121: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

We solve this problem for a simple set of target configurations.) Extensible to regular sets of target configurations

NotationLet � = (Q,�, ,!,P) be a pPDA, C ✓ Q⇥ �

⇤ a simple set of targetconfigurations and H be the associated set of heads.

I[pX•] = P(Reach(pX, C))

I[pXq] = probability of all r 2 Reach(pX, {q"}) that do not visit C

For pX 2 H:

I[pX•] = 1

I[pXq] = 0

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 37/42

Page 122: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

We solve this problem for a simple set of target configurations.) Extensible to regular sets of target configurations

NotationLet � = (Q,�, ,!,P) be a pPDA, C ✓ Q⇥ �

⇤ a simple set of targetconfigurations and H be the associated set of heads.

I[pX•] = P(Reach(pX, C))

I[pXq] = probability of all r 2 Reach(pX, {q"}) that do not visit C

For pX 2 H:I

[pX•] = 1

I[pXq] = 0

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 37/42

Page 123: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

For pX /2 H:

[pX•] =X

pXx

,!rY

x·[rY •]+X

pXx

,!rY Z

x·[rY •]+X

pXx

,!rY Z

X

t2Qx·[rY t]·[tZ•]

[pXq] =X

pXx

,!q"

x+

X

pXx

,!rY

x · [rY q] +X

pXx

,!rY Z

X

t2Qx · [rY t] · [tZq]

1. Construct equations for all [pX•] and [pXq] needed.2. Replace all [pX•] and [pXq] by fresh random variables hpX•i and

hpXqi3. Solve the system of recursive equations for least solution.

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 38/42

Page 124: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

For pX /2 H:

[pX•] =X

pXx

,!rY

x·[rY •]+X

pXx

,!rY Z

x·[rY •]+X

pXx

,!rY Z

X

t2Qx·[rY t]·[tZ•]

[pXq] =X

pXx

,!q"

x+

X

pXx

,!rY

x · [rY q] +X

pXx

,!rY Z

X

t2Qx · [rY t] · [tZq]

1. Construct equations for all [pX•] and [pXq] needed.2. Replace all [pX•] and [pXq] by fresh random variables hpX•i and

hpXqi3. Solve the system of recursive equations for least solution.

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 38/42

Page 125: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

For pX /2 H:

[pX•] =X

pXx

,!rY

x·[rY •]+X

pXx

,!rY Z

x·[rY •]+X

pXx

,!rY Z

X

t2Qx·[rY t]·[tZ•]

[pXq] =X

pXx

,!q"

x+

X

pXx

,!rY

x · [rY q] +X

pXx

,!rY Z

X

t2Qx · [rY t] · [tZq]

1. Construct equations for all [pX•] and [pXq] needed.2. Replace all [pX•] and [pXq] by fresh random variables hpX•i and

hpXqi3. Solve the system of recursive equations for least solution.

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 38/42

Page 126: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

For pX /2 H:

[pX•] =X

pXx

,!rY

x·[rY •]+X

pXx

,!rY Z

x·[rY •]+X

pXx

,!rY Z

X

t2Qx·[rY t]·[tZ•]

[pXq] =X

pXx

,!q"

x+

X

pXx

,!rY

x · [rY q] +X

pXx

,!rY Z

X

t2Qx · [rY t] · [tZq]

1. Construct equations for all [pX•] and [pXq] needed.

2. Replace all [pX•] and [pXq] by fresh random variables hpX•i andhpXqi

3. Solve the system of recursive equations for least solution.

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 38/42

Page 127: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

For pX /2 H:

[pX•] =X

pXx

,!rY

x·[rY •]+X

pXx

,!rY Z

x·[rY •]+X

pXx

,!rY Z

X

t2Qx·[rY t]·[tZ•]

[pXq] =X

pXx

,!q"

x+

X

pXx

,!rY

x · [rY q] +X

pXx

,!rY Z

X

t2Qx · [rY t] · [tZq]

1. Construct equations for all [pX•] and [pXq] needed.2. Replace all [pX•] and [pXq] by fresh random variables hpX•i and

hpXqi

3. Solve the system of recursive equations for least solution.

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 38/42

Page 128: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

For pX /2 H:

[pX•] =X

pXx

,!rY

x·[rY •]+X

pXx

,!rY Z

x·[rY •]+X

pXx

,!rY Z

X

t2Qx·[rY t]·[tZ•]

[pXq] =X

pXx

,!q"

x+

X

pXx

,!rY

x · [rY q] +X

pXx

,!rY Z

X

t2Qx · [rY t] · [tZq]

1. Construct equations for all [pX•] and [pXq] needed.2. Replace all [pX•] and [pXq] by fresh random variables hpX•i and

hpXqi3. Solve the system of recursive equations for least solution.

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Reachability/Termination

Justin Winkens | 30. June 2016 38/42

Page 129: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 130: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}) P(Reach(Ad0, C)) = [Ad0•] = 1 means qualitative termination

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 131: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}) P(Reach(Ad0, C)) = [Ad0•] = 1 means qualitative termination

[Ad0•] =X

Ad0x

,!rY

x·[rY •] +X

Ad0x

,!rY Z

x·[rY •] +X

Ad0x

,!rY Z

X

t2Qx·[rY t]·[tZ•]

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 132: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}) P(Reach(Ad0, C)) = [Ad0•] = 1 means qualitative termination

[Ad0•] =X

Ad0x

,!rY

x·[rY •] +X

Ad0x

,!rY Z

x·[rY •] +X

Ad0x

,!rY Z

X

t2Qx·[rY t]·[tZ•]

hAd0i p

,! hAs0d1ihAd0i 1�p

,! hBs0d1i

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 133: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}) P(Reach(Ad0, C)) = [Ad0•] = 1 means qualitative termination

[Ad0•] =X

Ad0x

,!rY

x·[rY •] +X

Ad0x

,!rY Z

x·[rY •] +X

Ad0x

,!rY Z

X

t2Qx·[rY t]·[tZ•]

= p·[As0•]

hAd0i p

,! hAs0d1ihAd0i 1�p

,! hBs0d1i

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 134: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}) P(Reach(Ad0, C)) = [Ad0•] = 1 means qualitative termination

[Ad0•] =X

Ad0x

,!rY

x·[rY •] +X

Ad0x

,!rY Z

x·[rY •] +X

Ad0x

,!rY Z

X

t2Qx·[rY t]·[tZ•]

= p·[As0•]+(1�p)·[Bs0•]

hAd0i p

,! hAs0d1ihAd0i 1�p

,! hBs0d1i

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 135: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}) P(Reach(Ad0, C)) = [Ad0•] = 1 means qualitative termination

[Ad0•] =X

Ad0x

,!rY

x·[rY •] +X

Ad0x

,!rY Z

x·[rY •] +X

Ad0x

,!rY Z

X

t2Qx·[rY t]·[tZ•]

= p·[As0•] + (1�p)·[Bs0•]+

X

Ad0x

,!rY Z

(x·[rY A]·[AZ•] + x·[rY B]·[BZ•])

hAd0i p

,! hAs0d1ihAd0i 1�p

,! hBs0d1i

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 136: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}) P(Reach(Ad0, C)) = [Ad0•] = 1 means qualitative termination

[Ad0•] = p·[As0•] + (1�p)·[Bs0•]+ (p·[As0A]·[Ad1•] + p·[As0B]·[Bd1•])+ ((1�p)·[Bs0A]·[Ad1•] + (1�p)·[Bs0B]·[Bd1•])

hAd0i p

,! hAs0d1ihAd0i 1�p

,! hBs0d1i

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 137: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}) P(Reach(Ad0, C)) = [Ad0•] = 1 means qualitative termination

[Ad0•] = p·[As0•] + (1�p)·[Bs0•]+ (p·[As0A]·[Ad1•] + p·[As0B]·[Bd1•])+ ((1�p)·[Bs0A]·[Ad1•] + (1�p)·[Bs0B]·[Bd1•])

) Remove zero summands

hAd0i p

,! hAs0d1ihAd0i 1�p

,! hBs0d1i

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 138: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let C be a set of target configurations with H = {Ak0, Bk0}) P(Reach(Ad0, C)) = [Ad0•] = 1 means qualitative termination

[Ad0•] = p·[As0•] + (1�p)·[Bs0•]

) We need to calculate [As0•] and [Bs0•]!

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 39/42

Page 139: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

[Ad0•] = p·[As0•] + (1�p)·[Bs0•][As0•] = s+ (1�s)·[Bs0•][Bs0•] = t+ (1� t)·[As0•]

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 40/42

Page 140: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

[Ad0•] = p·[As0•] + (1�p)·[Bs0•][As0•] = s+ (1�s)·[Bs0•][Bs0•] = t+ (1� t)·[As0•]

hAd0•i = p·hAs0•i+ (1�p)·hBs0•ihAs0•i = s+ (1�s)·hBs0•ihBs0•i = t+ (1� t)·hAs0•i

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 40/42

Page 141: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

hAd0•i = p·hAs0•i+ (1�p)·hBs0•ihAs0•i = s+ (1�s)·hBs0•ihBs0•i = t+ (1� t)·hAs0•i

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 40/42

Page 142: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

hAd0•i = p·hAs0•i+ (1�p)·hBs0•ihAs0•i = s+ (1�s)·hBs0•ihBs0•i = t+ (1� t)·hAs0•i

p = 1/2

s = 1/2

t = 1/3

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 40/42

Page 143: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

hAd0•i = p·hAs0•i+ (1�p)·hBs0•ihAs0•i = s+ (1�s)·hBs0•ihBs0•i = t+ (1� t)·hAs0•i

hAd0•i = 1, hAs0•i = 1, hBs0•i = 1

p = 1/2

s = 1/2

t = 1/3

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 40/42

Page 144: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

hAd0•i = p·hAs0•i+ (1�p)·hBs0•ihAs0•i = s+ (1�s)·hBs0•ihBs0•i = t+ (1� t)·hAs0•i

hAd0•i = 0, hAs0•i = 0, hBs0•i = 0

p = 1/2

s = 0

t = 0

Analyzing Probabilistic Pushdown Automata Qualitative Reachability/Termination

Qualitative Term./Reach. Dueling Cowboys

Justin Winkens | 30. June 2016 40/42

Page 145: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We know that the duel ends if both s, t > 0

I What is the probability that e.g. A wins the duel?I ) [Ad0A] =?, C = ;I Same equations apply!

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Quantitative Term./Reach Dueling Cowboys

Justin Winkens | 30. June 2016 41/42

Page 146: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We know that the duel ends if both s, t > 0

I What is the probability that e.g. A wins the duel?

I ) [Ad0A] =?, C = ;I Same equations apply!

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Quantitative Term./Reach Dueling Cowboys

Justin Winkens | 30. June 2016 41/42

Page 147: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We know that the duel ends if both s, t > 0

I What is the probability that e.g. A wins the duel?I ) [Ad0A] =?, C = ;

I Same equations apply!

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Quantitative Term./Reach Dueling Cowboys

Justin Winkens | 30. June 2016 41/42

Page 148: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We know that the duel ends if both s, t > 0

I What is the probability that e.g. A wins the duel?I ) [Ad0A] =?, C = ;I Same equations apply!

[Ad0A] = p · [As0A] + (1� p)[Bs0A]

[As0A] = s+ (1� s)[Bs0A]

[Bs0A] = (1� t)[As0A]

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Quantitative Term./Reach Dueling Cowboys

Justin Winkens | 30. June 2016 41/42

Page 149: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We know that the duel ends if both s, t > 0

I What is the probability that e.g. A wins the duel?I ) [Ad0A] =?, C = ;I Same equations apply!

hAd0Ai = p · hAs0Ai+ (1� p)hBs0AihAs0Ai = s+ (1� s)hBs0AihBs0Ai = (1� t)hAs0Ai

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Quantitative Term./Reach Dueling Cowboys

Justin Winkens | 30. June 2016 41/42

Page 150: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We know that the duel ends if both s, t > 0

I What is the probability that e.g. A wins the duel?I ) [Ad0A] =?, C = ;I Same equations apply!

p = 1/2, s = 1/2, t = 1/2

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Quantitative Term./Reach Dueling Cowboys

Justin Winkens | 30. June 2016 41/42

Page 151: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I We know that the duel ends if both s, t > 0

I What is the probability that e.g. A wins the duel?I ) [Ad0A] =?, C = ;I Same equations apply!

p = 1/2, s = 1/2, t = 1/2

hAd0Ai = 1/2

hAs0Ai = 2/3

hBs0Ai = 1/3

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Quantitative Term./Reach Dueling Cowboys

Justin Winkens | 30. June 2016 41/42

Page 152: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I pPDA nice way to model and analyze systems that use probability aswell as recursion

I 2 formulae enough to study quantitative and qualitative reachabilityI Can be done efficiently in polynomial spaceI Construction technique to pPBA allows analysis in polynomial time.

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Conclusion

Justin Winkens | 30. June 2016 42/42

Page 153: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I pPDA nice way to model and analyze systems that use probability aswell as recursion

I 2 formulae enough to study quantitative and qualitative reachability

I Can be done efficiently in polynomial spaceI Construction technique to pPBA allows analysis in polynomial time.

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Conclusion

Justin Winkens | 30. June 2016 42/42

Page 154: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I pPDA nice way to model and analyze systems that use probability aswell as recursion

I 2 formulae enough to study quantitative and qualitative reachabilityI Can be done efficiently in polynomial space

I Construction technique to pPBA allows analysis in polynomial time.

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Conclusion

Justin Winkens | 30. June 2016 42/42

Page 155: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

I pPDA nice way to model and analyze systems that use probability aswell as recursion

I 2 formulae enough to study quantitative and qualitative reachabilityI Can be done efficiently in polynomial spaceI Construction technique to pPBA allows analysis in polynomial time.

Analyzing Probabilistic Pushdown Automata Quantitative Reachability/Termination

Conclusion

Justin Winkens | 30. June 2016 42/42

Page 156: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: RuntimeLet � be a transition system with a set of configurations S and targetconfigurations T .

Let f : S ! R�0 be a function that assigns run times to states.For every run r 2 Runs(�) we define kr as the least n 2 N0 such thatr(n) 2 T .

T ime(�) =

krX

i=0

f(r(i)) .

) kr depends on probability) E(T ime(�)), E(T ime(�)|Reach(pX, C))

Expected Runtime

Justin Winkens | 30. June 2016 1/6

Page 157: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: RuntimeLet � be a transition system with a set of configurations S and targetconfigurations T .Let f : S ! R�0 be a function that assigns run times to states.

For every run r 2 Runs(�) we define kr as the least n 2 N0 such thatr(n) 2 T .

T ime(�) =

krX

i=0

f(r(i)) .

) kr depends on probability) E(T ime(�)), E(T ime(�)|Reach(pX, C))

Expected Runtime

Justin Winkens | 30. June 2016 1/6

Page 158: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: RuntimeLet � be a transition system with a set of configurations S and targetconfigurations T .Let f : S ! R�0 be a function that assigns run times to states.For every run r 2 Runs(�) we define kr as the least n 2 N0 such thatr(n) 2 T .

T ime(�) =

krX

i=0

f(r(i)) .

) kr depends on probability) E(T ime(�)), E(T ime(�)|Reach(pX, C))

Expected Runtime

Justin Winkens | 30. June 2016 1/6

Page 159: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: RuntimeLet � be a transition system with a set of configurations S and targetconfigurations T .Let f : S ! R�0 be a function that assigns run times to states.For every run r 2 Runs(�) we define kr as the least n 2 N0 such thatr(n) 2 T .

T ime(�) =

krX

i=0

f(r(i)) .

) kr depends on probability) E(T ime(�)), E(T ime(�)|Reach(pX, C))

Expected Runtime

Justin Winkens | 30. June 2016 1/6

Page 160: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: RuntimeLet � be a transition system with a set of configurations S and targetconfigurations T .Let f : S ! R�0 be a function that assigns run times to states.For every run r 2 Runs(�) we define kr as the least n 2 N0 such thatr(n) 2 T .

T ime(�) =

krX

i=0

f(r(i)) .

) kr depends on probability

) E(T ime(�)), E(T ime(�)|Reach(pX, C))

Expected Runtime

Justin Winkens | 30. June 2016 1/6

Page 161: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: RuntimeLet � be a transition system with a set of configurations S and targetconfigurations T .Let f : S ! R�0 be a function that assigns run times to states.For every run r 2 Runs(�) we define kr as the least n 2 N0 such thatr(n) 2 T .

T ime(�) =

krX

i=0

f(r(i)) .

) kr depends on probability) E(T ime(�)), E(T ime(�)|Reach(pX, C))

Expected Runtime

Justin Winkens | 30. June 2016 1/6

Page 162: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Expected Runtime pPDA

Let � = (Q,�, ,!,P) be a pPDA.EpXq = E(T ime(�)|Reach(pX, {q"})) conditional expected runtime

hEpXqi = f(pX) +

X

pXx

,!rY

x · [rY q]

[pXq]· hErY qi

+

X

pXx

,!rY Z

X

t2Qx · [rY t] · [tZq]

[pXq]· (hErY ti+ hEtZqi)

) Here: f(pX) = 1 for all pX 2 Q⇥ � ) discrete time

Expected Runtime

Justin Winkens | 30. June 2016 2/6

Page 163: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Expected Runtime pPDA

Let � = (Q,�, ,!,P) be a pPDA.EpXq = E(T ime(�)|Reach(pX, {q"})) conditional expected runtime

hEpXqi = f(pX) +

X

pXx

,!rY

x · [rY q]

[pXq]· hErY qi

+

X

pXx

,!rY Z

X

t2Qx · [rY t] · [tZq]

[pXq]· (hErY ti+ hEtZqi)

) Here: f(pX) = 1 for all pX 2 Q⇥ � ) discrete time

Expected Runtime

Justin Winkens | 30. June 2016 2/6

Page 164: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Definition: Expected Runtime pPDA

Let � = (Q,�, ,!,P) be a pPDA.EpXq = E(T ime(�)|Reach(pX, {q"})) conditional expected runtime

hEpXqi = f(pX) +

X

pXx

,!rY

x · [rY q]

[pXq]· hErY qi

+

X

pXx

,!rY Z

X

t2Qx · [rY t] · [tZq]

[pXq]· (hErY ti+ hEtZqi)

) Here: f(pX) = 1 for all pX 2 Q⇥ � ) discrete time

Expected Runtime

Justin Winkens | 30. June 2016 2/6

Page 165: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

P(Reach(rY, {q"})|Reach(pX, {q"})) = P(Reach(rY, {q"}) \Reach(pX, {q"}))P(Reach(pX, {q"}))

=

P(Reach(rY, {q"}))P(Reach(pX, {q"}))

=

[rY q]

[pXq]

Expected Runtime

Justin Winkens | 30. June 2016 3/6

Page 166: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Expected runtime for all runs that start in Ad0 and end in A":

hEAs0Ai = 1 +

[As1A]

[As0A]

· hEAs1Ai

hEAs1Ai = 1 +

s

[As1A]

· (hEAk0Ai+ hEAs3Ai) + (1� s) · [Bs0A]

[As1A]

(hEBs0Ai)

hEBs0Ai = 1 +

[Bs2A]

[Bs0A]· hEBs2Ai

hEBs2Ai = 1 + (1� t) · [As0A]

[Bs2A]

· (hEAs0Ai+ hEAs6Ai)

hEAd1Ai = 1

hEAk0Ai = 1

hEAs3Ai = 1

hEAs6Ai = 1

Expected Runtime

Justin Winkens | 30. June 2016 4/6

Page 167: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Expected runtime for all runs that start in Ad0 and end in A":

hEAs0Ai = 1 +

[As1A]

[As0A]

· hEAs1Ai

hEAs1Ai = 1 +

s

[As1A]

· (hEAk0Ai+ hEAs3Ai) + (1� s) · [Bs0A]

[As1A]

(hEBs0Ai)

hEBs0Ai = 1 +

[Bs2A]

[Bs0A]· hEBs2Ai

hEBs2Ai = 1 + (1� t) · [As0A]

[Bs2A]

· (hEAs0Ai+ hEAs6Ai)

hEAd1Ai = 1

hEAk0Ai = 1

hEAs3Ai = 1

hEAs6Ai = 1

Expected Runtime

Justin Winkens | 30. June 2016 4/6

Page 168: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let’s assume p = s = t = 1/2

hEAd0Ai = 2 +

2

3

· hAs0Ai+ 1

3

· hBs0AihEAs0Ai = 1 + hEAs1AihEAs1Ai =

5

2

+

1

4

hEBs0AihEBs0Ai = 1 + hEBs2AihEBs2Ai = 2 + hEAs0Ai

) hEAd0Ai = 26/3 = 8.66

Expected Runtime

Justin Winkens | 30. June 2016 5/6

Page 169: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let’s assume p = s = t = 1/2

hEAd0Ai = 2 +

2

3

· hAs0Ai+ 1

3

· hBs0AihEAs0Ai = 1 + hEAs1AihEAs1Ai =

5

2

+

1

4

hEBs0AihEBs0Ai = 1 + hEBs2AihEBs2Ai = 2 + hEAs0Ai

) hEAd0Ai = 26/3 = 8.66

Expected Runtime

Justin Winkens | 30. June 2016 5/6

Page 170: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

Let’s assume p = s = t = 1/2

hEAd0Ai = 2 +

2

3

· hAs0Ai+ 1

3

· hBs0AihEAs0Ai = 1 + hEAs1AihEAs1Ai =

5

2

+

1

4

hEBs0AihEBs0Ai = 1 + hEBs2AihEBs2Ai = 2 + hEAs0Ai

) hEAd0Ai = 26/3 = 8.66

Expected Runtime

Justin Winkens | 30. June 2016 5/6

Page 171: Analyzing recursive probabilistic Programs - Informatik 2 · PDF file1 Introduction 2 Preliminaries 3 Translating pGCL to pPDA 4 Analyzing Probabilistic Pushdown Automata Table of

hAd0Ai = �p� (1� p) · (1� t)

2(st� s� t)

hAs0Ai = �1

2(st� s� t)

hBs0Ai = �(1� t)

2(st� s� t)

Quantitative System Parametrized

Justin Winkens | 30. June 2016 6/6