exploiting synchrony and symmetry in relational
play

Exploiting Synchrony and Symmetry in Relational Verification - PowerPoint PPT Presentation

Exploiting Synchrony and Symmetry in Relational Verification Lauren Pick 1 Relational Verification 2 Relational Verification Given: k ( k >1) programs (renamed so that they have independent sets of variables) a relational


  1. Exploiting Synchrony and Symmetry in Relational Verification Lauren Pick 1

  2. Relational Verification 2

  3. Relational Verification Given: • k ( k >1) programs (renamed so that they have independent sets of variables) • a relational specification (relating the variables) over the k programs Prove that the relational specification holds for the programs 3

  4. Example: Equivalence Checking Given programs P 1 , P 2 , that respectively have inputs x1 , x2 and outputs y1 , y2 , prove x1 = x2 ⇒ y1 = y2 . Note: bold-faced variables are vectors = x 1 x 2 P 1 P 2 y 1 y 2 =? 4

  5. Hyperproperty Verification • A hyperproperty is a relational property over k copies of the same program • The hyperproperty verification problem is the relational verification problem where all k programs are copies of the same program. • E.g. noninterference, monotonicity, transitivity 5

  6. Example: Noninterference Security property for programs where variables have security types {low, high} Given two copies of the same program P 1 , P 2 , that respectively have inputs ( lx1 : low, hx1 : high ), ( lx2 : low, hx2 : high ) and outputs ( ly1 : low, hy1 : high ), ( ly2 : low, hy2 : high ), prove lx1 = lx2 ⇒ ly1 = ly2 . = hx 1 hx 2 lx 1 lx 2 P 1 P 2 hy 1 ly 1 ly 2 hy 2 =? 6

  7. Example: Monotonicity Given two copies of the same program P 1 , P 2 , that respectively have inputs x1 , x2 , and outputs y1 , y2 , prove x1 ≤ x2 ⇒ y1 ≤ y2 . ≤ x 1 x 2 P 1 P 2 y 1 y 2 ≤ ? 7

  8. Composition Sequential: { pre } P 1 ; … ; P k { post } pre • Pros: Can easily apply P 1 standard verification P 2 techniques … • Cons: Inflexible, can result in P k more difficult verification post problems [Barthe et al., 2004] 8 [Terauchi and Aiken, 2005]

  9. Composition Parallel: { pre } P 1 || … || P k { post } • Pros: Flexibility can let us pre pick easier verification … P 1 P 2 P k subproblems post • Cons: Need to come up with new techniques [Barthe et al., 2004] 9 [Terauchi and Aiken, 2005]

  10. Synchrony and Symmetry Two new techniques: Synchrony, Symmetry Let’s consider the challenges that motivate them…. 10

  11. Challenge 1: Loops 11

  12. Challenge 1: Loops { x1 < x2 ∧ i1 = i2 ∧ x1 > 0 ∧ i1 > 0 } L1 while (i1 < 10) { x1 *= i1; i1++; } ; L2 while (i2 < 10) { x2 *= i2; i2++; } { x1 < x2 ∧ i1 = i2 ∧ x1 > 0 ∧ i1 > 0 } Nonlinear Invariants: L1: x1 = x1 init × i1! / i1 init ∧ … L2: x2 = x2 init × i2! / i2 init ∧ … 12

  13. Challenge 1: Loops { x1 < x2 ∧ i1 = i2 ∧ x1 > 0 ∧ i1 > 0 } while (i1 < 10) { x1 *= i1; i1++; } || while (i2 < 10) { x2 *= i2; i2++; } { x1 < x2 ∧ i1 = i2 ∧ x1 > 0 ∧ i1 > 0 } Consider the loops in parallel instead. 13

  14. Challenge 1: Loops { x1 < x2 ∧ i1 = i2 ∧ x1 > 0 ∧ i1 > 0 } while (i1 < 10 && i2 < 10) { lockstep x1 *= i1; i1++; x2 *= i2; i2++; execution } { x1 < x2 ∧ i1 = i2 ∧ x1 > 0 ∧ i1 > 0 } (One) Relational Invariant: x1 < x2 ∧ i1 = i2 ∧ x1 > 0 ∧ i1 > 0 [Barthe et al., 2011] 14

  15. Relational Verification pre say that P 1,1 P 2,1 P k,1 s … P 2,2 P k,2 P 1,2 are structurally similar P 1,3 P 2,3 P k,3 post • Relating (i.e. synchronizing ) intermediate points in programs to get intermediate relational specifications can result in easier verification problems • In particular, synchronizing structurally similar parts of the different programs can yield simpler relational specifications [Barthe et al., 2011] [Sousa and Dillig, 2016] [De Angelis et al., 2016] 15 and more

  16. Lockstep Loops Loops that iterate the same number of times are able to be executed in lockstep [Barthe et al., 2011] 16 [Sousa and Dillig, 2016]

  17. Challenge 1: Loops y iterations x iterations y iterations x iterations y iterations Handling each loop individually can require the … L 3 generation of potentially L 1 L 2 L k-1 L k complicated loop invariants. I 3 I k-1 I k I 1 I 2 x iterations y iterations How can we maximize the number of loops over … … which we can compute L 1 L 3 L 2 L k-1 L k simpler relational invariants? I 2,…,k-1,k I 1,3,… 17

  18. Synchrony Partition a set of loops into maximal sets of loops that can be executed in lockstep 18

  19. Synchrony We assume we are given a relational invariant I . Note: You can use any of several existing techniques for invariant generation. The implementation (described later) uses a guess-and-check invariant generator. … L 1 L 2 L k c k c 1 c 2 I I L 2 … L 1 L k 19

  20. Synchrony When can we execute a set of loops in lockstep? … L 1 L 2 L k c k c 1 c 2 If any loop has terminated, all loops must have terminated. I ∧ (¬ c 1 ∨ ¬ c 2 ∨ … ∨ ¬ c k ) ⇒ (¬ c 1 ∧ ¬ c 2 ∧ … ∧ ¬ c k ) (check) 20 [Sousa and Dillig, 2016]

  21. Maximal Lockstep Loop Detection (check) ¬( I ∧ (¬ c 1 ∨ ¬ c 2 ∨ … ∨ ¬ c k ) ⇒ (¬ c 1 ∧ ¬ c 2 ∧ … ∧ ¬ c k )) • If unsatisfiable, all loops can be executed in lockstep. (Done!) • If satisfiable, then what? • Use model to partition the set of loops into (partition) those that have terminated (¬ c i holds in the model) and those that have not ( c i holds in the model) (recurse) • Recurse on the two sets…. 21

  22. Maximal Lockstep Loop Example y iterations x iterations z iterations y iterations x iterations L 3 L 1 L 2 L 4 L 5 c 1 c 2 c 3 c 4 c 5 ¬( I ∧ (¬ c 1 ∨ ¬ c 2 ∨ … ∨ ¬ c 5 ) ⇒ (¬ c 1 ∧ ¬ c 2 ∧ … ∧ ¬ c 5 )) (check) SAT: c 1 , c 2 , c 3 , ¬ c 4 , and c 5 hold in model x iterations y iterations x iterations y iterations z iterations L 3 L 4 L 1 L 2 L 5 (partition) c 4 c 1 c 2 c 3 c 5 22

  23. Maximal Lockstep Loop Example y iterations x iterations y iterations x iterations (recurse) L 1 L 2 L 3 L 5 c 1 c 2 c 3 c 5 ¬( I ∧ (¬ c 1 ∨ ¬ c 2 ∨ ¬ c 3 ∨ ¬ c 5 ) ⇒ (¬ c 1 ∧ ¬ c 2 ∧ ¬ c 3 ∧ ¬ c 5 )) (check) SAT: c 1 , ¬ c 2 , c 3 , ¬ c 5 hold in model z iterations x iterations y iterations y iterations x iterations L 2 L 4 L 5 L 1 L 3 (partition) c 4 c 1 c 3 c 2 c 5 Done! 23

  24. Summary: Maximal Lockstep Loop Detection Step 1. Check if current set can be executed in lockstep Step 2. Partition according to model (if necessary) Step 3. Recurse 24

  25. Challenge 2: Redundancy 25

  26. Challenge 2: Redundancy { x1 ≠ x2 } if (x1 > y1) then P1 else Q1 || if (x2 > y2) then P2 else Q2 { x1 ≠ x2 } 26

  27. RVP - Relational Verification Problem Challenge 2: Redundancy { x1 ≠ x2 } if (x1 > y1) then P1 else Q1 || if (x2 > y2) then P2 else Q2 { x1 ≠ x2 } { x1 ≠ x2 ∧ { x1 ≠ x2 ∧ { x1 ≠ x2 ∧ { x1 ≠ x2 ∧ x1 > y1 ∧ x1 ≤ y1 ∧ x1 > y1 ∧ x1 ≤ y1 ∧ x2 > y2} x2 > y2} x2 ≤ y2} x2 ≤ y2} P1 || P2 Q1 || P2 P1 || Q2 Q1 || Q2 { x1 ≠ x2 } { x1 ≠ x2 } { x1 ≠ x2 } { x1 ≠ x2 } RVP1 RVP2 RVP3 RVP4 27

  28. Challenge 2: Redundancy pre Maybe for the given relational specification, … P 1,1 P k,1 … … and P 1,2 P k,3 P 1,3 P k,2 P 1,2 P 1,3 P k,2 P k,3 are symmetric over indices. post How can we identify and use symmetries in programs and in relational specifications to avoid solving redundant verification problems? 28

  29. Symmetric Relational Verification Problems (RVPs) If you permute indices, you get the same problem. { x1 ≠ x2 } { x2 ≠ x1 } if (x1 > y1) then P1 else Q1 if (x2 > y2) then P2 else Q2 {1 ↦ 2, 2 ↦ 1} || || if (x2 > y2) then P2 else Q2 if (x1 > y1) then P1 else Q1 { x1 ≠ x2 } { x2 ≠ x1 } Need a permutation π of indices that is a symmetry of the formulas (pre- and postconditions) and of the programs (can e.g. check if at same program point for hyperproperties) 29

  30. Leveraging Symmetry to Reduce Redundancies • Find symmetries in formulas (permutation π ) • Find symmetric RVPs (make sure programs are symmetric, i.e. π is a symmetry of the programs also) • Prune (via symmetry-breaking, lifted from SAT) 30

  31. Leveraging Symmetry to Reduce Redundancies • Find symmetries in formulas (permutation π ) • Find symmetric RVPs (make sure programs are symmetric, i.e. π is a symmetry of the programs also) • Prune (via symmetry-breaking, lifted from SAT) 31

  32. Finding Symmetries of a Formula • Prior work for SAT formulas: based on finding automorphisms of a colored graph • Our work: Lift SAT techniques to first-order theories (with equality, linear integer arithmetic) [Aloul et al., 2006] 32 [Crawford et al., 2005]

  33. Example: Finding Symmetries of a Formula Step 1. Canonicalize 𝜚 = x 1 ≤ x 2 ∧ x 3 ≤ x 4 to CNF 𝜚 ’ = (( x 1 < x 2 ) ∨ ( x 1 = x 2 )) ∧ (( x 3 < x 4 ) ∨ ( x 3 = x 4 )) [Aloul et al., 2006] 33 [Crawford et al., 2005]

  34. Example: Finding Symmetries of a Formula Step 2. Create colored graph from AST 𝜚 ’ = (( x 1 < x 2 ) ∨ ( x 1 = x 2 )) ∧ (( x 3 < x 4 ) ∨ ( x 3 = x 4 )) 34

  35. Example: Finding Symmetries of a Formula Step 2. Create colored graph from ASTs Clauses: {( x 1 < x 2 ) ∨ ( x 1 = x 2 ), ( x 3 < x 4 ) ∨ ( x 3 = x 4 )} A T S S A T ∨ ∨ < = < = x 1 x 2 x 3 x 4 ( x 1 , L ) ( x 2 , R ) ( x 3 , L ) ( x 4 , R ) 35

  36. Example: Finding Symmetries of a Formula Step 2. Create graph from ASTs ∨ ∨ < = < = x 1 x 2 x 3 x 4 ( x 2 , R ) ( x 1 , L ) ( x 4 , R ) ( x 3 , L ) Id Id Id Id 1 2 3 4 36

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