generic and complete techniques for straight line string
play

Generic and Complete Techniques for Straight- Line String - PowerPoint PPT Presentation

Generic and Complete Techniques for Straight- Line String Constraints T aolue Chen (Birkbeck) Matthew Hague (Royal Holloway) Anthony W. Lin (Kaiserslautern) Philipp Ruemmer (Uppsala) Zhilin Wu (Chinese Academy of Science) 1 / 51 Abstract


  1. Generic and Complete Techniques for Straight- Line String Constraints T aolue Chen (Birkbeck) Matthew Hague (Royal Holloway) Anthony W. Lin (Kaiserslautern) Philipp Ruemmer (Uppsala) Zhilin Wu (Chinese Academy of Science) 1 / 51

  2. Abstract ● New techniques for string constraint solving – Straight-line fragment – String operations/assertions not fjxed – T wo semantic-conditions (regularity) – Proof of decidability ● Implementation – OSTRICH solver – Competitive, expressive, and complete 2 / 51

  3. String Programs S ::= x := f(x1, …, xn) | assert g(x1, …, xn) | S1; S2 ● f is a function from strings to strings ● g is a function from strings to boolean ● ; is sequential composition 3 / 51

  4. Example assert x in a*b*; assert y in b*; z := concat(x, y) ; assert z in a*b*; 4 / 51

  5. Example assert in(x, a*b*) assert in(x, a*b*) assert x in a*b*; assert y in b*; z := concat(x, y) ; assert z in a*b*; 5 / 51

  6. Example assert in(x, a*b*) assert in(x, a*b*) assert x in a*b*; assert y in b*; z := concat(x, y) ; Solution assert z in a*b*; 6 / 51

  7. Example assert in(x, a*b*) assert in(x, a*b*) assert x in a*b*; assert y in b*; z := concat(x, y) ; Solution assert z in a*b*; ● x = aa 7 / 51

  8. Example assert in(x, a*b*) assert in(x, a*b*) assert x in a*b*; assert y in b*; z := concat(x, y) ; Solution assert z in a*b*; ● x = aa ● y = bb 8 / 51

  9. Example assert in(x, a*b*) assert in(x, a*b*) assert x in a*b*; assert y in b*; z := concat(x, y) ; Solution assert z in a*b*; ● x = aa ● y = bb ● (z = aabb) 9 / 51

  10. Straight-Line Fragment ● Similar to single-static assignment form – Each variable only assigned once – Variables not used before they are assigned ● Free-variables are never assigned – (Our language has no loop support) 10 / 51

  11. Straight-Line Fragment ● Similar to single-static assignment form – Each variable only assigned once – Variables not used before they are assigned ● Free-variables are never assigned – (Our language has no loop support) Non-Example x := concat(y,z) y := x y := z 11 / 51

  12. Straight-Line Fragment ● Similar to single-static assignment form – Each variable only assigned once – Variables not used before they are assigned Assigned after use ● Free-variables are never assigned Assigned after use (Circular dependency) (Circular dependency) – (Our language has no loop support) Non-Example x := concat(y,z) y := x y := z 12 / 51

  13. Straight-Line Fragment ● Similar to single-static assignment form – Each variable only assigned once – Variables not used before they are assigned Assigned after use ● Free-variables are never assigned Assigned after use (Circular dependency) (Circular dependency) – (Our language has no loop support) Non-Example x := concat(y,z) Double assignment y := x Double assignment y := z 13 / 51

  14. Symbolic Execution ● Explore paths through a program ● Variables represented symbolically ● If-conditions &c. lead to constraints on variables ● Path is feasible if constraints are satisfjable ● Verifjcation / T est-case generation ● Famous tools such as Klee 14 / 51

  15. Example Path Program function get_user_header(name) while name.contains(“<script>”) name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” assert not header.contains(“script”) end 15 / 51

  16. Example Path Program function get_user_header(name) while name.contains(“<script>”) name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” assert not header.contains(“script”) end 16 / 51

  17. Example Path Program assert contains(n1, “<script>”); function get_user_header(name) while name.contains(“<script>”) name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” assert not header.contains(“script”) end 17 / 51

  18. Example Path Program assert contains(n1, “<script>”); function get_user_header(name) n2 := replaceAll(n1, “<script>”, “”); while name.contains(“<script>”) name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” assert not header.contains(“script”) end 18 / 51

  19. Example Path Program assert contains(n1, “<script>”); function get_user_header(name) n2 := replaceAll(n1, “<script>”, “”); while name.contains(“<script>”) assert contains(n2, “<script>”); name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” assert not header.contains(“script”) end 19 / 51

  20. Example Path Program assert contains(n1, “<script>”); function get_user_header(name) n2 := replaceAll(n1, “<script>”, “”); while name.contains(“<script>”) assert contains(n2, “<script>”); name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” n3 := replaceAll(n2, “<script>”, “”); assert not header.contains(“script”) end 20 / 51

  21. Example Path Program assert contains(n1, “<script>”); function get_user_header(name) n2 := replaceAll(n1, “<script>”, “”); while name.contains(“<script>”) assert contains(n2, “<script>”); name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” n3 := replaceAll(n2, “<script>”, “”); assert not header.contains(“script”) assert not contains(n3, “<script>”); end 21 / 51

  22. Example Path Program assert contains(n1, “<script>”); function get_user_header(name) n2 := replaceAll(n1, “<script>”, “”); while name.contains(“<script>”) assert contains(n2, “<script>”); name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” n3 := replaceAll(n2, “<script>”, “”); assert not header.contains(“script”) assert not contains(n3, “<script>”); hdr = concat(“<h1>”, n3, “</h1>”); end 22 / 51

  23. Example Path Program assert contains(n1, “<script>”); function get_user_header(name) n2 := replaceAll(n1, “<script>”, “”); while name.contains(“<script>”) assert contains(n2, “<script>”); name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” n3 := replaceAll(n2, “<script>”, “”); assert not header.contains(“script”) assert not contains(n3, “<script>”); hdr = concat(“<h1>”, n3, “</h1>”); end assert contains(hdr, “<script>”); 23 / 51

  24. Example Path Program assert contains(n1, “<script>”); function get_user_header(name) n2 := replaceAll(n1, “<script>”, “”); while name.contains(“<script>”) assert contains(n2, “<script>”); name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” n3 := replaceAll(n2, “<script>”, “”); assert not header.contains(“script”) assert not contains(n3, “<script>”); hdr = concat(“<h1>”, n3, “</h1>”); end assert contains(hdr, “<script>”); Assertion in code negated 24 / 51

  25. Example Path Program assert contains(n1, “<script>”); function get_user_header(name) n2 := replaceAll(n1, “<script>”, “”); while name.contains(“<script>”) assert contains(n2, “<script>”); name = name.replaceAll(“<script>”, “”) header = “<h1>” + name + “</h1>” n3 := replaceAll(n2, “<script>”, “”); assert not header.contains(“script”) assert not contains(n3, “<script>”); hdr = concat(“<h1>”, n3, “</h1>”); end assert contains(hdr, “<script>”); Assertion in code negated ● No solution: path correct! 25 / 51

  26. Solving Such Constraints Straight-line with ● Regular constraints, concat, fjnite transductions – x := concat(y, z); x’ = T(x); assert x’ in a*b*; – EXPSPACE-c / PSPACE-c [Lin, Barcelo, 2016] ● Regular constraints, concat, replaceAll – x := replaceAll(y, e, z) – Undecidable if e can be a variable – EXPSPACE / PSPACE if e is a regular expression – Undecidable with length constraints – [Chen et al, 2018] 26 / 51

  27. Generic Approach Which string constraints can we allow? ● Maintain decidability ● Expressivity: capture most benchmarks ● Easy: solve with a straight-forward algorithm ● Extensible: allow users-defjned string functions ● Effjcient: solve competitively 27 / 51

  28. Basic Approach: Go Backwards For one variable, assume: ● assert g(x) – g is a regular constraint ● x : = f(y) – suppose x must satisfy a regular constraint – take the weakest precondition Pre(f, x) – Pre(f, x) is a regular constraint on y 28 / 51

  29. Basic Approach: Go Backwards For one variable, assume: ● assert g(x) – g is a regular constraint ● x : = f(y) – suppose x must satisfy a regular constraint – take the weakest precondition Pre(f, x) – Pre(f, x) is a regular constraint on y Regular contraints on output variables become regular constraints on input variables. 29 / 51

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