1
Annabelle McIver Carroll Morgan
- Source-level program logic
- Meta-theorems for loops
- Examples
- Probabilistic amplification
- Uniform selection
Formal Methods for Probabilistic Systems Annabelle McIver Carroll - - PowerPoint PPT Presentation
1 Formal Methods for Probabilistic Systems Annabelle McIver Carroll Morgan Source-level program logic Meta-theorems for loops Examples Probabilistic amplification Uniform selection 2 Probabilistic amplification Is K
1
2
Is K prime? true “yes” false “no” The Miller-Rabin test “puts K to the Question”. If K is prime, it will never confess; but if it is composite, then it will confess with probability 1/ 2. Probabilistic amplification interrogates K a number of times, to increase the probability of confession. (The real Inquisition allowed only three interrogations.)
3
4
5
wp.( n:= n-1 )
wp.( a:= Q 1/ 2 true )
arithmetic
arithmetic
[a] from guard Invariant “at end of loop body” Invariant “at beginning of loop body” Loop guard
6
Invariant “at end of loop body”
arithmetic Negated loop guard
drop guard
arithmetic Overall post-expectation
7
sufficient
Invariant “at beginning of loop body”
Termination condition Probability of establishing Q=a is at least this...
wp.( a,n:=true,N )
arithmetic ...provided termination is guaranteed.
8
“postcondition”
9
“postcondition” invariant
10
invariant and negated guard
11
implies postcondition
12
invariant must be maintained
13
work backwards
14
work backwards
15
work backwards
16
1/ 2 }
should be implied by invariant and guard
17
1/ 2 1 Q 1 - 1/ 2n-1 }
simplify
18
simplify more
19
and more
20
strengthen and “massage”
21
is now of the form “guard and invariant”
22
pre-expectation is invariant and termination condition
23
backwards through initialisation
24
weaken, for simplicity
25
specification
26
The probability that question Q is correctly answered by answer a is at least 1 - 1/ 2N, provided N is non-negative. The error probability is at most 1/ 2N.
27
Demonic choice of m. “Expanded” syntax for probabilistic choice.
28
wp.( ••• | @ ••• )
+ (m-l )/ (h-l ) [l K < m ]/ (m-l ) [l K < h ]/ (h-l )
wp.( m:{l < m < h} ) and standard invariant l < h
The invariant is preserved
m:{l < m < h}; | l:= m @ (h-m)/ (h-l ) | h:=m @ (m-l )/ (h-l )
arithmetic
arithmetic
29
wp.( ••• | @ ••• )
wp.( m:{l < m < h} ) and standard invariant l < h
arithmetic
arithmetic
30
31
specification