Simpson’s 4-slot algorithm, proved in three slides
Richard Bornat School of Computing, Middlesex University (and Matthew Parkinson, ditto) 20th December 2005
1
Simpsons 4-slot algorithm, proved in three slides Richard Bornat - - PowerPoint PPT Presentation
Simpsons 4-slot algorithm, proved in three slides Richard Bornat School of Computing, Middlesex University (and Matthew Parkinson, ditto) 20th December 2005 1 Data structures: a bit array and a wide data array slot: 0 1 wide data: 2
1
2
3
3
4
◮ E → F is a single-celled heap with address E and content F. 4
◮ E → F is a single-celled heap with address E and content F. ◮ E → F0, F1 is a two-celled heap; E → F0, F1, F2 is three cells;
4
◮ E → F is a single-celled heap with address E and content F. ◮ E → F0, F1 is a two-celled heap; E → F0, F1, F2 is three cells;
◮ E and F must be ‘pure’ expressions that don’t mention the heap
4
◮ E → F is a single-celled heap with address E and content F. ◮ E → F0, F1 is a two-celled heap; E → F0, F1, F2 is three cells;
◮ E and F must be ‘pure’ expressions that don’t mention the heap
◮ A ⋆ B is separation of heaps; A ∧ B, A ∨ B, ¬A, A → B, ∀x · P(x),
4
◮ E → F is a single-celled heap with address E and content F. ◮ E → F0, F1 is a two-celled heap; E → F0, F1, F2 is three cells;
◮ E and F must be ‘pure’ expressions that don’t mention the heap
◮ A ⋆ B is separation of heaps; A ∧ B, A ∨ B, ¬A, A → B, ∀x · P(x),
◮ E → F0, F1 is just shorthand for E → F0 ⋆ E + 1 → F1. 4
5
◮ {Q} C {R} is a resourced and partial correctness assertion. C
5
◮ {Q} C {R} is a resourced and partial correctness assertion. C
◮ The ‘small axioms’ of assignment are
5
6
◮ The frame rule:
6
◮ The frame rule:
◮ The concurrency rule (has horrid side-condition):
6
◮ The frame rule:
◮ The concurrency rule (has horrid side-condition):
◮ The CCR rule (has atrocious side condition):
6
7
◮ Permissions (fractions of →, counts of ) to allow sharing of
7
◮ Permissions (fractions of →, counts of ) to allow sharing of
◮ Variable permissions, to allow variables to be resource; 7
◮ Permissions (fractions of →, counts of ) to allow sharing of
◮ Variable permissions, to allow variables to be resource; ◮ Trivial side conditions; 7
◮ Permissions (fractions of →, counts of ) to allow sharing of
◮ Variable permissions, to allow variables to be resource; ◮ Trivial side conditions; ◮ No side conditions at all (very new, this!). 7
8
9
10
latest0.5, reading0.5, slot0.5, data0.33, wuse0.5, ruse0.5 ∃s · slot[0] − − − →
0.5 s(0) ⋆ slot[1] −
− − →
0.5 s(1) ⋆
if wuse ≥ 0 ∧ ruse ≥ 0 then data[reading, not(ruse)] → ⋆ data[wuse, s(wuse)] → elsf wuse ≥ 0 then data[wuse, s(wuse)] → ⋆ data[not(wuse), s(not(wuse))] → ⋆ data[not(wuse), not(s(not(wuse)))] → elsf ruse ≥ 0 then data[reading, not(ruse)] → ⋆ data[not(reading), s(not(reading))] → ⋆ data[not(reading), not(s(not(reading))] → ) else data → , , , fi
11
0.5
0.5
0.5
0.5
0.5
0.5
0.5 i ⋆ slot[not(pair)] −
0.5
0.5
0.5
0.5
0.5
0.5 i ⋆ slot[not(pair)] −
0.5
0.5 not(index) ⋆ slot[not(pair)] −
0.5
0.5
0.5
0.5
0.5
0.5 i ⋆ slot[not(pair)] −
0.5
0.5 not(index) ⋆ slot[not(pair)] −
0.5
0.5 not(index) ⋆ slot[not(pair)] −
0.5
0.5
0.5
0.5
0.5
0.5 i ⋆ slot[not(pair)] −
0.5
0.5 not(index) ⋆ slot[not(pair)] −
0.5
0.5 not(index) ⋆ slot[not(pair)] −
0.5
0.5
0.5
0.5
0.5
− − →
0.5
⋆ slot[1] − − − →
0.5
pair := not(reading); wuse := pair
wuse = pair ∧ ∃i ·
− − →
0.5 i ⋆ slot[not(pair)] −
− − →
0.5
⋆ data[pair, not(i)] →
− − →
0.5
⋆ slot[1] − − − →
0.5
latest, reading0.5, slot, data0.66, wuse,pair, index ∃s · wuse = −1 ∧ slot → s(0), s(1) ⋆ data[not(reading), s(not(reading))] → ⋆ data[not(reading), not(s(not(reading)))] → ⋆ if ruse ≥ 0 then data[reading, not(ruse)] → else data[reading, s(reading)] → ⋆ data[reading, not(s(reading))] → fi pair := not(reading); wuse := pair
wuse = pair ∧ ∃i ·
− − →
0.5 i ⋆ slot[not(pair)] −
− − →
0.5
⋆ data[pair, not(i)] →
− − →
0.5
⋆ slot[1] − − − →
0.5
latest, reading0.5, slot, data0.66, wuse,pair, index ∃s · wuse = −1 ∧ slot → s(0), s(1) ⋆ data[not(reading), s(not(reading))] → ⋆ data[not(reading), not(s(not(reading)))] → ⋆ if ruse ≥ 0 then data[reading, not(ruse)] → else data[reading, s(reading)] → ⋆ data[reading, not(s(reading))] → fi pair := not(reading); latest, reading0.5, slot, data0.66, wuse,pair, index ∃s · wuse = −1 ∧ pair = not(reading) ∧ slot → s(0), s(1) ⋆ data[not(reading), s(not(reading))] → ⋆ data[not(reading), not(s(not(reading)))] → ⋆ if ruse ≥ 0 then data[reading, not(ruse)] → else data[reading, s(reading)] → ⋆ data[reading, not(s(reading))] → fi wuse := pair
wuse = pair ∧ ∃i ·
− − →
0.5 i ⋆ slot[not(pair)] −
− − →
0.5
⋆ data[pair, not(i)] →
− − →
0.5
⋆ slot[1] − − − →
0.5
latest, reading0.5, slot, data0.66, wuse,pair, index ∃s · wuse = −1 ∧ slot → s(0), s(1) ⋆ data[not(reading), s(not(reading))] → ⋆ data[not(reading), not(s(not(reading)))] → ⋆ if ruse ≥ 0 then data[reading, not(ruse)] → else data[reading, s(reading)] → ⋆ data[reading, not(s(reading))] → fi pair := not(reading); latest, reading0.5, slot, data0.66, wuse,pair, index ∃s · wuse = −1 ∧ pair = not(reading) ∧ slot → s(0), s(1) ⋆ data[not(reading), s(not(reading))] → ⋆ data[not(reading), not(s(not(reading)))] → ⋆ if ruse ≥ 0 then data[reading, not(ruse)] → else data[reading, s(reading)] → ⋆ data[reading, not(s(reading))] → fi wuse := pair latest, reading0.5, slot, data0.66, wuse,pair, index ∃s · wuse = pair ∧ pair = not(reading) ∧ slot → s(0), s(1) ⋆ data[not(reading), s(not(reading))] → ⋆ data[not(reading), not(s(not(reading)))] → ⋆ if ruse ≥ 0 then data[reading, not(ruse)] → else data[reading, s(reading)] → ⋆ data[reading, not(s(reading))] → fi
wuse = pair ∧ ∃i ·
− − →
0.5 i ⋆ slot[not(pair)] −
− − →
0.5
⋆ data[pair, not(i)] →
15
15