§ Regular Plain Separation Logic
- Have the separating conjuction
*and the magic wand operator-*. - We use what's called as the 'update pattern' (?) when trying to reason about thing like linked lists.
- For example, consider the program that returns the pointer to the
nth element on the linked list.
using LinkedList = ptr[(int, LinkedList)]def nth(x : ptr, i : int) -> ptr: match i: case 0: return x case succ i': return nth(x.next, i')§ Concurrent Separation Logic Without Higher Order Nonsense
§ Invariants
- An invariant is a proposition that's drawn as if it's in a box (I assume it's a modality?)
- Firstly an invaraiant is duplicable, and is thus not substructral.
- Secondly, an invariant can be 'opened', as long as can re-prove the invariant after closing it.
- I can't remember where ''atomically?'' was important.
Consider a program that adds 2 and 2 to a variable x.
def progi(_i : thread_id, x : int): x += 2 return xx = 0; progi(0, x) || progi(0, x);- If we just have invariants, then we can keep an invariant that
xis even, and we can prove that both threads maintain this invariant. - However, we cannot prove that the value of
xis4. - So, we invent some more machinery to allow us to prove that
xis4.
§ Resource Algebras
- Resource algebra is a commutative monoid that has a predicate
validon it. - For example, for fractional ownership, we use , where
valid(x)is true if . We use as the unit, and . - This generalizes heaps, because a heap is a RA with finite maps and a bottom element, with
valid(h)is true ifhis a finite map, andh1 * h2 = h1 \cup h2ifdom(h1) \cap dom(h2) = \emptyset, and bottom otherwise. The unit is the empty heap. - More interestingly, we can have an RA that has
frac(a)orbotha(a)orfull(a)orempty(a)orbottom. - We say that
frac(a) <> full(a) = both(a), andempty(a) <> x = x, and anything else isbottom.
x = 0; progi(0, x) || progi(0, x);- We start with the precondition that
x = p1 + p2and....
§ Atomically
I can't remmber where this played a role.