
Title Modular average case analysis: Language implementation and extension Author(s) Gao, Ang Publication date 2013 Original citation Gao, A. 2013. Modular average case analysis: Language implementation and extension. PhD Thesis, University College Cork. Type of publication Doctoral thesis Rights © 2013, Ang Gao http://creativecommons.org/licenses/by-nc-nd/3.0/ Embargo information No embargo required Item downloaded http://hdl.handle.net/10468/1089 from Downloaded on 2017-02-12T13:10:15Z Modular Average Case Analysis: Language Implementation And Extension Ang Gao A thesis submitted to the National University of Ireland, Cork for the degree of Doctor of Philosophy Department of Computer Science National University of Ireland, Cork Supervisor: Prof. Michel Schellekens Head of Department: Prof. Barry O’Sullivan April 2013 Contents Contents i List of Figures vi List of Tables ix List of Listings x Declaration xii Dedication xiii Acknowledgements xiv Abstract xvi 1 Introduction 1 1.1 Introduction.............................. 2 1.2 Researchtopics ............................ 4 1.2.1 MOQA language design and interpreter implementation . 4 1.2.2 Parallel Extension of MOQA ................ 5 1.2.3 Exploring MOQA applications . 6 1.3 Researchcontributions . 8 1.4 Dissertationstructure. 9 2 Background 11 2.1 Introduction.............................. 12 i CONTENTS 2.2 Static Average Case Analysis of Algorithms . 12 2.2.1 Static Program Analysis . 12 2.2.1.1 Data Flow Analysis . 12 2.2.1.2 Abstract Interpretation . 13 2.2.1.3 Symbolic Analysis . 14 2.2.2 Time Analysis of Programs . 14 2.2.3 MOQA Approach to Static Average Case Analysis . 15 2.3 A Review of MOQA Theory .................... 16 2.3.1 Timing Compositionality . 16 2.3.1.1 Worst-Case . 17 2.3.1.2 Average-Case . 18 2.3.2 MOQA DataStructures. 18 2.3.2.1 Partial Orders and Labelled Partial Orders . 19 2.3.2.2 RandomStructure/RandomBag . 22 2.3.2.3 Randomness Preserving . 25 2.3.3 MOQA BasicOperations . .. 28 2.3.3.1 MOQA Split . 28 2.3.3.2 MOQA Product.................. 31 2.3.3.3 MOQA Top/Bot ................. 36 2.3.3.4 MOQA Percolation . 37 2.4 Relatedwork ............................. 39 2.5 Summary ............................... 43 3 MOQA Language Design 44 3.1 Introduction.............................. 46 3.2 MOQA LanguageOverview. 46 3.2.1 Motivations and Design Goals . 47 3.2.2 Domain Specific Language . 48 3.2.3 WhyPython ......................... 49 3.2.4 Running MOQA ....................... 50 3.2.4.1 Execution Mode . 51 3.2.4.2 Analysis Mode . 52 3.3 MOQA LanguageSyntax ...................... 54 ii CONTENTS 3.3.1 Lexical Conventions . 55 3.3.1.1 Comments . 55 3.3.1.2 Identifiers . 55 3.3.1.3 Keywords . 55 3.3.1.4 Primitive Types . 56 3.3.2 Labelled Partial Order . 56 3.3.3 MOQA LanguageGrammar . 57 3.3.3.1 Structure of a MOQA Program ......... 58 3.3.3.2 Variable Declarations . 58 3.3.3.3 Function Definition . 59 3.3.3.4 Expression . 60 3.3.4 Scopes............................. 67 3.3.5 MOQA LanguageSyntaxSpecification . 67 3.4 MOQA LanguageTypeSystem. 69 3.4.1 TypeEnvironments. .. 69 3.4.2 Type Checking Rules . 71 3.5 MOQA LanguageSemantics . 78 3.5.1 MOQA ExecutionSemantics . 79 3.5.2 MOQA Analysis Semantics . 88 3.6 MOQA Programming Restrictions . 97 3.7 Summary ............................... 97 4 MOQA Language Implementation 99 4.1 PythonLex-Yacc ........................... 100 4.2 MOQA InterpreterArchitecture . 101 4.3 Lexer.................................. 104 4.4 Parser ................................. 104 4.5 Environment Implementation . 108 4.6 TypeChecker ............................. 109 4.7 ExecutionEngine ........................... 111 4.8 Analysis Engine . 115 4.8.1 Dynamic programming in ACETAnalysis .......... 117 4.9 Summary ............................... 127 iii CONTENTS 5 MOQA Programming Examples and Evaluation 128 5.1 Insertionsort.............................. 129 5.2 Quicksort ............................... 131 5.3 Quickselect .............................. 133 5.4 Mergesort ............................... 136 5.5 TreapGen ............................... 137 5.6 Treapsort ............................... 141 5.7 Heapify ................................ 143 5.8 Summary ............................... 147 6 Parallel Extension of MOQA 148 6.1 Introduction.............................. 149 6.2 RelatedWork ............................. 150 6.3 Overview of Multithreaded Program Analysis . 151 6.4 MOQA TheoryExtension. .. 153 6.5 Experimentation and Evaluating a Practical Example . 155 6.5.1 Experiment Result . 157 6.6 Summary ............................... 160 7 Applications of MOQA 162 7.1 RandomBagPreservation forHeap Algorithms . 163 7.1.1 BinaryHeap.......................... 164 7.1.2 LeonardoHeap ........................ 165 7.1.3 SkewHeap........................... 169 7.1.4 Min-Max Heap . 172 7.2 Complexity and Entropy based on MOQA ............ 176 7.2.1 Average Case Analysis of Treap Insertion . 176 7.2.2 Entropy Analysis based on Random Bags . 180 7.2.3 Tracking Entropy Changes in Sorting Algorithms . 183 7.3 Reversible Computing for MOQA ................. 189 7.3.1 Background .......................... 189 7.3.2 Reversible Split Operation . 190 7.3.3 Reversible Quicksort . 196 iv CONTENTS 7.4 Smoothed Analysis for MOQA ................... 200 7.5 Summary ............................... 204 8 Conclusions and Future Work 207 8.1 Conclusions .............................. 208 8.2 FutureWork.............................. 210 8.2.1 From An Application Perspective . 210 8.2.2 From A Theoretical Perspective . 212 A MOQA Language 213 A1 MOQA LanguageSyntaxSpecification. 214 A2 MOQA LanguageLexer....................... 216 A3 MOQA LanguageParser ...................... 219 B 227 B1 Approximation Timing for the Merge Operation . 228 References 230 v List of Figures 2.1 An example of a Hasse diagram with node set X = {a, b, c, d, e} . 20 2.2 AnexampleofSP-order ....................... 21 2.3 An example of LPO with labelling function F = {a 7→ 5, b 7→ 3,c 7→ 4,d 7→ 2, e 7→ 1} ........................ 22 2.4 An example of order-isomorphic data-labellings with the label set L = {1, 2, 3} .............................. 23 2.5 An example of random structure with the label set L = {1, 2, 3, 4, 5} 24 2.6 A size four heap random structure with label set L = {1, 2, 3, 4} . 26 2.7 Resulting size three heap random structure . 26 2.8 Isolatedsubsetsexample . 27 2.9 MOQA Split over a LPO....................... 29 2.10 MOQA Split over a discrete random structure R(∆3) with label set L = {1, 2, 3} ............................ 29 2.11 Split on list of size n ......................... 31 2.12 Productoftwopartialorders . 32 2.13 Illustration of steps involved in executing the MOQA Product operation ............................... 33 2.14 An example of the MOQA Top operation ............. 37 2.15 An example of the MOQA PercM operation . 38 3.1 sample.moqaoutput1 ........................ 52 3.2 sample.moqaoutput2 ........................ 53 3.3 sample.moqaACEToutput . 54 3.4 MOQA LanguageTypeSystem. 58 vi LIST OF FIGURES 4.1 MOQA InterpreterArchitecture . 102 4.2 MOQA abstractsyntax treeclass hierarchy . 105 4.3 Abstract syntax tree for MOQA Quicksort ............ 106 4.4 Interpreter analysis engine Flowchart . 116 4.5 MOQA analysis library class diagram . 122 4.6 Series SPPO creation example . 124 5.1 MOQA Treapcreationexample. 139 5.2 Treapgen algorithm maps R(∆3) to random bag T REAP(3) . 140 5.3 Treapsort example on a four element treap. 142 5.4 Heapifyexampletocreateafournodeheap. 144 6.1 A dag representation of a multithreaded program execution. Each vertex is a strand, edges represent strand dependencies. .. 152 6.2 A comparison of average time execution between different core amounts and how ACEST and ACEWT bounds the times. Green represents the sequential execution time. 159 6.3 A comparison of the obtained speedup differences for core amounts compared to sequential execution and the theoretically obtained values ................................. 160 7.1 Leonardo tree examples: Lt0, Lt1, Lt2, Lt3 .............. 167 7.2 EightnodesLeonardoHeapexample . 167 7.3 Leonardo Heap creation example with input List L = [3, 1, 4, 2] . 169 7.4 Leonardo Heap creation: random preserving contour example . .. 169 7.5 Skew Heap creation example: length three random list . 172 7.6 Min-Max heap built from input list [3, 5, 1, 2, 6, 4] ......... 173 7.7 MOQA Min-Max heapify on input list [3,5,1,2,6,4] . 174 7.8 One possible partial order generated by Min-Max heapify ..... 175 7.9 Result of random insertion on MOQA T REAP(3)........ 178 7.10 Bottom-up Mergesort example: first five merge operations . .. 185 7.11 Mergesort recursion tree on list size eight . 186 7.12 Forward and reverse split on random list [x,f,m,g,q,s,b,t,p,z]. 195 vii LIST OF FIGURES 7.13 MOQA Smoothed Analysis of Quicksort with input list size 50 on differentdegreesofperturbation . 205 viii List of Tables 2.1 worst-case IO-compositionality counter example . 17 3.1 MOQA language LPO operations ................. 57 5.1 Insertionsort: comparing the theoretical result with the interpreter result.................................. 131 5.2 Quicksort: comparing the theoretical result with the interpreter result.................................. 133 5.3 Quickselect: comparing the theoretical result with the interpreter result.................................. 136 5.4 Mergesort: comparing the theoretical result with the interpreter result.................................. 138 5.5 Treapsort: comparing the theoretical result
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages258 Page
-
File Size-