Markov chains and Markov decision processes in Isabelle/HOL - - PowerPoint PPT Presentation

markov chains and markov decision processes in isabelle
SMART_READER_LITE
LIVE PREVIEW

Markov chains and Markov decision processes in Isabelle/HOL - - PowerPoint PPT Presentation

Johannes Hlzl January 2016 TU Mnchen, Germany Markov chains and Markov decision processes in Isabelle/HOL Introduction Coalgebraic view on transition systems Fixed points to define queries on trace space Formalize probabilistic


slide-1
SLIDE 1

Markov chains and Markov decision processes in Isabelle/HOL

Johannes Hölzl January 2016

TU München, Germany

slide-2
SLIDE 2

Introduction

slide-3
SLIDE 3

Formalize probabilistic models:

  • Discrete infinite state spaces
  • Trace space & transition system
  • Support non-determinism
  • Compare different system types

Approach:

  • Coalgebraic view on transition systems
  • Fixed points to define queries on trace space

3

slide-4
SLIDE 4

Formalize probabilistic models:

  • Discrete infinite state spaces
  • Trace space & transition system
  • Support non-determinism
  • Compare different system types

Approach:

  • Coalgebraic view on transition systems
  • Fixed points to define queries on trace space

3

slide-5
SLIDE 5

Formalize probabilistic models:

  • Discrete infinite state spaces
  • Trace space & transition system
  • Support non-determinism
  • Compare different system types

Approach:

  • Coalgebraic view on transition systems
  • Fixed points to define queries on trace space

3

slide-6
SLIDE 6

Formalize probabilistic models:

  • Discrete infinite state spaces
  • Trace space & transition system
  • Support non-determinism
  • Compare different system types

Approach:

  • Coalgebraic view on transition systems
  • Fixed points to define queries on trace space

3

slide-7
SLIDE 7

Formalize probabilistic models:

  • Discrete infinite state spaces
  • Trace space & transition system
  • Support non-determinism
  • Compare different system types

Approach:

  • Coalgebraic view on transition systems
  • Fixed points to define queries on trace space

3

slide-8
SLIDE 8

Formalize probabilistic models:

  • Discrete infinite state spaces
  • Trace space & transition system
  • Support non-determinism
  • Compare different system types

Approach:

  • Coalgebraic view on transition systems
  • Fixed points to define queries on trace space

3

slide-9
SLIDE 9

Markov chains

slide-10
SLIDE 10

A B C1 C2 C3

1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 4 1 4

(a) A finite process 1 2

2 3 1 3 2 3 1 3 2 3

(b) An infinite birth-death process

5

slide-11
SLIDE 11

A B C1 C2 C3

1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 4 1 4

(a) A finite process 1 2

2 3 1 3 2 3 1 3 2 3

(b) An infinite birth-death process

5

slide-12
SLIDE 12

A B C1 C2 C3

1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 4 1 4

(a) A finite process 1 2

2 3 1 3 2 3 1 3 2 3

(b) An infinite birth-death process

  • PrA(♢C3) = ?
  • PrA

C3

  • PrA

C1 C2 C3

  • limn

PrA

n

C3 limn PrA

n

C2 ?

  • f0

d – f: first occurence

6

slide-13
SLIDE 13

A B C1 C2 C3

1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 4 1 4

(a) A finite process 1 2

2 3 1 3 2 3 1 3 2 3

(b) An infinite birth-death process

  • PrA(♢C3) = ?
  • PrA(□ ¬C3) = ?
  • PrA

C1 C2 C3

  • limn

PrA

n

C3 limn PrA

n

C2 ?

  • f0

d – f: first occurence

6

slide-14
SLIDE 14

A B C1 C2 C3

1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 4 1 4

(a) A finite process 1 2

2 3 1 3 2 3 1 3 2 3

(b) An infinite birth-death process

  • PrA(♢C3) = ?
  • PrA(□ ¬C3) = ?
  • PrA(□♢{C1, C2, C3}) = ?
  • limn

PrA

n

C3 limn PrA

n

C2 ?

  • f0

d – f: first occurence

6

slide-15
SLIDE 15

A B C1 C2 C3

1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 4 1 4

(a) A finite process 1 2

2 3 1 3 2 3 1 3 2 3

(b) An infinite birth-death process

  • PrA(♢C3) = ?
  • PrA(□ ¬C3) = ?
  • PrA(□♢{C1, C2, C3}) = ?
  • limn→∞ PrA(ωn = C3) > limn→∞ PrA(ωn = C2) ?
  • f0

d – f: first occurence

6

slide-16
SLIDE 16

A B C1 C2 C3

1 2 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 3 1 3 1 2 1 4 1 4

(a) A finite process 1 2

2 3 1 3 2 3 1 3 2 3

(b) An infinite birth-death process

  • PrA(♢C3) = ?
  • PrA(□ ¬C3) = ?
  • PrA(□♢{C1, C2, C3}) = ?
  • limn→∞ PrA(ωn = C3) > limn→∞ PrA(ωn = C2) ?

ω

f0 ω dT0 = ? – f: first occurence

6

slide-17
SLIDE 17

Markov Chains — A Coalgebraic View

How to represent Markov chains? K pmf K – Markov kernel: the transitions for each state – type of states pmf – probability mass functions (discrete distributions)

7

slide-18
SLIDE 18

Markov Chains — A Coalgebraic View

How to represent Markov chains? K :: σ ⇒ σ pmf K – Markov kernel: the transitions for each state – type of states pmf – probability mass functions (discrete distributions)

7

slide-19
SLIDE 19

Markov Chains — A Coalgebraic View

How to represent Markov chains? K :: σ ⇒ σ pmf K – Markov kernel: the transitions for each state σ – type of states σ pmf – probability mass functions (discrete distributions)

7

slide-20
SLIDE 20

Probability Mass Function

Model probabilistic transitions!

µ :: σ pmf ≈ µ :: σ ⇒ [0, 1], ∑

x µ x = 1

≈ µ :: σ measure, µ U = 1, discrete Similar to Audebaud & Paulin-Mohring [MPC 2006]

  • map f

x

f y x

y

  • set

x x

  • x

y

y

y x

  • return x

x 1 if x x else

  • Bernoulli
  • Uniform
  • Binomial
  • Geometric
  • Poisson
  • Conditional

8

slide-21
SLIDE 21

Probability Mass Function

Model probabilistic transitions!

µ :: σ pmf ≈ µ :: σ ⇒ [0, 1], ∑

x µ x = 1

≈ µ :: σ measure, µ U = 1, discrete Similar to Audebaud & Paulin-Mohring [MPC 2006]

  • map f µ = λx.

f y=x

µ y

  • set µ = {x | µ x ̸= 0}
  • µ >

> = ν = λx. ∑

y

µ y · νy x

  • return x = λx′.

{ 1 if x = x′ else

  • Bernoulli
  • Uniform
  • Binomial
  • Geometric
  • Poisson
  • Conditional

8

slide-22
SLIDE 22

Trace Space

Necessary to define ∫

ω dTs (and Prs(P ω)) codatatype stream stream Given K construct stream measure where:

s

do t Ks

t

return t Equivalently: for f Borel-measurable: f d

s t

f t d

t

dKs This construction is unique!

9

slide-23
SLIDE 23

Trace Space

Necessary to define ∫

ω dTs (and Prs(P ω)) codatatype σ stream = σ·(σ stream) ≈ N ⇒ σ Given K construct stream measure where:

s

do t Ks

t

return t Equivalently: for f Borel-measurable: f d

s t

f t d

t

dKs This construction is unique!

9

slide-24
SLIDE 24

Trace Space

Necessary to define ∫

ω dTs (and Prs(P ω)) codatatype σ stream = σ·(σ stream) ≈ N ⇒ σ Given K construct T :: σ ⇒ σ stream measure where: Ts = do { t ← Ks ; ω ← Tt ; return (t·ω) } Equivalently: for f Borel-measurable: ∫

ω

f(ω) dTs = ∫

t

(∫

ω

f(t·ω) dTt ) dKs This construction is unique!

9

slide-25
SLIDE 25

Trace Space

Necessary to define ∫

ω dTs (and Prs(P ω)) codatatype σ stream = σ·(σ stream) ≈ N ⇒ σ Given K construct T :: σ ⇒ σ stream measure where: Ts = do { t ← Ks ; ω ← Tt ; return (t·ω) } Equivalently: for f Borel-measurable: ∫

ω

f(ω) dTs = ∫

t

(∫

ω

f(t·ω) dTt ) dKs This construction is unique!

9

slide-26
SLIDE 26

Construct trace space for Markov chains

  • Traditional solution: use Caratheodory’s extension theorem
  • Generate trace space by

starts with xs

  • Countable additivity of pre-measure on cylinder sets
  • Our solution: reuse infinite product of probability spaces

Measure space of decisions D: D

n s

Ks run s d X s run d s X

s

D run s

  • Future Solution: Theorem by Ionescu-Tuclea

10

slide-27
SLIDE 27

Construct trace space for Markov chains

  • Traditional solution: use Caratheodory’s extension theorem
  • Generate trace space by

{ ω | ω starts with xs }

  • Countable additivity of pre-measure on cylinder sets
  • Our solution: reuse infinite product of probability spaces

Measure space of decisions D: D

n s

Ks run s d X s run d s X

s

D run s

  • Future Solution: Theorem by Ionescu-Tuclea

10

slide-28
SLIDE 28

Construct trace space for Markov chains

  • Traditional solution: use Caratheodory’s extension theorem
  • Generate trace space by

{ ω | ω starts with xs }

  • Countable additivity of pre-measure on cylinder sets
  • Our solution: reuse infinite product of probability spaces

Measure space of decisions D: D

n s

Ks run s d X s run d s X

s

D run s

  • Future Solution: Theorem by Ionescu-Tuclea

10

slide-29
SLIDE 29

Construct trace space for Markov chains

  • Traditional solution: use Caratheodory’s extension theorem
  • Generate trace space by

{ ω | ω starts with xs }

  • Countable additivity of pre-measure on cylinder sets
  • Our solution: reuse infinite product of probability spaces

Measure space of decisions D: D = ∏

n::N

s::σ

Ks run(s, d·X) = s·run(d s, X) Ts = D(run(s, ·))

  • Future Solution: Theorem by Ionescu-Tuclea

10

slide-30
SLIDE 30

Construct trace space for Markov chains

  • Traditional solution: use Caratheodory’s extension theorem
  • Generate trace space by

{ ω | ω starts with xs }

  • Countable additivity of pre-measure on cylinder sets
  • Our solution: reuse infinite product of probability spaces

Measure space of decisions D: D = ∏

n::N

s::σ

Ks run(s, d·X) = s·run(d s, X) Ts = D(run(s, ·))

  • Future Solution: Theorem by Ionescu-Tuclea

10

slide-31
SLIDE 31

Queries on the trace space

Eventually φ: ♢φ ω = n

n lfp

tl Always φ: □φ ω = n

n gfp

tl ψ Until φ:

ψUφ ω

= N n N

n N lfp

U tl First hit φ: fφ ω = LEAST n

n lfp

1 f tl if

  • therwise

Counting φ: cφ ω =

n n lfp

1 c tl if c tl

  • therwise

11

slide-32
SLIDE 32

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

tl Always φ: □φ ω = n

n gfp

tl ψ Until φ:

ψUφ ω

= N n N

n N lfp

U tl First hit φ: fφ ω = LEAST n

n lfp

1 f tl if

  • therwise

Counting φ: cφ ω =

n n lfp

1 c tl if c tl

  • therwise

11

slide-33
SLIDE 33

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

tl Always φ: □φ ω = ∀n. φ ωn

gfp

tl ψ Until φ:

ψUφ ω

= N n N

n N lfp

U tl First hit φ: fφ ω = LEAST n

n lfp

1 f tl if

  • therwise

Counting φ: cφ ω =

n n lfp

1 c tl if c tl

  • therwise

11

slide-34
SLIDE 34

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

tl Always φ: □φ ω = ∀n. φ ωn

gfp

tl ψ Until φ:

ψUφ ω

= ∃N. (∀n < N. ψ ωn) ∧ φ ωN

lfp

U tl First hit φ: fφ ω = LEAST n

n lfp

1 f tl if

  • therwise

Counting φ: cφ ω =

n n lfp

1 c tl if c tl

  • therwise

11

slide-35
SLIDE 35

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

tl Always φ: □φ ω = ∀n. φ ωn

gfp

tl ψ Until φ:

ψUφ ω

= ∃N. (∀n < N. ψ ωn) ∧ φ ωN

lfp

U tl First hit φ: fφ ω = LEAST n. φ ωn

lfp

1 f tl if

  • therwise

Counting φ: cφ ω =

n n lfp

1 c tl if c tl

  • therwise

11

slide-36
SLIDE 36

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

tl Always φ: □φ ω = ∀n. φ ωn

gfp

tl ψ Until φ:

ψUφ ω

= ∃N. (∀n < N. ψ ωn) ∧ φ ωN

lfp

U tl First hit φ: fφ ω = LEAST n. φ ωn

lfp

1 f tl if

  • therwise

Counting φ: cφ ω = ∑

n⌊φ ωn⌋ lfp

1 c tl if c tl

  • therwise

11

slide-37
SLIDE 37

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

= φ ω ∨ ♢φ (tl ω) Always φ: □φ ω = ∀n. φ ωn

gfp

tl ψ Until φ:

ψUφ ω

= ∃N. (∀n < N. ψ ωn) ∧ φ ωN

lfp

U tl First hit φ: fφ ω = LEAST n. φ ωn

lfp

1 f tl if

  • therwise

Counting φ: cφ ω = ∑

n⌊φ ωn⌋ lfp

1 c tl if c tl

  • therwise

11

slide-38
SLIDE 38

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

= φ ω ∨ ♢φ (tl ω) Always φ: □φ ω = ∀n. φ ωn

gfp

= φ ω ∧ □φ (tl ω) ψ Until φ:

ψUφ ω

= ∃N. (∀n < N. ψ ωn) ∧ φ ωN

lfp

U tl First hit φ: fφ ω = LEAST n. φ ωn

lfp

1 f tl if

  • therwise

Counting φ: cφ ω = ∑

n⌊φ ωn⌋ lfp

1 c tl if c tl

  • therwise

11

slide-39
SLIDE 39

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

= φ ω ∨ ♢φ (tl ω) Always φ: □φ ω = ∀n. φ ωn

gfp

= φ ω ∧ □φ (tl ω) ψ Until φ:

ψUφ ω

= ∃N. (∀n < N. ψ ωn) ∧ φ ωN

lfp

= ( ψ ω ∧

ψUφ (tl ω)

) ∨ φ ω First hit φ: fφ ω = LEAST n. φ ωn

lfp

1 f tl if

  • therwise

Counting φ: cφ ω = ∑

n⌊φ ωn⌋ lfp

1 c tl if c tl

  • therwise

11

slide-40
SLIDE 40

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

= φ ω ∨ ♢φ (tl ω) Always φ: □φ ω = ∀n. φ ωn

gfp

= φ ω ∧ □φ (tl ω) ψ Until φ:

ψUφ ω

= ∃N. (∀n < N. ψ ωn) ∧ φ ωN

lfp

= ( ψ ω ∧

ψUφ (tl ω)

) ∨ φ ω First hit φ: fφ ω = LEAST n. φ ωn

lfp

= { 1 + fφ (tl ω) if ¬ φ ω

  • therwise

Counting φ: cφ ω = ∑

n⌊φ ωn⌋ lfp

1 c tl if c tl

  • therwise

11

slide-41
SLIDE 41

Queries on the trace space

Eventually φ: ♢φ ω = ∃n. φ ωn

lfp

= φ ω ∨ ♢φ (tl ω) Always φ: □φ ω = ∀n. φ ωn

gfp

= φ ω ∧ □φ (tl ω) ψ Until φ:

ψUφ ω

= ∃N. (∀n < N. ψ ωn) ∧ φ ωN

lfp

= ( ψ ω ∧

ψUφ (tl ω)

) ∨ φ ω First hit φ: fφ ω = LEAST n. φ ωn

lfp

= { 1 + fφ (tl ω) if ¬ φ ω

  • therwise

Counting φ: cφ ω = ∑

n⌊φ ωn⌋ lfp

= { 1 + cφ (tl ω) if φ ω cφ (tl ω)

  • therwise

11

slide-42
SLIDE 42

Interception: Least/Greatest Fixed Points

Monotone functions f, g Least fixed point: lfp f = f (lfp f) (∀x. f x ⩽ x = ⇒ lfp f ⩽ x) lfp f =

  • f ◦ f ◦ f ◦ f ◦ f ◦ f ◦ f ◦ f ◦ f ◦ · · · ◦ ⊥

Rolling rule: g lfp f g lfp g f g f g f g f g f g g f g f g f g f g Iteration rule: lfp f f lfp f Nesting rule: lfp x lfp f x lfp x f x x Transfer rule: continuous f g f g lfp f lfp g C X monotone C f

i Ci i f Ci

lfp f f f f f f g g g f f g g g g g lfp g f f d for f Borel-measurable

12

slide-43
SLIDE 43

Interception: Least/Greatest Fixed Points

Monotone functions f, g Least fixed point: lfp f = f (lfp f) (∀x. f x ⩽ x = ⇒ lfp f ⩽ x) lfp f f f f f f f f f f Rolling rule: g (lfp (f ◦ g)) = lfp (g ◦ f) g ◦

  • f ◦ g ◦
  • f ◦ g ◦
  • f ◦ g ◦
  • f ◦ g ◦ . . .

g f g f g f g f g Iteration rule: lfp f f lfp f Nesting rule: lfp x lfp f x lfp x f x x Transfer rule: continuous f g f g lfp f lfp g C X monotone C f

i Ci i f Ci

lfp f f f f f f g g g f f g g g g g lfp g f f d for f Borel-measurable

12

slide-44
SLIDE 44

Interception: Least/Greatest Fixed Points

Monotone functions f, g Least fixed point: lfp f = f (lfp f) (∀x. f x ⩽ x = ⇒ lfp f ⩽ x) lfp f f f f f f f f f f Rolling rule: g (lfp (f ◦ g)) = lfp (g ◦ f) g f g f g f g f g

  • g ◦ f ◦
  • g ◦ f ◦
  • g ◦ f ◦
  • g ◦ f ◦ g ◦ . . .

Iteration rule: lfp f f lfp f Nesting rule: lfp x lfp f x lfp x f x x Transfer rule: continuous f g f g lfp f lfp g C X monotone C f

i Ci i f Ci

lfp f f f f f f g g g f f g g g g g lfp g f f d for f Borel-measurable

12

slide-45
SLIDE 45

Interception: Least/Greatest Fixed Points

Monotone functions f, g Least fixed point: lfp f = f (lfp f) (∀x. f x ⩽ x = ⇒ lfp f ⩽ x) lfp f f f f f f f f f f Rolling rule: g (lfp (f ◦ g)) = lfp (g ◦ f) g f g f g f g f g g f g f g f g f g Iteration rule: lfp (f ◦ f) = lfp f Nesting rule: lfp x lfp f x lfp x f x x Transfer rule: continuous f g f g lfp f lfp g C X monotone C f

i Ci i f Ci

lfp f f f f f f g g g f f g g g g g lfp g f f d for f Borel-measurable

12

slide-46
SLIDE 46

Interception: Least/Greatest Fixed Points

Monotone functions f, g Least fixed point: lfp f = f (lfp f) (∀x. f x ⩽ x = ⇒ lfp f ⩽ x) lfp f f f f f f f f f f Rolling rule: g (lfp (f ◦ g)) = lfp (g ◦ f) g f g f g f g f g g f g f g f g f g Iteration rule: lfp (f ◦ f) = lfp f Nesting rule: lfp (λx. lfp (f x)) = lfp (λx. f x x) Transfer rule: continuous f g f g lfp f lfp g C X monotone C f

i Ci i f Ci

lfp f f f f f f g g g f f g g g g g lfp g f f d for f Borel-measurable

12

slide-47
SLIDE 47

Interception: Least/Greatest Fixed Points

Monotone functions f, g Least fixed point: lfp f = f (lfp f) (∀x. f x ⩽ x = ⇒ lfp f ⩽ x) lfp f f f f f f f f f f Rolling rule: g (lfp (f ◦ g)) = lfp (g ◦ f) g f g f g f g f g g f g f g f g f g Iteration rule: lfp (f ◦ f) = lfp f Nesting rule: lfp (λx. lfp (f x)) = lfp (λx. f x x) Transfer rule: ⊔−continuous α, f, g α ⊥ = ⊥ α ◦ f = g ◦ α α(lfp f) = lfp g ∀C ∈ N → X. monotone C = ⇒ f (⊔

i Ci) = ⊔ i f Ci

α(lfp f) = α ◦ f ◦ f ◦ f ◦ f ◦ f ◦ · · · ◦ ⊥ = g ◦ g ◦ g ◦ α ◦ f ◦ f ◦ · · · ◦ ⊥ = g ◦ g ◦ g ◦ g ◦ g ◦ · · · ◦ α ⊥ = lfp g f f d for f Borel-measurable

12

slide-48
SLIDE 48

Interception: Least/Greatest Fixed Points

Monotone functions f, g Least fixed point: lfp f = f (lfp f) (∀x. f x ⩽ x = ⇒ lfp f ⩽ x) lfp f f f f f f f f f f Rolling rule: g (lfp (f ◦ g)) = lfp (g ◦ f) g f g f g f g f g g f g f g f g f g Iteration rule: lfp (f ◦ f) = lfp f Nesting rule: lfp (λx. lfp (f x)) = lfp (λx. f x x) Transfer rule: ⊔−continuous α, f, g α ⊥ = ⊥ α ◦ f = g ◦ α α(lfp f) = lfp g C X monotone C f

i Ci i f Ci

lfp f f f f f f g g g f f g g g g g lfp g f f d for f Borel-measurable

12

slide-49
SLIDE 49

Interception: Least/Greatest Fixed Points

Monotone functions f, g Least fixed point: lfp f = f (lfp f) (∀x. f x ⩽ x = ⇒ lfp f ⩽ x) lfp f f f f f f f f f f Rolling rule: g (lfp (f ◦ g)) = lfp (g ◦ f) g f g f g f g f g g f g f g f g f g Iteration rule: lfp (f ◦ f) = lfp f Nesting rule: lfp (λx. lfp (f x)) = lfp (λx. f x x) Transfer rule: ⊔−continuous α, f, g α ⊥ = ⊥ α ◦ f = g ◦ α α(lfp f) = lfp g C X monotone C f

i Ci i f Ci

lfp f f f f f f g g g f f g g g g g lfp g α f = ∫ f dM for f Borel-measurable

12

slide-50
SLIDE 50

Equation for queries under integration

Example (First hitting time φ on states) Define f: fφ

def

= lfp (λ f (s·ω). ⌊¬φ s⌋ · (1 + f ω)) f s

lfp

1 f if s

  • therwise

Prove computation rule by transfer rule: f d

s

lfp g s

t

t 1 g t dKs s For finite state space: lfp is a system of linear equations!

13

slide-51
SLIDE 51

Equation for queries under integration

Example (First hitting time φ on states) Define f: fφ

def

= lfp (λ f (s·ω). ⌊¬φ s⌋ · (1 + f ω)) fφ (s·ω)

lfp

= { 1 + fφ ω if ¬ φ s

  • therwise

Prove computation rule by transfer rule: f d

s

lfp g s

t

t 1 g t dKs s For finite state space: lfp is a system of linear equations!

13

slide-52
SLIDE 52

Equation for queries under integration

Example (First hitting time φ on states) Define f: fφ

def

= lfp (λ f (s·ω). ⌊¬φ s⌋ · (1 + f ω)) fφ (s·ω)

lfp

= { 1 + fφ ω if ¬ φ s

  • therwise

Prove computation rule by transfer rule: ∫

ω

fφ ω dTs = lfp ( λg s. ∫

t

⌊¬φ t⌋ · (1 + g t) dKs ) s For finite state space: lfp is a system of linear equations!

13

slide-53
SLIDE 53

Equation for queries under integration

Example (First hitting time φ on states) Define f: fφ

def

= lfp (λ f (s·ω). ⌊¬φ s⌋ · (1 + f ω)) fφ (s·ω)

lfp

= { 1 + fφ ω if ¬ φ s

  • therwise

Prove computation rule by transfer rule: ∫

ω

fφ ω dTs = lfp ( λg s. ∫

t

⌊¬φ t⌋ · (1 + g t) dKs ) s For finite state space: lfp is a system of linear equations!

13

slide-54
SLIDE 54

Proofs employing fixed point reasoning

Lemma (Fairness) Pr s ( □♢t = ⇒ □♢(t ∧ ⃝t′) ) = 1 if t′ ∈ Kt Proof. Show that gfp (λg s. (¬t) U (t · ¬t′ · g)) has probability 0. Lemma (Finite hitting time) ft d

s

if Pr s t 1 and finite state space Proof size is reduced to 65 !

14

slide-55
SLIDE 55

Proofs employing fixed point reasoning

Lemma (Fairness) Pr s ( □♢t = ⇒ □♢(t ∧ ⃝t′) ) = 1 if t′ ∈ Kt Proof. Show that gfp (λg s. (¬t) U (t · ¬t′ · g)) has probability 0. Lemma (Finite hitting time) ∫

ω

ft ω dTs < ∞ if Pr s(♢t) = 1 and finite state space Proof size is reduced to 65 !

14

slide-56
SLIDE 56

Proofs employing fixed point reasoning

Lemma (Fairness) Pr s ( □♢t = ⇒ □♢(t ∧ ⃝t′) ) = 1 if t′ ∈ Kt Proof. Show that gfp (λg s. (¬t) U (t · ¬t′ · g)) has probability 0. Lemma (Finite hitting time) ∫

ω

ft ω dTs < ∞ if Pr s(♢t) = 1 and finite state space Proof size is reduced to ≈ 65%!

14

slide-57
SLIDE 57

Stationary Distribution

N is a stationary distribution iff (N > > = K) = N Or: K × N = N — K as transition matrix

  • When support set of N is essential (bottom SCC):

ω

fs ω dTs = 1 N s − 1

  • When essential and aperiodic:

lim

n→∞ Prs(ωn = t) = N t

  • Stationary distribution for b): N = geometric

(

1 2

)

15

slide-58
SLIDE 58

DTMC (M :: α measure) (X :: nat ⇒ α ⇒ σ) = prob-space M ∧ (∀n. X n ∈ M →

σ U)

∧ (∃S. countable S ∧ ∀n. Pr(X n ∈ S) = 1) ∧ — The stochastic process X is memoryless: ( ∀n s t. Pr(∀n′ ⩽ n. X n′ = t n′) ̸= 0 − → Pr(X (n + 1) = s | ∀n′ ⩽ n. X n′ = t n′) = Pr(X (n + 1) = s | X n = t n) ) ∧ — The stochastic process X is time-homogeneous: ( ∀n n′ s t. Pr(X n = t) ̸= 0 ∧ Pr(X n′ = t) ̸= 0 − → Pr(X (n + 1) = s | X n = t) = Pr(X (n′ + 1) = s | X n′ = t) )

16

slide-59
SLIDE 59

Markov decision processes

slide-60
SLIDE 60

Markov decision process

Probabilistic & non-deterministic transitions

  • Kernels (coalgebras) of MDPs:

K pmf set Ks

  • Traditional definition of schedulers:

sc list pmf sc h s Ks

18

slide-61
SLIDE 61

Markov decision process

Probabilistic & non-deterministic transitions

  • Kernels (coalgebras) of MDPs:

K :: σ ⇒ σ pmf set, Ks ̸= ∅

  • Traditional definition of schedulers:

sc list pmf sc h s Ks

18

slide-62
SLIDE 62

Markov decision process

Probabilistic & non-deterministic transitions

  • Kernels (coalgebras) of MDPs:

K :: σ ⇒ σ pmf set, Ks ̸= ∅

  • Traditional definition of schedulers:

sc :: σ list ⇒ σ pmf, sc (h·s) ∈ Ks

18

slide-63
SLIDE 63

Configurations

(s0, α) (s0, β) (s1, α) (s2, α) (s0, α) (s0, α) (s1, α) (s2, α) s0 s1 s2

α

1 2 1 4 1 4

β 1

Attention: the configuration includes the entire tree!

19

slide-64
SLIDE 64

Configurations on MDPs

codatatype σ cfg = Cfg (state : σ) (act : σ pmf) (cont : σ ⇒ σ cfg) where state (cont c s) = s

  • Induces a Markov chain:

KMC :: σ cfg ⇒ σ cfg pmf KMCc = map (cont c) (act c)

  • Trace space: Tc = mapmeasure (mapstream state) TMCc
  • Valid Configuration: act is always compatible with K

20

slide-65
SLIDE 65

Definition (Minimal Expectation) Emin

s

[ f ] =

  • c∈valids

∫ f dTc Lemma (Iteration Rule)

min s f D Ks t min s f t

dD

21

slide-66
SLIDE 66

Definition (Minimal Expectation) Emin

s

[ f ] =

  • c∈valids

∫ f dTc Lemma (Iteration Rule) Emin

s

[ f ] =

  • D∈Ks

t

Emin

s

[ f (t·ω) ] dD

21

slide-67
SLIDE 67

Application: Reachability Problem Example

s0

p= 1

2

n=0

s1

p= 5

8

n= 1

4

s2

p=1 n=1

s3

p=0 n=0

s4

p=0 n=0

γ 1 α 1

3 4 1 4

α 1 α β

1 2 1 2

p is Prmax

s

(S1 U S2), n is Prmin

s

(S1 U S2)

22

slide-68
SLIDE 68

Application: Reachability problems on MDPs

Goal: certify solutions to reachability problems in MDPs Formalize MDPs and reachability problems Prmin

s

S1 U S2 lfp Implement and verify certification algorithm Currently: v Prmin S1 U S2 and Prmax S1 U S2 v Requires proof:

  • ptimal memoryless scheduler

Import results by executing algorithm in Isabelle/HOL

23

slide-69
SLIDE 69

Application: Reachability problems on MDPs

Goal: certify solutions to reachability problems in MDPs = ⇒ Formalize MDPs and reachability problems Prmin

s

(S1 U S2) = lfp(· · · ) Implement and verify certification algorithm Currently: v Prmin S1 U S2 and Prmax S1 U S2 v Requires proof:

  • ptimal memoryless scheduler

Import results by executing algorithm in Isabelle/HOL

23

slide-70
SLIDE 70

Application: Reachability problems on MDPs

Goal: certify solutions to reachability problems in MDPs = ⇒ Formalize MDPs and reachability problems Prmin

s

(S1 U S2) = lfp(· · · ) = ⇒ Implement and verify certification algorithm Currently: v ⩽ Prmin(S1 U S2) and Prmax(S1 U S2) ⩽ v Requires proof:

  • ptimal memoryless scheduler

Import results by executing algorithm in Isabelle/HOL

23

slide-71
SLIDE 71

Application: Reachability problems on MDPs

Goal: certify solutions to reachability problems in MDPs = ⇒ Formalize MDPs and reachability problems Prmin

s

(S1 U S2) = lfp(· · · ) = ⇒ Implement and verify certification algorithm Currently: v ⩽ Prmin(S1 U S2) and Prmax(S1 U S2) ⩽ v = ⇒ Requires proof: ∃ optimal memoryless scheduler Import results by executing algorithm in Isabelle/HOL

23

slide-72
SLIDE 72

Application: Reachability problems on MDPs

Goal: certify solutions to reachability problems in MDPs = ⇒ Formalize MDPs and reachability problems Prmin

s

(S1 U S2) = lfp(· · · ) = ⇒ Implement and verify certification algorithm Currently: v ⩽ Prmin(S1 U S2) and Prmax(S1 U S2) ⩽ v = ⇒ Requires proof: ∃ optimal memoryless scheduler = ⇒ Import results by executing algorithm in Isabelle/HOL

23

slide-73
SLIDE 73

Application: pGCL semantics

Present the pGCL semantics similar to [Gretz, Katoen, McIver (2014)]: pgcl := Skip | Abort | Assign (σ ⇒ σ) | Seq pgcl pgcl | Par pgcl pgcl | If (σ ⇒ bool) pgcl pgcl | Prob [0, 1] pgcl pgcl | While (σ ⇒ bool) pgcl pgcl

24

slide-74
SLIDE 74

Weakest pre-expectation transformer

wp :: pgcl ⇒ ( σ ⇒ R∞

⩾0

) ⇒ ( σ ⇒ R∞

⩾0

) wp Skip f = f wp Abort f = ⊥ wp (Assign u) f = f ◦ u wp (Seq c1 c2) f = wp c1 (wp c2 f) wp (Par c1 c2) f = wp c1 f ⊓ wp c2 f wp (If b c1 c2) f = λs. if b s then wp c1 f s else wp c2 f s wp (Prob p c1 c2) f = λs. p · wp c1 f s + (1 − p) · wp c2 f s wp (While b c) f = lfp (λg s. if b s then wp c g s else f s)

25

slide-75
SLIDE 75

Operational semantics as MDP

K :: (pgcl × σ) ⇒ (pgcl × σ) pmf set K (Skip, s) = ≪ Skip, s ≫ K (Abort, s) = ≪ Abort, s ≫ K (Assign u, s) = ≪ Skip, u s ≫ K (Seq c1 c2, s) = K(c1, s) [ λ(c′

1, s′).

{ (Seq c′

1 c2, s′)

if c′

1 ̸= Skip

(c2, s′) else }] K (Par c1 c2, s) = ≪ c1, s ≫ ∪ ≪ c2, s ≫ K (If b c1 c2, s) = if b s then K (c1, s) else K (c2, s) K (Prob p c1 c2, s) = {{(c1, s) → p, (c2, s) → (1 − p))}} K (While g c, s) = { ≪ Seq c (While g c), s ≫ if g s ≪ Skip, s ≫ else

26

slide-76
SLIDE 76

Equate wp and K

Definition (Result of a Trace) r f ((c, s)·ω)

lfp

=       

r f ω if c ̸= Skip f s else

Theorem (Operational semantics equals denotational semantics)

min c s r f

wp c f s

27

slide-77
SLIDE 77

Equate wp and K

Definition (Result of a Trace) r f ((c, s)·ω)

lfp

=       

r f ω if c ̸= Skip f s else

Theorem (Operational semantics equals denotational semantics) Emin

(c,s)(r f) = wp c f s 27

slide-78
SLIDE 78

Proof

Emin

(c,s) (r f) = lfp

 λg s.

  • µ∈K(c,s)

(c,s)

{ g (c, s) if c ̸= Skip f s else } dµ   (c, s) Case c = Seq c1 c2: Emin

(Seq c1 c2,s)(r f) = Emin (c1,s)

( r ( λs′. Emin

(c2,s′)(r f)

)) Case c = While b c′: Emin(While g c′,s)(r f) = lfp w s w g s =

  • µ∈Ks

(d,t)

     g (d, t) if d ̸= Skip g (c′, t) if b t f t else      dµ

28

slide-79
SLIDE 79

Probabilistic Hierarchy

slide-80
SLIDE 80

Zoo of Probabilistic System Types

H., Traytel & Lochbihler [ITP 2015]

Ana Sokolva – Coalgebraic Analysis of Probabilistic Systems (2005):

30

slide-81
SLIDE 81

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-82
SLIDE 82

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-83
SLIDE 83

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-84
SLIDE 84

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-85
SLIDE 85

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-86
SLIDE 86

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-87
SLIDE 87

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-88
SLIDE 88

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-89
SLIDE 89

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-90
SLIDE 90

Hierarchy of Probabilistic Systems Types

How to … …model system types? …compare systems of same type? …compare different system types? Coalgebras Bisimulation Embedding respecting bisimulation …formalize it in Isabelle/HOL? codatatype + Probability Mass Func.

31

slide-91
SLIDE 91

Coalgebras as Codatatypes in Isabelle/HOL

Idea: Analyse transition systems modulo bisimulation!

Equality :⇐ ⇒ Bisimulation

How to model all F-coalgebras as type? codatatype

F

C

F F

Example (Labeled Markov Chains where F pmf): codatatype mc MC mc pmf

32

slide-92
SLIDE 92

Coalgebras as Codatatypes in Isabelle/HOL

Idea: Analyse transition systems modulo bisimulation!

Equality :⇐ ⇒ Bisimulation

How to model all F-coalgebras as type? codatatype

F

C

F F

Example (Labeled Markov Chains where F pmf): codatatype mc MC mc pmf

32

slide-93
SLIDE 93

Coalgebras as Codatatypes in Isabelle/HOL

Idea: Analyse transition systems modulo bisimulation!

Equality :⇐ ⇒ Bisimulation

How to model all F-coalgebras as type? codatatype τF = C (τF F) Example (Labeled Markov Chains where F pmf): codatatype mc MC mc pmf

32

slide-94
SLIDE 94

Coalgebras as Codatatypes in Isabelle/HOL

Idea: Analyse transition systems modulo bisimulation!

Equality :⇐ ⇒ Bisimulation

How to model all F-coalgebras as type? codatatype τF = C (τF F) Example (Labeled Markov Chains where F = α × □ pmf): codatatype α mc = MC (α × α mc pmf)

32

slide-95
SLIDE 95

System Types

Name Functor Codatatype Markov chain σ pmf MC Labeled MC α × σ pmf α LMC Labeled MDP α × σ pmf setκ

1

α LMDPκ

  • Det. automaton

α ⇒ σ option α DLTS Non-det. automaton (α × σ) setκ α LTSκ Reactive system α ⇒ σ pmf option α React Generative system (α × σ) pmf option α Gen Stratified system σ pmf + (α × σ) option α Str Alternating system σ pmf + (α × σ) setκ α Altκ Simple Segala system (α × σ pmf) setκ α SSegκ Segala system (α × σ) pmf setκ α Segκ Bundle system (α × σ) setκ pmf α Bunκ Pnueli-Zuck system (α × σ) setκ1 pmf setκ2 α PZκ1, κ2 Most general system (α × σ + σ) setκ1 pmf setκ2 α MGκ1, κ2

33

slide-96
SLIDE 96

Hierarchy

α MGκ1, κ2 α option PZκ1, κ2 α option Bunκ α option Segκ α Altκ α PZκ1, κ2 α Bunκ α Segκ α Gen α SSegκ α option SSegκ α Str α LMDPκ α LMC α React α LTSκ MC α DLTS

κ⩽κ1 κ⩽κ2 κ⩽κ1 κ⩽κ2 α set⩽κ α set⩽κ 34

slide-97
SLIDE 97

Hierarchy of Probabilistic System Types

Ana Sokolva – Coalgebraic Analysis of Probabilistic Systems (2005):

35

slide-98
SLIDE 98

Conclusion

slide-99
SLIDE 99

Related Work

Formalizing probabilistic trace spaces:

  • Formal verification of probabilistic algorithms

Hurd [thesis 2002]

  • Formal reasoning about classified Markov chains in HOL

Liu, Hasan, Aravantinos, and Tahar [ITP 2013] Formalizing probabilistic transition systems:

  • Probabilistic guarded commands mechanized in HOL

Hurd, McIver, and Morgan [Theor. Comput. Sci. 2005]

  • Proofs of randomized algorithms in Coq

Audebaud and Paulin-Mohring [MPC 2006]

  • Verifying probabilistic correctness in Isabelle with pGCL

Cock [SSV 2012]

37

slide-100
SLIDE 100

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38

slide-101
SLIDE 101

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38

slide-102
SLIDE 102

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38

slide-103
SLIDE 103

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38

slide-104
SLIDE 104

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38

slide-105
SLIDE 105

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38

slide-106
SLIDE 106

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38

slide-107
SLIDE 107

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38

slide-108
SLIDE 108

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38

slide-109
SLIDE 109

Conclusion

  • Coalgebraic & Fixed point approach simplified out theory

(also smaller proofs)

  • Very usable for our applications
  • Probabilistic model checking
  • pGCL semantics equivalence
  • Small examples on fixed models
  • Formalized hierarchy of probabilistic systems types

Found two flaws

  • Probability theory also used for:
  • Density Compiler [Eberl, H., Nipkow (ESOP 2015)]
  • Central Limit Theorem [Avigad, H., Serafin (2014)]
  • Future Work:

Average Runtime Analysis, Probabilistic Programming

38