undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · practical...

76
Undecidability of propositional separation logic and its neighbours James Brotherston Computer Science Seminar Institute of Cybernetics, Tallinn University of Technology 17 Nov 2011 1/ 27

Upload: others

Post on 14-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Undecidability of propositional separation logic

and its neighbours

James Brotherston

Computer Science SeminarInstitute of Cybernetics, Tallinn University of Technology

17 Nov 2011

1/ 27

Page 2: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline

1. An overview of propositional separation logic

2/ 27

Page 3: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline

1. An overview of propositional separation logic

2. Undecidability of separation logic

2/ 27

Page 4: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline

1. An overview of propositional separation logic

2. Undecidability of separation logic

3. Decidable fragments: finite vs. infinite valuations

2/ 27

Page 5: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline

1. An overview of propositional separation logic

2. Undecidability of separation logic

3. Decidable fragments: finite vs. infinite valuations

4. Additional results

2/ 27

Page 6: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline

1. An overview of propositional separation logic

2. Undecidability of separation logic

3. Decidable fragments: finite vs. infinite valuations

4. Additional results

This is joint work with Prof. Max Kanovich, Queen MaryUniversity of London. This talk is based on the paper of thesame name (in Proc. LICS’10).

2/ 27

Page 7: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Part I

Propositional separation logic

3/ 27

Page 8: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Separation models

Separation logic is well established as a formalism for expressingand reasoning about properties of memory.

4/ 27

Page 9: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Separation models

Separation logic is well established as a formalism for expressingand reasoning about properties of memory.

Definition

A separation model is a cancellative partial commutativemonoid 〈H, ◦, E〉.

4/ 27

Page 10: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Separation models

Separation logic is well established as a formalism for expressingand reasoning about properties of memory.

Definition

A separation model is a cancellative partial commutativemonoid 〈H, ◦, E〉. We define:

X · Y =def {x ◦ y | x ∈ X, y ∈ Y }

whence E ⊆ H is a set of units such that X · E = X.

4/ 27

Page 11: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Separation models

Separation logic is well established as a formalism for expressingand reasoning about properties of memory.

Definition

A separation model is a cancellative partial commutativemonoid 〈H, ◦, E〉. We define:

X · Y =def {x ◦ y | x ∈ X, y ∈ Y }

whence E ⊆ H is a set of units such that X · E = X.

Definition

〈H, ◦, E〉 has indivisible units if h1 ◦ h2 ∈ E implies h1, h2 ∈ E.

(NB. All models of practical interest have indivisible units!)

4/ 27

Page 12: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Practical examples of separation models (I)

• Heap models 〈H, ◦, {e}〉, where H = L ⇀fin RV is the setof heaps (L is infinite). e is the function with emptydomain, and:

h1 ◦ h2 =

{h1 ∪ h2 if dom(h1), dom(h2) disjointundefined otherwise

5/ 27

Page 13: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Practical examples of separation models (I)

• Heap models 〈H, ◦, {e}〉, where H = L ⇀fin RV is the setof heaps (L is infinite). e is the function with emptydomain, and:

h1 ◦ h2 =

{h1 ∪ h2 if dom(h1), dom(h2) disjointundefined otherwise

• A basic example of the above: the RAM-domain model〈D, ◦, {e0}〉 where D is the class of finite subsets of N, theoperation ◦ is the union of disjoint sets, and the unit e0 is ∅.

5/ 27

Page 14: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Practical examples of separation models (II)

• Heap-with-permissions models 〈H, ◦, E〉, whereH = L ⇀fin (RV × P ) is a set of heaps with permissions.h1 ◦ h2 is defined as before, except that for heaps with thesame value at overlapping locations, we add thepermissions.

6/ 27

Page 15: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Practical examples of separation models (II)

• Heap-with-permissions models 〈H, ◦, E〉, whereH = L ⇀fin (RV × P ) is a set of heaps with permissions.h1 ◦ h2 is defined as before, except that for heaps with thesame value at overlapping locations, we add thepermissions.

• Stack-and-heap models 〈S ×H, ◦, E〉, where H is a set ofheaps or heaps-with-permissions, S = Var ⇀fin Val is a setof stacks, and 〈s1, h1〉 ◦ 〈s2, h2〉 is defined when s1 = s2 andh1 ◦ h2 is defined (as above).

6/ 27

Page 16: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Semantics (I)

Formulas extend standard propositional connectives with the“multiplicatives” I, ∗ and —∗.

7/ 27

Page 17: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Semantics (I)

Formulas extend standard propositional connectives with the“multiplicatives” I, ∗ and —∗.

A valuation for a separation model 〈H, ◦, E〉 is a function ρ

from propositional variables to P(H).

7/ 27

Page 18: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Semantics (I)

Formulas extend standard propositional connectives with the“multiplicatives” I, ∗ and —∗.

A valuation for a separation model 〈H, ◦, E〉 is a function ρ

from propositional variables to P(H).

Given h ∈ H and formula A we define the relation h |=ρ A byinduction on A:

7/ 27

Page 19: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Semantics (I)

Formulas extend standard propositional connectives with the“multiplicatives” I, ∗ and —∗.

A valuation for a separation model 〈H, ◦, E〉 is a function ρ

from propositional variables to P(H).

Given h ∈ H and formula A we define the relation h |=ρ A byinduction on A:

h |=ρ P ⇔ h ∈ ρ(P )h |=ρ F1 ∧ F2 ⇔ h |=ρ F1 and r |=ρ F2

...h |=ρ I ⇔ h = e

h |=ρ F1 ∗ F2 ⇔ h = h1 ◦ h2 and h1 |=ρ F1 and h2 |=ρ F2

h |=ρ F1 —∗ F2 ⇔ ∀h′. h ◦ h′ defined and h′ |=ρ F1 implies h ◦ h′ |=ρ F2

7/ 27

Page 20: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Semantics (I)

Formulas extend standard propositional connectives with the“multiplicatives” I, ∗ and —∗.

A valuation for a separation model 〈H, ◦, E〉 is a function ρ

from propositional variables to P(H).

Given h ∈ H and formula A we define the relation h |=ρ A byinduction on A:

h |=ρ P ⇔ h ∈ ρ(P )h |=ρ F1 ∧ F2 ⇔ h |=ρ F1 and r |=ρ F2

...h |=ρ I ⇔ h = e

h |=ρ F1 ∗ F2 ⇔ h = h1 ◦ h2 and h1 |=ρ F1 and h2 |=ρ F2

h |=ρ F1 —∗ F2 ⇔ ∀h′. h ◦ h′ defined and h′ |=ρ F1 implies h ◦ h′ |=ρ F2

We define JAKρ =def {h | h |=ρ A}.

7/ 27

Page 21: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Semantics (I)

Formulas extend standard propositional connectives with the“multiplicatives” I, ∗ and —∗.

A valuation for a separation model 〈H, ◦, E〉 is a function ρ

from propositional variables to P(H).

Given h ∈ H and formula A we define the relation h |=ρ A byinduction on A:

h |=ρ P ⇔ h ∈ ρ(P )h |=ρ F1 ∧ F2 ⇔ h |=ρ F1 and r |=ρ F2

...h |=ρ I ⇔ h = e

h |=ρ F1 ∗ F2 ⇔ h = h1 ◦ h2 and h1 |=ρ F1 and h2 |=ρ F2

h |=ρ F1 —∗ F2 ⇔ ∀h′. h ◦ h′ defined and h′ |=ρ F1 implies h ◦ h′ |=ρ F2

We define JAKρ =def {h | h |=ρ A}.

A “sequent” A ` B is valid in 〈H, ◦, E〉 if JAKρ ⊆ JBKρ for all ρ.

7/ 27

Page 22: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Semantics (II)

In any separation model 〈H, ◦, E〉 we have:

JIKρ = E

JA ∗BKρ = JAKρ · JBKρJA —∗ BKρ = largest Z ⊆ H. Z · JAKρ ⊆ JBKρ

8/ 27

Page 23: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Semantics (II)

In any separation model 〈H, ◦, E〉 we have:

JIKρ = E

JA ∗BKρ = JAKρ · JBKρJA —∗ BKρ = largest Z ⊆ H. Z · JAKρ ⊆ JBKρ

In particular this implies restricted ∗-contraction:

JI ∧AKρ = JI ∧AKρ · JI ∧AKρ = J(I ∧A) ∗ (I ∧A)Kρ

8/ 27

Page 24: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Semantics (II)

In any separation model 〈H, ◦, E〉 we have:

JIKρ = E

JA ∗BKρ = JAKρ · JBKρJA —∗ BKρ = largest Z ⊆ H. Z · JAKρ ⊆ JBKρ

In particular this implies restricted ∗-contraction:

JI ∧AKρ = JI ∧AKρ · JI ∧AKρ = J(I ∧A) ∗ (I ∧A)Kρ

which doesn’t hold in linear logic because, e.g.:

JA ∗BKρ = Cl(JAKρ · JBKρ)

where Cl is a closure operator. This is less precise, and rulesout finite valuations since, e.g., Cl(∅) is infinite.

8/ 27

Page 25: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Possible axiomatisations of separation logic

• BI, obtained by extending intuitionistic logic with thestandard MILL axioms and rules for I, ∗ and —∗;

9/ 27

Page 26: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Possible axiomatisations of separation logic

• BI, obtained by extending intuitionistic logic with thestandard MILL axioms and rules for I, ∗ and —∗;

• BBI, obtained by extending classical logic with thestandard MILL axioms and rules for I, ∗ and —∗;

9/ 27

Page 27: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Possible axiomatisations of separation logic

• BI, obtained by extending intuitionistic logic with thestandard MILL axioms and rules for I, ∗ and —∗;

• BBI, obtained by extending classical logic with thestandard MILL axioms and rules for I, ∗ and —∗;

• a minimal BBI with additives restricted to ∧ and →, i.e. nonegation and no falsum (see next slide);

9/ 27

Page 28: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Possible axiomatisations of separation logic

• BI, obtained by extending intuitionistic logic with thestandard MILL axioms and rules for I, ∗ and —∗;

• BBI, obtained by extending classical logic with thestandard MILL axioms and rules for I, ∗ and —∗;

• a minimal BBI with additives restricted to ∧ and →, i.e. nonegation and no falsum (see next slide);

• BBI+eW where eW is the restricted ∗-weakening:I ∧ (A ∗B) ` I ∧A, which holds in all models withindivisible units. Because of restricted ∗-contraction wehave I ∧ (A ∗B) ≡ I ∧A ∧B;

9/ 27

Page 29: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Possible axiomatisations of separation logic

• BI, obtained by extending intuitionistic logic with thestandard MILL axioms and rules for I, ∗ and —∗;

• BBI, obtained by extending classical logic with thestandard MILL axioms and rules for I, ∗ and —∗;

• a minimal BBI with additives restricted to ∧ and →, i.e. nonegation and no falsum (see next slide);

• BBI+eW where eW is the restricted ∗-weakening:I ∧ (A ∗B) ` I ∧A, which holds in all models withindivisible units. Because of restricted ∗-contraction wehave I ∧ (A ∗B) ≡ I ∧A ∧B;

• BBI+W where W is the full ∗-weakening: A ∗B ` A. Thissystem collapses into classical logic!

9/ 27

Page 30: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Minimal BBI

(A ∗B) ` (B ∗A) (A ∗ I) ` A

(A∗(B ∗ C)) ` ((A ∗B) ∗ C) A ` (A ∗ I)(A ∗ (A —∗ B)) ` B

A ` B

(A ∗ C) ` (B ∗ C)

(A ∗B) ` C

A ` (B —∗ C)(a) Axioms and rules for ∗, —∗ and I.

10/ 27

Page 31: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Minimal BBI

(A ∗B) ` (B ∗A) (A ∗ I) ` A

(A∗(B ∗ C)) ` ((A ∗B) ∗ C) A ` (A ∗ I)(A ∗ (A —∗ B)) ` B

A ` B

(A ∗ C) ` (B ∗ C)

(A ∗B) ` C

A ` (B —∗ C)(a) Axioms and rules for ∗, —∗ and I.

A ` (B → A) A ` (B → (A ∧B))(A → (B → C)) ` ((A → B) → (A → C)) (A ∧B) ` A

((A → B) → A) ` A (Peirce’s law) (A ∧B) ` B

A A ` B

B

(A ∧B) ` C

A ` (B → C)(b) Axioms and rules for → and ∧.

10/ 27

Page 32: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Part II

Undecidability

11/ 27

Page 33: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline proof of undecidability

M terminates from C

12/ 27

Page 34: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline proof of undecidability

M terminates from C

FM,C provable in minimal BBI

(Thm 1)

12/ 27

Page 35: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline proof of undecidability

M terminates from C

FM,C provable in minimal BBI

(Thm 1)

FM,C provable in BBI

FM,C provable in BBI+eW

12/ 27

Page 36: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline proof of undecidability

M terminates from C

FM,C provable in minimal BBI

(Thm 1)

FM,C provable in BBI

FM,C provable in BBI+eWFM,C valid in anyseparation model

FM,C valid in any separationmodel with indivisible units

12/ 27

Page 37: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline proof of undecidability

M terminates from C

FM,C provable in minimal BBI

(Thm 1)

FM,C provable in BBI

FM,C provable in BBI+eWFM,C valid in anyseparation model

FM,C valid in any separationmodel with indivisible units

FM,C valid in someconcrete heap model

12/ 27

Page 38: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline proof of undecidability

M terminates from C

FM,C provable in minimal BBI

(Thm 1)

FM,C provable in BBI

FM,C provable in BBI+eWFM,C valid in anyseparation model

FM,C valid in any separationmodel with indivisible units

FM,C valid in someconcrete heap model

(Thm 2)

12/ 27

Page 39: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Outline proof of undecidability

M terminates from C

FM,C provable in minimal BBI

(Thm 1)

FM,C provable in BBI

FM,C provable in BBI+eWFM,C valid in anyseparation model

FM,C valid in any separationmodel with indivisible units

FM,C valid in someconcrete heap model

(Thm 2)

All problems above are undecidable. Undecidability of BBI alsoestablished by Larchey-Wendling and Galmiche 2010.

12/ 27

Page 40: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Minsky machines

A Minsky machine M with counters c1, c2 is given by a finite setof labelled instructions of the following types, where k ∈ {1, 2}:

Li: ck++;goto Lj; “increment ck (and jump)”Li: ck−−;goto Lj; “decrement ck (and jump)”Li: if ck=0 goto Lj; “zero-test ck (and jump)”Li:goto Lj; “jump”

13/ 27

Page 41: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Minsky machines

A Minsky machine M with counters c1, c2 is given by a finite setof labelled instructions of the following types, where k ∈ {1, 2}:

Li: ck++;goto Lj; “increment ck (and jump)”Li: ck−−;goto Lj; “decrement ck (and jump)”Li: if ck=0 goto Lj; “zero-test ck (and jump)”Li:goto Lj; “jump”

Configurations of M have the form 〈Li, n1, n2〉. We write〈Li, n1, n2〉⇓M if 〈Li, n1, n2〉

∗M 〈L0, 0, 0〉.

13/ 27

Page 42: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Minsky machines

A Minsky machine M with counters c1, c2 is given by a finite setof labelled instructions of the following types, where k ∈ {1, 2}:

Li: ck++;goto Lj; “increment ck (and jump)”Li: ck−−;goto Lj; “decrement ck (and jump)”Li: if ck=0 goto Lj; “zero-test ck (and jump)”Li:goto Lj; “jump”

Configurations of M have the form 〈Li, n1, n2〉. We write〈Li, n1, n2〉⇓M if 〈Li, n1, n2〉

∗M 〈L0, 0, 0〉.

We introduce special labels L−1, L−2 with instructions:

L−1: c2−−;goto L−1; L−1:goto L0;L−2: c1−−;goto L−2; L−2:goto L0;

whence 〈L−k, n1, n2〉⇓M iff nk = 0.13/ 27

Page 43: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Encoding configurations in minimal BBI

For each label Li we have a propositional variable li. We alsopick two propositional variables p1, p2 to represent counters c1,c2.

14/ 27

Page 44: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Encoding configurations in minimal BBI

For each label Li we have a propositional variable li. We alsopick two propositional variables p1, p2 to represent counters c1,c2. A configuration 〈Li, n1, n2〉 will be represented as:

li ∗ pn1

1∗ pn2

2

where pnk denotes the formulan times

pk ∗ pk ∗ · · · ∗ pk︸ ︷︷ ︸

, with p0k = I.

14/ 27

Page 45: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Encoding configurations in minimal BBI

For each label Li we have a propositional variable li. We alsopick two propositional variables p1, p2 to represent counters c1,c2. A configuration 〈Li, n1, n2〉 will be represented as:

li ∗ pn1

1∗ pn2

2

where pnk denotes the formulan times

pk ∗ pk ∗ · · · ∗ pk︸ ︷︷ ︸

, with p0k = I.

Also pick propositional variable b and write

A =def A —∗ b

b will be interpreted as “all terminating configurations”.—∗ corresponds to replacement of parts of configurations.

14/ 27

Page 46: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Encoding machines in minimal BBI

We code each instruction γ of a machine M as a formula κ(γ)of minimal BBI:

Li: ck++;goto Lj; ⇒ ( (lj ∗ pk) —∗ li)Li: ck−−;goto Lj; ⇒ ( lj —∗ (li ∗ pk))Li: if ck=0 goto Lj; ⇒ ( (lj ∨ l−k) —∗ li)Li:goto Lj; ⇒ ( lj —∗ li)

15/ 27

Page 47: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Encoding machines in minimal BBI

We code each instruction γ of a machine M as a formula κ(γ)of minimal BBI:

Li: ck++;goto Lj; ⇒ ( (lj ∗ pk) —∗ li)Li: ck−−;goto Lj; ⇒ ( lj —∗ (li ∗ pk))Li: if ck=0 goto Lj; ⇒ ( (lj ∨ l−k) —∗ li)Li:goto Lj; ⇒ ( lj —∗ li)

We code a whole machine M = {γ1, . . . , γt} as:

κ(M) = I ∧t∧

i=1

κ(γi)

We’ll use restricted ∗-contraction to duplicate instructions asneeded!

15/ 27

Page 48: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

First main theorem

TheoremSuppose 〈Li, n1, n2〉⇓M . Then the following sequent is derivablein minimal BBI:

κ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0) ` b

16/ 27

Page 49: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

First main theorem

TheoremSuppose 〈Li, n1, n2〉⇓M . Then the following sequent is derivablein minimal BBI:

κ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0) ` b

Proof relies heavily on “quasi-negation” properties of (e.g.A ≡ A) and the restricted ∗-contraction:

I ∧A ` (I ∧A) ∗ (I ∧A)

which is derivable in minimal BBI.

16/ 27

Page 50: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Second main theorem

Theorem〈Li, n1, n2〉⇓M whenever the following sequent is valid in someconcrete heap-like model used in practice (recall examples):

κ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0) ` b

17/ 27

Page 51: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Second main theorem

Theorem〈Li, n1, n2〉⇓M whenever the following sequent is valid in someconcrete heap-like model used in practice (recall examples):

κ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0) ` b

Proof outline. Consider for simplicity the RAM-domain model〈D, ◦, {e0}〉 based on subsets of N. We have for any ρ:

Jκ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0)Kρ ⊆ JbKρ

17/ 27

Page 52: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Second main theorem

Theorem〈Li, n1, n2〉⇓M whenever the following sequent is valid in someconcrete heap-like model used in practice (recall examples):

κ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0) ` b

Proof outline. Consider for simplicity the RAM-domain model〈D, ◦, {e0}〉 based on subsets of N. We have for any ρ:

Jκ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0)Kρ ⊆ JbKρ

We want to pick ρ with e0 ∈ Jκ(M)Kρ and e0 ∈ JI ∧ l0Kρ to get:

Jli ∗ pn1

1∗ pn2

2Kρ ⊆ JbKρ

and infer 〈Li, n1, n2〉⇓M .17/ 27

Page 53: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

e0 ∈ Jκ(M)Kρ: The edge of disaster

To check e0 ∈ Jκ(M)Kρ we check e0 ∈ Jκ(γ)Kρ for eachinstruction γ.

18/ 27

Page 54: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

e0 ∈ Jκ(M)Kρ: The edge of disaster

To check e0 ∈ Jκ(M)Kρ we check e0 ∈ Jκ(γ)Kρ for eachinstruction γ.Why do we encode, e.g., Li: ck++;goto Lj; as

( (lj ∗ pk) —∗ li) and not li —∗ (lj ∗ pk) ?

18/ 27

Page 55: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

e0 ∈ Jκ(M)Kρ: The edge of disaster

To check e0 ∈ Jκ(M)Kρ we check e0 ∈ Jκ(γ)Kρ for eachinstruction γ.Why do we encode, e.g., Li: ck++;goto Lj; as

( (lj ∗ pk) —∗ li) and not li —∗ (lj ∗ pk) ?

Let’s try to check: e0 ∈ Jli —∗ (lj ∗ pk)Kρ, i.e. JliKρ ⊆ Jlj ∗ pkKρ.

18/ 27

Page 56: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

e0 ∈ Jκ(M)Kρ: The edge of disaster

To check e0 ∈ Jκ(M)Kρ we check e0 ∈ Jκ(γ)Kρ for eachinstruction γ.Why do we encode, e.g., Li: ck++;goto Lj; as

( (lj ∗ pk) —∗ li) and not li —∗ (lj ∗ pk) ?

Let’s try to check: e0 ∈ Jli —∗ (lj ∗ pk)Kρ, i.e. JliKρ ⊆ Jlj ∗ pkKρ.

But suppose Li = Lj. In separation models this means:

JliKρ ⊆ JliKρ · JpkKρ ⊆ JliKρ · JpkKρ · JpkKρ ⊆ . . .

i.e., any heap can be split into arbitrarily many pieces!(Not a problem in linear logic.)

18/ 27

Page 57: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

JpnkKρ: The (second) edge of disaster

We intend that Jli ∗ pn1

1∗ pn2

2Kρ should encode configuration

〈Li, n1, n2〉. Thus Jpnk

k Kρ should determine the number nk.

19/ 27

Page 58: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

JpnkKρ: The (second) edge of disaster

We intend that Jli ∗ pn1

1∗ pn2

2Kρ should encode configuration

〈Li, n1, n2〉. Thus Jpnk

k Kρ should determine the number nk.

But composition of heaps is disjoint so that, e.g., if we takeρ(pk) = {h} for a nonempty heap h, then ρ(p2k) = ρ(pk ∗ pk) isempty!

19/ 27

Page 59: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

JpnkKρ: The (second) edge of disaster

We intend that Jli ∗ pn1

1∗ pn2

2Kρ should encode configuration

〈Li, n1, n2〉. Thus Jpnk

k Kρ should determine the number nk.

But composition of heaps is disjoint so that, e.g., if we takeρ(pk) = {h} for a nonempty heap h, then ρ(p2k) = ρ(pk ∗ pk) isempty!

In general, whenever ρ(pk) is finite we must have:

JpnkKρ = Jpmk Kρ

for sufficiently large n and m, which obstructs us in uniquelyrepresenting the number nk by the formula pnk .(We discuss decidability consequences shortly.)

19/ 27

Page 60: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Choosing a valuation

We choose a valuation ρ for 〈D, ◦, {e0}〉 as follows:

ρ(p1) = {{2m} | m ∈ N}ρ(p2) = {{3m} | m ∈ N}ρ(li) = {{δmi } | m ∈ N}

where δi is a fresh prime number for each propositional variablel−2, l−1, l0, l1, . . .

20/ 27

Page 61: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Choosing a valuation

We choose a valuation ρ for 〈D, ◦, {e0}〉 as follows:

ρ(p1) = {{2m} | m ∈ N}ρ(p2) = {{3m} | m ∈ N}ρ(li) = {{δmi } | m ∈ N}

where δi is a fresh prime number for each propositional variablel−2, l−1, l0, l1, . . .

Finally, we define:

ρ(b) =⋃

〈Li, n1, n2〉⇓MJli ∗ p

n1

1∗ pn2

2Kρ

so ρ(b) is the set of interpretations of all terminatingconfigurations.

20/ 27

Page 62: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Proof of Theorem 2

If κ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0) ` b is valid in 〈D, ◦, {e0}〉

then:Jκ(M) ∗ li ∗ p

n1

1∗ pn2

2∗ (I ∧ l0)Kρ ⊆ JbKρ

21/ 27

Page 63: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Proof of Theorem 2

If κ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0) ` b is valid in 〈D, ◦, {e0}〉

then:Jκ(M) ∗ li ∗ p

n1

1∗ pn2

2∗ (I ∧ l0)Kρ ⊆ JbKρ

Since e0 ∈ Jκ(M)Kρ we get:

Jli ∗ pn1

1∗ pn2

2∗ (I ∧ l0)Kρ ⊆ J l0Kρ

21/ 27

Page 64: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Proof of Theorem 2

If κ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0) ` b is valid in 〈D, ◦, {e0}〉

then:Jκ(M) ∗ li ∗ p

n1

1∗ pn2

2∗ (I ∧ l0)Kρ ⊆ JbKρ

Since e0 ∈ Jκ(M)Kρ we get:

Jli ∗ pn1

1∗ pn2

2∗ (I ∧ l0)Kρ ⊆ J l0Kρ

Since e0 ∈ JI ∧ l0Kρ (because 〈L0, 0, 0〉⇓M), we get:

Jli ∗ pn1

1∗ pn2

2Kρ ⊆ JbKρ

21/ 27

Page 65: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Proof of Theorem 2

If κ(M) ∗ li ∗ pn1

1∗ pn2

2∗ (I ∧ l0) ` b is valid in 〈D, ◦, {e0}〉

then:Jκ(M) ∗ li ∗ p

n1

1∗ pn2

2∗ (I ∧ l0)Kρ ⊆ JbKρ

Since e0 ∈ Jκ(M)Kρ we get:

Jli ∗ pn1

1∗ pn2

2∗ (I ∧ l0)Kρ ⊆ J l0Kρ

Since e0 ∈ JI ∧ l0Kρ (because 〈L0, 0, 0〉⇓M), we get:

Jli ∗ pn1

1∗ pn2

2Kρ ⊆ JbKρ

Since Jli ∗ pn1

1∗ pn2

2Kρ uniquely determines n1 and n2 we

conclude 〈Li, n1, n2〉⇓M from definition of ρ(b).

21/ 27

Page 66: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Part III

Decidability: finite vs. infinite valuations

22/ 27

Page 67: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Finite valuations

The quantifier-free fragment of a certain separation theory overan infinite heap model is decidable (Calcagno et al., 2001).WTF?

23/ 27

Page 68: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Finite valuations

The quantifier-free fragment of a certain separation theory overan infinite heap model is decidable (Calcagno et al., 2001).WTF?

There, valuations are constrained to be finite, whereas ourvaluation ρ is necessarily infinite.

23/ 27

Page 69: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Finite valuations

The quantifier-free fragment of a certain separation theory overan infinite heap model is decidable (Calcagno et al., 2001).WTF?

There, valuations are constrained to be finite, whereas ourvaluation ρ is necessarily infinite.

TheoremThere is a sequent of the form κ(M) ∗ li ∗ p

n1

1∗ (I ∧ l0) ` b such

that, for any choice of heap-like model 〈H, ◦, E〉, the sequent isinvalid in the model, but valid under all finite valuations ρ.

23/ 27

Page 70: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Finite valuations

The quantifier-free fragment of a certain separation theory overan infinite heap model is decidable (Calcagno et al., 2001).WTF?

There, valuations are constrained to be finite, whereas ourvaluation ρ is necessarily infinite.

TheoremThere is a sequent of the form κ(M) ∗ li ∗ p

n1

1∗ (I ∧ l0) ` b such

that, for any choice of heap-like model 〈H, ◦, E〉, the sequent isinvalid in the model, but valid under all finite valuations ρ.

So to obtain decidable fragments of separation logic, one shouldeither give up infinite valuations (Calcagno et al., 2001), orrestrict the formula language (Berdine et al., 2004).

23/ 27

Page 71: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Part IV

Additional results

24/ 27

Page 72: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Classical BI (Brotherston and Calcagno, 2009)

A CBI-model is a separation model 〈H, ◦, E〉 enriched with atotal involution ·−1 such that for all h ∈ H. h ◦ h−1 = e−1. (Cf.effect algebras in quantum mechanics.)

25/ 27

Page 73: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Classical BI (Brotherston and Calcagno, 2009)

A CBI-model is a separation model 〈H, ◦, E〉 enriched with atotal involution ·−1 such that for all h ∈ H. h ◦ h−1 = e−1. (Cf.effect algebras in quantum mechanics.)

E.g., can take 〈D, ◦, {e0}, ·−1〉 where D is now the class of finite

and cofinite subsets of N, ◦ is union of disjoint sets, e0 = ∅ and·−1 is set complement.

25/ 27

Page 74: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Classical BI (Brotherston and Calcagno, 2009)

A CBI-model is a separation model 〈H, ◦, E〉 enriched with atotal involution ·−1 such that for all h ∈ H. h ◦ h−1 = e−1. (Cf.effect algebras in quantum mechanics.)

E.g., can take 〈D, ◦, {e0}, ·−1〉 where D is now the class of finite

and cofinite subsets of N, ◦ is union of disjoint sets, e0 = ∅ and·−1 is set complement.

CBI extends BBI with a multiplicative negation ∼ defined by:

h |=ρ ∼A ⇔ h−1 6|=ρ A

25/ 27

Page 75: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Undecidability of CBI and related problems

M terminates from C

FM,C provable in minimal BBI

FM,C provable in CBI

FM,C provable in CBI+eWFM,C valid in any

CBI-model

FM,C valid in any CBI-modelwith indivisible units

FM,C valid in theconcrete model 〈D, ◦, {e0}, ·

−1〉

(Thm 1)(Thm 2)

Proof of Thm 2 now uses a slightly modified valuation ρ. Allproblems above are again undecidable.

26/ 27

Page 76: Undecidability of propositional separation logic and its neighbours · 2011. 11. 15. · Practical examples of separation models (II) • Heap-with-permissions models hH, ,Ei, where

Some references

J. Berdine, C. Calcagno and P. O’Hearn.A decidable fragment of separation logic.In Proceedings of FSTTCS, 2004.

J. Brotherston and C. Calcagno.Classical BI (a logic for reasoning about dualising resources).In Proceedings of POPL, 2009.

C. Calcagno, P. O’Hearn and H. Yang.Computability and complexity results for a spatial assertion languagefor data structures.In Proceedings of FSTTCS, 2001.

D. Larchey-Wendling and D. Galmiche.Undecidability of Boolean BI through phase semantics.In Proceedings of LICS, 2010.

J.C. Reynolds.Separation logic: a logic for shared mutable data structures.In Proceedings of LICS, 2002.

27/ 27