Swarat Chaudhuri Roberto Lublinerman Pennsylvania State University Sumit Gulwani Microsoft Research CAUCHY Continuity analysis of programs.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

CSCE 411H Design and Analysis of Algorithms Set 8: Greedy Algorithms Prof. Evdokia Nikolova* Spring 2013 CSCE 411H, Spring 2013: Set 8 1 * Slides adapted.
1 Discrete Structures & Algorithms Graphs and Trees: III EECE 320.
Self Stabilizing Algorithms for Topology Management Presentation: Deniz Çokuslu.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Graph II MST, Shortest Path. Graph Terminology Node (vertex) Edge (arc) Directed graph, undirected graph Degree, in-degree, out-degree Subgraph Simple.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
CPSC 411, Fall 2008: Set 9 1 CPSC 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Fall 2008.
Discussion #36 Spanning Trees
Minimum Spanning Tree Algorithms
CS 311 Graph Algorithms. Definitions A Graph G = (V, E) where V is a set of vertices and E is a set of edges, An edge is a pair (u,v) where u,v  V. If.
CSE 421 Algorithms Richard Anderson Dijkstra’s algorithm.
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
Shortest Path Algorithms
Shortest Paths Definitions Single Source Algorithms
CSE 421 Algorithms Richard Anderson Lecture 10 Minimum Spanning Trees.
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
All-Pairs Shortest Paths
Cs466(Prasad)L8Norm1 Normal Forms Chomsky Normal Form Griebach Normal Form.
Prim’s Algorithm and an MST Speed-Up
1 Shortest Path Algorithms. 2 Routing Algorithms Shortest path routing What is a shortest path? –Minimum number of hops? –Minimum distance? There is a.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Design and Analysis of Algorithms - Chapter 11 Algorithm An algorithm is a.
Lecture 30 CSE 331 Nov 10, Online Office Hours
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
Theory of Computing Lecture 7 MAS 714 Hartmut Klauck.
Greedy Algorithms Intuition: At each step, make the choice that is locally optimal. Does the sequence of locally optimal choices lead to a globally optimal.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
CS112A1 Spring 2008 Practice Final. ASYMPTOTIC NOTATION: a)Show that log(n) and ln(n) are the same in terms of Big-Theta notation b)Show that log(n+1)
1 Shortest Path Algorithms Andreas Klappenecker [based on slides by Prof. Welch]
Algorithms: Design and Analysis Summer School 2013 at VIASM: Random Structures and Algorithms Lecture 3: Greedy algorithms Phan Th ị Hà D ươ ng 1.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 10.
Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible.
Proving Programs Robust Swarat Chaudhuri 1,3 Sumit Gulwani 2 Roberto Lublinerman 1 Sara Navidpour 1 1 Pennsylvania State University 2 Microsoft Research.
Minimum spanning trees (MST) Def: A spanning tree of a graph G is an acyclic subset of edges of G connecting all vertices in G. A sub-forest of G is an.
Spanning Trees. A spanning tree for a connected, undirected graph G is a graph S consisting of the nodes of G together with enough edges of G such that:
CS223 Advanced Data Structures and Algorithms 1 Review for Final Neil Tang 04/27/2010.
Runtime O(VE), for +/- edges, Detects existence of neg. loops
Nattee Niparnan. Greedy If solving problem is a series of steps Simply pick the one that “maximize” the immediate outcome Instead of looking for the long.
1 Prim’s algorithm. 2 Minimum Spanning Tree Given a weighted undirected graph G, find a tree T that spans all the vertices of G and minimizes the sum.
Nattee Niparnan. Greedy If solving problem is a series of steps Simply pick the one that “maximize” the immediate outcome Instead of looking for the long.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
CSEP 521 Applied Algorithms Richard Anderson Winter 2013 Lecture 3.
CS6045: Advanced Algorithms Sorting Algorithms. Heap Data Structure A heap (nearly complete binary tree) can be stored as an array A –Root of tree is.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
CSCE 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Spring 2012 CSCE 411, Spring 2012: Set 9 1.
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
Proof of correctness of Dijkstra’s algorithm: Basically, we need to prove two claims. (1)Let S be the set of vertices for which the shortest path from.
Shortest Paths and Minimum Spanning Trees
Lecture 26 CSE 331 Nov 2, 2016.
Single-Source Shortest Paths
COMP 6/4030 ALGORITHMS Prim’s Theorem 10/26/2000.
Short paths and spanning trees
Unit 3 (Part-I): Greedy Algorithms
Lecture 26 CSE 331 Nov 1, 2017.
Autumn 2015 Lecture 10 Minimum Spanning Trees
Minimum Spanning Tree Algorithms
CSE332: Data Abstractions Lecture 18: Minimum Spanning Trees
Lecture 27 CSE 331 Oct 31, 2014.
Lecture 28 CSE 331 Nov 7, 2012.
Lecture 27 CSE 331 Nov 2, 2010.
Weighted Graphs & Shortest Paths
Autumn 2016 Lecture 10 Minimum Spanning Trees
Prim’s algorithm for minimum spanning trees
Lecture 27 CSE 331 Nov 1, 2013.
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

Swarat Chaudhuri Roberto Lublinerman Pennsylvania State University Sumit Gulwani Microsoft Research CAUCHY Continuity analysis of programs

Uncertainty and robustness Trends: cyber-physical systems, integration of computation and science, … Uncertainty: stale satellite data, erroneous sensor measurements, … Does your program handle uncertainty robustly? – Correctness in settings without uncertainty does not imply correctness in uncertain environments.

Robustness analysis of programs Robustness: small perturbations to a program’s operating conditions do not change its behavior significantly. – Continuity: Infinitesimal changes to inputs only cause infinitesimal changes to outputs. – Discrete continuity: Similar, except for non-infinitesimal changes to discrete numbers. – Derivative has low complexity. – Asymptotic stability Verify these! P

First step: Continuity analysis of programs Continuity of mathematical functions: – definition. – Equivalently, infinitesimal changes in inputs only cause infinitesimal changes in outputs. Continuity of programs – Associate metric spaces with types, lift it into a metric over states. – Same question. Do infinitesimal changes in program inputs only cause infinitesimal changes to outputs? This paper: structural analysis of continuity. P

Example: an implementation of Dijkstra’s algorithm Small change to real array: each element changes at most by a small amount. Small change to graph with real edge weight: each edge weight changes at most by a small amount. Is this program continuous? procedure Dijkstra (G: graph, src: node): for each node v in G: { d[v] := Infinity } d[src] := 0; Worklist := set of all nodes in G; while Worklist is not empty { Remove node w from Worklist s.t. d[w] is minimal; for each neighbor v of w: { z := d[w] + G[w,v]; if (z < d[v]) { d[v] := z; prev[v] := w; } } }

Example: Dijkstra’s algorithm Small change to real array: each element changes at most by a small amount. Small change to graph with real edge weight: each edge weight changes at most by a small amount. Is this program continuous? procedure Dijkstra (G: graph, src: node): for each node v in G: { d[v] := Infinity } d[src] := 0; Worklist := set of all nodes in G; while Worklist is not empty { Remove node w from Worklist s.t. d[w] is minimal; for each neighbor v of w: { z := d[w] + G[w,v]; if (z < d[v]) { d[v] := z; prev[v] := w; } } } Depends on what is observable. At point of output, d is a continuous function of G, but prev is not.

Sorting algorithms are continuous … but only if output = array of keys. Minimum spanning tree algorithms are continuous … but only if the output is the weight of the tree. Integer knapsack is continuous in values of items but not in their weights. Fractional knapsack is continuous in values and weights. Continuity at work!

Key Idea: Prove branch-equivalence at the zeroes of b—i.e., conditions under which guard can flip on small changes. Example: d[v] is continuous after if (d[v] < z) d[v] := z. The guard (d[v] < z) flips (under small changes) only when d[v] = z. Then, d[v] has similar values on both branches. Automate using an SMT-solver. (cf. Translation validation) Challenge #1: Control flow if b P 1 P P 1 and P 2 are continuous. P is continuous P

Challenge #2: Noninductiveness while Worklist is not empty { Remove node w from Worklist s.t. d[w] is minimal; for each neighbor v of w: { z := d[w] + G[w,v]; if (z < d[v]) { d[v] := z; prev[v] := w; } } } Small change to d at iteration-entry can completely change the value of d at the end. Thus, continuity is not inductive. u 1 d[u 1 ] = 2.00 u 2 d[u 2 ] = 2.00 u 3 d[u 2 ] = 4.00

u 2 d[u 2 ] = 2.00 u 1 d[u 1 ] = 2.00 Key idea: Induction over epochs while Worklist is not empty { Remove node w from Worklist s.t. d[w] is minimal; To be reordered, iterations must be approximately tied on selection criterion. Epoch = cluster of such iterations. Prove that iterations within epochs are commutative. Proof can be discharged using an SMT-solver. u 3 d[u 2 ] = 4.00 u 1 d[u 2 ] = 2.01 u 2 d[u 1 ] = 2.00 u 3 d[u 2 ] = 4.02

u 2 d[u 2 ] = 2.00 u 1 d[u 1 ] = 2.00 Key idea: Induction over epochs while Worklist is not empty { Remove node w from Worklist s.t. d[w] is minimal; Now do induction over epochs. u 3 d[u 2 ] = 4.00 u 1 d[u 2 ] = 2.01 u 2 d[u 1 ] = 2.00 u 3 d[u 2 ] = 4.02 Original Perturbed

But often, simple induction is enough for k := 1 to N for i, j := 1 to N: if G[i, j] > G[i, k] + G [k, j] G[i, j] := G[i, k] + G[k. j]; Floyd-Warshall shortest path algorithm

Challenge #3: Early or late termination Key Idea: Prove idempotence under conditions when guard can flip. Example: while (z > 0) { x := x + z; z := z * w; } If z = 0, then loop body is idempotent. while b P Original Perturbed

Soundness with respect to definition. (Tricky!) Proof rules discharged using Z3 SMT solver. Able to prove 11 of the 13 continuous algorithms targeted: – Sorting (Merge sort, Bubble sort, Insertion sort, Selection sort). – Minimum Spanning Tree (Prim’s and Kruskal’s) – Shortest Paths (Floyd-Warshall, Bellman-Ford, Dijkstra) – Knapsack (Fractional and integer) Epoch induction needed in 5/13 cases. Early termination check needed in 3/13 cases. Current work exploring “real” applications (embedded medical devices and GPS apps). Results

Ongoing work: discrete derivatives of programs Instead of infinitesimal changes to real variables, consider unit changes to finite- precision variables. More natural in the quantitative setting. Changes the game somewhat: – E.g., Addition is not continuous. But most of the rules/insights still apply. Goal: Mechanically generate discrete derivatives of programs: – E.g., Discrete derivative of Dijkstra’s algorithm in O(n). P

The Cauchy challenge Cauchy Develop an analytical calculus of computation Limits of programs Hybrid representations Continuity analysis Analytic approximations of programs (Discrete) derivatives of programs Applications in cyber-physical systems, approximate computation. Also, pedagogical value. Fourier analysis of programs

Conclusion Robustness is an important correctness property for programs operating under uncertainty. Continuity is one, but by no means the only, robustness property. This paper offers one, but by no means the only, continuity analysis. First step towards an analytical calculus of computation.