Biabduction (and Related Problems) in Array Separation Logic James - - PowerPoint PPT Presentation

biabduction and related problems in array separation logic
SMART_READER_LITE
LIVE PREVIEW

Biabduction (and Related Problems) in Array Separation Logic James - - PowerPoint PPT Presentation

Biabduction (and Related Problems) in Array Separation Logic James Brotherston 1 Nikos Gorogiannis 2 Max Kanovich 1 1 UCL 2 Middlesex University University of Vienna, 14 Mar 2017 1/ 19 Compositional proofs in separation logic (1) Separation


slide-1
SLIDE 1

Biabduction (and Related Problems) in Array Separation Logic

James Brotherston1 Nikos Gorogiannis2 Max Kanovich1

1UCL 2Middlesex University

University of Vienna, 14 Mar 2017

1/ 19

slide-2
SLIDE 2

Compositional proofs in separation logic (1)

  • Separation logic is based on Hoare triples {A} C {B}, where

C is a program and A, B are formulas.

2/ 19

slide-3
SLIDE 3

Compositional proofs in separation logic (1)

  • Separation logic is based on Hoare triples {A} C {B}, where

C is a program and A, B are formulas.

  • Its compositional nature, the key to scalable analysis, is

supported by two main pillars.

2/ 19

slide-4
SLIDE 4

Compositional proofs in separation logic (1)

  • Separation logic is based on Hoare triples {A} C {B}, where

C is a program and A, B are formulas.

  • Its compositional nature, the key to scalable analysis, is

supported by two main pillars.

  • The first pillar is the soundness of the following frame rule:

{A} C {B} (Frame) {A ∗ F} C {B ∗ F} where the separating conjunction ∗ is read, intuitively, as “and separately in memory”.

2/ 19

slide-5
SLIDE 5

Compositional proofs in separation logic (2)

  • The second pillar is given by solving the biabduction problem:

3/ 19

slide-6
SLIDE 6

Compositional proofs in separation logic (2)

  • The second pillar is given by solving the biabduction problem:

given formulas A and B, find formulas X, Y with A ∗ X | = B ∗ Y , and A ∗ X is satisfiable.

3/ 19

slide-7
SLIDE 7

Compositional proofs in separation logic (2)

  • The second pillar is given by solving the biabduction problem:

given formulas A and B, find formulas X, Y with A ∗ X | = B ∗ Y , and A ∗ X is satisfiable.

  • Then, if we have {A′} C1 {A} and {B} C2 {B′}, we can infer a

spec for C1; C2:

3/ 19

slide-8
SLIDE 8

Compositional proofs in separation logic (2)

  • The second pillar is given by solving the biabduction problem:

given formulas A and B, find formulas X, Y with A ∗ X | = B ∗ Y , and A ∗ X is satisfiable.

  • Then, if we have {A′} C1 {A} and {B} C2 {B′}, we can infer a

spec for C1; C2:

{A′} C1 {A} (Frame) {A′ ∗ X} C1 {A ∗ X} (| =) {A′ ∗ X} C1 {B ∗ Y } {B} C2 {B′} (Frame) {B ∗ Y } C2 {B′ ∗ Y } (;) {A′ ∗ X} C1; C2 {B′ ∗ Y }

3/ 19

slide-9
SLIDE 9

Symbolic-heap separation logic

  • Terms t, pure formulas Π and spatial formulas F given by:

t ::= x ∈ Var | nil Π ::= t = t | t = t | Π ∧ Π F ::= emp | t → t | ls(t , t) | F ∗ F

4/ 19

slide-10
SLIDE 10

Symbolic-heap separation logic

  • Terms t, pure formulas Π and spatial formulas F given by:

t ::= x ∈ Var | nil Π ::= t = t | t = t | Π ∧ Π F ::= emp | t → t | ls(t , t) | F ∗ F

  • t1 → t2 (“points-to”) denotes a pointer in the heap.

4/ 19

slide-11
SLIDE 11

Symbolic-heap separation logic

  • Terms t, pure formulas Π and spatial formulas F given by:

t ::= x ∈ Var | nil Π ::= t = t | t = t | Π ∧ Π F ::= emp | t → t | ls(t , t) | F ∗ F

  • t1 → t2 (“points-to”) denotes a pointer in the heap.
  • ls(t1 , t2) denotes a linked list segment in the heap.

4/ 19

slide-12
SLIDE 12

Symbolic-heap separation logic

  • Terms t, pure formulas Π and spatial formulas F given by:

t ::= x ∈ Var | nil Π ::= t = t | t = t | Π ∧ Π F ::= emp | t → t | ls(t , t) | F ∗ F

  • t1 → t2 (“points-to”) denotes a pointer in the heap.
  • ls(t1 , t2) denotes a linked list segment in the heap.
  • ∗ (“and separately”) demarks domain-disjoint heaps.

4/ 19

slide-13
SLIDE 13

Symbolic-heap separation logic

  • Terms t, pure formulas Π and spatial formulas F given by:

t ::= x ∈ Var | nil Π ::= t = t | t = t | Π ∧ Π F ::= emp | t → t | ls(t , t) | F ∗ F

  • t1 → t2 (“points-to”) denotes a pointer in the heap.
  • ls(t1 , t2) denotes a linked list segment in the heap.
  • ∗ (“and separately”) demarks domain-disjoint heaps.
  • Symbolic heaps given by ∃x. Π : F.

4/ 19

slide-14
SLIDE 14

Array separation logic, ASL

  • Here we focus on a different data structure, namely arrays.

5/ 19

slide-15
SLIDE 15

Array separation logic, ASL

  • Here we focus on a different data structure, namely arrays.
  • Terms t, pure formulas Π and spatial formulas F given by:

t ::= x ∈ Var | n ∈ N | t + t Π ::= t = t | t = t | t ≤ t | t < t | Π ∧ Π F ::= emp | t → t | array(t, t) | F ∗ F

5/ 19

slide-16
SLIDE 16

Array separation logic, ASL

  • Here we focus on a different data structure, namely arrays.
  • Terms t, pure formulas Π and spatial formulas F given by:

t ::= x ∈ Var | n ∈ N | t + t Π ::= t = t | t = t | t ≤ t | t < t | Π ∧ Π F ::= emp | t → t | array(t, t) | F ∗ F

  • array(t1, t2) denotes an array from t1 to t2 (inclusive):

t2−t1+1

  • ·

t1 · · . . . · · · t2

5/ 19

slide-17
SLIDE 17

Array separation logic, ASL

  • Here we focus on a different data structure, namely arrays.
  • Terms t, pure formulas Π and spatial formulas F given by:

t ::= x ∈ Var | n ∈ N | t + t Π ::= t = t | t = t | t ≤ t | t < t | Π ∧ Π F ::= emp | t → t | array(t, t) | F ∗ F

  • array(t1, t2) denotes an array from t1 to t2 (inclusive):

t2−t1+1

  • ·

t1 · · . . . · · · t2

  • We also allow linear arithmetic in the pure part.

5/ 19

slide-18
SLIDE 18

Semantics of ASL

  • Stacks are s : Var → Val; heaps are h : Loc ⇀fin Val; ◦ is

union of domain-disjoint heaps; e is the empty heap.

6/ 19

slide-19
SLIDE 19

Semantics of ASL

  • Stacks are s : Var → Val; heaps are h : Loc ⇀fin Val; ◦ is

union of domain-disjoint heaps; e is the empty heap.

  • Forcing relation s, h |

= A given by

s, h | = t1 ∼ t2 ⇔ s(t1) ∼ s(t2) (∼ ∈ {=, =, <, ≤}) s, h | = Π1 ∧ Π2 ⇔ s, h | = Π1 and s, h | = Π2

6/ 19

slide-20
SLIDE 20

Semantics of ASL

  • Stacks are s : Var → Val; heaps are h : Loc ⇀fin Val; ◦ is

union of domain-disjoint heaps; e is the empty heap.

  • Forcing relation s, h |

= A given by

s, h | = t1 ∼ t2 ⇔ s(t1) ∼ s(t2) (∼ ∈ {=, =, <, ≤}) s, h | = Π1 ∧ Π2 ⇔ s, h | = Π1 and s, h | = Π2 s, h | = emp ⇔ h = e s, h | = t1 → t2 ⇔ dom(h) = {s(t1)} and h(s(t1)) = s(t2)

6/ 19

slide-21
SLIDE 21

Semantics of ASL

  • Stacks are s : Var → Val; heaps are h : Loc ⇀fin Val; ◦ is

union of domain-disjoint heaps; e is the empty heap.

  • Forcing relation s, h |

= A given by

s, h | = t1 ∼ t2 ⇔ s(t1) ∼ s(t2) (∼ ∈ {=, =, <, ≤}) s, h | = Π1 ∧ Π2 ⇔ s, h | = Π1 and s, h | = Π2 s, h | = emp ⇔ h = e s, h | = t1 → t2 ⇔ dom(h) = {s(t1)} and h(s(t1)) = s(t2) s, h | = array(t1, t2) ⇔ s(t1) ≤ s(t2) and dom(h) = {s(t1), . . . , s(t2)}

6/ 19

slide-22
SLIDE 22

Semantics of ASL

  • Stacks are s : Var → Val; heaps are h : Loc ⇀fin Val; ◦ is

union of domain-disjoint heaps; e is the empty heap.

  • Forcing relation s, h |

= A given by

s, h | = t1 ∼ t2 ⇔ s(t1) ∼ s(t2) (∼ ∈ {=, =, <, ≤}) s, h | = Π1 ∧ Π2 ⇔ s, h | = Π1 and s, h | = Π2 s, h | = emp ⇔ h = e s, h | = t1 → t2 ⇔ dom(h) = {s(t1)} and h(s(t1)) = s(t2) s, h | = array(t1, t2) ⇔ s(t1) ≤ s(t2) and dom(h) = {s(t1), . . . , s(t2)} s, h | = F1 ∗ F2 ⇔ h = h1 ◦ h2 and s, h1 | = F1 and s, h2 | = F2

6/ 19

slide-23
SLIDE 23

Semantics of ASL

  • Stacks are s : Var → Val; heaps are h : Loc ⇀fin Val; ◦ is

union of domain-disjoint heaps; e is the empty heap.

  • Forcing relation s, h |

= A given by

s, h | = t1 ∼ t2 ⇔ s(t1) ∼ s(t2) (∼ ∈ {=, =, <, ≤}) s, h | = Π1 ∧ Π2 ⇔ s, h | = Π1 and s, h | = Π2 s, h | = emp ⇔ h = e s, h | = t1 → t2 ⇔ dom(h) = {s(t1)} and h(s(t1)) = s(t2) s, h | = array(t1, t2) ⇔ s(t1) ≤ s(t2) and dom(h) = {s(t1), . . . , s(t2)} s, h | = F1 ∗ F2 ⇔ h = h1 ◦ h2 and s, h1 | = F1 and s, h2 | = F2 s, h | = ∃z. Π : F ⇔ ∃v. s[z → v], h | = Π and s[z → v], h | = F

6/ 19

slide-24
SLIDE 24

Motivating example

Suppose we have procedure foo with spec {array(c, d)} foo(c, d) {Q}

7/ 19

slide-25
SLIDE 25

Motivating example

Suppose we have procedure foo with spec {array(c, d)} foo(c, d) {Q} Now, consider code C; foo(c, d); . . ., with spec for C {emp} C {array(a, b)}

7/ 19

slide-26
SLIDE 26

Motivating example

Suppose we have procedure foo with spec {array(c, d)} foo(c, d) {Q} Now, consider code C; foo(c, d); . . ., with spec for C {emp} C {array(a, b)} By solving the biabduction problem array(a, b) ∗ X | = array(c, d) ∗ Y we get a valid spec {X} C; foo(c, d) {Q ∗ Y }.

7/ 19

slide-27
SLIDE 27

Motivating example

Suppose we have procedure foo with spec {array(c, d)} foo(c, d) {Q} Now, consider code C; foo(c, d); . . ., with spec for C {emp} C {array(a, b)} By solving the biabduction problem array(a, b) ∗ X | = array(c, d) ∗ Y we get a valid spec {X} C; foo(c, d) {Q ∗ Y }. Spatially minimal, and incomparable, solutions include: X := a = c ∧ b = d : emp and Y := emp X := d < a : array(c, d) and Y := array(a, b) X := a < c ∧ b < d : emp and Y := array(a, c − 1) ∗ array(b + 1, d) X := a < c < b < d : array(b + 1, d) and Y := array(a, c − 1)

7/ 19

slide-28
SLIDE 28

Satisfiability, upper bound

Satisfiability problem for ASL. Given symbolic heap A, decide if there is a stack s and heap h with s, h | = A.

8/ 19

slide-29
SLIDE 29

Satisfiability, upper bound

Satisfiability problem for ASL. Given symbolic heap A, decide if there is a stack s and heap h with s, h | = A.

  • Write A as Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui.

8/ 19

slide-30
SLIDE 30

Satisfiability, upper bound

Satisfiability problem for ASL. Given symbolic heap A, decide if there is a stack s and heap h with s, h | = A.

  • Write A as Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui.

  • Observe A is satisfiable iff there is stack s such that
  • s |

= Π, and

8/ 19

slide-31
SLIDE 31

Satisfiability, upper bound

Satisfiability problem for ASL. Given symbolic heap A, decide if there is a stack s and heap h with s, h | = A.

  • Write A as Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui.

  • Observe A is satisfiable iff there is stack s such that
  • s |

= Π, and

  • each array is well-defined (s(ai) ≤ s(bi)), and

8/ 19

slide-32
SLIDE 32

Satisfiability, upper bound

Satisfiability problem for ASL. Given symbolic heap A, decide if there is a stack s and heap h with s, h | = A.

  • Write A as Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui.

  • Observe A is satisfiable iff there is stack s such that
  • s |

= Π, and

  • each array is well-defined (s(ai) ≤ s(bi)), and
  • all pointers and arrays are mutually non-overlapping

((s(b1) < s(a2) ∨ s(a1) > s(b2)) ∧ . . .).

8/ 19

slide-33
SLIDE 33

Satisfiability, upper bound

Satisfiability problem for ASL. Given symbolic heap A, decide if there is a stack s and heap h with s, h | = A.

  • Write A as Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui.

  • Observe A is satisfiable iff there is stack s such that
  • s |

= Π, and

  • each array is well-defined (s(ai) ≤ s(bi)), and
  • all pointers and arrays are mutually non-overlapping

((s(b1) < s(a2) ∨ s(a1) > s(b2)) ∧ . . .).

  • We can code this up as a formula γ(A) in Σ0

1 Presburger

arithmetic.

8/ 19

slide-34
SLIDE 34

Satisfiability, upper bound

Satisfiability problem for ASL. Given symbolic heap A, decide if there is a stack s and heap h with s, h | = A.

  • Write A as Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui.

  • Observe A is satisfiable iff there is stack s such that
  • s |

= Π, and

  • each array is well-defined (s(ai) ≤ s(bi)), and
  • all pointers and arrays are mutually non-overlapping

((s(b1) < s(a2) ∨ s(a1) > s(b2)) ∧ . . .).

  • We can code this up as a formula γ(A) in Σ0

1 Presburger

arithmetic.

  • Thus the problem is in NP.

8/ 19

slide-35
SLIDE 35

Satisfiability, lower bound

  • NP-hardness follows by reduction from

9/ 19

slide-36
SLIDE 36

Satisfiability, lower bound

  • NP-hardness follows by reduction from

3-partition problem. Given B ∈ N and a sequence of natural numbers S = (k1, k2, . . . , k3m) with 3m

j=1 kj = mB and

B/4 < kj < B/2 for all j ∈ [1, 3m], decide whether there is a complete 3-partition of S s.t. each partition sums to B.

9/ 19

slide-37
SLIDE 37

Satisfiability, lower bound

  • NP-hardness follows by reduction from

3-partition problem. Given B ∈ N and a sequence of natural numbers S = (k1, k2, . . . , k3m) with 3m

j=1 kj = mB and

B/4 < kj < B/2 for all j ∈ [1, 3m], decide whether there is a complete 3-partition of S s.t. each partition sums to B.

  • We can encode an instance (B, S) as a symbolic heap in ASL.

9/ 19

slide-38
SLIDE 38

Satisfiability, lower bound

  • NP-hardness follows by reduction from

3-partition problem. Given B ∈ N and a sequence of natural numbers S = (k1, k2, . . . , k3m) with 3m

j=1 kj = mB and

B/4 < kj < B/2 for all j ∈ [1, 3m], decide whether there is a complete 3-partition of S s.t. each partition sums to B.

  • We can encode an instance (B, S) as a symbolic heap in ASL.
  • Roughly, the idea is that we have m + 1 “delimiters” di at

intervals of B cells, and 3m arrays of length kj.

9/ 19

slide-39
SLIDE 39

Satisfiability, lower bound

  • NP-hardness follows by reduction from

3-partition problem. Given B ∈ N and a sequence of natural numbers S = (k1, k2, . . . , k3m) with 3m

j=1 kj = mB and

B/4 < kj < B/2 for all j ∈ [1, 3m], decide whether there is a complete 3-partition of S s.t. each partition sums to B.

  • We can encode an instance (B, S) as a symbolic heap in ASL.
  • Roughly, the idea is that we have m + 1 “delimiters” di at

intervals of B cells, and 3m arrays of length kj. We can fit all the arrays between the di iff there is a 3-partition: . . .

di

  • B
  • ·

· · · ·

  • kji,1

· · · ·

  • kji,2

· · ·

  • kji,3

di+1

  • . . .

9/ 19

slide-40
SLIDE 40

Biabduction

Biabduction problem for ASL. Given satisfiable symbolic heaps A and B, find symbolic heaps X and Y such that A ∗ X is satisfiable and A ∗ X | = B ∗ Y .

10/ 19

slide-41
SLIDE 41

Biabduction

Biabduction problem for ASL. Given satisfiable symbolic heaps A and B, find symbolic heaps X and Y such that A ∗ X is satisfiable and A ∗ X | = B ∗ Y .

  • We concentrate on the quantifier-free case.

10/ 19

slide-42
SLIDE 42

Biabduction

Biabduction problem for ASL. Given satisfiable symbolic heaps A and B, find symbolic heaps X and Y such that A ∗ X is satisfiable and A ∗ X | = B ∗ Y .

  • We concentrate on the quantifier-free case.
  • Our approach, diagrammatically, is as follows:

10/ 19

slide-43
SLIDE 43

Biabduction

Biabduction problem for ASL. Given satisfiable symbolic heaps A and B, find symbolic heaps X and Y such that A ∗ X is satisfiable and A ∗ X | = B ∗ Y .

  • We concentrate on the quantifier-free case.
  • Our approach, diagrammatically, is as follows:

existence of biabduction solution for (A, B) satisfiability

  • f β(A, B)

existence of solu- tion seed for (A, B)

10/ 19

slide-44
SLIDE 44

The formula β(A, B)

  • Let (A, B) be an instance of the biabduction problem, where

A = Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui

B = Π′ :∗

m i=1 array(ci, di) ∗∗ ℓ i=1 vi → wi

11/ 19

slide-45
SLIDE 45

The formula β(A, B)

  • Let (A, B) be an instance of the biabduction problem, where

A = Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui

B = Π′ :∗

m i=1 array(ci, di) ∗∗ ℓ i=1 vi → wi

  • For a solution to exist, we need to know that
  • A and B are simultaneously satisfiable; and

11/ 19

slide-46
SLIDE 46

The formula β(A, B)

  • Let (A, B) be an instance of the biabduction problem, where

A = Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui

B = Π′ :∗

m i=1 array(ci, di) ∗∗ ℓ i=1 vi → wi

  • For a solution to exist, we need to know that
  • A and B are simultaneously satisfiable; and
  • pointers vj → wj in B are either covered by pointers ti → ui in

A with the right data value (ti = vj ∧ ui = wj), or else not covered by anything in A.

11/ 19

slide-47
SLIDE 47

The formula β(A, B)

  • Let (A, B) be an instance of the biabduction problem, where

A = Π :∗

n i=1 array(ai, bi) ∗∗ k i=1 ti → ui

B = Π′ :∗

m i=1 array(ci, di) ∗∗ ℓ i=1 vi → wi

  • For a solution to exist, we need to know that
  • A and B are simultaneously satisfiable; and
  • pointers vj → wj in B are either covered by pointers ti → ui in

A with the right data value (ti = vj ∧ ui = wj), or else not covered by anything in A.

  • This can be coded up as a Presburger formula β(A, B), using

the γ(−) encoding of satisfiability.

11/ 19

slide-48
SLIDE 48

Solution seeds

  • Write TA,B for the set of all terms in A and B. A solution

seed for (A, B) is a pure formula ∆ =

i∈I δi such that:

12/ 19

slide-49
SLIDE 49

Solution seeds

  • Write TA,B for the set of all terms in A and B. A solution

seed for (A, B) is a pure formula ∆ =

i∈I δi such that:

  • 1. ∆ is satisfiable, and ∆ |

= β(A, B);

12/ 19

slide-50
SLIDE 50

Solution seeds

  • Write TA,B for the set of all terms in A and B. A solution

seed for (A, B) is a pure formula ∆ =

i∈I δi such that:

  • 1. ∆ is satisfiable, and ∆ |

= β(A, B);

  • 2. each δi is of the form (t < u) or (t = u), where t, u ∈ TA,B;

12/ 19

slide-51
SLIDE 51

Solution seeds

  • Write TA,B for the set of all terms in A and B. A solution

seed for (A, B) is a pure formula ∆ =

i∈I δi such that:

  • 1. ∆ is satisfiable, and ∆ |

= β(A, B);

  • 2. each δi is of the form (t < u) or (t = u), where t, u ∈ TA,B;
  • 3. all terms in TA,B are ordered by a conjunct of ∆.

12/ 19

slide-52
SLIDE 52

Solution seeds

  • Write TA,B for the set of all terms in A and B. A solution

seed for (A, B) is a pure formula ∆ =

i∈I δi such that:

  • 1. ∆ is satisfiable, and ∆ |

= β(A, B);

  • 2. each δi is of the form (t < u) or (t = u), where t, u ∈ TA,B;
  • 3. all terms in TA,B are ordered by a conjunct of ∆.
  • That is, solution seeds enforce a total ordering on TA,B,

including all array bounds and pointer addresses.

12/ 19

slide-53
SLIDE 53

Solution seeds

  • Write TA,B for the set of all terms in A and B. A solution

seed for (A, B) is a pure formula ∆ =

i∈I δi such that:

  • 1. ∆ is satisfiable, and ∆ |

= β(A, B);

  • 2. each δi is of the form (t < u) or (t = u), where t, u ∈ TA,B;
  • 3. all terms in TA,B are ordered by a conjunct of ∆.
  • That is, solution seeds enforce a total ordering on TA,B,

including all array bounds and pointer addresses.

  • It is fairly straightforward to show
  • ∃ biabduction soln. for (A, B) ⇒ β(A, B) is satisfiable;

12/ 19

slide-54
SLIDE 54

Solution seeds

  • Write TA,B for the set of all terms in A and B. A solution

seed for (A, B) is a pure formula ∆ =

i∈I δi such that:

  • 1. ∆ is satisfiable, and ∆ |

= β(A, B);

  • 2. each δi is of the form (t < u) or (t = u), where t, u ∈ TA,B;
  • 3. all terms in TA,B are ordered by a conjunct of ∆.
  • That is, solution seeds enforce a total ordering on TA,B,

including all array bounds and pointer addresses.

  • It is fairly straightforward to show
  • ∃ biabduction soln. for (A, B) ⇒ β(A, B) is satisfiable;
  • β(A, B) is satisfiable

⇒ ∃ solution seed for (A, B).

12/ 19

slide-55
SLIDE 55

From seeds to solutions

  • A seed defines a total ordering of all array endpoints and

pointer addresses in A and B.

13/ 19

slide-56
SLIDE 56

From seeds to solutions

  • A seed defines a total ordering of all array endpoints and

pointer addresses in A and B.

  • Given this info, computing X and Y becomes a relatively

simple (PTIME) process!

13/ 19

slide-57
SLIDE 57

From seeds to solutions

  • A seed defines a total ordering of all array endpoints and

pointer addresses in A and B.

  • Given this info, computing X and Y becomes a relatively

simple (PTIME) process!

  • First we compute X by covering every array / pointer in B

not already covered by A; then we compute Y the same way:

13/ 19

slide-58
SLIDE 58

From seeds to solutions

  • A seed defines a total ordering of all array endpoints and

pointer addresses in A and B.

  • Given this info, computing X and Y becomes a relatively

simple (PTIME) process!

  • First we compute X by covering every array / pointer in B

not already covered by A; then we compute Y the same way:

A ∗ X B ∗ Y c1 a1 − 1 a1 b1 b1 + 1 d2 c3 a2 − 1 a2 b2 b2 + 1 d3 c1 d1 d1 + 1 c2 − 1 c2 d2 c3 d3

13/ 19

slide-59
SLIDE 59

From seeds to solutions

  • A seed defines a total ordering of all array endpoints and

pointer addresses in A and B.

  • Given this info, computing X and Y becomes a relatively

simple (PTIME) process!

  • First we compute X by covering every array / pointer in B

not already covered by A; then we compute Y the same way:

A ∗ X B ∗ Y c1 a1 − 1 a1 b1 b1 + 1 d2 c3 a2 − 1 a2 b2 b2 + 1 d3 c1 d1 d1 + 1 c2 − 1 c2 d2 c3 d3

  • We have to be a little careful about the pointer / array

distinction though.

13/ 19

slide-60
SLIDE 60

Lower bounds and quantification

  • Quantifier-free case is NP-hard, again by reduction from the

3-partition problem.

14/ 19

slide-61
SLIDE 61

Lower bounds and quantification

  • Quantifier-free case is NP-hard, again by reduction from the

3-partition problem.

  • When we disallow ∃ over R-values (∃y.x → y) in B, the

problem is equivalent to the quantifier-free case.

14/ 19

slide-62
SLIDE 62

Lower bounds and quantification

  • Quantifier-free case is NP-hard, again by reduction from the

3-partition problem.

  • When we disallow ∃ over R-values (∃y.x → y) in B, the

problem is equivalent to the quantifier-free case.

  • Otherwise, we get ΠP

2 -hardness by reduction from

14/ 19

slide-63
SLIDE 63

Lower bounds and quantification

  • Quantifier-free case is NP-hard, again by reduction from the

3-partition problem.

  • When we disallow ∃ over R-values (∃y.x → y) in B, the

problem is equivalent to the quantifier-free case.

  • Otherwise, we get ΠP

2 -hardness by reduction from

2-round 3-colourability problem Given an undirected graph G, decide whether every 3-colouring of the leaves can be extended to a 3-colouring of G, such that no two adjacent vertices have the same colour.

14/ 19

slide-64
SLIDE 64

Lower bounds and quantification

  • Quantifier-free case is NP-hard, again by reduction from the

3-partition problem.

  • When we disallow ∃ over R-values (∃y.x → y) in B, the

problem is equivalent to the quantifier-free case.

  • Otherwise, we get ΠP

2 -hardness by reduction from

2-round 3-colourability problem Given an undirected graph G, decide whether every 3-colouring of the leaves can be extended to a 3-colouring of G, such that no two adjacent vertices have the same colour.

  • (Given G, we define AG to encode a 3-colouring of the leaves,

and BG to encode a 3-colouring of G.)

14/ 19

slide-65
SLIDE 65

Entailment, upper bound

Entailment problem for ASL. Given symbolic heaps A and B, decide whether A | = B.

15/ 19

slide-66
SLIDE 66

Entailment, upper bound

Entailment problem for ASL. Given symbolic heaps A and B, decide whether A | = B.

  • Intuition: a stack s yields a countermodel for A |

= B if A is satisfiable under s and for every instantiation of existential variables z, either:

15/ 19

slide-67
SLIDE 67

Entailment, upper bound

Entailment problem for ASL. Given symbolic heaps A and B, decide whether A | = B.

  • Intuition: a stack s yields a countermodel for A |

= B if A is satisfiable under s and for every instantiation of existential variables z, either:

  • 1. B becomes unsatisfiable; or

15/ 19

slide-68
SLIDE 68

Entailment, upper bound

Entailment problem for ASL. Given symbolic heaps A and B, decide whether A | = B.

  • Intuition: a stack s yields a countermodel for A |

= B if A is satisfiable under s and for every instantiation of existential variables z, either:

  • 1. B becomes unsatisfiable; or
  • 2. some heap location is covered by an array or pointer in A, but

not by any array or pointer in B, or vice versa; or

15/ 19

slide-69
SLIDE 69

Entailment, upper bound

Entailment problem for ASL. Given symbolic heaps A and B, decide whether A | = B.

  • Intuition: a stack s yields a countermodel for A |

= B if A is satisfiable under s and for every instantiation of existential variables z, either:

  • 1. B becomes unsatisfiable; or
  • 2. some heap location is covered by an array or pointer in A, but

not by any array or pointer in B, or vice versa; or

  • 3. the LHS of some pointer in B is covered by an array in A; or

15/ 19

slide-70
SLIDE 70

Entailment, upper bound

Entailment problem for ASL. Given symbolic heaps A and B, decide whether A | = B.

  • Intuition: a stack s yields a countermodel for A |

= B if A is satisfiable under s and for every instantiation of existential variables z, either:

  • 1. B becomes unsatisfiable; or
  • 2. some heap location is covered by an array or pointer in A, but

not by any array or pointer in B, or vice versa; or

  • 3. the LHS of some pointer in B is covered by an array in A; or
  • 4. some pointer in B is covered by a pointer in A, but their data

contents disagree.

15/ 19

slide-71
SLIDE 71

Entailment, upper bound

Entailment problem for ASL. Given symbolic heaps A and B, decide whether A | = B.

  • Intuition: a stack s yields a countermodel for A |

= B if A is satisfiable under s and for every instantiation of existential variables z, either:

  • 1. B becomes unsatisfiable; or
  • 2. some heap location is covered by an array or pointer in A, but

not by any array or pointer in B, or vice versa; or

  • 3. the LHS of some pointer in B is covered by an array in A; or
  • 4. some pointer in B is covered by a pointer in A, but their data

contents disagree.

  • Thus we can encode existence of a countermodel as a Σ0

2

Presburger formula. Entailment becomes a Π0

2 formula.

15/ 19

slide-72
SLIDE 72

Entailment, upper bound

Entailment problem for ASL. Given symbolic heaps A and B, decide whether A | = B.

  • Intuition: a stack s yields a countermodel for A |

= B if A is satisfiable under s and for every instantiation of existential variables z, either:

  • 1. B becomes unsatisfiable; or
  • 2. some heap location is covered by an array or pointer in A, but

not by any array or pointer in B, or vice versa; or

  • 3. the LHS of some pointer in B is covered by an array in A; or
  • 4. some pointer in B is covered by a pointer in A, but their data

contents disagree.

  • Thus we can encode existence of a countermodel as a Σ0

2

Presburger formula. Entailment becomes a Π0

2 formula.

  • Due to item 3, we can’t allow ∃ over R-values in pointers.

15/ 19

slide-73
SLIDE 73

Entailment, lower bound

  • We get ΠP

2 -hardness of entailment, even for restricted ∃

quantifiers, by reduction from the previous colourability problem.

16/ 19

slide-74
SLIDE 74

Entailment, lower bound

  • We get ΠP

2 -hardness of entailment, even for restricted ∃

quantifiers, by reduction from the previous colourability problem.

  • Let’s not go into the details!

16/ 19

slide-75
SLIDE 75

Entailment, lower bound

  • We get ΠP

2 -hardness of entailment, even for restricted ∃

quantifiers, by reduction from the previous colourability problem.

  • Let’s not go into the details!
  • This gives a gap in our complexity bounds for entailment:

16/ 19

slide-76
SLIDE 76

Entailment, lower bound

  • We get ΠP

2 -hardness of entailment, even for restricted ∃

quantifiers, by reduction from the previous colourability problem.

  • Let’s not go into the details!
  • This gives a gap in our complexity bounds for entailment:
  • lower bound of ΠP

2 ;

16/ 19

slide-77
SLIDE 77

Entailment, lower bound

  • We get ΠP

2 -hardness of entailment, even for restricted ∃

quantifiers, by reduction from the previous colourability problem.

  • Let’s not go into the details!
  • This gives a gap in our complexity bounds for entailment:
  • lower bound of ΠP

2 ;

  • upper bound of ΠEXP

1

in the exponential-time hierarchy.

16/ 19

slide-78
SLIDE 78

Entailment, lower bound

  • We get ΠP

2 -hardness of entailment, even for restricted ∃

quantifiers, by reduction from the previous colourability problem.

  • Let’s not go into the details!
  • This gives a gap in our complexity bounds for entailment:
  • lower bound of ΠP

2 ;

  • upper bound of ΠEXP

1

in the exponential-time hierarchy.

  • I suspect the upper bound is closer to the “true complexity”.

16/ 19

slide-79
SLIDE 79

Future work

  • Obvious thing to do: implement a prototype INFER-style

analysis for array programs.

17/ 19

slide-80
SLIDE 80

Future work

  • Obvious thing to do: implement a prototype INFER-style

analysis for array programs.

  • Our biabduction algorithm could be improved:

17/ 19

slide-81
SLIDE 81

Future work

  • Obvious thing to do: implement a prototype INFER-style

analysis for array programs.

  • Our biabduction algorithm could be improved:
  • commit to as little ordering as possible;

17/ 19

slide-82
SLIDE 82

Future work

  • Obvious thing to do: implement a prototype INFER-style

analysis for array programs.

  • Our biabduction algorithm could be improved:
  • commit to as little ordering as possible;
  • find heuristics for improving solution quality.

17/ 19

slide-83
SLIDE 83

Future work

  • Obvious thing to do: implement a prototype INFER-style

analysis for array programs.

  • Our biabduction algorithm could be improved:
  • commit to as little ordering as possible;
  • find heuristics for improving solution quality.
  • One could also try to do biabduction proof-theoretically.

17/ 19

slide-84
SLIDE 84

Future work

  • Obvious thing to do: implement a prototype INFER-style

analysis for array programs.

  • Our biabduction algorithm could be improved:
  • commit to as little ordering as possible;
  • find heuristics for improving solution quality.
  • One could also try to do biabduction proof-theoretically.
  • Another essential program analysis component is abstraction

heuristics for finding invariants, etc.

17/ 19

slide-85
SLIDE 85

Future work

  • Obvious thing to do: implement a prototype INFER-style

analysis for array programs.

  • Our biabduction algorithm could be improved:
  • commit to as little ordering as possible;
  • find heuristics for improving solution quality.
  • One could also try to do biabduction proof-theoretically.
  • Another essential program analysis component is abstraction

heuristics for finding invariants, etc.

  • Extension of ASL with more expressive features (e.g. combine

with list segments?).

17/ 19

slide-86
SLIDE 86

Conclusions

  • We propose ASL, a version of symbolic-heap separation logic

for arrays.

18/ 19

slide-87
SLIDE 87

Conclusions

  • We propose ASL, a version of symbolic-heap separation logic

for arrays.

  • Biabduction is the most critical step in inferring specifications
  • f whole programs.

18/ 19

slide-88
SLIDE 88

Conclusions

  • We propose ASL, a version of symbolic-heap separation logic

for arrays.

  • Biabduction is the most critical step in inferring specifications
  • f whole programs.
  • We give a sound, complete biabduction algorithm that runs in

NP-time.

18/ 19

slide-89
SLIDE 89

Conclusions

  • We propose ASL, a version of symbolic-heap separation logic

for arrays.

  • Biabduction is the most critical step in inferring specifications
  • f whole programs.
  • We give a sound, complete biabduction algorithm that runs in

NP-time.

  • Indeed, biabduction is NP-complete, climbing higher when ∃

quantifiers are added.

18/ 19

slide-90
SLIDE 90

Conclusions

  • We propose ASL, a version of symbolic-heap separation logic

for arrays.

  • Biabduction is the most critical step in inferring specifications
  • f whole programs.
  • We give a sound, complete biabduction algorithm that runs in

NP-time.

  • Indeed, biabduction is NP-complete, climbing higher when ∃

quantifiers are added.

  • We also establish decision procedures and complexity bounds

for satisfiability and entailment.

18/ 19

slide-91
SLIDE 91

Thanks for listening!

Paper available on arXiv: arXiv:1607.01993

19/ 19