SMT Solvers in Program Analysis and Verification

SMT Solvers in Program Analysis and Verification

IJCAR 2008 4th International Joint Conference on Automated Reasoning Sydney, Australia, August 10–15, 2008 Tutorial Program SMT Solvers in Program Analysis and Verification Nikolaj Bjørner and Leonardo de Moura T 3 – August 10 8/4/2008 Appetizers SMT solving Applications Applications at Microsoft Research Background Basics, DPLL(), Equality, Arithmetic, Leonardo de Moura and Nikolaj Bjørner DPLL(T), Arrays, Matching Microsoft Research Z3 – An Efficient SMT solver Bits and bytes 0 ((x 1) & x ) x 00100000..00 Numbers x y y x Arrays read( write ( a , i ,4), i ) 4 Records mkpair(,)(,) x y mkpair z u x z Heaps n** n'(,)' m cons a n m n Data-types car( cons ( x , nil )) x Object inheritance BACBCA::: x 2 y f (read(write(a, x,3), y 2) f (y x 1) Arithmetic Arrays Free Functions © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. 1 8/4/2008 SMT solvers are used in several applications: Program Verification Program Analysis Program Exploration Hyper-V Software Modeling VCC Boogie SMT solvers are Verification directly applicable, or HAVOC condition disguised beneath a transformation Theories and quantifiers supply abstractions Bug path Replace ad-hoc, often non-scalable, solutions Rustan Leino, Mike Barnet, Michal Mosƙal, Shaz Qadeer, Shuvendu Lahiri, Herman Venter, Peter Muller, Wolfram Schulte, Ernie Cohen Z3 is part of SDV 2.0 (Windows 7) Run Test and Monitor Execution Path Condition Path It is used for: Test Predicate abstraction (c2bp) seed Inputs Known Counter-example refinement (newton) Paths New input Constraint System Solve Unexplored path Vigilante Nikolai Tillmann, Peli de Halleux, Patrice Godefroid Ella Bounimova, Vlad Levin, Jakob Lichtenberg, Aditya Nori, Jean Philippe Martin, Miguel Castro, Tom Ball, Sriram Rajamani, Byron Cook Manuel Costa, Lintao Zhang Bounded model-checking of model programs Termination Security protocols, F#/7 Business application modeling Cryptography Model Based Testing (SQL-Server) Verified garbage collectors © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. 2 8/4/2008 Test input generator Pex starts from parameterized unit tests Generated tests are emitted as traditional unit tests Dynamic symbolic execution framework Program Exploration with Pex Analysis of .NET instructions (bytecode) Instrumentation happens automatically at JIT time Using SMT-solver Z3 to check satisfiability and generate models = test inputs Nikolai Tillmann, Peli de Halleux http://research.microsoft.com/Pex class ArrayListTest { [PexMethod] void AddItem(int c, object item) { var list = new ArrayList(c); list.Add(item); Assert(list[0] == item); } } class ArrayList { object[] items; int count; ArrayList(int capacity) { if (capacity < 0) throw ...; items = new object[capacity]; } void Add(object item) { if (count == items.Length) ResizeArray(); items[this.count++] = item; } ... class ArrayListTest { Inputs class ArrayListTest { Inputs [PexMethod] [PexMethod] void AddItem(int c, object item) { void AddItem(int c, object item) { (0,null) var list = new ArrayList(c); var list = new ArrayList(c); list.Add(item); list.Add(item); Assert(list[0] == item); } Assert(list[0] == item); } } } class ArrayList { class ArrayList { object[] items; object[] items; int count; int count; ArrayList(int capacity) { ArrayList(int capacity) { if (capacity < 0) throw ...; if (capacity < 0) throw ...; items = new object[capacity]; items = new object[capacity]; } } void Add(object item) { void Add(object item) { if (count == items.Length) if (count == items.Length) ResizeArray(); ResizeArray(); items[this.count++] = item; } items[this.count++] = item; } ... ... © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. 3 8/4/2008 class ArrayListTest { Inputs Observed class ArrayListTest { Inputs Observed [PexMethod] Constraints [PexMethod] Constraints void AddItem(int c, object item) { void AddItem(int c, object item) { var list = new ArrayList(c); (0,null) !(c<0) var list = new ArrayList(c); (0,null) !(c<0) && 0==c list.Add(item); list.Add(item); Assert(list[0] == item); } Assert(list[0] == item); } } } class ArrayList { class ArrayList { object[] items; object[] items; int count; int count; ArrayList(int capacity) { ArrayList(int capacity) { if (capacity < 0) throw ...; c < 0 false if (capacity < 0) throw ...; items = new object[capacity]; items = new object[capacity]; } } void Add(object item) { void Add(object item) { if (count == items.Length) if (count == items.Length) 0 == c true ResizeArray(); ResizeArray(); items[this.count++] = item; } items[this.count++] = item; } ... ... class ArrayListTest { Inputs Observed class ArrayListTest { Constraints to Inputs Observed [PexMethod] Constraints [PexMethod] solve Constraints void AddItem(int c, object item) { void AddItem(int c, object item) { var list = new ArrayList(c); (0,null) !(c<0) && 0==c var list = new ArrayList(c); (0,null) !(c<0) && 0==c list.Add(item); list.Add(item); !(c<0) && 0!=c Assert(list[0] == item); } Assert(list[0] == item); } } item == item true } class ArrayList { class ArrayList { object[] items; This is a tautology, object[] items; int count; i.e. a constraint that is always true, int count; regardless of the chosen values. ArrayList(int capacity) { ArrayList(int capacity) { if (capacity < 0) throw ...; if (capacity < 0) throw ...; items = new object[capacity]; We can ignore such constraints. items = new object[capacity]; } } void Add(object item) { void Add(object item) { if (count == items.Length) if (count == items.Length) ResizeArray(); ResizeArray(); items[this.count++] = item; } items[this.count++] = item; } ... ... class ArrayListTest { Constraints to Inputs Observed class ArrayListTest { Constraints to Inputs Observed [PexMethod] solve Constraints [PexMethod] solve Constraints void AddItem(int c, object item) { void AddItem(int c, object item) { var list = new ArrayList(c); (0,null) !(c<0) && 0==c var list = new ArrayList(c); (0,null) !(c<0) && 0==c list.Add(item); !(c<0) && 0!=c (1,null) list.Add(item); !(c<0) && 0!=c (1,null) !(c<0) && 0!=c Assert(list[0] == item); } Assert(list[0] == item); } } } class ArrayList { class ArrayList { object[] items; object[] items; int count; Z3 int count; Constraint solver ArrayList(int capacity) { ArrayList(int capacity) { if (capacity < 0) throw ...; Z3 has decision procedures for if (capacity < 0) throw ...; items = new object[capacity]; - Arrays items = new object[capacity]; } - Linear integer arithmetic } - Bitvector arithmetic void Add(object item) { - … void Add(object item) { if (count == items.Length) - (Everything but floating-point numbers) if (count == items.Length) 0 == c false ResizeArray(); ResizeArray(); items[this.count++] = item; } items[this.count++] = item; } ... ... © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. 4 8/4/2008 class ArrayListTest { Constraints to Inputs Observed class ArrayListTest { Constraints to Inputs Observed [PexMethod] solve Constraints [PexMethod] solve Constraints void AddItem(int c, object item) { void AddItem(int

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    40 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us