biabduction and related problems in array separation logic
play

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


  1. 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

  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

  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

  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

  5. Compositional proofs in separation logic (2) • The second pillar is given by solving the biabduction problem: 3/ 19

  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

  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 ′ } C 1 { A } and { B } C 2 { B ′ } , we can infer a spec for C 1 ; C 2 : 3/ 19

  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 ′ } C 1 { A } and { B } C 2 { B ′ } , we can infer a spec for C 1 ; C 2 : { A ′ } C 1 { A } (Frame) { A ′ ∗ X } C 1 { A ∗ X } { B } C 2 { B ′ } ( | =) (Frame) { A ′ ∗ X } C 1 { B ∗ Y } { B ∗ Y } C 2 { B ′ ∗ Y } (;) { A ′ ∗ X } C 1 ; C 2 { B ′ ∗ Y } 3/ 19

  9. Symbolic-heap separation logic • Terms t , pure formulas Π and spatial formulas F given by: ::= x ∈ Var | nil t Π ::= t = t | t � = t | Π ∧ Π ::= emp | t �→ t | ls( t , t ) | F ∗ F F 4/ 19

  10. Symbolic-heap separation logic • Terms t , pure formulas Π and spatial formulas F given by: ::= x ∈ Var | nil t Π ::= t = t | t � = t | Π ∧ Π ::= emp | t �→ t | ls( t , t ) | F ∗ F F • t 1 �→ t 2 (“points-to”) denotes a pointer in the heap. 4/ 19

  11. Symbolic-heap separation logic • Terms t , pure formulas Π and spatial formulas F given by: ::= x ∈ Var | nil t Π ::= t = t | t � = t | Π ∧ Π ::= emp | t �→ t | ls( t , t ) | F ∗ F F • t 1 �→ t 2 (“points-to”) denotes a pointer in the heap. • ls( t 1 , t 2 ) denotes a linked list segment in the heap. 4/ 19

  12. Symbolic-heap separation logic • Terms t , pure formulas Π and spatial formulas F given by: ::= x ∈ Var | nil t Π ::= t = t | t � = t | Π ∧ Π ::= emp | t �→ t | ls( t , t ) | F ∗ F F • t 1 �→ t 2 (“points-to”) denotes a pointer in the heap. • ls( t 1 , t 2 ) denotes a linked list segment in the heap. • ∗ (“and separately”) demarks domain-disjoint heaps. 4/ 19

  13. Symbolic-heap separation logic • Terms t , pure formulas Π and spatial formulas F given by: ::= x ∈ Var | nil t Π ::= t = t | t � = t | Π ∧ Π ::= emp | t �→ t | ls( t , t ) | F ∗ F F • t 1 �→ t 2 (“points-to”) denotes a pointer in the heap. • ls( t 1 , t 2 ) denotes a linked list segment in the heap. • ∗ (“and separately”) demarks domain-disjoint heaps. • Symbolic heaps given by ∃ x . Π : F . 4/ 19

  14. Array separation logic, ASL • Here we focus on a different data structure, namely arrays. 5/ 19

  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

  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( t 1 , t 2 ) denotes an array from t 1 to t 2 (inclusive): t 2 − t 1 +1 � �� � · · · . . . · · · t 1 t 2 5/ 19

  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( t 1 , t 2 ) denotes an array from t 1 to t 2 (inclusive): t 2 − t 1 +1 � �� � · · · . . . · · · t 1 t 2 • We also allow linear arithmetic in the pure part. 5/ 19

  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

  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 | = t 1 ∼ t 2 ⇔ s ( t 1 ) ∼ s ( t 2 ) ( ∼ ∈ { = , � = , <, ≤} ) s , h | = Π 1 ∧ Π 2 ⇔ s , h | = Π 1 and s , h | = Π 2 6/ 19

  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 | = t 1 ∼ t 2 ⇔ s ( t 1 ) ∼ s ( t 2 ) ( ∼ ∈ { = , � = , <, ≤} ) s , h | = Π 1 ∧ Π 2 ⇔ s , h | = Π 1 and s , h | = Π 2 s , h | = emp ⇔ h = e s , h | = t 1 �→ t 2 ⇔ dom ( h ) = { s ( t 1 ) } and h ( s ( t 1 )) = s ( t 2 ) 6/ 19

  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 | = t 1 ∼ t 2 ⇔ s ( t 1 ) ∼ s ( t 2 ) ( ∼ ∈ { = , � = , <, ≤} ) s , h | = Π 1 ∧ Π 2 ⇔ s , h | = Π 1 and s , h | = Π 2 s , h | = emp ⇔ h = e s , h | = t 1 �→ t 2 ⇔ dom ( h ) = { s ( t 1 ) } and h ( s ( t 1 )) = s ( t 2 ) s , h | = array( t 1 , t 2 ) ⇔ s ( t 1 ) ≤ s ( t 2 ) and dom ( h ) = { s ( t 1 ) , . . . , s ( t 2 ) } 6/ 19

  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 | = t 1 ∼ t 2 ⇔ s ( t 1 ) ∼ s ( t 2 ) ( ∼ ∈ { = , � = , <, ≤} ) s , h | = Π 1 ∧ Π 2 ⇔ s , h | = Π 1 and s , h | = Π 2 s , h | = emp ⇔ h = e s , h | = t 1 �→ t 2 ⇔ dom ( h ) = { s ( t 1 ) } and h ( s ( t 1 )) = s ( t 2 ) s , h | = array( t 1 , t 2 ) ⇔ s ( t 1 ) ≤ s ( t 2 ) and dom ( h ) = { s ( t 1 ) , . . . , s ( t 2 ) } s , h | = F 1 ∗ F 2 ⇔ h = h 1 ◦ h 2 and s , h 1 | = F 1 and s , h 2 | = F 2 6/ 19

  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 | = t 1 ∼ t 2 ⇔ s ( t 1 ) ∼ s ( t 2 ) ( ∼ ∈ { = , � = , <, ≤} ) s , h | = Π 1 ∧ Π 2 ⇔ s , h | = Π 1 and s , h | = Π 2 s , h | = emp ⇔ h = e s , h | = t 1 �→ t 2 ⇔ dom ( h ) = { s ( t 1 ) } and h ( s ( t 1 )) = s ( t 2 ) s , h | = array( t 1 , t 2 ) ⇔ s ( t 1 ) ≤ s ( t 2 ) and dom ( h ) = { s ( t 1 ) , . . . , s ( t 2 ) } s , h | = F 1 ∗ F 2 ⇔ h = h 1 ◦ h 2 and s , h 1 | = F 1 and s , h 2 | = F 2 s , h | = ∃ z . Π : F ⇔ ∃ v . s [ z �→ v ] , h | = Π and s [ z �→ v ] , h | = F 6/ 19

  24. Motivating example Suppose we have procedure foo with spec { array( c , d ) } foo ( c , d ) { Q } 7/ 19

  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

  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

  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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend