pointer-manipulating programs Nadia Polikarpova joint work with - - PowerPoint PPT Presentation

pointer manipulating programs
SMART_READER_LITE
LIVE PREVIEW

pointer-manipulating programs Nadia Polikarpova joint work with - - PowerPoint PPT Presentation

SuSLik: synthesis of safe pointer-manipulating programs Nadia Polikarpova joint work with Ilya Sergey (Yale-NUS) follow along https://github.com/TyGuS/suslik-tutorial 2 pointer-manipulating programs network / security operating systems


slide-1
SLIDE 1

SuSLik: synthesis of safe pointer-manipulating programs

Nadia Polikarpova

joint work with Ilya Sergey (Yale-NUS)

slide-2
SLIDE 2

follow along

2

https://github.com/TyGuS/suslik-tutorial

slide-3
SLIDE 3

3

pointer-manipulating programs

  • perating systems

network / security protocols

☺ efficient  hard to write  memory safety bugs

browsers

slide-4
SLIDE 4

4

how to make them safe?

 hard to write

write in a high-level language write in C, verify in Coq

☺ easy to write  have to rewrite everything ☺ backwards compatible

slide-5
SLIDE 5

program synthesis to the rescue

5

specification code

☺ easy to write ☺ efficient ☺ backwards compatible ☺ provably memory-safe  verbose  unstructured  pointers & aliasing

slide-6
SLIDE 6

(Synthesis using Separation Logik ik)

SuSLik

slide-7
SLIDE 7

the SuSLik approach

7

specification separation logic code deductive synthesis

☺ reasoning about pointers & aliasing ☺ uses specs to guide synthesis

slide-8
SLIDE 8

this tutorial

  • 1. example: swap

a taste of SuSLik

  • 2. intro to separation logic

reasoning about pointer-manipulating programs

  • 3. deductive synthesis

from SL specifications to programs

8

slide-9
SLIDE 9

this tutorial

1.example: swap

  • 2. intro to separation logic
  • 3. deductive synthesis

9

slide-10
SLIDE 10

example: swap

Swap values of two distinct pointers

10

void swap(loc x, loc y)

slide-11
SLIDE 11

example: swap

11

A start state: end state:

x

B

y

B

x

A

y

in separation logic:

{ x ↦ A * y ↦ B } { x ↦ B * y ↦ A }

void swap(loc x, loc y)

separately precondition postcondition ghost variables

slide-12
SLIDE 12

demo 1: swap

Swap values of two distinct pointers

12

void swap(loc x, loc y)

slide-13
SLIDE 13

{ x ↦ A * y ↦ B } { x ↦ B * y ↦ A } ??

slide-14
SLIDE 14

{ x ↦ a1 * y ↦ B } { x ↦ B * y ↦ a1 } ?? let a1 = *x;

slide-15
SLIDE 15

{ x ↦ a1 * y ↦ b1 } { x ↦ b1 * y ↦ a1 } ?? let a1 = *x; let b1 = *y;

slide-16
SLIDE 16

{ x ↦ b1 * y ↦ b1 } { x ↦ b1 * y ↦ a1 } let a1 = *x; ?? let b1 = *y; *x = b1;

slide-17
SLIDE 17

{ x ↦ b1 * y ↦ a1 } { x ↦ b1 * y ↦ a1 } let a1 = *x; ?? let b1 = *y; *x = b1; *y = a1; same

slide-18
SLIDE 18

let a1 = *x; let b1 = *y; *x = b1; *y = a1;

slide-19
SLIDE 19

let a1 = *x; let b1 = *y; *x = b1; *y = a1; void swap(loc x, loc y) { }

slide-20
SLIDE 20

exercise 1: rotate three

20

A start state: end state:

x

B

y

C

x

A

y

void rotate(loc x, loc y, loc z) C

z

B

z

slide-21
SLIDE 21

this tutorial

  • 1. example: swap

2.intro to separation logic

  • 3. deductive synthesis

21

slide-22
SLIDE 22

separation logic (SL)

22

Hoare logic “about the heap”

slide-23
SLIDE 23

separation logic (SL)

23

{P} {Q} c

starting in a state that satisfies P program c will execute without memory errors, and upon its termination the state will satisfy Q SL assertions program

slide-24
SLIDE 24

this tutorial

  • 1. example: swap

2.intro to separation logic

2.1. programs and assertions 2.2. inductive predicates 2.3. specifying data transformations

  • 3. deductive synthesis

24

slide-25
SLIDE 25

separation logic (SL)

25

{P} {Q} c

program

slide-26
SLIDE 26

programs

26

do nothing

skip

slide-27
SLIDE 27

programs

27

do nothing

skip let y = *(x + n)

read from heap variables

  • ffset (natural number)
slide-28
SLIDE 28

programs

28

do nothing

skip let y = *(x + n)

read from heap

*(x + n) = e

write to heap expression (arithmetic, boolean)

slide-29
SLIDE 29

programs

29

do nothing

skip let y = *(x + n)

read from heap

*(x + n) = e

write to heap

let y = malloc(n)

allocate block

slide-30
SLIDE 30

programs

30

do nothing

skip let y = *(x + n)

read from heap

*(x + n) = e

write to heap

let y = malloc(n)

allocate block

free(x)

free block

slide-31
SLIDE 31

programs

31

do nothing

skip let y = *(x + n)

read from heap

*(x + n) = e

write to heap

let y = malloc(n)

allocate block

free(x)

free block

p(e1, …, en)

procedure call

slide-32
SLIDE 32

programs

32

do nothing

skip let y = *(x + n)

read from heap

*(x + n) = e

write to heap

let y = malloc(n)

allocate block

free(x)

free block

p(e1, …, en)

procedure call assignment

  • nly heap is mutable, not stack variables!
slide-33
SLIDE 33

programs

33

do nothing

skip let y = *(x + n)

read from heap

*(x + n) = e

write to heap

let y = malloc(n)

allocate block

free(x)

free block

p(e1, …, en)

procedure call

c1 ; c2

sequential composition conditional

if (e) {c1} else {c2}

slide-34
SLIDE 34

separation logic (SL)

34

{P} {Q} c

SL assertions

slide-35
SLIDE 35

SL assertions

35

empty heap

{ emp }

slide-36
SLIDE 36

SL assertions

36

empty heap

{ emp } { y ↦ 5 }

singleton heap

5

y

slide-37
SLIDE 37

SL assertions

37

empty heap

{ emp } { y ↦ 5 } { x ↦ y * y ↦ 5 }

singleton heap separating conjunction

5

y x

heaplets

slide-38
SLIDE 38

SL assertions

38

empty heap

{ emp } { y ↦ 5 } { x ↦ y * y ↦ 5 }

singleton heap separating conjunction memory block

{ [x, 2] * x ↦ 5 * (x + 1) ↦ 10 } 10 5

x

slide-39
SLIDE 39

SL assertions

39

empty heap

{ emp } { y ↦ 5 } { x ↦ y * y ↦ 5 }

singleton heap separating conjunction memory block

{ [x, 2] * x ↦ 5 * (x + 1) ↦ 10 }

+ pure formula

{ A > 5 ; x ↦ A } A

x

slide-40
SLIDE 40

separation logic (SL)

40

{P} {Q} c

starting in a state that satisfies P program c will execute without memory errors, and upon its termination the state will satisfy Q

slide-41
SLIDE 41

example triples

41

{ x ↦ A } *x = 5 { x ↦ 5 } { x ↦ A } *(x + 1) = 5 { x ↦ A } let y = *x { x ↦ y } { emp } let y = malloc(2) { [y, 2] * y ↦ A * (y + 1) ↦ B } { [x, 2] * x ↦ 5 * (x + 1) ↦ 7 } free(x + 1)

slide-42
SLIDE 42

this tutorial

  • 1. example: swap

2.intro to separation logic

2.1. programs and assertions 2.2. inductive predicates 2.3. specifying data transformations

  • 3. deductive synthesis

42

slide-43
SLIDE 43

SL assertions: linked structures

43

x

slide-44
SLIDE 44

SL assertions: linked structures

44

x { x = 0 ; emp }

linked list

slide-45
SLIDE 45

SL assertions: linked structures

45

V

x { [x, 2] * x ↦ V * (x + 1) ↦ 0 }

linked list

slide-46
SLIDE 46

SL assertions: linked structures

46

V V’

x { [x, 2] * x ↦ V * (x + 1) ↦ Y * } [Y, 2] * Y ↦ V’ * (Y + 1) ↦ 0 Y

linked list

slide-47
SLIDE 47

SL assertions: linked structures

47

V V’

x { [x, 2] * x ↦ V * (x + 1) ↦ Y * } … [Y, 2] * Y ↦ V’ * (Y + 1) ↦ Y’ * Y

linked list

inductive predicates to the rescue!

slide-48
SLIDE 48

the linked list predicate

48

V

x Y predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } x

slide-49
SLIDE 49

this tutorial

  • 1. example: swap

2.intro to separation logic

2.1. programs and assertions 2.2. inductive predicates 2.3. specifying data transformations

  • 3. deductive synthesis

49

slide-50
SLIDE 50

demo 2: dispose a list

50

{ list(x) } { emp }

void dispose(loc x)

slide-51
SLIDE 51

linked list with elements

51

predicate list (loc x, set s) { | x = 0 => { s = ∅ ; emp } | x ≠ 0 => { s = {V} + S’ ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y, S’) } }

V

x S’ x s Y

slide-52
SLIDE 52

demo 3: copy a list

52

{ list(x, S) * r ↦ _ } { list(x, S) * r ↦ Y * list(Y, S) }

void copy(loc x, loc r) return location

slide-53
SLIDE 53

exercise 2: append two lists

53

{ ??? } { ???}

void append( ??? )

slide-54
SLIDE 54

exercise 3: schema migration

54

{ ??? } { ??? }

void single_to_double(loc x) singly-linked list with reserved space in each node doubly-linked list at the same address

slide-55
SLIDE 55

this tutorial

  • 1. example: swap
  • 2. intro to separation logic

3.deductive synthesis

55

slide-56
SLIDE 56

deductive synthesis

56

synthesis as proof search

slide-57
SLIDE 57

this tutorial

  • 1. example: swap
  • 2. intro to separation logic

3.deductive synthesis

3.1. proof system 3.2. proof search

57

slide-58
SLIDE 58

transforming entailment

58

P Q ⇝ | c

a state that satisfies P can be transformed into a state that satisfies Q using a program c

slide-59
SLIDE 59

synthetic separation logic (SSL)

59

proof system for transforming entailment

slide-60
SLIDE 60

{emp} ⇝ {emp} | ??

slide-61
SLIDE 61

{emp} ⇝ {emp} | skip

(Emp)

slide-62
SLIDE 62

{ P * R } ⇝ { Q * R } | c ?? { P } ⇝ { Q } | c

(Frame)

slide-63
SLIDE 63

{ x ↦ _ ∗ P } ⇝ { x ↦ e ∗ Q } | *x = e; c ?? { x ↦ e ∗ P } ⇝ { x ↦ e ∗ Q } | c

(Write)

slide-64
SLIDE 64

{ x ↦ A ∗ P } ⇝ { Q } | let y = *x; c ?? [y/A]{ x ↦ A ∗ P } ⇝ [y/A]{ Q } | c

(Read)

slide-65
SLIDE 65

SSL: basic rules

65

{emp} ⇝ {emp} | skip

(Emp)

{ x ↦ A ∗ P } ⇝ { Q } | let y = *x; c [y/A]{ x ↦ A ∗ P } ⇝ [y/A]{ Q } | c

(Read)

{ P * R } ⇝ { Q * R } | c { P } ⇝ { Q } | c

(Frame)

{ x ↦ _ ∗ P } ⇝ { x ↦ e ∗ Q } | *x = e; c { x ↦ e ∗ P } ⇝ { x ↦ e ∗ Q } | c

(Write)

slide-66
SLIDE 66

⇝ { x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } |

??

example: swap

slide-67
SLIDE 67

⇝ { x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } |

??

slide-68
SLIDE 68

⇝ { x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } |

let a1 = *x; ??

(Read)

⇝ { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 }|

??

slide-69
SLIDE 69

⇝ { x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } |

let a1 = *x; ??

(Read)

⇝ { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 }|

let b1 = *y; ??

⇝ { x ↦ a1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 } |

??

(Read)

slide-70
SLIDE 70

⇝ |

(Read)

⇝ | ⇝ { x ↦ a1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 } |

*x = b1; ??

(Read)

⇝ { x ↦ b1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 } |

??

(Write)

{ x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A }

let a1 = *x; ??

{ x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 }

let b1 = *y; ??

slide-71
SLIDE 71

⇝ |

let a1 = *x; ??

(Read)

⇝ |

let b1 = *y; ??

⇝ { x ↦ a1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 } |

*x = b1; ??

(Read)

⇝ { x ↦ b1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 } |

??

(Write) (Frame)

⇝ { y ↦ b1 } { y ↦ a1 } |

??

{ x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 }

slide-72
SLIDE 72

⇝ |

(Read)

⇝ | ⇝ |

(Read)

⇝ { x ↦ b1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 } |

??

(Write) (Frame)

⇝ { y ↦ b1 } { y ↦ a1 } |

(Write)

*y = a1; ??

⇝ { y ↦ a1 } { y ↦ a1 } | ??

let a1 = *x; ?? let b1 = *y; ??

{ x ↦ a1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 }

*x = b1; ??

{ x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 }

slide-73
SLIDE 73

⇝ |

(Read)

⇝ | ⇝ |

(Read)

⇝ { x ↦ b1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 } |

??

(Write) (Frame)

⇝ { y ↦ b1 } { y ↦ a1 } |

(Write)

*y = a1; ??

⇝ { y ↦ a1 } { y ↦ a1 } | ?? ⇝ { emp } { emp } | ??

(Frame)

let a1 = *x; ?? let b1 = *y; ??

{ x ↦ a1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 }

*x = b1; ??

{ x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 }

slide-74
SLIDE 74

⇝ |

(Read)

⇝ | ⇝ |

(Read)

⇝ { x ↦ b1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 } |

??

(Write) (Frame)

⇝ { y ↦ b1 } { y ↦ a1 } |

(Write)

*y = a1; ??

⇝ { y ↦ a1 } { y ↦ a1 } | ?? ⇝ { emp } { emp } |

(Frame)

let a1 = *x; ?? let b1 = *y; ??

{ x ↦ a1 ∗ y ↦ b1 } { x ↦ b1 ∗ y ↦ a1 }

*x = b1; ??

{ x ↦ A ∗ y ↦ B } { x ↦ B ∗ y ↦ A } { x ↦ a1 ∗ y ↦ B } { x ↦ B ∗ y ↦ a1 }

skip

(Emp)

slide-75
SLIDE 75

*y = a1; let a1 = *x; let b1 = *y; *x = b1; skip

{ x ↦ A * y ↦ B } { x ↦ B * y ↦ A }

slide-76
SLIDE 76

demo 4: tracing swap

76

slide-77
SLIDE 77

synthetic separation logic (SSL)

  • basic rules

(Emp), (Read), (Write), (Frame) (Alloc), (Free)

  • pure reasoning and unification
  • inductive predicates and recursion

77

slide-78
SLIDE 78

synthetic separation logic (SSL)

  • basic rules

(Emp), (Read), (Write), (Frame) (Alloc), (Free)

  • pure reasoning and unification
  • inductive predicates and recursion

78

slide-79
SLIDE 79

example: dispose a list

79

{ list(x) } { emp }

void dispose(loc x)

slide-80
SLIDE 80

??

{ list0(x) } { emp }

{ list1 (x) } void dispose(loc x) { emp }

(Induction)

slide-81
SLIDE 81

??

{ list0(x) } { emp }

{ list1 (x) } void dispose(loc x) { emp } predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } }

(Open)

slide-82
SLIDE 82

{ x = 0 ; emp } { emp }

} else { } ??

{ emp }

??

{ x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list1 (Y) }

if (x == 0) {

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

slide-83
SLIDE 83

{ x = 0 ; emp } { emp }

} else { } ??

{ emp }

??

{ x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list1 (Y) }

if (x == 0) {

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

(Emp)

slide-84
SLIDE 84

{ x = 0 ; emp } { emp }

} else { } skip

{ emp }

??

{ x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list1 (Y) }

if (x == 0) {

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

slide-85
SLIDE 85

}

{ emp }

??

{ x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list1 (Y) }

if (x == 0) { skip } else {

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

slide-86
SLIDE 86

}

{ emp }

??

{ x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list1 (Y) }

if (x == 0) { skip } else {

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

(Read)

slide-87
SLIDE 87

}

{ emp }

??

{ x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ y1 ∗ list1 (y1) }

if (x == 0) { skip } else { let y1 = *(x + 1);

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

slide-88
SLIDE 88

}

{ emp }

??

{ x ≠ 0 ; [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ y1 ∗ list1 (y1) }

if (x == 0) { skip } else { let y1 = *(x + 1);

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

(Free)

slide-89
SLIDE 89

}

{ emp }

??

{ x ≠ 0 ; list1 (y1) }

if (x == 0) { skip } else { let y1 = *(x + 1); free x;

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

slide-90
SLIDE 90

}

{ emp }

??

{ x ≠ 0 ; list1 (y1) }

if (x == 0) { skip } else { let y1 = *(x + 1); free x;

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

(Call)

slide-91
SLIDE 91

}

{ emp }

??

{ x ≠ 0 ; emp }

if (x == 0) { skip } else { let y1 = *(x + 1); free x; dispose(y1);

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

slide-92
SLIDE 92

}

{ emp }

??

{ x ≠ 0 ; emp }

if (x == 0) { skip } else { let y1 = *(x + 1); free x; dispose(y1);

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

(Emp)

slide-93
SLIDE 93

} if (x == 0) { skip } else { let y1 = *(x + 1); free x; dispose(y1); skip

predicate list (loc x) { | x = 0 => { emp } | x ≠ 0 => { [x, 2] ∗ x ↦ V ∗ (x + 1) ↦ Y ∗ list(Y) } } { list1 (x) } void dispose(loc x) { emp }

slide-94
SLIDE 94

94

void dispose(loc x) { if (x == 0) { } else { let y1 = *(x + 1); free x; dispose(y1) }

slide-95
SLIDE 95

synthetic separation logic (SSL)

  • basic rules

(Emp), (Read), (Write), (Frame), (Alloc), (Free)

  • pure reasoning and unification
  • inductive predicates and recursion

(Open), (Close), (Induction), (Call)

95

slide-96
SLIDE 96

this tutorial

  • 1. example: swap
  • 2. intro to separation logic

3.deductive synthesis

3.1. proof system 3.2. proof search

96

slide-97
SLIDE 97

SuSLik backtracking search in SSL + optimizations

slide-98
SLIDE 98

demo 5: backtracking

98

slide-99
SLIDE 99
  • ptimizations
  • invertible rules
  • early failure
  • multi-phase search
  • symmetry reduction

99

slide-100
SLIDE 100
  • ptimization: invertible rules
  • invertible rules do not restrict the set of derivable programs
  • idea: invertible rules need not be backtracked

100

{ x ↦ A ∗ P } ⇝ { Q } | let y = *x; c [y/A]{ x ↦ A ∗ P } ⇝ [y/A]{ Q } | c

(Read)

slide-101
SLIDE 101
  • ptimization: early failure
  • idea: sometimes you know that a goal is unsatisfiable

101

{ φ ; P } ⇝ { ψ ;Q } | c ψ ≠ ⊥ ⊢ φ ∧ ψ ⇒ ⊥ { emp } ⇝ { ⊥ ; emp } | c

(Post-Inconsistent)

slide-102
SLIDE 102
  • ptimization: multi-phase search
  • unfolding phase: deals with inductive predicates

(Open), (Close), (Call), (Frame)

  • flat phase: deals with points-to and blocks

(Write), (Call), (Alloc), (Free), (Frame)

  • idea: if unfolding phase cannot eliminate all predicates, give up

102

slide-103
SLIDE 103
  • ptimization: symmetry reduction
  • sometimes rule applications commute
  • idea: only allow one order of commuting applications

103

⇝ { x ↦ a ∗ y ↦ b * a ↦ 0 } { x ↦ a ∗ y ↦ b * b ↦ 0 } |

??

(Frame)

⇝ { y ↦ b * a ↦ 0 } { y ↦ b * b ↦ 0 } | ??

(Frame)

⇝ { a ↦ 0 } { b ↦ 0 } | ??

slide-104
SLIDE 104

limitations & future work

104

  • pure synthesis

use an off-the-shelf pure synthesizer

  • reasoning about inductive predicates

identify decidable fragment

  • goal must be inductive

cyclic proofs to the rescue!

{ r ↦ _ } ⇝ { r ≥ x ∧ r ≥ y ; r ↦ M } | c { P } ⇝ { Q } | skip { tree(t, S) * r ↦ _ } {r ↦ X * list(X, S) } void flatten(loc t, loc r)

slide-105
SLIDE 105

deductive synthesis with SuSLik

105

specification separation logic code deductive synthesis

☺ reasoning about pointers & aliasing ☺ uses specs to guide synthesis ☺ provably memory-safe