June 27, 2002 HornstrupCentret1 Using Compile-time Techniques to Generate and Visualize Invariants for Algorithm Explanation Thursday, 27 June 2002 13:00-13:30.

Slides:



Advertisements
Similar presentations
Introduction to Algorithms Quicksort
Advertisements

110/6/2014CSE Suprakash Datta datta[at]cse.yorku.ca CSE 3101: Introduction to the Design and Analysis of Algorithms.
Introduction to Computer Science 2 Lecture 7: Extended binary trees
Traveling Salesperson Problem
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Copyright © Cengage Learning. All rights reserved.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Advanced Data Structures
EDMEDIA, June 24, A New Approach to Learning Algorithms Tomasz Müldner*, Elhadi Shakshuki and Joe Merrill Jodrey School of Computer Science, Acadia.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
Improving code generation. Better code generation requires greater context Over expressions: optimal ordering of subtrees Over basic blocks: Common subexpression.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Michael Ernst, page 1 Improving Test Suites via Operational Abstraction Michael Ernst MIT Lab for Computer Science Joint.
Improving Code Generation Honors Compilers April 16 th 2002.
(1 - 2) Abstract Data Types D & D Chapter 12 Instructor - Andrew S. O’Fallon CptS 122 (June 10, 2015) Washington State University.
Data Flow Analysis Compiler Design Nov. 8, 2005.
Chapter 3: Arrays, Linked Lists, and Recursion
Advanced Topics in Algorithms and Data Structures 1 Two parallel list ranking algorithms An O (log n ) time and O ( n log n ) work list ranking algorithm.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 20: Binary Trees.
Data Structures Using C++ 2E
Induction and recursion
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Review Binary Tree Binary Tree Representation Array Representation Link List Representation Operations on Binary Trees Traversing Binary Trees Pre-Order.
Advanced Algorithms Analysis and Design Lecture 8 (Continue Lecture 7…..) Elementry Data Structures By Engr Huma Ayub Vine.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Chapters 7, 8, & 9 Quiz 3 Review 1. 2 Algorithms Algorithm A set of unambiguous instructions for solving a problem or subproblem in a finite amount of.
Big Idea 1: The Practice of Science Description A: Scientific inquiry is a multifaceted activity; the processes of science include the formulation of scientifically.
Searching: Binary Trees and Hash Tables CHAPTER 12 6/4/15 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education,
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 19: Searching and Sorting Algorithms.
Binary Trees Chapter 10. Introduction Previous chapter considered linked lists –nodes connected by two or more links We seek to organize data in a linked.
1 Trees A tree is a data structure used to represent different kinds of data and help solve a number of algorithmic problems Game trees (i.e., chess ),
10/14/ Algorithms1 Algorithms - Ch2 - Sorting.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
1 CSE 1342 Programming Concepts Lists. 2 Basic Terminology A list is a finite sequence of zero or more elements. –For example, (1,3,5,7) is a list of.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
(1 - 1) Introduction to C Data Structures & Abstract Data Types Instructor - Andrew S. O’Fallon CptS 122 (August 26, 2015) Washington State University.
CSC 211 Data Structures Lecture 13
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Formal verification of skiplist algorithms Student: Trinh Cong Quy Supervisor: Bengt Jonsson Reviewer: Parosh Abdulla.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Objectives At the end of the class, students are expected to be able to do the following: Understand the searching technique concept and the purpose of.
Review 1 Queue Operations on Queues A Dequeue Operation An Enqueue Operation Array Implementation Link list Implementation Examples.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
Binary Trees Chapter 10. Introduction Previous chapter considered linked lists –nodes connected by two or more links We seek to organize data in a linked.
Quantified Data Automata on Skinny Trees: an Abstract Domain for Lists Pranav Garg 1, P. Madhusudan 1 and Gennaro Parlato 2 1 University of Illinois at.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Putting Static Analysis to Work for Verification A Case Study Tal Lev-Ami Thomas Reps Mooly Sagiv Reinhard Wilhelm.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Data Structure and Algorithm: CIT231 Lecture 6: Linked Lists DeSiaMorewww.desiamore.com/ifm1.
UNIT - IV SORTING By B.Venkateswarlu Dept of CSE.
CSE 1342 Programming Concepts
Top 50 Data Structures Interview Questions
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Lectures linked lists Chapter 6 of textbook
Data Structure and Algorithms
Chapter 9 Structuring System Requirements: Logic Modeling
UNIT-3 LINKED LIST.
Lecture 22 Binary Search Trees Chapter 10 of textbook
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Chapter 9 Structuring System Requirements: Logic Modeling
Chapter 9 Structuring System Requirements: Logic Modeling
CS212D: Data Structures Week 5-6 Linked List.
Data Structures and Algorithm: SEARCHING TECHNIQUES
Chapter 9 Structuring System Requirements: Logic Modeling
Chapter 9 Structuring System Requirements: Logic Modeling
Basic Concepts of Algorithm
(1 - 2) Introduction to C Data Structures & Abstract Data Types
Presentation transcript:

June 27, 2002 HornstrupCentret1 Using Compile-time Techniques to Generate and Visualize Invariants for Algorithm Explanation Thursday, 27 June :00-13:30 Reinhard WilhelmTomasz Müldner Informatik Jodrey School of Computer Science Universität des Saarlandes Acadia University Saarbrücken, Germany Wolfville, Canada

June 27, 2002 HornstrupCentret 2 Introduction Algorithm : A specific set of instructions for carrying out a procedure or solving a problem, usually with the requirement that the procedure terminate at some point.

June 27, 2002 HornstrupCentret 3 Models of Human Understanding Step-by-step textual representation of an algorithm is analytic (reducing a whole to its parts) Visual representation may provide a synthetic view (build up separate elements into a connected whole) But many visual representations are more analytic than synthetic

June 27, 2002 HornstrupCentret 4 Analytic versus Synthetic One of animations of Insertion Sort gives these instructions: Start by comparing the first two rectangles in the group, and shift the second rectangle to the left if it is smaller. Look at the next rectangle, compare with the one on its left, and shift it to the left until it is smaller than the one to its right and larger than the one to its left. Repeat step 2 until finished.

June 27, 2002 HornstrupCentret 5 Analytic versus Synthetic: Animal

June 27, 2002 HornstrupCentret 6 Implementation Standard way to implement visualizations for algorithm explanation: use run-time techniques Our approach use compile-time techniques

June 27, 2002 HornstrupCentret 7 Implementation Shape analysis, parameterized with sets of observation properties, which statically determine the invariants of the algorithm Abstract execution of the algorithm showing invariants

June 27, 2002 HornstrupCentret 8 What’s “Algorithm Explanation”? It is not: Algorithm animation Debugging (at least in its traditional sense) Proving (partial) correctness It is a tool to help understanding various algorithms Focus on relevant part of data structures

June 27, 2002 HornstrupCentret 9 Focus: Insertion to BST Standard algorithm visualization shows the entire tree, even though the insertion takes place only in one of the subtrees One should show an essential invariant, stating that for each inner node, the elements in its left subtree have data components smaller than that of the node and elements in its right subtree have data components larger than that of the node

June 27, 2002 HornstrupCentret 10 Our Approach: What to show 1. The designer selects a data structure and an algorithm to be explained. 2. The designer selects a set of properties characterizing the data structure (to be used to formulate invariants for the algorithm).

June 27, 2002 HornstrupCentret 11 Our Approach: How to show 3. The designer runs a shape analysis, which will annotate each program point with a set of shape graphs describing all heap contents that may exist when program execution reaches this program point 4. The designer defines a visual representation for the shape graphs computed by the shape analysis

June 27, 2002 HornstrupCentret 12 Our Approach: User 5. Now, the user: - selects one particular shape graph at the entry to one particular program statement and then executes the statement and observes the effect on the chosen shape graph - performs a visualized abstract execution of the algorithm.

June 27, 2002 HornstrupCentret 13 Example: Insertion Sort (on lists) /* list.h */ typedef struct elem { struct elem* n; double data; }* List;

June 27, 2002 HornstrupCentret 14 List insert_sort(List x) { List r, pr, l, pl; r = x; pr = NULL; while (r != NULL) { /* while the suffix r is not empty */ l = x; /* sorted prefix is pointed to by x */ pl = NULL; while (l != r) { … } pr = r; r = r->n; } return x; }

June 27, 2002 HornstrupCentret 15 /* inner loop */ while (l != r) { /* P1: */ if (l->data > r->data) { /* P2 : after positive outcome of comparison, move r before l */ pr->n = r->n; r->n = l; if (pl == NULL) x = r; else pl->n = r; r = pr; break; } pl = l; l = l->n; }

June 27, 2002 HornstrupCentret 16 Visualization: Point P1 Here, the inner loop has been executed several times and the current execution point is P1: while (l != r) { /* P1: */ if (l->data > r->data) { … }

June 27, 2002 HornstrupCentret 17 Visualization: Kinds of nodes Unique nodes (shown as rectangles) represent single concrete elements of the heap, Summary nodes (shown as cubes) represent sets of nodes that are not distinguishable by the selected observation properties Non-empty lists of nodes (shown as cubes with an additional rectangle at the back)

June 27, 2002 HornstrupCentret 18 Visualization: Abstract Heap the above figure shows the abstract heap; an infinite set of singly linked lists with a set of pointers pointing into this list and some conditions on the minimal lengths of sublists. horizontal arrows are implicitly labelled by the successor in the singly-linked list Dashed self-loops show that we deal with summarized sublists

June 27, 2002 HornstrupCentret 19 Visualization: Partial order The placement on the x-axis indicates the relative value of the represented concrete elements However, not all elements are comparable We need a graphical representation of partial order on nodes, and use ascending chains (shown with patterns) we have two chains x, t1, pl, l, t2, pr x, t1, pl, r suffix

June 27, 2002 HornstrupCentret 20 Visualization: Summary The above graph represents all lists for which the prefix of the list, pointed to by x, up to the element pointed to by pr, is already sorted (the sorted prefix). The next element in the list is pointed to by pointer variable r; it is the one to be inserted in the sorted prefix; the suffix of the list following this element is represented by t3.

June 27, 2002 HornstrupCentret 21 Visualization: Next step What happens in the transition corresponding to the /* P1: */ if (l->data > r->data) assuming it is true? This transition increases the sortedness of the list

June 27, 2002 HornstrupCentret 22 Visualization: Next state There is only one chain, representing the sorted prefix, and the transition, which explains the preservation of the invariant.

June 27, 2002 HornstrupCentret 23 Visualization: Summary Shape analysis starts with a description of all possible inputs and has to compute invariants at all program points, in particular show that the postcondition holds, namely that upon termination the elements are sorted Shape analysis abstracts from the values of data- components. Data structure elements are thus incomparable to start with, but “gain comparability” by abstractly executing conditions.

June 27, 2002 HornstrupCentret 24 Visualization: Summary Invariants do not refer to actual data, but only mention relative sizes Only a partial order on the elements of the data structure is known to the shape analysis. Abstractly executing comparisons may insert elements into chains, i.e. totally ordered subsets of the partial order.

June 27, 2002 HornstrupCentret 25 Conclusion: Current State New approach to algorithm explanation based on compile-time techniques used to automatically generate and visualize invariants The simple example is representative for many similar programs operating on linked lists Our approach involves several steps and only some of them are fully researched; others require additional work. The invariants are pre-computed by shape analysis, implemented in the TVLA system.

June 27, 2002 HornstrupCentret 26 Conclusion: Future Work Current analysis produces too many graphs for the users to traverse. Some of the graphs are redundant for the abstract execution and can be eliminated We need to find appropriate visualizations for various kinds of nodes in shape graphs More theoretical work

June 27, 2002 HornstrupCentret 27 Conclusion: Promises, promises We believe that our research is promising: Automatic generation of invariants; based on observation properties Abstract execution that runs on all input data Focusing on the relevant part of the data structure

June 27, 2002 HornstrupCentret 28 Shape Analysis Shape analysis is concerned with programs operating on heap-based data structures, such as singly and doubly linked lists, trees, etc. To summarize these data structures, use descriptors and Kleene 3-valued logic

June 27, 2002 HornstrupCentret 29 Descriptors Descriptors can be represented as “shapes”, and are called shape descriptors. This representation is a possible visualization of data structures.

June 27, 2002 HornstrupCentret 30 Shape Analysis, cont. Abstract interpretation of program statements operates on shape descriptors Information that is obtained from shape analysis includes: - structural properties of data - local properties of data