SLIDE 1 A posteriori soundness for nondeterministic abstract interpretations
Matthew Might (University of Utah) Panagiotis Manolios (Northeastern University)
SLIDE 2
Questions you don’t want at your defense
SLIDE 3 Questions you don’t want at your defense
- “But, why did you prove it that way?”
SLIDE 4 Questions you don’t want at your defense
- “But, why did you prove it that way?”
- “But, why is that necessary?”
SLIDE 5 Questions you don’t want at your defense
- “But, why did you prove it that way?”
- “But, why is that necessary?”
- “So, why did the Cousots do it that way?”
SLIDE 6
- Where did it come from?
- How do you prove it sound?
- Why would you want to use it?
Nondeterministic Abstract Interpretation
SLIDE 7
- Where did it come from?
- How do you prove it sound?
- Why would you want to use it?
Nondeterministic Abstract Interpretation
- Frustration with the standard recipe.
SLIDE 8
- Where did it come from?
- How do you prove it sound?
- Why would you want to use it?
Nondeterministic Abstract Interpretation
- Frustration with the standard recipe.
- A posteriori proof technique.
SLIDE 9
- Where did it come from?
- How do you prove it sound?
- Why would you want to use it?
Nondeterministic Abstract Interpretation
- Frustration with the standard recipe.
- A posteriori proof technique.
- Better speed, better precision.
SLIDE 10 Outline
- Review standard recipe.
- Find annoyances.
- Get rid of them.
SLIDE 11
Define abstraction map: α : L → ˆ L Prove simulates under . α f ˆ f
The Standard Recipe
Define concrete state-space: L Define abstract state-space: ˆ L Define concrete semantics: f : L → L Define abstract semantics: ˆ f : ˆ L → ˆ L
SLIDE 12
Define abstraction map: α : L → ˆ L
The A Posteriori Recipe
Prove simulates under . α f ˆ f Execute abstract semantics to obtain . ˆ ℓ′ = ˆ f(ˆ ℓ) Define concrete state-space: L Define abstract state-space: ˆ L Define concrete semantics: f : L → L Define abstract semantics: ˆ f : ˆ L → ˆ L
SLIDE 13
Define abstraction map: α : L → ˆ L
The A Posteriori Recipe
Prove simulates under . α f ˆ ℓ′ Execute abstract semantics to obtain . ˆ ℓ′ = ˆ f(ˆ ℓ) Define concrete state-space: L Define abstract state-space: ˆ L Define concrete semantics: f : L → L Define abstract semantics: ˆ f : ˆ L → ˆ L
SLIDE 14 ˆ f : ˆ L → 2
ˆ L
Define abstract semantics: Define abstraction map: α : L → ˆ L
The A Posteriori Recipe
Prove simulates under . α f ˆ ℓ′ Execute abstract semantics to obtain . ˆ ℓ′ = ˆ f(ˆ ℓ) Define concrete state-space: L Define abstract state-space: ˆ L Define concrete semantics: f : L → L
SLIDE 15
Illustrating the Standard Recipe
SLIDE 16
Malloc: The Language
v := malloc()
SLIDE 17
Malloc: The Language
v := malloc() lab :
SLIDE 18 Concrete Semantics
State = Instruction × Store
SLIDE 19 Concrete Semantics
State = Instruction × Store f(ς) = ς′
SLIDE 20 Concrete Semantics
Fresh State = Instruction × Store f([ [v := malloc()] ] : i, σ) = (
SLIDE 21 Concrete Semantics
Fresh State = Instruction × Store a′ = alloc(ς) f([ [v := malloc()] ] : i, σ) = (
SLIDE 22 Concrete Semantics
Fresh State = Instruction × Store a′ = alloc(ς) = max(range(σ)) + 1 f([ [v := malloc()] ] : i, σ) = (
SLIDE 23 ˆ a = alloc(ˆ ς)
Abstract Semantics
Store ˆ f([ [v := malloc()] ] : i, ˆ σ) = (
σ[v → ˆ a]) (from some finite set)
SLIDE 24 What to allocate?
- Abstract addresses = Scarce resource
- Avoid over-allocation: Good for speed
- Avoid under-allocation: Good for precision
SLIDE 25
Example: Over-allocation
3 ˆ a1 ˆ a2
SLIDE 26
Example: Over-allocation
3 ˆ a1,2
SLIDE 27
Example: Under-allocation
3 4 ˆ a′
SLIDE 28 ˆ a1 ˆ a2
Example: Under-allocation
3 4
SLIDE 29
Allocation heuristics
Observation: Objects from like contexts act alike.
SLIDE 30 Allocation heuristics
Example:
[lab : . . .] ] : i, ) = lab Observation: Objects from like contexts act alike.
SLIDE 31 Annoyance: Soundness
α(ς) ⊑ ˆ ς α(f(ς)) ⊑ ˆ f(ˆ ς) If then
SLIDE 32 Annoyance: Soundness
α(ς) ⊑ ˆ ς If then αAddr(alloc(ς)) ⊑ alloc(ˆ ς)
SLIDE 33 The Issue
[lab : . . .] ] : i, ) = lab What abstraction map will work here? alloc( , σ) = max(range(σ)) + 1
SLIDE 34
Example
B : y := malloc() A : x := malloc() [x → , y → ] [ →A, → B] 1 2 1 2 αAddr = σ =
SLIDE 35
Example
B : y := malloc() A : x := malloc() [x → , y → ] [ →A, → B] 1 2 1 2 αAddr = σ =
SLIDE 36
Example
B : y := malloc() A : x := malloc() [x → , y → ] [ →A, → B] 1 2 1 2 αAddr = σ =
SLIDE 37
Example
B : y := malloc() A : x := malloc() [x → , y → ] [ →A, → B] 1 2 1 2 αAddr = σ =
SLIDE 38
Change the concrete semantics!
Standard Solution
SLIDE 39 Change the concrete semantics!
Standard Solution
alloc( , σ) = max(range(σ)) + 1 Addr = N
SLIDE 40 Change the concrete semantics! Addr = N × Lab
Standard Solution
alloc([ [lab : . . .] ], σ) = (max(range(σ)1) + 1, lab)
SLIDE 41 Change the concrete semantics! Addr = N × Lab
Standard Solution
alloc([ [lab : . . .] ], σ) = (max(range(σ)1) + 1, lab) α( , lab) = lab
SLIDE 42
Another problem: Heuristics sometimes make stupid decisions
SLIDE 43
Another problem: Heuristics sometimes make stupid decisions Why not adapt on the fly?
SLIDE 44
Example: Greedy Strategy
3 ˆ a1 Heuristic says, “Allocate , and bind 4.” ˆ a1
SLIDE 45
Example: Greedy Strategy
3 4 ˆ a1 Heuristic says, “Allocate , and bind 4.” ˆ a1
SLIDE 46
Example: Greedy Strategy
3 4 ˆ a1 Adaptive allocator says, “Try first.” r(ˆ a1) Heuristic says, “Allocate , and bind 4.” ˆ a1
SLIDE 47
Example: Greedy Strategy
3 4 ˆ a1 r(ˆ a1) Adaptive allocator says, “Try first.” r(ˆ a1) Heuristic says, “Allocate , and bind 4.” ˆ a1
SLIDE 48
Example: Greedy Strategy
3 ˆ a1 Heuristic says, “Allocate , and bind 3.” ˆ a2
SLIDE 49
Example: Greedy Strategy
3 ˆ a1 ˆ a2 Heuristic says, “Allocate , and bind 3.” ˆ a2
SLIDE 50
Example: Greedy Strategy
3 ˆ a1 ˆ a2 Adaptive allocator says, “Just use .” ˆ a1 Heuristic says, “Allocate , and bind 3.” ˆ a2
SLIDE 51
Example: Greedy Strategy
3 ˆ a1 Adaptive allocator says, “Just use .” ˆ a1 Heuristic says, “Allocate , and bind 3.” ˆ a2
SLIDE 52
Dynamic Optimization
Given m abstract addresses, how should they be allocated to maximize precision?
SLIDE 53
So, why not?
Can’t within confines of standard recipe. (Counter-example in paper.)
SLIDE 54
Making it so
SLIDE 55
- Factor allocation out of semantics.
- Make allocation nondeterministic.
- Prove nondeterministic allocation sound.
Making it so
SLIDE 56
Locative = Address
(But also times, bindings, contours, etc.)
SLIDE 57
Factoring out allocation
SLIDE 58 ς
f : State → State
SLIDE 59 ς ς′
f : State → State
SLIDE 60 ς
f : State → State
SLIDE 61 ς
F : State → Loc → State
SLIDE 62 ς
F : State → Loc → State
SLIDE 63 ς ς′ ℓ
F : State → Loc → State
SLIDE 64 ˆ ς
ˆ f : State → 2
SLIDE 65 ˆ ς ˆ ς′ ˆ ς′′ ˆ ς′′′
ˆ f : State → 2
SLIDE 66 ˆ ς
ˆ f : State → 2
SLIDE 67 ˆ ς
ˆ F : State → 2
d Loc→ State
SLIDE 68 ˆ ς
ˆ F : State → 2
d Loc→ State
SLIDE 69 ˆ ς ˆ ς′ ˆ ς′′ ˆ ς′′′
ˆ F : State → 2
d Loc→ State
ˆ ℓ′ ˆ ℓ′′′ ˆ ℓ′′
SLIDE 70
Nondeterministic Abstract Interpretation
SLIDE 71
- Sealed abstract transition graphs.
- Factored abstraction maps.
- A posteriori soundness condition.
Nondeterministic Abstract Interpretation
SLIDE 72 Transition Graphs
- Nodes = States
- Edge = Transition labeled by chosen locative
SLIDE 73
Sealed Graphs
Graph is sealed under factored semantics iff every state has an edge to cover every transition.
SLIDE 74
Example: Unsealed Graph
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 73 28 74 29 30 31 32 33 34 35 36 38 37 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 63 59 64 60 61 62 65 66 67 68 69 70 71 72 75 76 77 78 79 80 81 82
SLIDE 75
Example: Unsealed Graph
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 73 28 74 29 30 31 32 33 34 35 36 38 37 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 63 59 64 60 61 62 65 66 67 68 69 70 71 72 75 76 77 78 79 80 81 82
SLIDE 77 ˆ ℓ1 ˆ ℓ2 ˆ h1(ˆ ℓ1) ˆ h2(ˆ ℓ2) ˆ F(ˆ ς) = {ˆ h1, ˆ h2, ˆ h3} ˆ ς
SLIDE 78 ˆ ℓ1 ˆ ℓ2 ˆ h1(ˆ ℓ1) ˆ h2(ˆ ℓ2)
?
ˆ F(ˆ ς) = {ˆ h1, ˆ h2, ˆ h3} ˆ ς
SLIDE 79
Proving Sealed Graphs Sound
SLIDE 80 Factoring Abstraction
α : State → State
SLIDE 81 Factoring Abstraction
α : State → State β : (Loc → Loc) → (State → State)
SLIDE 82
Dependent Simulation
SLIDE 83 Dependent Simulation
ς
SLIDE 84 Dependent Simulation
ς ς′ ℓ
SLIDE 85 Dependent Simulation
ς ˆ ς′ ς′ ℓ β(αLoc[ℓ → ˆ ℓ])
SLIDE 86 Dependent Simulation
ς ˆ ς ˆ ς′ ς′ ℓ ˆ ℓ β(αLoc) β(αLoc[ℓ → ˆ ℓ])
SLIDE 87
A Posteriori Theorem
Dependent simulation → Abstraction always exists
SLIDE 88 Proof Highlights
- Reduces to existence of locative abstractor.
- Construct abstractor as limit of sequence:
αLoc = lim
i→N αi Loc
SLIDE 89 More in the paper
- Nondeterministic CFA: ∃CFA.
- More on greedy adaptive allocation.
- Discussion of global precision sensitivity.
SLIDE 90 Ongoing Work
- Empirical trials: 1.5x - 3x space, time savings
- Genetic algorithms
- Probabilistic allocation
SLIDE 91 So...
- Stop changing concrete semantics.
- Look beyond context for allocation.
- Don’t allocate context if bad for precision.
SLIDE 92
Thanks, y’all