preventing arithmetic overflows in alloy
play

Preventing Arithmetic Overflows in Alloy Aleksandar Milicevic - PowerPoint PPT Presentation

Preventing Arithmetic Overflows in Alloy Aleksandar Milicevic Daniel Jackson (aleks@csail.mit.edu) (dnj@csail.mit.edu) Software Design Group Massachusetts Institute of Technology Cambridge, MA International Conference of Alloy, ASM, B, VDM,


  1. Preventing Arithmetic Overflows in Alloy Aleksandar Milicevic Daniel Jackson (aleks@csail.mit.edu) (dnj@csail.mit.edu) Software Design Group Massachusetts Institute of Technology Cambridge, MA International Conference of Alloy, ASM, B, VDM, and Z Users Pisa, Italy, June 2012 1

  2. Checking Prim’s Algorithm C Prim’s algorithm for finding A 8 7 minimum spanning tree in a graph 5 B 5 7 9 15 E D 8 9 6 11 F G

  3. Checking Prim’s Algorithm C Prim’s algorithm for finding A 8 7 minimum spanning tree in a graph 5 B 5 select an arbitrary node to start with 7 9 15 E D D 8 9 6 11 F G 2

  4. Checking Prim’s Algorithm C Prim’s algorithm for finding A 8 7 minimum spanning tree in a graph 5 5 B 5 select an arbitrary node to start with 7 9 9 15 15 find edges from selected to unselected nodes E D D 8 9 6 6 11 F G 2

  5. Checking Prim’s Algorithm C Prim’s algorithm for finding A A 8 7 minimum spanning tree in a graph 5 B 5 select an arbitrary node to start with 7 9 15 find edges from selected to unselected nodes E D D 8 9 select the edge with the smallest weight 6 11 F G 2

  6. Checking Prim’s Algorithm C Prim’s algorithm for finding A A 8 7 7 minimum spanning tree in a graph 5 B 5 select an arbitrary node to start with 7 9 9 15 15 find edges from selected to unselected nodes E D D 8 9 select the edge with the smallest weight 6 6 11 F G repeat until all nodes have been selected 2

  7. Checking Prim’s Algorithm C Prim’s algorithm for finding A A 8 7 minimum spanning tree in a graph 5 B 5 select an arbitrary node to start with 7 9 15 find edges from selected to unselected nodes E D D 8 9 select the edge with the smallest weight 6 11 F F G repeat until all nodes have been selected 2

  8. Checking Prim’s Algorithm C C Prim’s algorithm for finding A A 8 7 minimum spanning tree in a graph 5 B B 5 select an arbitrary node to start with 7 9 15 find edges from selected to unselected nodes E E D D 8 9 select the edge with the smallest weight 6 11 F F G G repeat until all nodes have been selected 2

  9. Checking Prim’s Algorithm C C A A 8 7 sig Node {} sig Edge { 5 B B 5 weight: Int , 7 9 nodes: set Node, 15 E E D D 8 9 } { 6 11 weight >= 0 && #nodes = 2 F F G G } 2

  10. Checking Prim’s Algorithm open util/ordering[Time] C C sig Time {} A A 8 7 sig Node {} sig Edge { 5 B B 5 weight: Int , 7 9 nodes: set Node, 15 E E chosen: set Time D D 8 9 } { 6 11 weight >= 0 && #nodes = 2 F F G G } 2

  11. Checking Prim’s Algorithm open util/ordering[Time] C C sig Time {} A A 8 7 sig Node {} sig Edge { 5 B B 5 weight: Int , 7 9 nodes: set Node, 15 E E chosen: set Time D D 8 9 } { 6 11 weight >= 0 && #nodes = 2 F F G G } fact prim { /* model of execution of Prim’s algorithm */ } 2

  12. Checking Prim’s Algorithm open util/ordering[Time] C C sig Time {} A A 8 7 sig Node {} sig Edge { 5 B B 5 weight: Int , 7 9 nodes: set Node, 15 E E chosen: set Time D D 8 9 } { 6 11 weight >= 0 && #nodes = 2 F F G G } fact prim { /* model of execution of Prim’s algorithm */ } pred spanningTree(edges: set Edges) { /* checks whether a given set of edges forms a spanning tree */ } 2

  13. Checking Prim’s Algorithm open util/ordering[Time] C C sig Time {} A A 8 7 sig Node {} sig Edge { 5 B B 5 weight: Int , 7 9 nodes: set Node, 15 E E chosen: set Time D D 8 9 } { 6 11 weight >= 0 && #nodes = 2 F F G G } fact prim { /* model of execution of Prim’s algorithm */ } pred spanningTree(edges: set Edges) { /* checks whether a given set of edges forms a spanning tree */ } /* no set of edges is a spanning tree with a smaller total weight than the one returned by Prim’s algorithm */ smallest: check { no edges: set Edge { spanningTree[edges] ( sum e: edges | e.weight) < ( sum e: chosen.last | e.weight)}} 2

  14. Checking Prim’s Algorithm open util/ordering[Time] C C sig Time {} A A 8 7 sig Node {} sig Edge { 5 B B 5 weight: Int , 7 9 nodes: set Node, 15 E E chosen: set Time D D 8 9 } { 6 11 weight >= 0 && #nodes = 2 F F G G } fact prim { /* model of execution of Prim’s algorithm */ } pred spanningTree(edges: set Edges) { /* checks whether a given set of edges forms a spanning tree */ } /* no set of edges is a spanning tree with a smaller total weight than the one returned by Prim’s algorithm */ smallest: check { counterexample: leftSum = -5; rightSum = 24 no edges: set Edge { spanningTree[edges] ( sum e: edges | e.weight) < ( sum e: chosen.last | e.weight)}} 2

  15. Checking Prim’s Algorithm open util/ordering[Time] C C sig Time {} A A 8 7 sig Node {} sig Edge { 5 B B 5 weight: Int , 7 9 nodes: set Node, 15 E E chosen: set Time D D 8 9 } { 6 11 weight >= 0 && #nodes = 2 F F G G } fact prim { /* model of execution of Prim’s algorithm */ } pred spanningTree(edges: set Edges) { /* checks whether a given set of edges forms a spanning tree */ } /* no set of edges is a spanning tree with a smaller total weight than the one returned by Prim’s algorithm */ smallest: check { counterexample: leftSum = -5; rightSum = 24 no edges: set Edge { spanningTree[edges] and ( sum e: edges | e.weight) > 0 ( sum e: edges | e.weight) < ( sum e: chosen.last | e.weight)}} 2

  16. Checking Prim’s Algorithm open util/ordering[Time] C C sig Time {} A A 8 7 sig Node {} sig Edge { 5 B B 5 weight: Int , 7 9 nodes: set Node, 15 E E chosen: set Time D D 8 9 } { 6 11 weight >= 0 && #nodes = 2 F F G G } fact prim { /* model of execution of Prim’s algorithm */ } pred spanningTree(edges: set Edges) { /* checks whether a given set of edges forms a spanning tree */ } /* no set of edges is a spanning tree with a smaller total weight than the one returned by Prim’s algorithm */ smallest: check { counterexample: leftSum = 2; rightSum = 28 no edges: set Edge { spanningTree[edges] and ( sum e: edges | e.weight) > 0 ( sum e: edges | e.weight) < ( sum e: chosen.last | e.weight)}} 2

  17. Checking Prim’s Algorithm open util/ordering[Time] C C sig Time {} A A 8 7 sig Node {} sig Edge { 5 B B 5 weight: Int , 7 9 nodes: set Node, 15 E E chosen: set Time D D 8 9 } { 6 11 weight >= 0 && #nodes = 2 F F G G } fact prim { /* model of execution of Prim’s algorithm */ } pred spanningTree(edges: set Edges) { /* checks whether a given set of edges forms a spanning tree */ } /* no set of edges is a spanning tree with a smaller total weight than the one returned by Prim’s algorithm */ smallest: check { causes arithmetic overflows! no edges: set Edge { spanningTree[edges] and ( sum e: edges | e.weight) > 0 ( sum e: edges | e.weight) < ( sum e: chosen.last | e.weight)}} 2

  18. Soundness of Alloy reason for overflows wraparound semantics for arithmetic operations Int = {-4, -3, ..., 2, 3} � ⇒ 3 + 1 = -4 3

  19. Soundness of Alloy reason for overflows wraparound semantics for arithmetic operations Int = {-4, -3, ..., 2, 3} � ⇒ 3 + 1 = -4 alloy first order relational modeling language the alloy analyzer fully automated, bounded model finder for alloy 3

  20. Soundness of Alloy reason for overflows wraparound semantics for arithmetic operations Int = {-4, -3, ..., 2, 3} � ⇒ 3 + 1 = -4 alloy first order relational modeling language the alloy analyzer fully automated, bounded model finder for alloy consequences of the bounded analysis not sound with respect to proof → if no counterexample is found, one may still exist in a larger scope 3

  21. Soundness of Alloy reason for overflows wraparound semantics for arithmetic operations Int = {-4, -3, ..., 2, 3} � ⇒ 3 + 1 = -4 alloy first order relational modeling language the alloy analyzer fully automated, bounded model finder for alloy consequences of the bounded analysis not sound with respect to proof → if no counterexample is found, one may still exist in a larger scope not sound w.r.t. counterexamples when integers are used → arithmetic operations can overflow ⇒ spurious counterexamples 3

  22. Soundness of Alloy reason for overflows wraparound semantics for arithmetic operations Int = {-4, -3, ..., 2, 3} � ⇒ 3 + 1 = -4 alloy first order relational modeling language the alloy analyzer fully automated, bounded model finder for alloy consequences of the bounded analysis not sound with respect to proof → if no counterexample is found, one may still exist in a larger scope not sound w.r.t. counterexamples when integers are used → arithmetic operations can overflow ⇒ spurious counterexamples sound w.r.t. counterexamples if no integers are used → i.e., if a counterexample is found, the property does not hold → reason : relational operators are closed under finite universe 3

  23. Goal & Approach goal eliminate spurious counterexamples caused by overflows → makes the analyzer sound w.r.t. to counterexamples 4

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