Higher-Order Concurrent Separation Logic: Why and How
Lars Birkedal Aarhus University Nijmegen, Netherlands Dec, 2015
Modular Reasoning about Higher-Order Concurrent Imperative Programs
1 / 33
Higher-Order Concurrent Separation Logic: Why and How Lars Birkedal - - PowerPoint PPT Presentation
Higher-Order Concurrent Separation Logic: Why and How Lars Birkedal Aarhus University Nijmegen, Netherlands Dec, 2015 Modular Reasoning about Higher-Order Concurrent Imperative Programs 1 / 33 Introduction Goal Program logics for
1 / 33
◮ Program logics for modular reasoning about partial
2 / 33
◮ via example of layered and recursive abstraction.
◮ via example verification of lock implementation ◮ invariants to enforce protocols ◮ monoids to express protocols (ownership)
◮ BI-hyperdoctrine over ultra-metric spaces, Kripke model
◮ tutorial material ◮ papers: iCAP [ESOP-2014] and Iris [POPL-2015] ◮ paper on formalization: ModuRes Library [ITP-2015]
3 / 33
◮ Programming features
◮ HO functions ◮ Interfaces in OO languages ◮ Function Pointers in low-level languages
◮ for
◮ Building libraries ◮ Returning libraries ◮ Parameterization
◮ Point:
◮ Features important for modularizing large programs ◮ Allow programming relative to unknown code
◮ Goal: Logics and Models that support correspondingly
4 / 33
◮ Modular library specifications that supports
5 / 33
◮ Modular library specifications that supports
5 / 33
◮ Modular library specifications that supports
5 / 33
6 / 33
6 / 33
6 / 33
6 / 33
7 / 33
7 / 33
7 / 33
7 / 33
7 / 33
7 / 33
7 / 33
8 / 33
8 / 33
8 / 33
◮ Since we are interested in memory safety, eloop has to
9 / 33
◮ Since we are interested in memory safety, eloop has to
◮ Since an event loop can call handlers, its footprint include
◮ Since handlers can signal events, the footprint of handlers
9 / 33
◮ Since we are interested in memory safety, eloop has to
◮ Since an event loop can call handlers, its footprint include
◮ Since handlers can signal events, the footprint of handlers
◮ The footprint of an event loop is thus recursively defined.
9 / 33
◮ Imagine an implementation that maintains a set of signal
◮ Tying Landin’s Knot using a reference protected by a lock.
10 / 33
◮ The footprint of an event loop is thus recursively
11 / 33
◮ The footprint of an event loop is thus recursively
◮ We define eloop using guarded recursion and the
11 / 33
◮ The footprint of an event loop is thus recursively
◮ We define eloop using guarded recursion and the
11 / 33
◮ The footprint of an event loop is thus recursively
◮ We define eloop using guarded recursion and the
11 / 33
◮ The footprint of an event loop is thus recursively
◮ We define eloop using guarded recursion and the
11 / 33
◮ The footprint of an event loop is thus recursively
◮ We define eloop using guarded recursion and the
11 / 33
◮ The footprint of an event loop is thus recursively
◮ We define eloop using guarded recursion and the
11 / 33
◮ Higher-order logic + guarded recursion useful for
◮ Next: impredicative protocols for verifying module
12 / 33
◮ Upon allocating a lock, we introduce a protocol to govern
13 / 33
◮ Upon allocating a lock, we introduce a protocol to govern
◮ A lock can be in one of two abstract states:
13 / 33
◮ Upon allocating a lock, we introduce a protocol to govern
◮ A lock can be in one of two abstract states:
13 / 33
◮ Upon allocating a lock, we introduce a protocol to govern
◮ A lock can be in one of two abstract states:
13 / 33
◮ Protocol expressed via invariant:
14 / 33
◮ Protocol expressed via invariant:
14 / 33
◮ Protocol expressed via invariant:
◮ Parameterized by R, any predicate, including one referring
14 / 33
◮ Protocol expressed via invariant:
◮ Parameterized by R, any predicate, including one referring
◮ Only the owner of the lock should be able to unlock:
◮ Expressed via monoid: the • is an element of a partial
◮ Also uses standard PCM of heaps.
14 / 33
◮ Monoids to express protocols on shared state ◮ Invariants to enforce protocol governing shared state ◮ Protocol parametric in R: impredicative protocols.
15 / 33
◮ Modular Bag Specification (excerpt)
0.5
0.5
0.5
◮ Parameterization to allow clients to reason about what
16 / 33
◮ pending: an offer has been made and it is waiting for
◮ accepted: the offer has been accepted, ◮ ack’ed: we have acknowledged that somebody has
◮ revoked: in case we revoke the offer (since no one
17 / 33
0.5
0.5
18 / 33
◮ Key logical tools: impredicative protocols and view shifts.
◮ iCap was the first logic to allow verification of such FCDs
19 / 33
◮ Prop = W →mon P(M)
◮ M a PCM (a product of all the necessary monoids) ◮ W : worlds, keeping track of invariants 20 / 33
◮ Prop = W →mon P(M)
◮ M a PCM (a product of all the necessary monoids) ◮ W : worlds, keeping track of invariants
◮ W = N ⇀fin Prop
◮ names of invariants are natural numbers ◮ each invariant described by a predicate (recall I(R) for
20 / 33
◮ Prop = W →mon P(M)
◮ M a PCM (a product of all the necessary monoids) ◮ W : worlds, keeping track of invariants
◮ W = N ⇀fin Prop
◮ names of invariants are natural numbers ◮ each invariant described by a predicate (recall I(R) for
◮ So need something like
20 / 33
◮ Our approach: solve in model of guarded type theory:
◮ iCAP: use topos of trees and construct model
◮ Iris: more explicit using subcat U corresponding to
21 / 33
◮ Let U be category of complete bisected ultrametric
◮ Equivalently described as complete ordered families of
◮ Use uniform predicates instead of just predicates:
◮ Can model guarded predicates (the ⊲) by “shifting a
◮ Solve
ne
22 / 33
◮ Theorem U( , Prop) is a BI-hyperdoctrine, which also
◮ models guarded recursive predicates ◮ models invariants ◮ also models hoare triples and associated proof rules, but
23 / 33
◮ Theorem U( , Prop) is a BI-hyperdoctrine, which also
◮ models guarded recursive predicates ◮ models invariants ◮ also models hoare triples and associated proof rules, but
◮ Explicitly:
◮ Γ ⊢ φ : prop is interpreted as a non-expansive function
23 / 33
n+1
[σ] ]
[σ] ]
24 / 33
25 / 33
26 / 33
K]
n+1
27 / 33
◮ Theorem U( , Prop) is a BI-hyperdoctrine, which also
◮ models guarded recursive predicates ◮ models invariants
◮ Key Observation (Iris):
◮ By choosing monoids appropriately, we can encode many
28 / 33
◮ Verify meta-theory (model construction and soundness of
◮ Tool(s) for experimenting with larger program
◮ Support for higher-order quantification is important.
◮ Earlier work: Charge! (with Bengtson, Jensen,
◮ For sequential OO language, logic without invariants. ◮ Shallow embedding of logic, Coq tactics to automate
◮ Non-trivial to reason efficiently in embedded logic. 29 / 33
◮ ModuRes Coq Library [ITP-2015]
◮ Implementation of U and solutions to g.r. domain eqn’s. ◮ Draft tutorial material online (model of ML references) ◮ Used to verify meta-theory of Iris
◮ Ongoing and Future Work (with Krebbers, Jung, Dreyer,
◮ New tool for concurrency reasoning based on
◮ Hope to make use of progress by Malecha and Bengtson
30 / 33
◮ Elementary tutorial notes on categorical logic (including
◮ Papers:
◮ ModuRes Coq Library [ITP-2015] ◮ iCAP [ESOP-2014] ◮ Iris [POPL-215] ◮ Cover many other aspects, e.g. advanced FCDs, logical
◮ http://cs.au.dk/~birke/modures/
31 / 33
◮ Defining logical relations in Iris (a la Plokin-Abadi for
◮ security properties such as non-interference ◮ optimizations based on type and effect systems
◮ Liveness properties.
32 / 33
◮ Kasper Svendsen ◮ Aleˇ
◮ Filip Sieczkowski ◮ Yannick Zakowski ◮ Derek Dreyer ◮ Aaron Turon ◮ Ralf Jung ◮ David Swasey
33 / 33