Fast Polyhedra Abstract Domain Gagandeep Singh Markus Püschel Martin Vechev Department of Computer Science ETH Zurich
Polyhedra Domain Analysis Automatic Discovery of Linear Restraints Among Variables of a Program, POPL ’ 78
Polyhedra Domain Analysis Automatic Discovery of Linear Restraints Among Variables of a Program, POPL ’ 78 Introduced by Patrick Cousot and Nicolas Halbwachs Represents linear constraints between program variables Patrick Cousot Nicolas Halbwachs
Polyhedra Domain Analysis Automatic Discovery of Linear Restraints Among Variables of a Program, POPL ’ 78 Introduced by Patrick Cousot and Nicolas Halbwachs Represents linear constraints between program variables Patrick Cousot Nicolas Halbwachs y ≤ 3 -x ≤ 2
Polyhedra Domain Analysis
Polyhedra Domain Analysis if(*){ y:=2x-1; } else{ y:=2x-2; } assert(y<=2x);
Polyhedra Domain Analysis if(*){ Abstract Can Prove the Domain Assertion? y:=2x-1; Interval } ❌ Pentagon else{ ❌ y:=2x-2; Zones ❌ } Octagon ❌ Polyhedra assert(y<=2x); ✅
Polyhedra Domain Analysis if(*){ Abstract Can Prove the Domain Assertion? y:=2x-1; Interval } ❌ Pentagon else{ ❌ y:=2x-2; Zones ❌ } Octagon ❌ Polyhedra assert(y<=2x); ✅ Polyhedra analysis: time and space exponential in number of variables
This work: contributions
This work: contributions Online decomposition: reduction in space and time without losing precision
This work: contributions Online decomposition: Constant factor improvements reduction in space and time via reduced operation count and without losing precision cache optimizations
This work: contributions Online decomposition: Constant factor improvements reduction in space and time via reduced operation count and without losing precision cache optimizations elina.ethz.ch Complete end-to-end implementation
This work: contributions Online decomposition: Constant factor improvements reduction in space and time via reduced operation count and without losing precision cache optimizations Driver NewPolka PPL ELINA elina.ethz.ch 500 var OOM OOM 4 sec Complete end-to-end 39K LOC (> 12 GB) (> 12 GB) 0.9 GB implementation 650 var TO TO 2 sec 25K LOC (> 4 hr) (> 4 hr) 0.4 GB
Double Representation of Polyhedron
Double Representation of Polyhedron Constraints( ⊔ ) easy with the Generators x 2 x 2 = 2 x 1 𝒟 = {-x 2 ≤ -2, x 2 ≤ 2x 1 } m: number of constraints
Double Representation of Polyhedron Generators ( ⊔ ) easy Constraints( ⊔ ) easy with the Generators with the Generators x 2 x 2 (1,2) (1,0) x 2 = 2 x 1 x 1 𝒟 = {-x 2 ≤ -2, x 2 ≤ 2x 1 } Vertices 𝒲 = {(1,2)}, m: number of constraints Rays ℛ = {(1,2), (1,0)}, Lines 𝒶 = ∅ g: number of generators
Asymptotic Time Complexity of Polyhedra
Asymptotic Time Complexity of Polyhedra Operator Constraints Generators Both Join ( ⊔ ) exp(n,m) Ο(𝑜) Ο(𝑜) Meet ( ⊓ ) exp(n,g) Ο(𝑜𝑛) Ο(𝑜𝑛) Inclusion ( ⊑ ) exp(n,m) exp(n,g) Ο(𝑜𝑛) Assignment Ο(𝑜𝑛 2 ) Ο(𝑜) Ο(𝑜) Conditional exp(n,g) Ο(𝑜) Ο(𝑜)
Asymptotic Time Complexity of Polyhedra Operator Constraints Generators Both Join ( ⊔ ) exp(n,m) Ο(𝑜) Ο(𝑜) Meet ( ⊓ ) exp(n,g) Ο(𝑜𝑛) Ο(𝑜𝑛) Inclusion ( ⊑ ) exp(n,m) exp(n,g) Ο(𝑜𝑛) Assignment Ο(𝑜𝑛 2 ) Ο(𝑜) Ο(𝑜) Conditional exp(n,g) Ο(𝑜) Ο(𝑜) exp(n,m) Constraints Generators exp(n,g)
Key Idea: Online Decomposition
Key Idea: Online Decomposition Polyhedron { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 , 𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟔 = 𝟐 , 𝒚 𝟕 = 𝟑 }
Key Idea: Online Decomposition Set of factors Polyhedron { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , 𝒚 𝟑 = 𝟑, { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 } 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 , {𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟔 = 𝟐 } 𝒚 𝟔 = 𝟐 , 𝒚 𝟕 = 𝟑 } {𝒚 𝟕 = 𝟑 }
Key Idea: Online Decomposition Partition ( 𝜌 ) = set of blocks Set of factors Polyhedron { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } 𝒚 𝟑 = 𝟑, { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 } 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 , {𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , { 𝒚 𝟓 , 𝒚 𝟔 } 𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟔 = 𝟐 } 𝒚 𝟔 = 𝟐 , 𝒚 𝟕 = 𝟑 } {𝒚 𝟕 = 𝟑 } { 𝒚 𝟕 }
Key Idea: Online Decomposition Partition ( 𝜌 ) = set of blocks Set of factors Polyhedron { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } 𝒚 𝟑 = 𝟑, { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 } 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 , {𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , { 𝒚 𝟓 , 𝒚 𝟔 } 𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟔 = 𝟐 } 𝒚 𝟔 = 𝟐 , 𝒚 𝟕 = 𝟑 } {𝒚 𝟕 = 𝟑 } { 𝒚 𝟕 } working on smaller Polyhedra enables reduction in space and time
Permissible Partitions
Permissible Partitions Polyhedron { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 , 𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟔 = 𝟐 , 𝒚 𝟕 = 𝟑 }
Permissible Partitions Best (finest) Polyhedron partition ( 𝜌 ) { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 , { 𝒚 𝟓 , 𝒚 𝟔 } 𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟔 = 𝟐 , 𝒚 𝟕 = 𝟑 } { 𝒚 𝟕 }
Permissible Partitions Best (finest) Permissible Polyhedron partition ( 𝜌 ) partition ( 𝜌 ) { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 , { 𝒚 𝟓 , 𝒚 𝟔 } { 𝒚 𝟓 , 𝒚 𝟔 , 𝒚 𝟕 } 𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟔 = 𝟐 , 𝒚 𝟕 = 𝟑 } { 𝒚 𝟕 }
Permissible Partitions Best (finest) Invalid Permissible Polyhedron partition ( 𝜌 ) partition partition ( 𝜌 ) { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } { 𝒚 𝟐 , 𝒚 𝟑 } { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 , { 𝒚 𝟒 , 𝒚 𝟓 , 𝒚 𝟔 } { 𝒚 𝟓 , 𝒚 𝟔 } { 𝒚 𝟓 , 𝒚 𝟔 , 𝒚 𝟕 } 𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟔 = 𝟐 , { 𝒚 𝟕 } 𝒚 𝟕 = 𝟑 } { 𝒚 𝟕 }
Permissible Partitions Best (finest) Invalid Permissible Polyhedron partition ( 𝜌 ) partition partition ( 𝜌 ) { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } { 𝒚 𝟐 , 𝒚 𝟑 } { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 , { 𝒚 𝟒 , 𝒚 𝟓 , 𝒚 𝟔 } { 𝒚 𝟓 , 𝒚 𝟔 } { 𝒚 𝟓 , 𝒚 𝟔 , 𝒚 𝟕 } 𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , 𝒚 𝟔 = 𝟐 , { 𝒚 𝟕 } 𝒚 𝟕 = 𝟑 } { 𝒚 𝟕 } Definition: A partition 𝜌 is permissible for Polyhedron P, if there are no two variables 𝒚 𝒋 and 𝒚 𝒌 in different blocks of 𝜌 related by a constraint in P
Partition of Variable Set: Summary
Partition of Variable Set: Summary The set of all partitions of variable set 𝒴 form a lattice ordered by “ finer than ” ( < ) relation The best (finest) partition 𝜌 𝑄 for Polyhedron P is unique Any 𝜌, s.t., 𝜌 𝑄 < 𝜌 , is permissible An unconstrained variable 𝑦 𝑗 yields a singleton set { 𝑦 𝑗 } in the partition
Partition of Variable Set: Summary The set of all partitions of variable set 𝒴 form a lattice ordered by “ finer than ” ( < ) relation The best (finest) partition 𝜌 𝑄 for Polyhedron P is unique Any 𝜌, s.t., 𝜌 𝑄 < 𝜌 , is permissible An unconstrained variable 𝑦 𝑗 yields a singleton set { 𝑦 𝑗 } in the partition Challenge: maintain permissible partitions for > 30 operators
Operator: Conditional
Operator: Conditional Definition: Let 𝜌 be a partition and ℬ be a block, then 𝜌 ↑ ℬ is the finest partition 𝜌 ’ such that 𝜌 ⊑ 𝜌 ’ and ℬ is a subset of an element of 𝜌 ’ Theorem (finest partition after conditional) : If O ≠⊥ and let ℬ be block containing all variables appearing in the conditional, then 𝜌 𝑃 = 𝜌 𝑄 ↑ ℬ
Operator: Conditional Definition: Let 𝜌 be a partition and ℬ be a block, then 𝜌 ↑ ℬ is the finest partition 𝜌 ’ such that 𝜌 ⊑ 𝜌 ’ and ℬ is a subset of an element of 𝜌 ’ P 𝜌 𝑄 { 𝒚 𝟐 ≤ 𝟑𝒚 𝟑 , { 𝒚 𝟐 , 𝒚 𝟑 , 𝒚 𝟒 } 𝒚 𝟑 = 𝟑, 𝒚 𝟐 + 𝒚 𝟑 + 𝟑𝒚 𝟒 ≤ 𝟔 } {𝒚 𝟓 - 𝒚 𝟔 ≤ 𝟒 , { 𝒚 𝟓 , 𝒚 𝟔 } 𝒚 𝟔 = 𝟐 } {𝒚 𝟕 = 𝟑 } { 𝒚 𝟕 } Theorem (finest partition after conditional) : If O ≠⊥ and let ℬ be block containing all variables appearing in the conditional, then 𝜌 𝑃 = 𝜌 𝑄 ↑ ℬ
Recommend
More recommend