Bunched logic explained

Bunched logic[1] is a variety of substructural logic proposed by Peter O'Hearn and David Pym. Bunched logic provides primitives for reasoning about resource composition, which aid in the compositional analysis of computer and other systems. It has category-theoretic and truth-functional semantics, which can be understood in terms of an abstract concept of resource, and a proof theory in which the contexts Γ in an entailment judgement Γ ⊢ A are tree-like structures (bunches) rather than lists or (multi)sets as in most proof calculi. Bunched logic has an associated type theory, and its first application was in providing a way to control the aliasing and other forms of interference in imperative programs.[2] The logic has seen further applications in program verification, where it is the basis of the assertion language of separation logic,[3] and in systems modelling, where it provides a way to decompose the resources used by components of a system.

Foundations

The deduction theorem of classical logic relates conjunction and implication:

A\wedgeB\vdashCiffA\vdashBC

Bunched logic has two versions of the deduction theorem:

A*B\vdashCiffA\vdashB{-*}C    andalso    A\wedgeB\vdashCiffA\vdashBC

A*B

and

B{-*}C

are forms of conjunction and implication that take resources into account (explained below). In addition to these connectivesbunched logic has a formula, sometimes written I or emp, which is the unit of *. In the original version of bunched logic

\wedge

and

were the connectives from intuitionistic logic, while a boolean variant takes

\wedge

and

(and

\neg

) as from traditional boolean logic. Thus, bunched logic is compatible with constructive principles, but is in no way dependent on them.

Truth-functional semantics (resource semantics)

The easiest way to understand these formulae is in terms of its truth-functional semantics. In this semantics a formula is true or false with respect to given resources.

A*B

asserts that the resource at hand can be decomposed into resources that satisfy

A

and

B

.

B{-*}C

says that if we compose the resource at hand with additional resource that satisfies

B

, then the combined resource satisfies

C

.

\wedge

and

have their familiar meanings.

The foundation for this reading of formulae was provided bya forcing semantics

r\modelsA

advanced by Pym, where the forcing relation means A holds of resource r. The semantics is analogous to Kripke's semantics of intuitionistic or modal logic, but where the elements of the model are regarded as resources that can be composed and decomposed, rather than as possible worlds that are accessible from one another. For example, the forcing semantics for the conjunction is of the form

r\modelsA*Biff\existsrArB.rA\modelsA,rB\modelsB,andrA\bulletrB\leqr

where

rA\bulletrB

is a way of combining resources and

\leq

is a relation of approximation.

This semantics of bunched logic draws on prior work in relevance logic (especially the operational semantics of Routley–Meyer), but differs from it by not requiring

r\bulletr\leqr

and by accepting the semantics of standard intuitionistic or classical versions of

\wedge

and

. The property

r\bulletr\leqr

is justified when thinking about relevance but denied by considerations of resource; having two copies of a resource is not the same as having one, and in some models (e.g. heap models)

r\bulletr

might not even be defined. The standard semantics of

(or of negation) is often rejected by relevantists in their bid to escape the `paradoxes of material implication', which are not a problem from the perspective of modelling resources and so not rejected by bunched logic. The semantics is also related to the 'phase semantics' of linear logic, but again is differentiated by accepting the standard (even boolean) semantics of

\wedge

and

, which in linear logic is rejected in a bid to be constructive. These considerations are discussed in detail in an article on resource semantics by Pym, O'Hearn and Yang.[4]

Categorical semantics (doubly closed categories)

The double version of the deduction theorem of bunched logic has a corresponding category-theoretic structure. Proofs in intuitionistic logic can be interpreted in cartesian closed categories, that is, categories with finite products satisfying the (natural in A and C) adjunction correspondence relating hom sets:

Hom(A\wedgeB,C)isisomorphictoHom(A,BC)

Bunched logic can be interpreted in categories possessing two such structures

a categorical model of bunched logic is a single category possessing two closed structures, one symmetric monoidal closed the other cartesian closed.A host of categorial models can be given using Day's tensor product construction.[5] Additionally, the implicational fragment of bunched logic has been given a game semantics.[6]

Algebraic semantics

The algebraic semantics of bunched logic is a special case of its categorical semantics, but is simple to state and can be more approachable.

An algebraic model of bunched logic is a poset that is a Heyting algebra and that carries an additional commutative residuated lattice structure (for the same lattice as the Heyting algebra): that is, an ordered commutative monoid with an associated implication satisfying

A*B\leqCiffA\leqB{-*}C

.The boolean version of bunched logic has models as follows.

An algebraic model of boolean bunched logic is a poset that is a Boolean algebra and that carries an additional residuated commutative monoid structure.

Proof theory and type theory (bunches)

The proof calculus of bunched logicdiffers from usual sequent calculi in having a tree-like context of hypotheses instead of a flat list-like structure. In its sequent-based proof theories, the context

\Delta

in an entailment judgement

\Delta\vdashA

is a finite rooted tree whose leaves are propositions and whose internal nodes are labelled with modes of composition corresponding to the two conjunctions. The two combining operators, comma and semicolon, are used (for instance) in the introduction rules for the two implications.
\Gamma,A\vdashB
\Gamma\vdashA{-*

B}      

\Gamma;A\vdashB
\Gamma\vdashA{

B}

The difference between the two composition rules comes from additional rules that apply to them.

\Delta,\Gamma

denies the structural rules of weakening and contraction.

\Delta;\Gamma

admits weakening and contraction of entire bunches.The structural rules and other operations on bunches are often applied deep within a tree-context, and not only at the top level: it is thus in a sense a calculus of deep inference.

Corresponding to bunched logic is a type theory having two kinds of function type. Following the Curry–Howard correspondence, introduction rules for implications correspond to introduction rules for function types.

\Gamma,x:A\vdashM:B
\Gamma\vdashλx.M:A{-*

B}      

\Gamma;x:A\vdashM:B
\Gamma\vdash\alphax.M:A{

B}

Here, there are two distinct binders,

λ

and

\alpha

, one for each kind of function type.

The proof theory of bunched logic has an historical debt to the use of bunches in relevance logic.[7] But the bunched structure can in a sense be derived from the categorical and algebraic semantics:to formulate an introduction rule for

{-*}

we should mimick

*

on the left in sequents, and to introduce

we should mimick

\wedge

. This consideration leads to the use of two combining operators.

James Brotherston has done further significant work on a unified proof theory for bunched logic and variants,[8] employing Belnap's notion of display logic.[9]

Galmiche, Méry, and Pym have provided a comprehensive treatment of bunched logic, including completeness and other meta-theory, based on labelled tableaux.[10]

Applications

Interference control

In perhaps the first use of substructural type theory to control resources, John C. Reynolds showed how to use an affine type theory to control aliasing and other forms of interference in Algol-like programming languages.[11] O'Hearn used bunched type theory to extend Reynolds' system by allowing interference and non-interference to be more flexibly mixed. This resolved open problems concerning recursion and jumps in Reynolds' system.

Separation logic

Separation logic is an extension of Hoare logic that facilitates reasoning about mutable data structures that use pointers. Following Hoare logic the formulae of separation logic are of the form

\{Pre\}program\{Post\}

, but the preconditions and postconditions are formulae interpreted in a model of bunched logic.The original version of the logic was based on models as follows:

Heaps=L\rightharpoonupfV   

(finite partial functions from locations to values)

h0\bulleth1=

union of heaps with disjoint domains, undefined when domains overlap.It is the undefinedness of the composition on overlapping heaps that models the separation idea. This is a model of the boolean variant of bunched logic.

Separation logic was used originally to prove properties of sequential programs, but then was extended to concurrency using a proof rule

\{P1\
C

1\{Q1\}\{P2\}C2\{Q2\}}{\{P1*P2\}C1\parallelC2\{Q1*Q2\}}

that divides the storage accessed by parallel threads.[12]

Later, the greater generality of the resource semantics was utilized: an abstract version of separation logic works for Hoare tripleswhere the preconditions and postconditions are formulae interpreted over an arbitrary partial commutative monoid instead of a particular heap model.[13] By suitable choice of commutative monoid, it was surprisingly found that the proofs rules of abstract versions of concurrent separation logic could be used to reason about interfering concurrent processes, for example by encoding rely-guarantee and trace-based reasoning.[14] [15]

Separation logic is the basis of a number of tools for automatic and semi-automatic reasoning about programs, and is used in the Infer program analyzer currently deployed at Facebook.[16]

Resources and processes

Bunched logic has been used in connection with the (synchronous) resource-process calculus SCRP[17] [18] [19] in order to give a (modal) logic that characterizes, in the sense of HennessyMilner, the compositional structure of concurrent systems.

SCRP is notable for interpreting

A*B

in terms of both parallel composition of systems and composition of their associated resources.The semantic clause of SCRP's process logic that corresponds to separation logic's rule for concurrency asserts that a formula

A*B

is true in resource-process state

R

,

E

just in case there are decompositions of the resource

R=S\bulletT

and process

E

~

F x G

, where ~ denotes bisimulation, such that

A

is true in the resource-process state

S

,

F

and

B

is true in the resource-process state

T

,

G

; that is

R,E\modelsA

iff

S,F\modelsA

and

T,G\modelsB

.

The system SCRP is based directly on bunched logic's resource semantics; that is, on ordered monoids of resource elements. While direct and intuitively appealing, this choice leads to a specific technical problem: the Hennessy–Milner completeness theorem holds only for fragments of the modal logic that exclude the multiplicative implication and multiplicative modalities. This problem is solved by basing resource-process calculus on a resource semantics in which resource elements are combined using two combinators, one corresponding to concurrent composition and one corresponding to choice.[20]

Spatial logics

Cardelli, Caires, Gordon and others have investigated a series of logics of process calculi, where a conjunction is interpreted in terms of parallel composition.Unlike the work of Pym et al. in SCRP, they do not distinguish between parallel composition of systems and composition of resources accessed by the systems.

Their logics are based on instances of the resource semantics that give rise to models of the boolean variant of bunched logic. Although these logics give rise to instances of boolean bunched logic, they appear to have been arrived at independently, and in any case have significant additional structure in the way of modalities and binders. Related logics have been proposed as well for modelling XML data.

See also

Notes and References

  1. O'Hearn. Peter. Pym. David. The Logic of Bunched Implications. Bulletin of Symbolic Logic. 1999. 5. 2. 215–244. 10.2307/421090. 421090. 10.1.1.27.4742. 2948552 .
  2. O'Hearn. Peter. On Bunched Typing. Journal of Functional Programming. 2003. 13. 4. 747–796. 10.1017/S0956796802004495.
  3. Ishtiaq. Samin. O'Hearn. Peter. BI as an assertion language for mutable data structures. POPL. 2001. 28th. 3. 14–26. 10.1145/373243.375719. 10.1.1.11.4925.
  4. Pym. David. O'Hearn. Peter. Yang. Hongseok. Possible worlds and resources: The semantics of BI. Theoretical Computer Science. 2004. 315. 1. 257–305. 10.1016/j.tcs.2003.11.020. free.
  5. Book: Day. Brian. On closed categories of functors. Reports of the Midwest Category Seminar IV . Lecture Notes in Mathematics . 137. Springer. 1970. 1–38. https://www.math.rochester.edu/people/faculty/doug/otherpapers/DayReport.pdf.
  6. Book: McCusker. Guy. Pym. David. A Games Model of Bunched Implications. Computer Science Logic . Lecture Notes in Computer Science . 4646 . Springer. 2007. http://www.cs.bath.ac.uk/~gam23/papers/innocentBI.pdf.
  7. Book: Read. Stephen. Relevant Logic: A Philosophical Examination of Inference. 1989. Wiley-Blackwell.
  8. Brotherston. James. Bunched logics displayed. Studia Logica. 2012. 100. 6. 1223–1254. 10.1007/s11225-012-9449-0. 10.1.1.174.8777. 13634990.
  9. Belnap. Nuel. Display logic. Journal of Philosophical Logic. 1982. 11. 4. 375–417. 10.1007/BF00284976. 41451176.
  10. The Semantics of BI and Resource Tableaux. Galmiche. Didier. 2005. Mathematical Structures in Computer Science. 10.1017/S0960129505004858. Méry. Daniel. Pym. David. 15. 6. 1033–1088. 10.1.1.144.1421. 1700033.
  11. Book: Reynolds. John. Proceedings of the 5th ACM SIGACT-SIGPLAN symposium on Principles of programming languages - POPL '78 . Syntactic control of interference . 39–46. 10.1145/512760.512766. 1978. 9781450373487. 18716926. free.
  12. O'Hearn. Peter. Resources, Concurrency and Local Reasoning. Theoretical Computer Science. 2007. 375. 1–3. 271–307. 10.1016/j.tcs.2006.12.035. free.
  13. Book: 10.1109/LICS.2007.30. http://www.cs.ox.ac.uk/people/hongseok.yang/paper/asl-short.pdf. 978-0-7695-2908-0. 10.1.1.66.6337. Local Action and Abstract Separation Logic. 22nd Annual IEEE Symposium on Logic in Computer Science (LICS 2007). 366–378. 2007. Calcagno. Cristiano. O'Hearn. Peter W.. Yang. Hongseok. 1044254.
  14. Dinsdale-Young. Thomas. Birkedal. Lars. Gardner. Philippa. Parkinson. Matthew. Yang. Hongseok. Views: Compositional Reasoning for Concurrent Programs. Proceedings of the 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 48. 287–300. 2013. 10.1145/2480359.2429104.
  15. Sergey. Ilya. Nanevski. Aleksandar. Banerjee. Anindya. Specifying and Verifying Concurrent Algorithms with Histories and Subjectivity. 24th European Symposium on Programming. 2015. 2014arXiv1410.0306S. 1410.0306.
  16. Web site: Calcagno. Cristiano. Distefano. Dino. O'Hearn. Peter. Open-sourcing Facebook Infer: Identify bugs before you ship. 2015-06-11.
  17. Pym. David. Tofts. Chris. A Calculus and logic of resources and processes. Formal Aspects of Computing. 2006. 8. 4. 495–517. 10.1007/s00165-006-0018-z. 16623194.
  18. Algebra and Logic for Resource-based Systems Modelling. Collinson. Matthew. Mathematical Structures in Computer Science. 10.1017/S0960129509990077. Pym. David. 2009. 19. 5. 959–1027. 10.1.1.153.3899. 14228156.
  19. Book: A Discipline of Mathematical Systems Modelling. Collinson. Matthew. College Publications. 2012. 978-1-904987-50-5. London. Monahan. Brian. Pym. David.
  20. A Calculus and Logic of Bunched Resources and Processes. Anderson. Gabrielle. 2015. Theoretical Computer Science. 614. 63–96. 10.1016/j.tcs.2015.11.035. Pym. David. free.