Support for Model Checking Z Specifications Maria Ulfah Siregar
Total Page:16
File Type:pdf, Size:1020Kb
Support for Model Checking Z Specifications By: Maria Ulfah Siregar A thesis submitted in partial fulfilment of the requirements for the degree of Doctor of Philosophy The University of Sheffield Faculty of Engineering Department of Computer Science 20 December 2016 Abstract One of deficiencies in the Z tools is that there is limited support for model checking Z specifications. To build a model checker directly for a Z spec- ification would take considerable effort and time due to the abstraction of the language. Translating inputs of a Z specification into a language that an existing model checker tool accepts is an alternative method. Researchers at the University of Sheffield implemented a translation tool which took a Z specification and translated it into the input for the Symbolic Analysis Labo- ratory (SAL) tool, a framework for combining different tools for abstraction, program analysis, theorem proving and model checking, which they called Z2SAL. In this paper, support for model checking Z specifications is dis- cussed, in which the ability of the existing Z2SAL is extended. This support includes a translation for generic constant and schema calculus. Instead of translating these aspects of the Z language into the SAL language as Z2SAL does, a Z specification containing these two notations will be pre-processed, in which a generic constant definition will be redefined to its equivalent ax- iomatic definition, and schema calculus will be expanded to a new schema definition. This paper discusses the implementation of these types of sup- port, and illustration of some working examples. The discussion also includes other several issues related to a new approach in translating Z functions and constants in SAL language, which originates from the type incompatibility obtained during execution by the SAL tool, an approach to a SAL transla- tion of embedded theorems on Z specifications, and a manual experiment on applying an abstraction on Z specifications. Results have been gathered dur- ing our experiments with the implemented support. Several of these results could be translated by Z2SAL and be executed by the SAL tool. Declaration I declare that the composition of this thesis and the work within are entirely my own except where explicitly stated otherwise in the text. This work has not been put forward for any other degree or professional qualification, except as stated. Maria Ulfah Siregar 1 Acknowledgment First, I thank Allah for the guidance to complete this study. Second, I wish to express my gratitude to my supervisor, Prof John Der- rick, who always supports and gives invaluable advice for me throughout this study. Last but not least, I also wish to thank my second supervisor, Dr Siobh´anNorth, who has shown support and encouragement to me during this study. I am much obliged to the Ministry of Religion Affairs of the Indonesia Government for offering and funding my study in the United Kingdom and to UIN Sunan Kalijaga for giving me permission and time to pursue this study. I would like to thank my dear parents and my big family for their love, support and advice. My success in this research is because of their praying. I am incredibly grateful to my husband and our wonderful daughter with- out whom I could have finished this study. Thank you for giving me the motivation I need to undertake this study, being my best friends and patient during my study. I would like to thank my lab mates and DCS staffs and technical support for their assistance throughout my time in this department. Specifically Mathew and Thomas Gyeera who help me in proofreading my thesis, I wish more successful works for you. Also Hanaa and Ermira who encourage me to finish this study, I wish that both of you will finish your study soon. Nina who also supports me to finish this study, I am waiting to hear your happiness when you submit your thesis. Finally, thank you very much for my friends of awardees of MORA Schol- arship 2012 and Indonesian Society in this country, who plays as an extended family, for encouragements and advice. I wish better luck for all of you. 2 Contents 1 Introduction 12 1.1 Research Motivation . 15 1.2 Research Objective and Contribution . 15 1.3 Thesis Structure . 16 1.4 Publications . 18 1.4.1 Peer Reviewed Journal Paper . 18 1.4.2 Peer Reviewed Conference Papers . 18 1.4.3 Posters . 19 2 Background 20 2.1 Formal Methods . 20 2.1.1 Z . 21 2.1.2 VDM . 21 2.1.3 RAISE Specification Language (RSL) . 21 2.1.4 CSP . 22 2.1.5 Conclusion . 22 2.2 The Z Notation . 22 2.2.1 Sets . 23 2.2.2 The First-Order Predicate Logic . 24 2.2.3 Schema Operators . 26 Disjunction . 26 Conjunction . 26 Negation . 27 Implication . 28 Bi-implication . 28 Renaming . 29 Hiding . 29 Schema Composition . 30 Quantification . 31 2.2.4 A Z Notation Example . 32 2.2.5 The Z Tools . 35 3 2.2.6 Conclusion . 38 2.3 Model Checking . 39 2.3.1 The Temporal Logic . 39 2.3.2 Binary Decision Diagram . 44 2.3.3 Introduction to Abstraction . 46 2.3.4 Abstraction on Z Specifications . 47 2.3.5 Conclusion . 48 2.4 The SAL Tools . 49 2.4.1 A Glance at SAL . 49 2.4.2 SAL Components . 52 2.4.3 The SAL Environment . 53 The SAL Model Checker . 53 The SAL Simulator . 57 2.4.4 Conclusion . 60 2.5 The Z2SAL Translator . 61 2.5.1 Introduction . 61 2.5.2 The Current Z2SAL Translator . 63 The #1 Aspect: Generic Constant Definition . 67 The #2 Aspect: Schema Calculus Definition . 71 2.5.3 Conclusion . 73 3 Translation of Embedded Theorems in Z Specifications: A Proposed Method 74 3.1 Adding Theorems in the Generated SAL . 74 3.2 Embedded Theorems on Z Specifications . 76 3.2.1 Proposed Method in a Translation of Embedded The- orems on Z Specifications . 79 3.2.2 Experiment 1: Unique Allocator Specification . 80 3.2.3 Experiment 2: Counter 4 Modulo Specification . 81 3.2.4 Experiment 3: Cars Park Specification . 82 3.2.5 Experiment 4: Birthday Book Specification . 83 3.2.6 Experiment 5: Paper Example Specification . 83 3.2.7 Experiment 6: Shop Specification . 85 3.2.8 Result and Discussion . 85 3.3 Conclusion . 87 4 Implementing A Z Scanner and Parser 88 4.1 A Z Scanner . 89 4.1.1 Introduction . 89 4.1.2 A Lexical Specification . 90 User Code . 90 4 Options and Declarations . 90 Lexical Rules . 90 4.1.3 An Implementation of a Z Scanner . 92 4.1.4 Conclusion . 94 4.2 A Z Parser . 96 4.2.1 Introduction . 96 4.2.2 A YACC Parser . 96 Shift/Reduce Conflict . 98 Reduce/Reduce Conflict . 99 Precedence, Associativity, and Operator Declarations . 99 4.2.3 An Implementation of a Z Parser . 100 The First Conflict . 105 The Second Conflict . 106 The Third Conflict . 107 The Fourth Conflict . 108 The Fifth Conflict . 108 The Sixth Conflict . 109 4.2.4 Conclusion . 109 5 Redefining Generic Constants 111 5.1 Introduction . 111 5.2 A Method for Redefining a Generic Constant . 113 5.3 An Implementation of the Redefinition System . 113 5.3.1 Reading a Z specification . 113 5.3.2 Spotting Generic Constant Definition . 114 5.3.3 Spotting Usages of Generic Constants . 118 5.4 Important Findings around a Redefinition of Generic Constants125 5.5 A Proposed Translation of SAL Function . 126 5.6 Conclusion . 128 6 Expanding Schema Calculus 130 6.1 Introduction . 130 6.2 An Implementation of the Expansion System . 130 6.2.1 Expansion Processes in Java Main Program . 131 6.2.2 Expansion Processes in schConstruction function . 133 An Operator with Two Operands . 135 The First Simplification . 135 The Second Simplification . 136 The First Not Regular Simplification . 137 The Second Not Regular Simplification . 137 An Operator with a Right Operand . 138 5 An Operator with a Left Operand . 138 An Only Operator . 139 An Implication Operator . 140 A Bi-implication Operator . 144 A Negation Operator . 147 Separators in a Schema Calculus Definition . 148 Other Processes . 148 6.2.3 Expansion Processes in operate function . 150 Conjunction and Disjunction . 152 Negation . 152 Renaming . 153 Hiding . 153 Composition . 153 6.2.4 Expansion Processes in expand function . 154 6.2.5 Expansion Processes in normalised function . 155 6.2.6 Expansion Processes in collapse function . 158 6.2.7 Expansion Processes in negateSch function . 161 6.2.8 Expansion Processes in rename function . 162 6.2.9 Expansion Processes in hide function . 164 6.3 Conclusion . 168 7 Integration among the Scanner, the Parser, and Java Pro- grams 171 7.1 Java Main Program . 171 7.2 Reading a Z Specification . 172 7.3 Establishing a Connection Amongst Systems . 177 7.4 Conclusion . 177 8 A Generic Constants Redefinition 179 8.1 Setting up Questions for Evaluation . 179 8.2 Experiments with the Generic Constant Redefinition . 180 8.2.1 Experiment 1: bbook.tex . ..