symbolic heap abstraction with demand driven
play

Symbolic Heap Abstraction with Demand-Driven Axiomatization of - PowerPoint PPT Presentation

Symbolic Heap Abstraction with Demand-Driven Axiomatization of Memory Invariants Isil Dillig Thomas Dillig Alex Aiken Stanford University Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization


  1. Enforcing Memory Invariants Idea Enforce memory invariants symbolically using constraints on a single heap abstraction. No explicit case splits on the heap, but solver may internally need to perform case analysis Still advantageous because: Solver can often prove a constraint SAT or UNSAT without considering all cases: eager vs. lazy Don’t duplicate shared portions of the heap Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  2. Enforcing Memory Invariants Idea Enforce memory invariants symbolically using constraints on a single heap abstraction. No explicit case splits on the heap, but solver may internally need to perform case analysis Still advantageous because: Solver can often prove a constraint SAT or UNSAT without considering all cases: eager vs. lazy Don’t duplicate shared portions of the heap No heuristics for merging“similar”heaps Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  3. Enforcing Memory Invariants x a b To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬ φ Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  4. Enforcing Memory Invariants x a b To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬ φ Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  5. Enforcing Memory Invariants x a b To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬ φ ⇒ Uniqueness Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  6. Enforcing Memory Invariants x a b To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬ φ ⇒ Uniqueness Also encodes that x must point to either a or b Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  7. Enforcing Memory Invariants x a b To encode that x cannot point to a and b at the same time, we can use two constraints φ and ¬ φ ⇒ Uniqueness Also encodes that x must point to either a or b ⇒ Existence Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  8. Enforcing Memory Invariants x a y b Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  9. Enforcing Memory Invariants x a y b Correlation between x and y preserved x and y point to different locations under φ ∧ ¬ φ ⇒ Can prove the assertion! Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  10. Memory Invariants on Unbounded Locations Easy to enforce these invariants when each abstract location corresponds to one concrete location. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  11. Memory Invariants on Unbounded Locations Easy to enforce these invariants when each abstract location corresponds to one concrete location. But what about abstract locations that represent multiple concrete locations? Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  12. x a b Memory Invariants on Summary Locations Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  13. Memory Invariants on Summary Locations x a b Most techniques represent the array with a summary node. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  14. Memory Invariants on Summary Locations x a b Most techniques represent the array with a summary node. Graph encodes that any element in x may point to either a or b . Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  15. Memory Invariants on Summary Locations x a b Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  16. Memory Invariants on Summary Locations x a b Encodes that an element of x cannot point to both a and b Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  17. Memory Invariants on Summary Locations x a b Encodes that an element of x cannot point to both a and b . . . but erroneously encodes x[1] and x[2] must have same value! Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  18. Memory Invariants on Summary Locations x a b Conclusion To enforce memory invariants symbolically, we need a way to refer to individual elements in summary locations. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  19. Symbolic Heap Abstraction Use the symbolic heap from our previous work that allows distinguishing individual elements in a summary location. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  20. Symbolic Heap Abstraction Use the symbolic heap from our previous work that allows distinguishing individual elements in a summary location. This basic symbolic heap does not enforce memory invariants Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  21. Symbolic Heap Abstraction Use the symbolic heap from our previous work that allows distinguishing individual elements in a summary location. This basic symbolic heap does not enforce memory invariants Describe new technique to enforce memory invariants on the symbolic heap without explicit case splits Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  22. a b Symbolic Heap Abstract locations that represent more than one concrete location are qualified by index variables. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  23. Symbolic Heap a b Abstract locations that represent more than one concrete location are qualified by index variables. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  24. Symbolic Heap a b Abstract locations that represent more than one concrete location are qualified by index variables. Index variables allow us to refer to individual elements inside the abstract location Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  25. Symbolic Heap a b Bracketing constraints on points-to edges qualify which elements in the source location may and must point to which elements in the target location. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  26. Symbolic Heap a b Bracketing constraints on points-to edges qualify which elements in the source location may and must point to which elements in the target location. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  27. Symbolic Heap a b Bracketing constraints on points-to edges qualify which elements in the source location may and must point to which elements in the target location. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  28. Symbolic Heap a b This heap does not enforce memory invariants Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  29. Symbolic Heap a b This heap does not enforce memory invariants Uniqueness violated because conjunction of may conditions is not unsatisfiable. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  30. Symbolic Heap a b This heap does not enforce memory invariants Uniqueness violated because conjunction of may conditions is not unsatisfiable. Existence violated because disjunction of must conditions is not valid. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  31. Making the Symbolic Heap Relational Goal: Modify the basic symbolic heap such that: Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  32. Making the Symbolic Heap Relational Goal: Modify the basic symbolic heap such that: 1 Enforces the existence and uniqueness of memory contents Symbolically using constraints Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  33. Making the Symbolic Heap Relational Goal: Modify the basic symbolic heap such that: 1 Enforces the existence and uniqueness of memory contents Symbolically using constraints Replace original constraints with new constraints ∆ enforcing these invariants. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  34. Making the Symbolic Heap Relational Goal: Modify the basic symbolic heap such that: 1 Enforces the existence and uniqueness of memory contents Symbolically using constraints Replace original constraints with new constraints ∆ enforcing these invariants. 2 Preserves all the partial information encoded in the original symbolic heap Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  35. Making the Symbolic Heap Relational Goal: Modify the basic symbolic heap such that: 1 Enforces the existence and uniqueness of memory contents Symbolically using constraints Replace original constraints with new constraints ∆ enforcing these invariants. 2 Preserves all the partial information encoded in the original symbolic heap Restore existing information by adding quantified axioms relating ∆ to the original constraints Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  36. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  37. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  38. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . These ∆ i ’s are of the form Γ i ∧ Θ i Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  39. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . These ∆ i ’s are of the form Γ i ∧ Θ i Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  40. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . These ∆ i ’s are of the form Γ i ∧ Θ i Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  41. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . These ∆ i ’s are of the form Γ i ∧ Θ i Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  42. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . These ∆ i ’s are of the form Γ i ∧ Θ i Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  43. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . These ∆ i ’s are of the form Γ i ∧ Θ i Γ : Each concrete element → one abstract target Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  44. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . These ∆ i ’s are of the form Γ i ∧ Θ i Γ : Each concrete element → one abstract target Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  45. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . These ∆ i ’s are of the form Γ i ∧ Θ i Γ : Each concrete element → one abstract target Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  46. Enforcing Existence and Uniqueness on the Symbolic Heap Consider any location A for which invariants are violated. Replace constraint on i ’th edge from A with constraint ∆ i enforcing memory invariants on each concrete element in A . These ∆ i ’s are of the form Γ i ∧ Θ i Γ : Each concrete element → one abstract target Θ : In this abstract target, select one concrete element. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  47. Constructing Γ ’s Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  48. Constructing Γ ’s Want to ensure i ’th element of A points to exactly one B j . Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  49. Constructing Γ ’s Want to ensure i ’th element of A points to exactly one B j . Introduce an uninterpreted function δ ( i ) that selects an edge for the i ’th element. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  50. Constructing Γ ’s Want to ensure i ’th element of A points to exactly one B j . Introduce an uninterpreted function δ ( i ) that selects an edge for the i ’th element. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  51. Constructing Γ ’s Want to ensure i ’th element of A points to exactly one B j . Introduce an uninterpreted function δ ( i ) that selects an edge for the i ’th element. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  52. Constructing Γ ’s Want to ensure i ’th element of A points to exactly one B j . Introduce an uninterpreted function δ ( i ) that selects an edge for the i ’th element. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  53. Constructing Γ ’s Want to ensure i ’th element of A points to exactly one B j . Introduce an uninterpreted function δ ( i ) that selects an edge for the i ’th element. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  54. Constructing Γ ’s For any assignment v to i : Γ j ( v ) ∧ Γ m ( v ) is UNSAT. � j Γ j ( v ) is VALID. Want to ensure i ’th element of A points to exactly one B j . Introduce an uninterpreted function δ ( i ) that selects an edge for the i ’th element. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  55. Constructing Γ ’s For any assignment v to i : Γ j ( v ) ∧ Γ m ( v ) is UNSAT. � j Γ j ( v ) is VALID. Want to ensure i ’th element of A points to exactly one B j . Introduce an uninterpreted function δ ( i ) that selects an edge for the i ’th element. ⇒ Each concrete element in A has exactly one abstract target. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  56. Constructing Γ ’s For any assignment v to i : Γ j ( v ) ∧ Γ m ( v ) is UNSAT. � j Γ j ( v ) is VALID. Want to ensure i ’th element of A points to exactly one B j . Introduce an uninterpreted function δ ( i ) that selects an edge for the i ’th element. ⇒ Each concrete element in A has exactly one abstract target. Correctly allows different indices to point to same target. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  57. Example a b Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  58. Example a b Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  59. Example a b Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  60. Example a b We can now prove the assertion! Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  61. Example a b We can now prove the assertion! Because x[k] and y[k] point to different locations under δ ( k ) ≤ 0 ∧ δ ( k ) ≥ 1 ⇒ UNSAT Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  62. Why do we need Θ ? Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  63. Why do we need Θ ? Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  64. Why do we need Θ ? Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  65. Why do we need Θ ? Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  66. Why do we need Θ ? Encodes x[i] cannot point to a and b at the same time. Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  67. Why do we need Θ ? Encodes x[i] cannot point to a and b at the same time. But x[i] can still point to two different elements in a Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  68. Constructing Θ Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  69. Constructing Θ Want the heap abstraction to encode that i ’th element of A must point to exactly one element in B . Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  70. Constructing Θ Want the heap abstraction to encode that i ’th element of A must point to exactly one element in B . Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  71. Constructing Θ Want the heap abstraction to encode that i ’th element of A must point to exactly one element in B . Since τ is a function, each element in A is mapped to exactly one element in B . Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

  72. Constructing Θ Want the heap abstraction to encode that i ’th element of A must point to exactly one element in B . Since τ is a function, each element in A is mapped to exactly one element in B . Since τ is uninterpreted, each element in A is mapped to an unknown element in B . Isil Dillig Thomas Dillig Alex Aiken Symbolic Heap Abstraction with Demand-Driven Axiomatization

Recommend


More recommend