Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD...

113

Transcript of Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD...

Page 1: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Ákos Dávid

Veri�cation of Component-Based Software with ModelChecking

Ph.D. Thesis

Supervisor: Dr. László Kozma C.Sc.

Eötvös Loránd University of Sciences

Foundations and Methodology of Informatics Ph.D. ProgramProf. János Demetrovics D.Sc.

Ph.D. School of Computer ScienceProf. András Benczúr D.Sc.

Budapest2012

Page 2: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Acknowledgments

� First and foremost, I owe my most sincere gratitude to my supervisor andmentor, Dr. László Kozma C.Sc. for the continuous support of my Ph.D. studyand research, for his patience, motivation and immense knowledge.

� I would like to express my sincere gratitude to Prof. Em. László Varga D.Sc.as well, who gave me the opportunity to work with him, which has been ofgreat value in this study.

� My sincere thanks are due to Dr. Zoltán Süle Ph.D. for teaching me the foun-dations of LaTeX, and providing editing assistance later on.

� My special thanks goes to Dr. Ildikó Hortobágyi Ph.D. for providing me withadvice at times of critical need and proofreading my thesis.

� I wish to thank János Csatári for his help with the implementation of our toolsupporting the OIMC algorithm.

� I must also acknowledge Tibor Volánszki for his help with the quality graphicsin this document.

� I wish to extend my warmest thanks to my colleagues working for the Facultyof Information Technology at the University of Pannonia for their guidance, ex-pertise and constructive comments, and for providing an inspiring atmospherethroughout my studies and research.

� I would also like to thank my parents for their ongoing support and motivationthroughout my life.

� Last but not least, my loving thanks go to my wife and children for theircontinuous support and patience during my studies and research. Withouttheir encouragement and understanding it would have been impossible for meto �nish this thesis.

� This research project was supported by the European Union and co-�nanced bythe European Social Fund (grant agreement no. TAMOP 4.2.1./B-09/1/KMR-2010-0003).

Page 3: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Contents

1 Background 11.1 Component based software development . . . . . . . . . . . . . . . . 1

1.1.1 Component library . . . . . . . . . . . . . . . . . . . . . . . . 11.1.2 Component models . . . . . . . . . . . . . . . . . . . . . . . . 21.1.3 Software architecture . . . . . . . . . . . . . . . . . . . . . . . 3

1.2 Software veri�cation challenges in Component-Based Software Devel-opment (CBSD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2.1 Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2.2 Testing and proving methods . . . . . . . . . . . . . . . . . . 51.2.3 Synthesis methods . . . . . . . . . . . . . . . . . . . . . . . . 71.2.4 Model checking . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.3 Temporal logics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.3.1 Syntax of Linear Temporal Logic (LTL) . . . . . . . . . . . . 101.3.2 Semantics of LTL . . . . . . . . . . . . . . . . . . . . . . . . . 111.3.3 Syntax and semantics of Computational Tree Logic (CTL) . . 12

1.4 Basic concepts of model checking . . . . . . . . . . . . . . . . . . . . 121.4.1 Model checking tools . . . . . . . . . . . . . . . . . . . . . . . 131.4.2 Open Incremental Model Checking . . . . . . . . . . . . . . . 14

1.5 On the correctness of data type classes based on contracts . . . . . . 151.5.1 Basic notions . . . . . . . . . . . . . . . . . . . . . . . . . . . 161.5.2 Case study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201.5.3 Applying the results in CBSD . . . . . . . . . . . . . . . . . . 23

1.6 The structure of the thesis . . . . . . . . . . . . . . . . . . . . . . . . 24

2 On the granularity of components 242.1 The need for an educational framework . . . . . . . . . . . . . . . . . 242.2 Granularity supported by synthesis methods . . . . . . . . . . . . . . 27

2.2.1 Producer � Consumer Problem (coarse) . . . . . . . . . . . . . 282.2.2 Producer � Consumer Problem (�ne) . . . . . . . . . . . . . . 292.2.3 General extension of the Producer � Consumer Problem . . . 302.2.4 A variant of the Producer - Consumer Problem . . . . . . . . 31

2.3 The general version of the Producer � Consumer Problem modeled inNuSMV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

2.4 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

3 On the model checking of a system consisting of many similar com-ponents 353.1 Motives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353.2 A simple method proposed . . . . . . . . . . . . . . . . . . . . . . . . 363.3 A sample system: Airport . . . . . . . . . . . . . . . . . . . . . . . . 37

3.3.1 Airport model (with one tower and one airplane) . . . . . . . 37

i

Page 4: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

3.3.2 Airport model (with one tower and more airplanes) . . . . . . 393.4 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

4 Extending systems with veri�ed components 434.1 Scalability issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434.2 An example: Automatic Betting Machine . . . . . . . . . . . . . . . . 444.3 Veri�cation of the system . . . . . . . . . . . . . . . . . . . . . . . . . 464.4 Extending the sample system with multiple terminals . . . . . . . . . 484.5 Another sample system: An Airport . . . . . . . . . . . . . . . . . . . 51

4.5.1 The basic version . . . . . . . . . . . . . . . . . . . . . . . . . 514.5.2 A (faulty) variant of the airplane . . . . . . . . . . . . . . . . 524.5.3 A correct solution improved with Open Incremental Model

Checking (OIMC) . . . . . . . . . . . . . . . . . . . . . . . . . 534.6 Comparing OIMC with our method . . . . . . . . . . . . . . . . . . . 564.7 JanKo, a tool supporting the use of OIMC . . . . . . . . . . . . . . . 574.8 Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594.9 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

5 Formal veri�cation of network protocols 605.1 The relationship between formal methods and protocols . . . . . . . . 61

5.1.1 Formal veri�cation of protocols . . . . . . . . . . . . . . . . . 625.1.2 Formal veri�cation methods . . . . . . . . . . . . . . . . . . . 62

5.2 Characteristics related to routing protocol veri�cation . . . . . . . . . 635.3 An example: the Open Shortest Path First routing protocol . . . . . . 635.4 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

6 Related works 73

7 Conclusion 77

8. Összefoglalás 80

A The source code of JanKo 91A.1 Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

A.1.1 Binary.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91A.1.2 CTL.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91A.1.3 Unary.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

A.2 Formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92A.2.1 Formula.java . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

A.3 Graphical User Interface (GUI) . . . . . . . . . . . . . . . . . . . . . 93A.3.1 ComparePanel.java . . . . . . . . . . . . . . . . . . . . . . . . 93A.3.2 GUI.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97A.3.3 MyTextArea.java . . . . . . . . . . . . . . . . . . . . . . . . . 99A.3.4 SplitterPanel.java . . . . . . . . . . . . . . . . . . . . . . . . . 99

ii

Page 5: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

A.4 Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102A.4.1 Logic.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

A.5 Main . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105A.5.1 Runner.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

iii

Page 6: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

List of Abbreviations

ABM Advanced Betting Machine

BDD Binary Decision Diagram

BDR Backup Designated Router

BMC Bounded Model Checking

CBSD Component-Based Software Development

CCM CORBA Component Model

CEO Chief Executive O�cer

CMC Compositional Model Checking

COM Component Object Model

COM+ Component Object Model Plus

COTS Components O�-The-Shelf

CTL Computational Tree Logic

DBC Design-By-Contract

DCOM Distributed Component Object Model

DD Database Description

DMZ Demilitarized Zone

DR Designated Router

EJB Enterprise Java Beans

FGS Flight Guidance System

FSM Finite State Machine

GUI Graphical User Interface

IDL Interface De�nition Language

IDS Intrusion Detection System

IETF Internet Engineering Task Force

IGP Interior Gateway Protocol

iv

Page 7: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

IOS Internetwork Operating System

IPS Intrusion Prevention System

IT Information Technology

ITL Interval Temporal Logic

JIT Just-In-Time

JPF Java Path Finder

LSA Link-State Advertisement

LSDB Link-State Database

LSR Link-State Request

LSU Link-State Update

LTL Linear Temporal Logic

MTS Microsoft Transaction Server

NBMA Non-Broadcast Multi-Access

OIMC Open Incremental Model Checking

OMG Object Management Group

OOP Object-Oriented Programming

OSPF Open Shortest Path First

PAT Process Analysis Tool

RFC Request For Comments

RIP Routing Information Protocol

SAL Symbolic Analysis Laboratory

SAT Satis�ability Problem

SME Small and Medium Enterprise

SMV Symbolic Model Veri�er

SPIN Simple Promela Interpreter

SSH Secure Shell

v

Page 8: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

STM State Transition Model

UML Uni�ed Modeling Language

XML Extensible Markup Language

vi

Page 9: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

1 Background

1.1 Component based software development

In today's fast-paced world the opportunities to use conventional software engineer-ing methods like for instance the waterfall-approach are considerably diminishing.The looming deadlines force application developers to work in parallel on smallerprojects. As a consequence, it is necessary for those projects to be handled inde-pendently of each other [106]. This concept led to the emergence of CBSD methods[26, 61, 72, 109, 113, 115, etc.]. Component-Based Software Development buildsaround two basic concepts [56]:

� Reuse, which means the use of preexisting software with or without modi�ca-tions.

� Evolution, which keeps the costs of a highly componentized system low byenabling the replacement of certain components without a�ecting the func-tionality of other parts.

There are three conditions that need to be satis�ed in order to use the driving forcesof reuse and evolution for developing component-based systems:

� Component library

� Component model

� Software Architecture

These will be discussed in the following subsections.

1.1.1 Component library

Undoubtedly, Component-Based Software Development has recently become the ul-timate software development method for building large and complex systems. Anattractive advantage of CBSD over traditional software engineering methods is thatdevelopers are not forced to lean exclusively on their own software products but theycan borrow the domain knowledge of other experts by using third-party componentssometimes referred to as Components O�-The-Shelf (COTS). The de�nition andclassi�cation of COTS can be found in [87]. This seems to presuppose speeding upthe development process of large and complex systems, but meanwhile it raises thequestion how reliable these components will be in their new environment. Since mostcomponents are designed for generic purposes in the spirit of reusability, it is ratherdi�cult to �nd a way to ensure that a system built by integrating components isworking properly. The related problems and their possible solutions will be discussedin the following sections. The basic concept of CBSD is the component, which can

1

Page 10: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

be de�ned as follows: �A software component is a physical packaging of executablesoftware with a well-de�ned and published interface.� [56] Although there are severalother de�nitions used [6, 26, 109, etc.], in this thesis a component is considered apart of a sequential or parallel program. Reuse is one of the focal points in CBSD.Unfortunately, software developers still tend to write new components for a givenproblem domain rather than integrating already existing ones into a system. Themain reason for that, according to Michael Sparling, is that experts insist on thetraditional measure of productivity, which is the number of code lines [106].That is why the author considers it important to provide a component library for theeducational framework in which future Information Technology (IT) experts shouldfocus on integrating the available components into a system instead of producingpractically an in�nite number of code lines.In the following subsections a brief description will be given for each veri�cationmethod used in our framework because the component library will contain onlyveri�ed components for a given speci�cation in a particular environment.

1.1.2 Component models

In the following subsections a brief overview of the three most widespread componentmodels in the commercial area is given [3].

CORBA Component Model (CCM) CORBA is a standard developed by theObject Management Group (OMG) which provides an infrastructure for programs ofdi�erent companies to work together [25]. CCM is a speci�cation that focuses on thestrength of CORBA as a server-side object model. It concentrates on issues that mustbe addressed to provide a complete server-side middleware component model. It canbe described as a cross-platform, cross-language superset of Enterprise JavaBeans.The CCM gives developers the ability to quickly build web-enabled enterprise-scalee-commerce applications while leveraging the industrial strength of CORBA. Tightintegration with Enterprise Java Beans (EJB) leverages CORBA's cross-platformand multiple-language capabilities.

Microsoft component models A few years ago Microsoft introduced an entirefamily of software technologies to support developers to create reusable softwarecomponents, to link components together to build applications, and to take advan-tage of Windows services [24]. The Microsoft Transaction Server (MTS) is built onthe Distributed Component Object Model (DCOM) and brings in mainframe-liketransactional reliability to the PC-world following a �write one, run many� strat-egy. Developers use MTS to deploy scalable server applications built from Com-ponent Object Model (COM) components, focusing on solving business problemsinstead of programming application infrastructure. The Component Object ModelPlus (COM+) is the latest version of MTS. Collectively, the services that supportCOM and .NET component-based applications are known as COM+ Component

2

Page 11: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Services, or simply as COM+. The most important services provided by COM+deal with administration, Just-In-Time (JIT) activation, object pooling, transac-tions, synchronization, security, queued components and events.

Enterprise Java Beans Enterprise JavaBeans provides a fully-scalable, distributedand cross-platform architecture to support the communication between softwarecomponents [43]. What is more, the components can not only run on any platformbut they are also completely portable across any vendor's EJB component executionsystem. The EJB environment automatically maps the components to the underly-ing vendor-speci�c execution services.

1.1.3 Software architecture

In [7] software architecture is de�ned in the following way: �The software architectureof the program or computing system is the structure or structures of the system,which comprise software elements, the externally visible properties of those elements,and the relationships among them.� The importance of software architecture can besummarized based on three reasons:

� It provides a high level abstraction of a system, which can be used for com-munication between the stakeholders.

� It also represents the earliest design decisions (which can be analyzed) thatdetermine the rest of the development process, the deployment and the main-tenance of a system.

� The abstraction of a system does not only show the structure of the systemand the interaction between its elements but is also transferable to other sys-tems with similar quality and functional properties, which thus promotes theconcept of reuse in large and complex systems.

There are numbers of research projects dealing with the theory of modeling dis-tributed systems and automated analysis of high-level state-based models usingstate-space exploration techniques such as model-checking [47, 54, 96, 101, etc.].The author studies the possibility of applying the theory of algebraic structure ofinterfaces in practice during the assembly phase of the development process in orderto improve the quality of a system built from veri�ed components. A new variantof the generally used Uni�ed Modeling Language (UML) that is able to supportdistributed objects and components is recommended to model component-basedsystems [64].

3

Page 12: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

1.2 Software veri�cation challenges in CBSD

1.2.1 Contracts

Component-Based Software Development is ideally not more than putting piecestogether. On the one hand traditional software development approaches make itpossible for system developers to pre-check the compatibility of the individual partsof the system before the actual integration process takes place because in mostcases the environment of the development and the deployment are the same. Onthe other hand, CBSD uses an approach assuming that the original deploymentenvironment of a component and its new deployment environment into which it isgoing to be integrated may be considerably di�erent from each other. Even if thenew environment is the same or similar, the component can be used in di�erent,still undiscovered ways, which lack any kind of validation concerning the originalpurpose it was meant to be used.However, Component-Based Software Development would not be considered a revo-lutionary step in today's software development technologies if � compared to tradi-tional techniques � the use of prefabricated components could lead to such a majorsetback during the integration process.Then what is the use of verifying the individual components if all information ontheir correctness becomes irrelevant and obsolete from the moment they are usedanywhere but in the original environment? The answer is based on the idea of build-ing correct programs with built-in reliability. This means that the correctness prop-erties of a program may be transferable or at least checkable in other environmentsas well. The concept behind that is the method of �Design-By-Contract (DBC)�introduced by Bertrand Meyer in Object-Oriented Programming (OOP) [83]. Hisde�nition for the contracts is that they are �formal agreements expressing eachparty's rights and obligations�.According to him, de�ning a precondition and a postcondition for a routine is a wayto de�ne a contract that binds the routine and its callers. The notion of contracts isnow extended to components where di�erent reuse and deployment considerationsbecome important, parameterizing the pre- and postconditions of components' con-tracts. This extension was proposed by Reussner and others and was referred to asparameterized contracts according to the �architecture-by-contract� principle [97].The idea of using contracts in combination with built-in testing technologies ac-cording to Hans Gerhard Gross would o�er a long-waited solution to increase ourcon�dence in third-party components [51].Built-in testing usually refers to all additional information with the exception ofthe code of a component for checking assertions and conditions at runtime. Built-intesting is usually not part of the original functional requirements of a componentand it does not stay incorporated in the code after the release of a component, butthe author in [51] argues that components should be developed with permanentbuilt-in testing capabilities from the beginning.Built-in contract testing is based on the notion of providing individual components

4

Page 13: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

with the ability to be checked by their execution environment at runtime. Whenevera component is deployed in a new environment, its built-in contract test part is goingto check whether the component, the partner components and the environment likeeach other. The meta information in contracts can clarify at which level and for whatpurposes they can be used. Beugnard et al. di�erentiate four levels of increasinglynegotiable properties [13]:

� Basic contracts (a syntactic contract) are speci�ed either at the programminglanguage level or through some Interface De�nition Language (IDL) providedby the component platform.

� Behavioral contracts de�ne the overall functionality of a component in termsof pre- and postconditions of operations and externally visible provided andrequired state transitions.

� Synchronization contracts add another dimension to the behavioral contractby providing the necessary information to coordinate the interdependent op-erations.

� Quantitative contracts or quality-of-service contracts quantify the expectedbehavior or the component interaction in terms of minimum and maximumresponse delays, average response, quality of a result.

The last category would help to compare di�erent components built for the samepurpose but with di�erent component models by using measurable data. Accordingto Hans Gerhard Gross [51], it is not only feasible but also desirable to combinethese testing techniques with modeling based on UML diagrams.So there must be an environment � which must be a framework � in which this canbe done [46, 47, 64, 70, 96, etc.]. There are several de�nitions of frameworks. Thispaper considers them �a skeleton of an application which can be customized by anapplication developer� [61]. The relationship between frameworks and componentsis also important. In [26] a component is identi�ed as �an atomic part that canbe used (and not changed) within the framework�. Unfortunately, even today mostsystem developers consider writing an application from scratch a greater challengeand therefore a greater recognition for them than developing an application usingpreexisting software components.A similar framework (CDT) was developed by the authors of [11]. However, theirframework is focusing primarily on the testability of third-party components whichoutlines a possible solution that uses the Extensible Markup Language (XML) anddoes not contain any educational aspects.

1.2.2 Testing and proving methods

The general process of testing can be seen in Figure 1. Today's most widely usedtechniques of testing proved to be insu�cient to verify large and complex systems,

5

Page 14: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 1: Testing (Activity Diagram)

because they are unable to guarantee that there are no more hidden errors leftin the design or in the code [19, 48, 53, 103, etc.]. Component-based applicationsare generally distributed systems, so the testing of such systems is extremely com-plicated. Testing of a component-based solution consists of two distinct activities:testing of the components and an integration testing of the assembled application.A system cannot be considered correct if its components do not work properly. Asa component is a standalone, physical package of software, it is supposed to betested independently. However, Michael Sparling [106] points to the problem thata component can only be tested through a user interface or a �virtual test bench�.Unfortunately, developing a user interface usually takes as much time as developingthe component itself. On the other hand, developing test benches for all componentmodels also seems to be complicated.A possible solution to the problems above can be contract testing [51, 83, 97, etc.]discussed later in Section 1.5.Moreover it is almost or completely impossible to detect timing errors in a system,which is the main reason why in recent years the approach of formal veri�cationappeared as an alternative to testing [78]. However, new testing methods (staticand dynamic slicing, etc.) are also developed to handle the problems above [12].

6

Page 15: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

While testing explores some of the possible behaviors and scenarios of the system,formal veri�cation performs an exploration of all possible behaviors. The generalproblem of correctness methods based on Classical Logic is that time cannot beused explicitly in the speci�cation. Therefore, it is rather di�cult or impossible toexpress time-dependent properties of concurrent programs in that case [91].Deductive veri�cation normally refers to the use of axioms and proof rules to provethe correctness of a system, but unfortunately it is usually time-consuming and canonly be performed by mathematicians or logicians. As a consequence this method israther unusable in practice, especially for the veri�cation of large systems. Veri�ca-tion methods based on Temporal Logic can help to overcome those problems [66, 93,etc.].

1.2.3 Synthesis methods

The derivation methods of a correct concurrent program reverse the steps employedin constructing an assertional proof of a given concurrent program. Di�erent kindsof synthesis methods are based on di�erent kinds of speci�cation tools, ClassicalLogic and Temporal Logic [44, 77, 69, etc.]. A concurrent program consists of pos-sible non-deterministic sequential programs called processes. Those processes canshare objects with each other or they can interact exclusively through well-de�nedinterprocess input/output operations. It is an important question how to synthesizeparallel or concurrent programs for some problems to be solved. There are severalsystematic ways for synthesizing concurrent programs meeting a given speci�cation.The frameworks of those derivation procedures are based on di�erent mathematicaltools: Predicate Logic [69], Temporal Logic [44, 52, 77, etc.] or UNITY Logic [18, 57,etc.], etc.

The process of program synthesis can be seen in Figure 2.The early approaches of synthesis method based on Temporal Logic speci�cation arethe re�nements of the general model in Figure 2. The main steps are the following:

� Specify each process of a system separately. It makes the speci�cation taskeasier.

� Generalization. Modify the speci�cations so that they refer to the global se-quence of operations executed in the system of processes.

� Apply the Satis�ability Algorithm to obtain the model graph.

� Check whether Unwinding is necessary to satisfy eventualities.

� Generate the individual processes [77].

At the end of the second step a global speci�cation of the problem is given. TheSatis�ability Algorithm uses a tableau method to decide whether a set of temporalformulas is satis�able or not. The problem is that the number of nodes in the resulted

7

Page 16: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 2: Program synthesis (Activity Diagram)

model graph is at most 24K , where K is the length of the formula to be tested. Thus,the earliest approach to synthesis su�ers from the state explosion problem.The same problem exists if branching time Temporal Logic is used to synthesizesynchronization skeletons of concurrent programs [44]. If we had a �nite but arbi-trary large number N of individual processes and each of them had only two localstates, the global state transition diagram would contain 2N global states. Attie andEmerson proposed synthesis methods to overcome this state explosion problem in[5], but their methods can only be applied to a narrow problem domain.

1.2.4 Model checking

Model checking, on the other hand, is an automatic technique for verifying �nitestate concurrent systems [9, 23, 88, etc.]. It has a number of advantages over tradi-tional approaches. It is su�cient for the user to provide a high level representationof the model and the speci�cation to be checked, so no veri�cation expert is needed.The procedure normally uses an exhaustive search of the space of a system to eitherterminate with the answer true, indicating that the model satis�es the speci�cation,or give a counterexample that may provide an important clue in �nding subtle er-rors in complex systems. The procedure is also quite fast, even on moderate-sizedcomputers. In some cases in�nite systems may be veri�ed using model checking incombination with various abstraction and induction principles [75]. Finally, the logicused for speci�cations can directly express many of the properties that are needed forreasoning about concurrent systems. Temporal Logic makes it possible to describe

8

Page 17: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 3: Model checking (Activity Diagram)

how the behavior of a system evolves over time.The process of model checking consists of three main tasks [23]:

� The �rst task is modeling, that is to convert a design into a formalism acceptedby a model checking tool. In order to reduce the resources needed, the modelingof a design may require the use of abstraction to eliminate irrelevant details.

� The second step is speci�cation, where it is necessary to state the propertiesthat the design must satisfy. The speci�cation is usually given in some logicalformalism.

� The third task is veri�cation, which is ideally completely automatic. In prac-tice, human assistance is usually needed to analyze the results.

The main challenge in model checking is dealing with the state space explosionproblem. This problem occurs in systems with many components that can make

9

Page 18: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

transitions in parallel. During the past ten years considerable progress has beenmade in dealing with this problem [54, 84, 101, etc.]. Much of the increase has beendue to the use of Binary Decision Diagrams (BDDs), a data structure for representingBoolean functions. The process of model checking can be seen in Figure 3.This research can result in the better use of formal methods in practical applica-tions, the better understanding of speci�cations, and �nally less debugging work fordevelopers who could easily misinterpret speci�cations.

1.3 Temporal logics

The speci�cations of component-based systems can be expressed with several di�er-ent temporal logic languages � e.g. Interval Temporal Logic (ITL), CTL, LTL withPast Tense operators, CTL* (a superset of the previous two) � but in this thesis weare focusing on the ones supported by most model checkers and discussed in a widebody of literature. In the following subsections the syntax and semantics of LTL arede�ned based on the intuitive description in [17].

1.3.1 Syntax of LTL

The logic LTL is a linear temporal logic, meaning that the formulas are interpretedover in�nite sequences of states. A minimal syntax for LTL formulas can be givenin the following way. Given the non-empty set of atomic propositions (AP ), an LTLformula is:

• true, false or p where p ∈ AP

• ¬f1, f1 ∨ f2, Xf1 (read �next time�) or f1 U f2 (read �until�) where f1 and f2

are LTL formulas

For describing real-world problems it is often necessary to use a non-minimal versionof the LTL syntax. Given the set AP , an LTL formula is:

• true, false or p where p ∈ AP

• ¬f1, f1 ∨ f2, f1 ∧ f2, Xf1, f1 U f2 or f1 R f2 (read �f1 releases f2�, meaningf2 is either always true, or f2 is true until f1 ∧ f2 is true) where f1 and f2 areLTL formulas

• Past temporal operators: Y f1 (read �previously�), Hf1 (read �historically�or �always in the past�), Of1 (read �once�) or f1 S f2 (read �f1 since f2�) wheref1 and f2 are LTL formulas

Some often used temporal logic shorthands are:

• Ff1 = true U f1 (read ��nally f1�)

• Gf1 = ¬F¬f1 (read �globally f1�)

10

Page 19: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

1.3.2 Semantics of LTL

A path π is an in�nite sequence of states π = s0, s1, s2, . . . where (si, si+1) ∈ R (anS×S transition relation) holds for all i ≥ 0. (π, si) |= f denotes that an LTL formulaf holds in a world (π, si), in other words (π, si) is a model of the formula f . Modelchecking refers to the process of checking whether the behaviors of the system aremodels of the speci�cation formulas. The relation (π, si) |= f is de�ned inductivelyas follows:

• (π, si) |= true

• (π, si) 6|= false

• (π, si) |= p i� p ∈ L(si) where p ∈ AP and L is a function labeling each siwith the atomic propositions holding

• (π, si) |= ¬f1 i� not (π, si) |= f1

• (π, si) |= f1 ∨ f2 i� (π, si) |= f1 or (π, si) |= f2

• (π, si) |= f1 ∧ f2 i� (π, si) |= f1 and (π, si) |= f2

• (π, si) |= Xf1 i� (π, si+1) |= f1

• (π, si) |= f1 U f2 i� for all j ≥ i (π, sj) |= f1 or there is j ≥ i such that(π, sj) |= f2 and for all i ≤ k < j, (π, sk) |= f1

• (π, si) |= f1 R f2 i� for every j ≥ i (π, sj) |= f2 or there is j ≥ i that(π, sj) |= f1 ∧ f2 and for every i ≤ k < j (π, sj) |= f2

If necessary, we can also express the semantics of Ff1 and Gf1 directly:

• (π, si) |= Ff1 i� there is j ≥ i, that (π, sj) |= f1

• (π, si) |= Gf1 i� for all j ≥ i, (π, sj) |= f1

The semantics of the past temporal operators can also be expressed:

• (π, si) |= Y f1 i� (π, si−1) |= f1 where i > 0

• (π, si) |= Hf1 i� for all 0 ≤ j ≤ i (π, sj) |= f1

• (π, si) |= Of1 i� there is 0 ≤ j ≤ i such that (π, sj) |= f1

• (π, si) |= f1 S f2 i� for all 0 ≤ j ≤ i (π, sj) |= f1 or there is 0 ≤ j ≤ i suchthat (π, sj) |= f2 and for all j < k ≤ i, (π, sk) |= f1

11

Page 20: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

1.3.3 Syntax and semantics of CTL

The syntax of CTL is slightly di�erent as the use of Past Tense operators is notallowed, and the language is expanded with existential and universal quanti�ers formore expressive power. The semantics of CTL can be de�ned analogously [17, 44,etc.].

1.4 Basic concepts of model checking

Model checking is an algorithmic way of verifying software systems formally [9, 23,88, etc.]. This can be done automatically by verifying whether a speci�c model meetsthe expectations of a formal speci�cation. The speci�cation is usually available as aset of temporal logic formulas describing given properties of a system.The model is preferably given as a source code description in a special-purpose lan-guage. Such a program corresponds to a Finite State Machine (FSM), usually adirected graph consisting of nodes and edges. A set of atomic propositions is asso-ciated with each node. The nodes represent states of a system, the edges representpossible transitions which may alter the state, while the atomic propositions repre-sent the basic properties that hold at a point of execution. In some cases in�nitesystems may also be veri�ed using model checking in combination with various ab-straction and induction principles.The main challenge in applying model checking in real-world problems is dealingwith the state space explosion problem. This problem occurs in systems with manycomponents that can make transitions in parallel. During the past few years a con-siderable progress has been made using the following approaches.

� Symbolic algorithms do not actually build the graph for the FSM, theywould rather represent the graph implicitly using a formula in propositionallogic. Much of the increase has been due to the use of BDDs, a data struc-ture for representing Boolean functions recommended by Ken McMillan [81].Recently, Satis�ability Problem (SAT) solvers have been used to perform thegraph search [1, 82, etc.].

� Partial order reduction can be used to reduce the number of independentinterleavings of concurrent processes that must be considered. The basic idea isthat if two interleaving sequences are not distinguished by a given speci�cationthen it is su�cient to analyze only one of them [49, 94, 112, etc.].

� Abstraction uses a di�erent approach by removing the unnecessary detailsof a system, thus simplifying the veri�cation process. The simpli�ed systemusually does not satisfy exactly the same properties as the original one so thata process of re�nement may be necessary [8, 22, 27, 28, 68, etc.].

� Symmetry is also a possibility to reduce the state space as �nite state con-current systems usually build upon replicated elements. This is rather typi-

12

Page 21: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

cal for systems consisting of entities using identical communicating protocols[45, 58, 59, 84, etc.].

� Bounded Model Checking (BMC) veri�es a speci�c property in maximumk steps starting from the initial state of �nite state transition automata [15].The states that are unreachable in k steps will be omitted from further analysis,but the value of k could be incremented later (re-checks are allowed) dependingon the problem domain. The primary use of this method is to provide counterexamples.

� OIMC is a relatively new approach which focuses on the changes of a systeminstead of re-checking the entire system. An overview of this method and thealgorithm used can be found in [110, 111, etc.].

Model checking tools use their own speci�cation languages, but most of them supportthe temporal logic languages LTL and CTL. In Sections 1.3.1 and 1.3.2 we haveprovided an overview of the syntax and semantics of LTL with the extension of pasttemporal operators.

1.4.1 Model checking tools

As the e�ciency of formal methods has signi�cantly progressed in recent years,several model checking tool implementations have been developed and have becomeavailable. A thorough � yet not full � list is available at [74]. In this section we arefocusing on four that are either the most widespread or provide unique features.

Bogor is an extensible and customizable model checking framework. It uses amodeling language which can be extended with new primitive types, expressionsand domain-speci�c commands on a particular level of abstraction. The modularstructure of Bogor also supports the development and use of new algorithms andoptimization to replace the built-in model checking algorithms [101].

Simple Promela Interpreter (SPIN) has been widely used for verifying thecorrectness of distributed software models [107]. SPIN consists of three components:the Promela speci�cation language, a protocol simulator which is able to executeeither ad-hoc or controlled simulations and a model checker traversing the entirestate space.The general process of operation includes the following steps:

1. A system model needs to be created in Promela language.

2. An environment should be created where the behavior of the system may besimulated with the support of SPIN.

13

Page 22: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

3. The system can be veri�ed with the SPIN model checker whether it operatescorrectly with respect to its speci�cation.

SPIN features the partial order reduction technique, but unfortunately does onlysupport Linear Temporal Logic expressions.

Symbolic Model Veri�er (SMV) is a tool for checking that �nite-state systemssatisfy speci�cations given in CTL. NuSMV is originated from the reengineering,reimplementation and extension of SMV, which is robust and close to industrialsystems standards. It is the �rst model checker based on BDDs and it also supportsbounded model checking. The analysis of speci�cations expressed in LTL is alsopossible in later versions [17]. In this thesis most of the sample systems have beenimplemented in the NuSMV environment.

Symbolic Analysis Laboratory (SAL) � on the other hand � is a frameworkwhich combines the tools used for abstraction, program analysis, correctness proofand model checking to compute the properties of state transition systems, whichis in fact symbolic analysis itself. The SAL model checker is based on BDD, whichprovides di�erent ordering and classi�cation options for state transitions. Moreover,it supports forward, backward and priority-based traversal for greater e�ciency[104].

1.4.2 Open Incremental Model Checking

OIMC introduced in [111] addresses the changes to a system instead of re-checkingthe entire system model which includes the new extensions. The model checking isexecuted in an incremental manner only within the extension component.The conditions � basically inter-component constraints � resemble to pre- and post-conditions in DBC [83].The de�nition they used to describe a software system is given below:A state transition modelM is represented by a tuple 〈S,Σ, s0, R, L〉 where S is a setof states, Σ is the set of input events, s0 ∈ S is the initial state, R ⊆ S×PL(Σ)→ Sis the transition function (where PL(Σ) denotes the set of guarded events in Σ whoseconditions are propositional logic expressions), and L : S → 2AP labels each statewith the set of atomic propositions true in that state.Components can be veri�ed to be consistent via OIMC. Initially, a CTL property pis known to hold in B where B is the base component (the original betting machinein our example). We need to check that E (standing for the extension component)does not violate p. The incremental veri�cation method only needs to verify theconformance at all exit states between B and E. Corresponding to each exit stateex, within E, the algorithm to verify preservation constraints νB(ex, cl(p)) can bebrie�y described as follows [110]:

14

Page 23: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

1. Seeding νB(re, cl(p)) at any reentry state re where cl(p) is the set of allsub-formulae of p including itself. The assumption function As is: As(re) =νB(re, cl(p)).

2. Executing a CTL assumption model checking procedure in E to check φ, ∀φ ∈cl(p). In case of COTS, a standard CTL model checking is executed within Einstead.

3. Checking if νE(ex, cl(p)) = νB(ex, cl(p)).

At the end of the algorithm, if at all exit states, the truth values with respect tocl(p) are matched respectively, B and E are consistent with respect to p.The theorem concerning the scalability of the OIMCmethod has already been provedin [90] and can be read below:

Theorem 1. If all respective pairs of base (Ci−1) and re�ning (Ei) componentsconform, the complexity of OIMC to verify the consistency between En and B isindependent from the n-th version of Cn, i.e. it only executes within En.

Despite the proof, further studies are necessary to see the e�ciency of OIMC in realapplications using third-party components-o�-the-shelf. Also, it is quite importantto integrate the OIMC method into a commonly used model checker tool such asthe previously mentioned NuSMV.

1.5 On the correctness of data type classes based on contracts

This section basically includes our results published in [31] based on the resultsachieved primarily by Prof. Em. László Varga in this �eld of research.In the development of programming systems for large applications the compositionalapproach to interactive concurrency is generally used. In this technology a possibleway of ensuring the correctness of independently developed components is the use ofcontracts [80], which are formal agreements expressing each party's rights and obli-gations. De�ning a precondition and a postcondition, or an invariant for a routine,is a way to de�ne a contract that binds the routine to its callers [83]. This conceptwas later extended to the component-based world [97].Component-based applications are generally distributed systems, and the veri�ca-tion of such systems is extremely complicated, usually done on two levels. A possiblesolution addressing these problems can be contract-based testing proposed in [51].In [20] the authors propose a novel method to improve the modular veri�cationof object-oriented programs by using Separation Logic. In [92] a similar research ispresented, which focuses speci�cally on the veri�cation of codes that use inheritance.However, both papers concentrate on the theoretical issues, while we would like toshift our focus to a more practical approach.

15

Page 24: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

PAR EXP

IMP BOD? ?

e

ib

-

-

i eb=

Figure 4: Data type module

1.5.1 Basic notions

As most of today's large and complex software systems are designed and built byusing the object-oriented or the component-based approach, where objects and com-ponents are interoperating with one another on a concurrent basis, it seems suitablefor us to consider a program as a distributed system where the correctness of com-ponents is controlled by contracts.

Distributed system:parbegin S1‖ . . . ‖Sn parend;Si : Si0; do bi1 → Si1 8 . . . 8 bim → Sim od;bi1, . . . , bim are guardsSi0 is the initialization partSi1, . . . , Sim; i = 1, . . . , n non-deterministic programs (components)with the contract Ict which is generally given in the form of an invariant.Here the components use a common data type.

According to H. Ehring and B. Mahr [42], the data type class can be de�ned by adiagram as illustrated in Figure 4:

where PAR, EXP, IMP and BOD are speci�cationse, i, eb, ib are speci�cation morphisms.

De�nition 1. A speci�cation is a SPEC = (Σ, E), where Σ is a signature andE is a set of pre- and postconditions, or algebraic axioms.

Example:Here is a speci�cation for the non-negative integers with a number of operations.nat =

16

Page 25: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

sorts:natoprs:zerus : → natsucc : nat→ natadd : natnat→ natprec : nat→ nateqns:n,m ∈ nat;add(n,m) = add(m,n)add(n, zerus) = nadd(n, succ(m)) = succ(add(n,m))prec(zerus) = “undefined′′

prec(succ(n)) = n

De�nition 2. A signature is a Σ = (S,OP ), where S is a �nite set of sorts andOP is a �nite set of operational symbols in the following form: w : s1 . . . sk → s,where w is the name of the operation, while s1 . . . sk, s ∈ S are sorts, where k ≥ 0.

De�nition 3. Let Σ = (S,OP ) and Σ′= (S

′, OP

′) signatures. A signature mor-

phism is a (µ : Σ → Σ′); µ = (µs, µop) function pair, where µs : S → S

′,

µop : OP → OP′and ∀n : s1 . . . sk → s ∈ OP and in case k ≥ 0, ∃o operation

name, where µop(n : s1 . . . sk → s) = (m : µs(s1) . . . µs(sk)→ µs(s)).

De�nition 4. Let Σ = (S,OP ) and Σ′

= (S′, OP

′) signatures and µ : Σ → Σ

a signature morphism. X and X′denote a set of variables in signatures Σ and Σ

respectively.The injective function µx : (∪Xs)∀s∈S → (∪X ′

s′ )∀s′∈S′ is the extension of the

signature morphism µ to variables, whensoever if x ∈ Xs, s ∈ S then µx(x) ∈X

′µ(s).

De�nition 5. The extension of the signature morphism to terms. For eachterm t ∈ TΣ(X) in the case of any x ∈ X.µT (x) = µ(x);for any n :→ s ∈ OP , for which µ(n : → s) = (m : → µ(s)),µT (n) = m;for any n : s1, . . . , sk → s ∈ OP , for which µ(n : s1, . . . , sk → s) = (m :µ(s1), . . . , µ(sk)→ µ(s));µT (n(t1, . . . , tk)) = m(µT (t1), . . . , µT (tk)).

Example:Let Σ = ({N}, {0 : → N ;_ + 1 : N → N ;_ + _ : NN → N},{a, b ∈ N ; a+ b = b+ a, a+ 0 = a, a+ (b+ 1) = ((a+ b) + 1)})Σ

′= ({nat}, {zerus : → nat; succ : nat→ nat; add : natnat→ nat},

{a, b ∈ nat; add(a, b) = add(b, a), add(a, 0) = a, add(a, succ(b)) = succ((add(a, b))});

17

Page 26: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

PAR' EXP'

IMP'

PAR EXP

IMP

?

e'

i'

-

-

?

e

i

rI

rPrE

R

s ~

Figure 5: Specialization

then for example:µT (a+ (b+ 1)) = add(a, succ(b));

De�nition 6. An interface is a (PAR, EXP, IMP, e, i) where PAR, EXP, IMPare speci�cations, and e, i are inclusions (speci�cation morphisms).

Re�nement (specialization) (See Figure 5).r : interface1 → interface

′;

r = (rP , rE, rI), such that e′ ◦ rP = rE ◦ e; i

′ ◦ rP = rI ◦ i;

Inheritance is a relation between two data type classes. An object of the subclasscan be used instead of the appropriate object of the superclass in a program, andmethods in the subclass must have the same signatures as in the superclass.Therefore, if a subclass inherits from a superclass, then the subclass comprises thesame attributes and methods. Some of the methods can be overwritten. The subclassmay also contain additional attributes and methods. However, there is nothing guar-anteed about the behavior of a subclass with respect to the behavior of its superclassin addition to the syntactic property that it contains the same set of methods andattributes.Hence this inheritance procedure could be semantically inconsistent.

Behavior inheritance is based on the Substitution Principle, which was de�ned byB. Liskov and J. Wing [73] in the following way:

De�nition 7. If for each object o1 of type T1 there is an object o2 in type T2 suchthat for all programs P de�ned in terms of T1, if o1 is substituted for o2 and thebehavior of P is unchanged, then T2 is a subtype of T1.

18

Page 27: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

T1

T2

6mT : T1 T2

-

Figure 6: Inheritance morphism

In the case of data types according to the Substitution Principle we have to requirethat entities of the subtype should behave the same way as entities of the supertypewhen put into a context where an entity of at-least-supertype is required.

De�nition 8. Given the speci�cation of supertype T1 = (Σ1, E1) and the speci�ca-tion of subtype T2 = (Σ2, E2) where signature Σi = (Si, OPi), i = 1, 2.Let A1 =

⋃s∈S1

Xs and A2 =⋃s∈S2

Ys be sets of variables of sorts S1 and variablesof the sort of S2 respectively. We denote the set of terms for Σi in a similar way:TOPi,Si

, i = 1, 2.

De�nition 9. Given T1 = (S1, OP1, E1);T2 = (S2, OP2, E2) data type speci�cations,where S1, S2 are sets of sorts, OP1, OP2 are operation symbols, E1, E2 are sets ofsemantic axioms in the form of equations: Li = Ri where Li, Ri ∈ TOPi,Si

. i = 1, 2.Let mT be the inheritance morphism (See Figure 6).Let φ : mS(A1)→ A2 be the inverse function of mS in the case of variables of sortsfor which the following is true:The function φ is de�ned on the subset of mS(A1) so that(∀a1 ∈ A1, ∃a2 ∈ mS(A1) ⊆ A2)(a1 = φ(a2)).

If (φ(t) = φ(t′)) ⇒ (t = t

′), for all pairs of terms (t, t

′) where φ(t), φ(t

′) ∈ TOP1,S1,

t, t′ ∈ TOP2,S2, then subtype T2 is a behavioral subtype of supertype T1 with respect

to morphism mT .

De�nition 10. Let fx: Ax → Bx; be a function of type T1: and fx ∈ OP1; Ax ⊆ A1;Bx ⊆ A1; Let fy: Ay → By; be a function of type T2: fy ∈ OP2; Ay ⊆ A2; By ⊆ A2;If mS(Ax) ⊆ Ay; By ⊆ mS(Bx); then fy is a subfunction of superfunction fx withrespect to morphism mT .

If

19

Page 28: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

• (∀ay ∈ mS(Ax))(fx(φ(ay)) is de�ned, then fy(ay) is also de�ned),

• (∀ay ∈ mX(Ax))(fx(φ(ay)) = φ(fy(ay))),

then function fy is a behavioral subfunction of fx with respect to morphismmT .

Theorem 11. Given T1 = (A1, OP1, E1); T2 = (A2, OP2, E2); mT : T1 → T2; andgiven the inverse function φ: mS(Ax) → Ax, as de�ned above. If for all fx ∈ OP1;there is a function fy ∈ OP2 such that fy is a behavioral subfunction of fx, then typeT2 is a behavioral subtype of supertype T1 as understood by B. Liskov and J. Wing.

Proof. Let term t be a variable a2 ∈ mS(A1), then (∃a1 ∈ A1)(a1 = φ(a2)); withrespect to the de�nition of the inverse function φ. So φ(t) can be substituted intothe semantic axioms of T1 for L(φ(t)) = R(φ(t)).Let term t be a constant function f2 ∈ mOP (OP1), then (∃f1 ∈ A1)(f1 = φ(f2));with respect to the de�nition of the inverse function φ. So in this case φ(t) can alsobe substituted into the semantic axioms of T1 for L(φ(t)) = R(φ(t)).Let term t be a function fy ∈ OP2. While mS(Ax) ⊆ Ay, therefore if fx is de�ned forax ∈ Ax then, fy is also de�ned for the appropriate ay ∈ mS(Ax). On the other hand,while (∀ay ∈ mS(Ax))(fx(φ(ay)) = φ(fy(ay))), hence φ(t) can also be substitutedinto the semantic axioms of T1 for L(φ(t)) = R(φ(t)).Hence T2 is a behavioral subtype of T1 and fy simulates the behavioral of fx on theset of Ax and φ(fy(ay)) can be substituted into the program P for fx(φ(ay)).

Theorem 12. Given T1 = (A1, OP1, E1); T2 = (A2, OP2, E2); mT : T1 → T2; andgiven the inverse function φ: mS(Ax) → Ax, as de�ned above. Let us suppose thatthe semantics of the operations are given by pre- and postconditions:

(prefx , postfx), (prefy , postfy)

If we prove, that

prefx(φ(ay))⇒ prefy(ay); postfx(φ(ay))⇒ postfy(ay);

then type T2 is a behavioral subtype of supertype T1 as understood by B. Liskov andJ. Wing. (The correctness of a class is formulated this way by Meyer [83].)

Proof. The theorem can be proved similarly to the previous one.

1.5.2 Case study

In what follows we consider an example which illustrates the ideas presented inthe previous section. In this example �rst a data type (AB − Store) is developed,and then a subtype (ABC − Store) is introduced. The preservation of behavior isguaranteed by the application of behavioral contracts in the form of invariants.

20

Page 29: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

AB-Store Let us consider a given store AB − Store in which two di�erent kindsof goods can be stored. Transports of goods are arriving to the store in a non-deterministic manner. At the same time some of the goods are sold to customers ina non-deterministic manner. There is a constraint on the proper functioning of thestore, that is A and B kinds of goods are not allowed to be stored mixed.Let us produce the simulator program of the store.

The capacity of the store is: N .The storable kinds of goods are: A,B.

The number of pieces of goods in the store are:nA = count(A, ent)− count(A, ex).nB = count(B, ent)− count(B, ex).

count(X, ent) denotes the number of goods arrived and stored in the store from thestarting point, while count(X, ex) denotes the number of goods sold from the store.In both cases X ∈ A ∪B.

The used capacity in the store is: n = nA + nB.

The formalization of contracts:In the store A and B kinds of goods are not allowed to be stored together:N ≥ nA + nB ≥ 0 ∧ (nA = 0 ∨ nB = 0);The contract is expressed by the following invariant:Ict(N, n, nA, nB): (N ≥ n ≥ 0) ∧ (n = nA + nB) ∨ (nA = 0 ∨ nB = 0);

Let the operations be:insAB(b, x): nX ::= nX + 1; delAB(b, x): nX ::= nX − 1; where b ∈ AB − Store;x ∈ A ∪B.

The general preconditions for the operations concerned with the capacity of thestore only are the following:{0 ≤ nA + nB < N} b ::= insAB(b, x);{0 < nA + nB ≤ N} b ::= delAB(b, x);

Mutual exclusion must be ensured between the two operations:in(insAB) = 0 ∧ in(delAB) = 0.in(insAB) = 1 if the operation insAB is currently executed, and in(insAB) = 0 if theoperation is not currently executed. The same applies to the operation in(delAB).therefore

syninsAB(x) :((x ∈ B ∧ nA = 0) ∨ (x ∈ A ∧ nB = 0) ∧ (in(insAB) = 0 ∧ in(delAB) = 0);syndelAB(x): (nX 6= 0) ∧ (in(insAB) = 0 ∧ in(delAB) = 0);

21

Page 30: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

The operations will be correct with respect to the contract Ict if we prove the fol-lowing theorems:{syninsAB ∧ preinsAB ∧ Ict} nX ::= nX + 1 {postinsAB(b) ∧ Ict}.{syndelAB ∧ predelAB ∧ Ict} nX ::= nX − 1 {postdelAB(b) ∧ Ict}.

where postinsAB(b) informally means that x has been stored in b. The meaning ofpostdelAB can be given analogously.

ABC-Store Let us now consider a store ABC − Store in which three di�erentkinds of goods can be stored. Transports of goods are arriving to the store in a non-deterministic manner. At the same time some of the goods are sold to customers ina non-deterministic manner.

The following constraints apply to the proper functioning of the store:In the store B and C kinds of goods can be stored together.A and C kinds of goods can also be stored together.A and B kinds of goods are not allowed to be stored mixed.Let us produce the simulator program of the store.

The capacity of the store is: N .The storable kinds of goods are: A,B,C.

The number of pieces of goods in the store are:nA = count(A, ent)− count(A, ex).nB = count(B, ent)− count(B, ex).nC = count(C, ent)− count(C, ex).

count(X, ent) denotes the number of goods arrived and stored in the store from thestarting point, while count(X, ex) denotes the number of goods sold from the store.In each case X ∈ A ∪B ∪ C.

The used capacity in the store is: n = nA + nB + nC .

The formalization of contracts:In the store B and C kinds of goods can be stored together if there are no A kindof goods in it: N ≥ nB + nC ≥ 0 ∧ nA = 0;In the store A and C kinds of goods can be stored together if there are no B kindof goods in it: N ≥ nA + nC ≥ 0 ∧ nB = 0;The contract is expressed by the following invariant:Ict(N, n, nA, nB, nC): (N ≥ n ≥ 0) ∧ (n = nA + nB + nC) ∧ (nA = 0 ∨ nB = 0);

Let the operations be:insABC(b, x): nX ::= nX + 1; delABC(b, x): nX ::= nX − 1; where b ∈ ABC − Store;x ∈ A ∪B ∪ C.

22

Page 31: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

The general preconditions for the operations concerned with the capacity of thestore only are the following:{0 ≤ nA + nB + nC < N} b ::= insABC(b, x);{0 < nA + nB + nC ≤ N} b ::= delABC(b, x);

Mutual exclusion must be ensured between the two operations:in(insABC) = 0 ∧ in(delABC) = 0.in(insABC) = 1 if the operation insABC is currently executed, and in(insABC) =0 if the operation is not currently executed. The same applies to the operationin(delABC).therefore

syninsABC(x) :((x ∈ B∧nA = 0)∨ (x ∈ A∧nB = 0)∨x ∈ C)∧ (in(insABC) = 0∧ in(delABC) = 0);syndelABC(x): (nX 6= 0) ∧ (in(insABC) = 0 ∧ in(delABC) = 0);

The operations will be correct with respect to the contract Ict if we prove the fol-lowing theorems:{syninsABC ∧ preinsABC ∧ Ict} nX ::= nX + 1 {postinsABC(b) ∧ Ict}.{syndelABC ∧ predelABC ∧ Ict} nX ::= nX − 1 {postdelABC(b) ∧ Ict}.

where postinsABC(b) informally means that x has been stored in b. The meaning ofpostdelABC can be given analogously.

From Theorem 11 and the informal speci�cations of AB − Store and ABC − Storeit is clear that ABC − Store is a behavioral subtype of AB − Store, and this factcan easily be proved formally from the example.

1.5.3 Applying the results in CBSD

In this section the behavioral inheritance contract driven environment has beenformally de�ned for the object oriented environment on the basis of the SubstitutionPrinciple. In order to apply these results in the component based environment, wehave to set up certain parallels between the two paradigms. Although each object canbe mapped into a component, nevertheless a component may consist of (multiple)di�erent, inter-operating objects. In component based systems a phenomenon similarto inheritance can occur when the system is extended with components of similaror identical types. Therefore we suspect that using type inheritance and contractstogether in the component based environment may not only increase the reliabilityof a program or a system, but may also simplify its veri�cation procedure. However,further investigation is required on this topic.

23

Page 32: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

1.6 The structure of the thesis

In Section 2 we examine the granularity of the components of software systems byusing formal methods, and point out that while granularity is helping our struggleto narrow the state space, it can also yield conceptual faults. In Section 3 we proposea new method that is able to reduce the state space by exploiting the structure ofsystems consisting of many similar components. In Section 4 we are exploring thepossibilities of extending component-based systems. We propose a new tool we havedeveloped which is able to support the algorithm of OIMC, and we compare theOIMC to our method. In Section 5 we approach the formal veri�cation of networkprotocols from a new perspective, exploiting the similarities between component-based systems and the layered structure used in networking. In Section 6 we providean overview of the related works, highlighting the points of possible connection withour research. In Section 7 we summarize the carried out research.

2 On the granularity of components

2.1 The need for an educational framework

In this section we rely on our results published in [33]. De�ning the range of com-ponent granularity can also be di�cult because several factors (level of abstraction,likelihood of change, complexity of a component, etc.) have to be considered whiledesigning components. A component should not be too small as the interactionbetween smaller components requires more time and resources, in addition a com-ponent should not be too large as it provides more complex interfaces, is subject tomore frequent changes and makes a system using it less �exible.That is why it is essential to �nd a balance between the factors of cohesion andcoupling [113]. One of the main purposes of the educational framework is to supportthe students to practice those design decisions. The other main objective is to helpstudents and future IT experts to learn how to apply CBSD in a framework thatprovides a context in which at least the three most generally used component modelsdescribed earlier would be available.A set of veri�ed components for each model should be available in the componentlibrary described earlier. A brief outline of the structure of the framework can beseen in Figure 7.As each component model requires the use of its own interface language (CORBAIDL, Microsoft IDL and Java Interface De�nition), an application developer usingthe framework has to select one of the models around which to build the application.Then the necessary components should be selected accordingly from the componentlibrary. Obviously, if there is no suitable component in the library this must bedeveloped with respect to a particular component model. The component has to beveri�ed with one of the methods described in Sections 1.2.2, 1.2.3 or 1.2.4 in orderto get it into the component library. The dynamic model of the framework with the

24

Page 33: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 7: Static model of the framework (Class Diagram)

tasks of an application developer can be seen in Figure 8.The signi�cance of such a framework lies not only in its educational ends, but also inthe fact that the component-based structure would also make it possible to replacesome/any of the components with commercial ones for a higher performance whileretaining the interfaces. This way the framework could be easily adopted for realsoftware developing projects in the business area.We emphasized the necessity of an educational framework for developing component-based applications in combination with a library of components that are correct fora given speci�cation in a particular environment (component model). Today's mostpopular software veri�cation methods and component models were also discussedbrie�y. The design of the educational framework brought up a new problem. Once anapplication developer has decided to follow one of the component models, it becomesimpossible to integrate a new component of another model into the application.The introduction of a new level of a so-called universal component would solve theproblem if the model speci�c interface de�nition language could be transformedinto a universal interface given in a general language, possibly XML as it was rec-ommended in [56]. The identi�cation of the component model which is used by acomponent may seem to be problematic at �rst but can be resolved by integrating

25

Page 34: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 8: Dynamic model of the framework (Activity Diagram)

it into the component as a part of a contract. A modi�cation of the original staticmodel of the framework applying the concept of a universal component can be seenin Figure 9. Our proposal was further discussed in [40].

In the future we will become more and more dependent of the proper functioningof computer systems, so new methods are needed to increase our con�dence in thecorrectness of such systems. Today's most widely used techniques of testing are onlyable to post-verify applications and they are not able to guarantee that there are nomore hidden errors left in the design or in the code. However, with the emergence offormal methods, it has become possible to create correct programs with respect toa given speci�cation. Di�erent types of synthesis methods and model checking arethe most widespread formal techniques in practice today.

26

Page 35: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 9: Static model of the framework (Class Diagram)

2.2 Granularity supported by synthesis methods

There are several di�erent methods for synthesizing programs [5, 44, 52, 77, etc.].In the following sections simpli�ed variants of the Producer � Consumer Problemare used to show a method based on Classical Logic introduced by G. R. Andrews[2]. The general steps of this solution are the following:

� De�ning the problem

� Determining the skeleton of the solution

� Generating an abstract solution

� Implementing the atomic operations (beyond the scope of this paper)

In order to generate an abstract solution, the guard conditions (based on Dijkstra'sWeakest Precondition Calculus) must be determined in such a way that the invariantshould hold before and after the atomic instructions [41]. In our examples the atomicinstruction <await E then S> is used, meaning that the sequence of statementsS is not executed until the evaluation of the logical expression E is true.

27

Page 36: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

2.2.1 Producer � Consumer Problem (coarse)

The �rst variant of the Producer � Consumer Problem is the simplest one consistingof 1 producer, 1 consumer and a bu�er with capacity 1. Let pt be the fullness-pointerof the bu�er B.

Speci�cation:Ia : 0 ≤ pt ≤ 1

Skeleton of the solution:var pt : integer := 0; var B, a, aa : item;# invariant Ia

Producer ::do true then<pt := pt+ 1; B := a>;od

Consumer ::do true then<aa := B; pt := pt− 1>;od

The guard conditions described earlier are the following:Bp = wp(pt := pt+ 1, Ia)⇒ pt = 0Bc = wp(pt := pt− 1, Ia)⇒ pt = 1

Abstract solution (with guards):# variables are just as before# invariant Ia

Producer ::do true thenDeposit: <await pt = 0 then pt := pt+ 1; B := a>;od

Consumer ::do true thenFetch: <await pt = 1 then aa := B; pt := pt− 1>;od

Analysis:With such an invariant Ia, the increase/decrease of the bu�er cannot be divided intomicroinstructions, must be handled as atomic instructions just as in the exampleabove. Let us take a look at the following solution:

28

Page 37: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Producer ::do true thenDeposit: <pt := pt+ 1>; B := a;od

Consumer ::do true thenFetch: <pt := pt− 1>; aa := B;odExecuting the Producer and the Consumer processes it is possible that the followingsequence occurs.

<pt := pt+ 1>; <pt := pt− 1>; aa := B; B := a;

It means that a data is attempted to be read from bu�er B before it has actuallybeen placed there. However, there are several correct solutions if we still want a �nerstructure as the skeleton of the solution.

2.2.2 Producer � Consumer Problem (�ne)

Speci�cation:It is based on the previous solution but a �ner structure is used. Let pt be thefullness-pointer of the bu�er, inp and inc the indicators of the critical sections.

Invariant Ib:0 ≤ pt ≤ 1 ∧ 0 ≤ inp ≤ 1 ∧ 0 ≤ inc ≤ 1 ∧ 0 ≤ inp + inc ≤ 1

Abstract solution (with guards):var pt : integer := 0; var B, a, aa : item; var inp, inc : boolean := 0, 0;# invariant Ib

Producer ::do true then # invariant IbDeposit: <await pt = 0 ∧ inc = 0 then inp := 1; pt := pt+ 1>; B := a;<await true then inp := 0>;od

Consumer ::do true then # invariant IbFetch: <await pt = 1 ∧ inp = 0 then inc := 1; pt := pt− 1>; aa := B;<await true then inc := 0>;od

Analysis:

29

Page 38: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

The producing and consuming processes have (�ner structure) more granularity inthis case, they express it better that producing and consuming are executed in sucha critical section that is preceded by an explicit prologue and followed by an explicitepilogue.Another advantage of this solution is that it can be easily extended to a system witha bu�er sized K > 1, more producers and more consumers.

2.2.3 General extension of the Producer � Consumer Problem

Speci�cation:In this variant there are M producers, N consumers and a bu�er with capacityK > 1. Let pti (the number of items deposited in the bu�er), pto (the number ofitems fetched from the bu�er) be pointers where (pti−pto) is the fullness pointer, inpthe number of producers in their critical section and inc the number of consumersin their critical section.

Invariant Ic:0 ≤ pti − pto ≤ K ∧ 0 ≤ inp ≤ 1 ∧ 0 ≤ inc ≤ 1 ∧ pti ≥ 0 ∧ pto ≥ 0

Abstract solution (with guards):var pti, pto : integer := 0, 0; var B[1..K] of item;var inp, inc : integer := 0, 0;# invariant Ic

Producer ::do true then # invariant IcDeposit: <await inp = 0 then inp := inp + 1>;<await pti − pto < K then pti := pti + 1>;B[pti mod K] := a;<await true then inp := inp − 1>;od

Consumer ::do true then # invariant IcFetch: <await inc = 0 then inc := inc + 1>;<await pti − pto > 0 then pto := pto + 1>;aa := B[pto mod K];<await true then inc := inc − 1>;od

Analysis:This is a general solution. Producers have mutual exclusion among them. Consumersalso have mutual exclusion among them. However, it is still possible that producingand consuming can be executed concurrently. That is why it is worth dividing theprologue into two atomic instructions.

30

Page 39: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

It seems that the �ner structure (more granularity) of the system makes it possibleto increase concurrency.Note: This solution also works correctly in the case of a bu�er with capacity K = 1.The coarser granularity has the advantage of expressing and illustrating speci�cproperties of programs better. This is illustrated by the following example.

2.2.4 A variant of the Producer - Consumer Problem

In this case there are M producers, N consumers and a bu�er with capacity K ≥ 1.Two types of consumers C1 and C2 can be distinguished whether 1 or 2 productsare consumed at once.Speci�cation:Invariant Id : 0 ≤ pt ≤ 2

Abstract solution (with guards):var pt : integer := 0; var B[1..2] of item; var a, aa, aa1, aa2 : item;# invariant Id

P ::do true then<await pt ≤ 1 then pt := pt+ 1; B[pt] := a>;od

C1 ::do true then<await pt ≥ 1 then aa := B[pt]; pt := pt− 1>;od

C2 ::do true then<await pt = 2 then aa2 := B; pt := pt− 1; aa1 := B; pt := pt− 1>;od

Analysis:This solution has a very coarse granularity similarly to the �rst example. It is pro-hibited to produce and consume concurrently, but it is possible to produce an itemand consume the very same item alternately. As a result of this process C2 is neverable to consume 2 items from the bu�er. This property is known as starvation prob-lem. However, at this level of abstraction it is possible to solve it by modifying theguard condition of process C1.

C1 ::do true then<await pt = 2 then aa := B[pt]; pt := pt− 1>;od

31

Page 40: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 10: Result screen of the model checking process

As we have seen synthesis methods are more usable in practice than deductivereasoning. However, there is still too much human interaction needed for both ap-proaches. The extent of this human interaction can be signi�cantly decreased withthe use of model checking tools.

2.3 The general version of the Producer � Consumer Problem

modeled in NuSMV

In this subsection the use of the NuSMV model checker [17] is illustrated by anexample. In this scenario the system consists ofM producers (M = 2), N consumers(N = 2) and a bu�er with capacity K ≥ 1 (K = 2). Figure 10 shows the evaluationof the speci�cation formulas that can be further analyzed. Concurrency, for example,between a producer and a consumer is checked with the following CTL temporallogic formula:

SPEC EF ( producer1 . s t a t e = producing & ( consumer1 . s t a t e = consuming xorconsumer2 . s t a t e = consuming ) )

SPEC EF ( producer2 . s t a t e = producing & ( consumer1 . s t a t e = consuming xorconsumer2 . s t a t e = consuming ) )

We have created this model of the Producer � Consumer Problem with all of thenecessary local and global speci�cations based on the formal speci�cation describedin Section 2.2.3 where the synthesis method was used. This is a more general solutionand it is easily scalable. However, mutual exclusion requires some attention from ourside.

MODULE main

DEFINEmax:= 2 ;−− could be l a r g e r as the re may be more than one producers and consumers

VAR

32

Page 41: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

semaphore_prod : boolean ;semaphore_cons : boolean ;

This is necessary as only one of the producers is allowed to produce at the sametime. If the bu�er is not empty or full, one producer and one consumer can reach itat the same moment.

bu f f e r : 0 . .max ;−− should be s e t accord ing to maxproducer1 : p roce s s producing ( semaphore_prod , bu f f e r , max) ;producer2 : p roce s s producing ( semaphore_prod , bu f f e r , max) ;consumer1 : p roce s s consuming ( semaphore_cons , bu f f e r , max) ;consumer2 : p roce s s consuming ( semaphore_cons , bu f f e r , max) ;

ASSIGNi n i t ( semaphore_prod ) := 0 ;i n i t ( semaphore_cons ) := 0 ;

Semaphores have zero value if the relevant critical sections are free to enter.i n i t ( bu f f e r ) := 0 ;

−− s p e c i f i c a t i o n s t a r t s hereSPEC AG ! ( producer1 . s t a t e = producing & producer2 . s t a t e = producing )−− mutual ex c l u s i on BETWEEN PRODUCERSSPEC AG ! ( consumer1 . s t a t e = consuming & consumer2 . s t a t e = consuming )−− the same BETWEEN CONSUMERSSPEC EF ( producer1 . s t a t e = producing & ( consumer1 . s t a t e = consuming xor

consumer2 . s t a t e = consuming ) )−− j u s t to make sure i t i s POSSIBLE to produce and consume at the same timeSPEC EF ( producer2 . s t a t e = producing & ( consumer1 . s t a t e = consuming xor

consumer2 . s t a t e = consuming ) )−− the same f o r the other producerSPEC AG ! ( bu f f e r = 0 & ( consumer1 . s t a t e = consuming | consumer2 . s t a t e = consuming ) )SPEC AG ! ( bu f f e r = max & ( producer1 . s t a t e = producing | producer2 . s t a t e = producing

) )−− check whether the re are e x t r em i t i e s

MODULE producing ( semaphore , bu f f e r , max)

As it is a parameter of the module, there is no need to distinguish this semaphorefrom the other one.VAR

s t a t e : { i d l e , ente r ing , producing , e x i t i n g } ;

ASSIGNi n i t ( s t a t e ) := i d l e ;next ( s t a t e ) :=case

( s t a t e = i d l e & bu f f e r < max) : en t e r i ng ;( s t a t e = ent e r i ng & semaphore = 0 & bu f f e r < max) : producing ;

This bu�er condition is seemingly unnecessary but there may be situations where aconsumer is �stuck� in the entering state, while another one consumes the remainingitem(s).

( s t a t e = producing ) : e x i t i n g ;( s t a t e = ex i t i n g ) : i d l e ;1 : s t a t e ;

e sac ;−− now the semaphore needs same care

33

Page 42: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

next ( semaphore ) :=case

( s t a t e = ent e r i ng ) : 1 ;( s t a t e = ex i t i n g ) : 0 ;1 : semaphore ;

e sac ;−− s e t t i n g the bu f f e r a c co rd ing lynext ( bu f f e r ) :=case

( s t a t e = producing & bu f f e r < max) : bu f f e r + 1 ;1 : bu f f e r ;

e sac ;

In some similar cases fairness constraints need to be applied because the modelchecker will consequently select each module to run except for the one we need.However, it is highly recommended to avoid fairness constraints as long as we canbecause there might be errors that will be covered up by these excluded paths,ignoring cases where a producer who gets into the entering state will not be selectedanymore.FAIRNESS ! ( s t a t e = ent e r i ng )

−− s p e c i f i c a t i o n that i s bound to only the module i t s e l f comes hereSPEC AG ( s t a t e = ent e r i ng −> EF( s t a t e = producing ) )−− no need to name the in s t ance o f the module , more economic

FAIRNESSrunning

−− the consumer module i s qu i t e s im i l a r so copy−paste i s recommended

MODULE consuming ( semaphore , bu f f e r , max)

As it is a parameter of the module, there is no need to distinguish this semaphorefrom the other one.VAR

s t a t e : { i d l e , ente r ing , consuming , e x i t i n g } ;

ASSIGNi n i t ( s t a t e ) := i d l e ;next ( s t a t e ) :=case

( s t a t e = i d l e & bu f f e r > 0) : en t e r i ng ;( s t a t e = ent e r i ng & semaphore = 0 & bu f f e r > 0) : consuming ;−− same reason ing that was provided at producer module( s t a t e = consuming ) : e x i t i n g ;

Only one item is allowed to be consumed when possessing the semaphore.( s t a t e = ex i t i n g ) : i d l e ;1 : s t a t e ;

e sac ;−− now the semaphore needs same carenext ( semaphore ) :=case

( s t a t e = ent e r i ng ) : 1 ;( s t a t e = ex i t i n g ) : 0 ;1 : semaphore ;

e sac ;−− s e t t i n g the bu f f e r a c co rd ing lynext ( bu f f e r ) :=

34

Page 43: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

case( s t a t e = consuming & bu f f e r > 0) : bu f f e r − 1 ;1 : bu f f e r ;

e sac ;

FAIRNESS ! ( s t a t e = ent e r i ng )

SPEC AG ( s t a t e = ent e r i ng ) −> EF( s t a t e = consuming )

FAIRNESSrunning

2.4 Conclusions

In the previous sections we have illustrated how the early design decisions on thegranularity of components may have an impact on essential properties of a system(e.g. concurrency, freedom of starvation) and how we have to organize them � usuallyin the form of logical expressions � to meet certain demands.The above examples were created manually by a synthesis method suggested by G.R. Andrews [2]. Although the algorithm is quasi-automatic, it is usually not possibleto synthesize large and complex software systems in the real business world.In Section 2.3 we have created an improved formal model of the general Producer� Consumer Problem implemented in NuSMV by deriving the formal speci�cationgiven in previous sections. Our original model was presented in [33], but had to berevised after discovering that a special case of starvation was hidden by the fairnessconstraints. This is a more general solution which, in addition, is also easily scalable.It may be more complicated to describe the model of a system in detail, but theprocess of veri�cation requires less time and resources.

3 On the model checking of a system consisting ofmany similar components

3.1 Motives

Our dependence on the correct functioning of computer systems in our daily life be-comes more and more evident. Considering the automatic control of heating systemsor the safety systems of cars, faults � not even the subtle ones � are not tolerated.Only formal veri�cation methods are able to guarantee that a software system iserror-free from the design to the deployment of the actual code.Of the most widespread formal methods model checking has already proved itse�ectiveness in handling real-world problems. However, in one of today's favoriteparadigms, CBSD encounters the problem of separately developed components,COTS used in an environment di�erent from the original one [11, 106, etc.].It may sound reasonable to take into consideration building the information on theircorrectness into the design and the code of components [13]. The basis of this concept

35

Page 44: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

is DBC introduced by Bertrand Meyer [83] and later extended by Reussner [97].The advantages of structural similarities between components can also be exploitedto reduce the number of formulas in the local speci�cation of each component. Pleasenote that in this thesis the notion of similarity is restricted to the various entitiesoriginating from the very same class. It is desirable but also beyond the scope of thiswork to extend the notion of similarity among components to increase the e�ciencyof this approach in real-life situations. It is important to note that similarity isdi�erent from symmetry, which also can be an e�cient technique to handle thestate space explosion [84].

3.2 A simple method proposed

Our idea is that components may be considered to be the implementations of entitiesoriginating from one abstract class in which speci�cation formulas can be separatedaccording to whether they refer only to states and variables within a given compo-nent. As these formulas have no e�ect on any other components of the system, theseformulas and their truth values are stored temporarily and consequently need to bechecked only once when encountering one or more similar modules. In other words,model checking is shifted to a higher, �class� level. In this case the relevant formulascan be ignored, thus reducing the time and memory needs of model checking.The underlying steps of our method are the following:

1. The solution of a system is given for the simplest case. For instance, the solu-tion is worked out for one of the components only.

2. Model checking is executed on the system. If the process is successful, we moveto Step 3. Should the model checker return with a failure, the solution needsto be revised and modi�ed accordingly. Then model checking is executed againuntil we get the expected results.

3. The solution is analyzed from a new perspective, namely whether the speci�-cation can be decomposed to local and global parts.

4. A model of the system is given for more components. The global and localspeci�cations are separated from one another. The latter ones are excluded,as model checking is executed for the global speci�cation only. If we get theexpected results, the entire system should be considered correct with respectto both global and local speci�cations. Otherwise, the solution needs to berevised and modi�ed accordingly.

This approach is illustrated by simple examples and some experimental statisticsin the following sections. The initial version of our new approach including thebackground and motives was presented in [29].

36

Page 45: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 11: A simpli�ed state diagram of the tower

3.3 A sample system: Airport

A small airport is given with one control tower and a number of airplanes leaving andarriving. An aircraft is either on the ground, taking o�, �ying or landing. The towerand the airplanes are communicating with one another via messages (the airplanesrequesting takeo�s and landings, while the tower issuing the relevant permits).In Section 3.3.1 an oversimpli�ed version of the airport with one control tower andone airplane is modeled and analyzed. On this high level of abstraction the toweris symbolized as a boolean variable tower, and all the communication between thetower and the airplane is reduced to setting and querying the value of this variable.The simpli�ed functioning of the control tower can be seen in Figure 11 while theState Transition Model (STM) of the airplane can be seen in Figure 12.In Section 3.3.2 the functioning of the airport is extended to handle more airplanesby one control tower. In this case direct communication between the airplanes is notallowed (they should not be aware of one another) as it is the responsibility of thecontrol tower to synchronize the airplanes so that only one of them can be on therunway of the airport either taking o� or landing.

3.3.1 Airport model (with one tower and one airplane)

In the following code excerpt the airport system consists of two components (imple-mented as modules in NuSMV). The airplane is explicitly present while the toweris represented by a boolean variable tower. The airplane is parameterized with thevalue of tower replacing the entire process of communication with querying andsetting the actual value of this variable. The speci�cation is represented by LTL for-mulas earlier de�ned in Sections 1.3.1 and 1.3.2. For more �exibility, the extensionof LTL with past temporal operators may be used to express certain properties ofthe airport (e.g. checking whether the doors are locked before takeo� or the wheelsare out before landing) more elegantly.

37

Page 46: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 12: A simpli�ed state diagram of an airplane

The following model of the airplane implemented as module plane is a one-to-onemapping of the UML state transition diagram shown in Figure 12. By analyzing thespeci�cation, we can conclude that there are certain global elements are a�ecting theentire system, while others are carrying only local information for a component. Thisrecognition gave us the idea that it would be enough to check the local speci�cationfor only one component when a system consisting of similar components needs tobe veri�ed. In this case a decrease of the state space is expected.MODULE mainVAR

tower : boolean ;plane1 : p roce s s plane ( tower ) ;

ASSIGNi n i t ( tower ) := 1 ;

LTLSPEC G( tower=0 xor tower=1)

MODULE plane ( tower )VAR

s t a t e : {on_ground , req_takeof f , tak ing_of f , f l y i n g , req_land , land ing } ;ASSIGN

i n i t ( s t a t e ) := on_ground ;next ( s t a t e ) :=

cases t a t e = on_ground : {on_ground , req_takeo f f } ;( s t a t e = req_takeo f f ) & ( tower ) : tak ing_of f ;s t a t e = tak ing_of f : f l y i n g ;−− ext ra cond i t i on f o r wheels ins t a t e = f l y i n g : { f l y i n g , req_land } ;( s t a t e = req_land ) & ( tower ) : l and ing ;−− ext ra cond i t i on f o r wheels out

38

Page 47: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

s t a t e = land ing : on_ground ;1 : s t a t e ;

e sac ;next ( tower ) :=

case( s t a t e = req_takeo f f ) xor ( s t a t e = req_land ) : 0 ;( s t a t e = tak ing_of f ) xor ( s t a t e = land ing ) : 1 ;1 : tower ;

e sac ;

FAIRNESS ! ( s t a t e = req_takeo f f )FAIRNESS ! ( s t a t e = f l y i n g )FAIRNESS ! ( s t a t e = req_land )

LTLSPEC G! ( s t a t e = on_ground & s t a t e = f l y i n g )LTLSPEC G( s t a t e = f l y i n g −> F( s t a t e = land ing ) )LTLSPEC G( s t a t e = f l y i n g −> O( s t a t e = tak ing_of f ) )LTLSPEC G( s t a t e = tak ing_of f −> O( s t a t e = req_takeo f f ) )LTLSPEC G( s t a t e = req_takeo f f −> O( s t a t e = on_ground ) )LTLSPEC G( s t a t e = landing −> O( s t a t e = req_land ) )LTLSPEC G( s t a t e = req_land −> O( s t a t e = f l y i n g ) )

The following code excerpt shows a part of the global speci�cation placed within alocal module because otherwise the services provided by NuSMV would require themodi�cation of these formulas each time a new entity is introduced into the system.For this reason they were built into the module plane.LTLSPEC G (( s t a t e = req_takeo f f & tower = 1) −> F ( s t a t e = tak ing_of f ) )LTLSPEC G(( s t a t e = req_takeo f f & tower = 0) −> X( ! ( s t a t e = tak ing_of f ) ) )LTLSPEC G (( s t a t e = req_land & tower = 1) −> F ( s t a t e = land ing ) )LTLSPEC G(( s t a t e = req_land & tower = 0) −> X( ! ( s t a t e = land ing ) ) )LTLSPEC G ( tower = 1 −> ! ( s t a t e = tak ing_of f | s t a t e = landing ) )

FAIRNESSrunning

The execution of the NuSMV model checking process is successful providing theexpected results. This means that the model and the speci�cation are in alignmentwith each other. There are also comments in the module of the airplane referring tosome extra conditions that may be applied to make the model more life-like.

3.3.2 Airport model (with one tower and more airplanes)

In this example the airport is extended to handle more airplanes at a time. The be-havioral speci�cation of the airplane is basically the same but the global speci�cationneeds to be extended with the following formulas to verify the correct interpretationof messages (tower = 1 means the tower is free and the runway is clear, not theother way around) and the proper scheduling of the airplanes in the area:LTLSPEC G( tower=1 −> ! ( plane1 . s t a t e = tak ing_of f |

p lane1 . s t a t e = landing | plane2 . s t a t e = tak ing_of f |p lane2 . s t a t e = landing ) )

LTLSPEC G( tower=0 −> ( plane1 . s t a t e = tak ing_of f xorplane1 . s t a t e = landing xor plane2 . s t a t e = tak ing_of f xorplane2 . s t a t e = landing ) )

In the modular speci�cation the formulas are separated according to whether theyrefer to variables and states of other modules (the main module is also included) or

39

Page 48: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

not. In the �rst case re-checking of the formulas is unavoidable as there is explicitdependency between components that may be a�ected by other parts of the system.However, in the latter case there is no need to re-check the formulas that are notcrossing the �borders� of the modules. The relevant formulas to be ignored are thefollowing:

LTLSPEC G ! ( s t a t e = on_ground & s t a t e = f l y i n g )LTLSPEC G ( s t a t e = f l y i n g −> F ( s t a t e = land ing ) )LTLSPEC G ( s t a t e = f l y i n g −> O ( s t a t e = tak ing_of f ) )LTLSPEC G ( s t a t e = tak ing_of f −> O ( s t a t e = on_ground ) )LTLSPEC G ( s t a t e = req_takeo f f −> O ( s t a t e = on_ground ) )LTLSPEC G ( s t a t e = land ing −> O ( s t a t e = req_land ) )

This way the model checking of similar components becomes easier with a signi�cantreduction on the state space of the model.Below is the model including the speci�cation for the extended version of the airportdescribed earlier in this section.

MODULE mainVAR

tower : boolean ;plane1 : p roce s s plane ( tower ) ;plane2 : p roce s s plane ( tower ) ;

ASSIGNi n i t ( tower ) := 1 ;

−− from the o r i g i n a l s p e c i f i c a t i o nLTLSPEC G( tower = 0 xor tower = 1)

−− begin o f the extended formulasLTLSPEC G( tower=1 −> ! ( plane1 . s t a t e = tak ing_of f |

p lane1 . s t a t e = landing | plane2 . s t a t e = tak ing_of f |p lane2 . s t a t e = landing ) )

LTLSPEC G( tower=0 −> ( plane1 . s t a t e = tak ing_of f xorplane1 . s t a t e = landing xor plane2 . s t a t e = tak ing_of f xorplane2 . s t a t e = landing ) )

−− end o f the extended formulas

MODULE plane ( tower )

The model describing the functioning of the airplane is exactly the same as in theprevious example, so it is not detailed here. Fairness constraints are also unchanged.The following formulas can be removed from each module except for the one thatrepresents the abstract class.

LTLSPEC G ! ( s t a t e = on_ground & s t a t e = f l y i n g )LTLSPEC G ( s t a t e = f l y i n g −> F ( s t a t e = land ing ) )LTLSPEC G ( s t a t e = f l y i n g −> O ( s t a t e = tak ing_of f ) )LTLSPEC G ( s t a t e = tak ing_of f −> O ( s t a t e = on_ground ) )LTLSPEC G ( s t a t e = req_takeo f f −> O ( s t a t e = on_ground ) )LTLSPEC G ( s t a t e = land ing −> O ( s t a t e = req_land ) )

The following part is also unchanged with respect to the previous example, butthese formulas cannot be trusted without re-checking them each time the systemis extended with a new entity as they contain references to the actual state of thetower (variable), which makes them dependent on that.

LTLSPEC G (( s t a t e = req_takeo f f & tower = 1) −> F ( s t a t e = tak ing_of f ) )

40

Page 49: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

LTLSPEC G(( s t a t e = req_takeo f f & tower = 0) −> X( ! ( s t a t e = tak ing_of f ) ) )LTLSPEC G (( s t a t e = req_land & tower = 1) −> F ( s t a t e = land ing ) )LTLSPEC G(( s t a t e = req_land & tower = 0) −> X( ! ( s t a t e = land ing ) ) )LTLSPEC G ( tower = 1 −> ! ( s t a t e = tak ing_of f | s t a t e = landing ) )

FAIRNESSrunning

Running a model check without removing the formulas identi�ed in the previoussection results in the screen illustrated by Figure 13. The total numbers of allocatednodes in case of 2, 3 and 4 airplanes are 49, 666; 250, 501; 685, 005 respectively.Applying the reduction rules described earlier to force the model checker to ignorethe relevant formulas results in the screen shown by Figure 14. The number offormulas checked, the size of the state space, just like the time and memory needs ofmodel checking are seemingly down. The total numbers of allocated nodes in case of2, 3 and 4 airplanes are 32, 801 (34% reduction); 185, 284 (26% reduction); 530, 401(23% reduction) respectively. The pattern is too small to provide su�cient base forfurther conclusions, but the fact of the reduction in the state space is demonstratedwell.The organization of the components guarantees the scalability of extending the sys-tem with more airplanes without any di�culties. Introducing new airplanes requiresa small number of changes in the global speci�cation. These changes are based onthe same structure, so it may be done mechanically by the model checker (not yetsupported by NuSMV).

LTLSPEC G( tower=1 −> ! ( plane1 . s t a t e = tak ing_of f |p lane1 . s t a t e = landing | plane2 . s t a t e = tak ing_of f |p lane2 . s t a t e = landing | plane3 . s t a t e = tak ing_of f |p lane3 . s t a t e = landing | . . . | . . . ) )

LTLSPEC G( tower=0 −> ( plane1 . s t a t e = tak ing_of f xorplane1 . s t a t e = landing xor plane2 . s t a t e = tak ing_of f xorplane2 . s t a t e = landing xor plane3 . s t a t e = tak ing_of f xorplane3 . s t a t e = landing xor . . . xor . . . ) )

3.4 Conclusions

Building a system from components is supposed to ease the burden on softwarearchitects by making it possible to reuse already existing software parts, but thisis also full of challenges because the deployment environments and purposes canseverely di�er from the original ones.Model checking is a formal method to verify whether the model of a system iscorrect to a given speci�cation. The main challenge concerning the usability of modelchecking in the business world is to handle state space explosion. Building a systemfrom many similar components can help to cope with this problem by making itunnecessary to check a subset of formulas in the local speci�cation of components,as we have shown it in a life-like example.A challenging and open question is whether it is possible to further reduce theresource needs of model checking by adapting and applying Open Incremental Model

41

Page 50: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 13: NuSMV result screen without removing some of the formulas

42

Page 51: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 14: NuSMV result screen after removing some of the formulas

Checking to handle incremental models with LTL speci�cations using Past Tenseoperators. Studying the possibility of giving a modi�ed algorithm and implementingit in NuSMV is currently underway.It is worth mentioning at this point that the model checking based on local and globalspeci�cations may be more e�ective when combining it with incremental techniques.

4 Extending systems with veri�ed components

4.1 Scalability issues

The paradigm of CBSD builds around the idea that certain parts of a softwaresystem can easily be replaced on demand, or the entire system can be extended toprovide additional features and services for the users.Model checking has undoubtedly emerged as one of the most e�ective formal meth-ods for verifying �nite, concurrent systems automatically. The most signi�cant prob-lem of model checking is the state space explosion problem which occurs in large,complex systems where components can make transitions in parallel. Consequently,extending an existing system with one or more components can lead to an exponen-tial increase in the state space, thus causing serious problems for model checkingtools.The approach of OIMC is trying to compensate these di�culties by focusing exclu-sively on the changes of a system instead of rechecking the entire extended system

43

Page 52: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

which includes both the original and the new components [110, 111, etc.].In this section we study the practical and educational aspects of this new methodstrongly emphasizing the role of granularity and scalability, meanwhile intending toshow also its e�ciency. Two sample systems are used to illustrate the scalabilityof the extension of a given system. The �rst example in Section 4.2 is used tointroduce the basic concepts of the underlying techniques. Our study including theresearch motives can be found in [30]. The second example presented in Section 4.5is derived from the model presented in Section 3.3, and it includes experimentalstatistical results on the e�ciency of the OIMC algorithm. We presented this studyby including the educational aspects in [32].

4.2 An example: Automatic Betting Machine

In our example we designed an Advanced Betting Machine (ABM) for the game�TippMix�, the Hungarian version of �Bet and Win�. The only input needed for thebetting machine is the number of events a person wants to bet on (two-digit numbersentered on a console), and produces a ticket that is bound to the rules of the gamewith a combination of bets. A short overview of the game can be read below.Customers of �TippMix� can bet on the outcome of events listed in the betting o�ersissued by �Szerencsejatek Zrt.� every week or every two weeks typically containing200 betting events. (An optional input parameter may be the actual number ofevents for a given week.) Bets can be placed on the outcome of at least 1 and notmore than 14 events in single bets or a combination of events in multi bets. In singlebets the customer wins if they get right all the outcomes of the events they placeda bet on. In multi bets the customer can win with 1, 2 or 3 missed outcomes aswell � depending on the type of the combination. The most signi�cant constraintsconcerning the game are listed bellow:

� Only one bet can be placed on any one betting event.

� Bets can be placed on any combination of events.

� If you place bets on less than 3 events, these have to be selected from the �rst50 events.

� If you place bets on 3 to 5 events, these have to be selected from the �rst 150events.

� If you place bets on 5 or more events, these can be selected from all 200 events.

The simpli�ed functioning of the ABM can be seen in Figure 15.There are di�erent conditions that need to be satis�ed in order to make a transitionfrom one state to another. These conditions can guarantee the end results afterleaving a state. These constraints are collected into the behavioral speci�cation ofthe component, listed in Table 1. Our related results were published in [30].

44

Page 53: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

InitialState

andPrecondition

Transition

FinalState

andPostcondition

IdleandEnter

notPressed

Waiting

IdleandDisplay(0)

IdleandEnter

notPressed

EnterNum

(Num)

IdleandDisplay(Num)

IdleandEnterNum

(0)

PressEnter

IdleandDisplay(0)

IdleandEnterNum

(Num)

PressEnter

CheckingNum

andDisplay(Num)

CheckingNum

and

1≤Num<

3Working

andDisplay(Num)andMax

=50)

CheckingNum

and

3≤Num<

5Working

andDisplay(Num)andMax

=15

0)CheckingNum

and

5≤Num≤

14Working

andDisplay(Num)andMax

=20

0)CheckingNum

andNum>

14Error

IdleandDisplay(0)

Working

andNum

=1

GenerateTipsandPrint

Ticket

IdleandEventNum≤

50and

Tip

in(�Hom

e�,�Draw�,�Guest�)

Working

andNum>

1GenerateTipsandPrint

Ticket

IdleandEventNumiin

(1..Max

)Wherei

=1..Num

andEventNumi6=EventNumj

Wherei6=jandTip

in(�Hom

e�,�Draw�,�Guest�)

Table1:The

behavioralspeci�cation

oftheABM

45

Page 54: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 15: A simpli�ed state diagram of the ABM

4.3 Veri�cation of the system

In NuSMV the speci�cation of the system � usually a state transition machine � andthe constraints imposed on its functioning expressed by CTL formulas are presenttogether just as it can be seen in the following (oversimpli�ed) excerpt of the mainmodule.

MODULE main

VARs t a t e : { i d l e , checking , working} ;num : {0 . . 9 9} ;

ASSIGNi n i t ( s t a t e ) := i d l e ;i n i t (num) := 0 ;

next ( s t a t e ) :=case

( s t a t e = i d l e ) & (num > 0) : check ing ;( s t a t e = check ing ) & (num <= 14) : working ;( s t a t e = working ) : {working , i d l e } ;1 : i d l e ;

e sac ;

next (num) :=case

46

Page 55: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 16: Components of the ABM

(num < 99) : num + 1 ;1 : 0 ;

e sac ;

FAIRNESS ! ( s t a t e = checking )FAIRNESS ! ( s t a t e = working )

SPEC AG(( s t a t e = check ing ) −> AF( s t a t e = i d l e ) )SPEC AG(( s t a t e = check ing ) −> EF( s t a t e = working ) )SPEC AG(( s t a t e = working ) −> AF( s t a t e = i d l e ) )

The variable num in the module is equivalent with the input data Num from thebehavioral speci�cation in Table 1. An oversimpli�ed algorithm is used to simulatethe input of num. Within a short time NuSMV returns the result that none of theconstraints has been violated, which is quite easy to see.

Figure 16 shows how the ABM is composed of two components and how they interactwith each other. Labels ex1, ex2, ex3 and re1 are explained in Subsection 1.4.2.

47

Page 56: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

4.4 Extending the sample system with multiple terminals

Now we consider a situation where the previously discussed ABM should be able tohandle two terminals from which input data can arrive. We require mutual exclusionbetween the terminal components as only data from one terminal can be processed ata time. This is provided by a scheduler using a variant of the method introduced byPeterson [95]. The speci�cation and the constraints are extended from the previous�base�.MODULE main

VARsta t e0 : { i d l e , ente r ing , checking , working} ;s t a t e 1 : { i d l e , ente r ing , checking , working} ;turn : boolean ;term0 : p roce s s te rmina l ( s tate0 , s tate1 , turn , 0 ) ;term1 : p roce s s te rmina l ( s tate1 , s tate0 , turn , 1 ) ;

ASSIGNi n i t ( turn ) := 0 ;

FAIRNESS ! ( s t a t e 0 = check ing )FAIRNESS ! ( s t a t e 1 = check ing )FAIRNESS ! ( s t a t e 0 = working )FAIRNESS ! ( s t a t e 1 = working )

SPEC AG ! ( ( s t a t e 0 = check ing ) & ( s t a t e 1 = check ing ) )SPEC AG ! ( ( s t a t e 0 = check ing ) & ( s t a t e 1 = working ) )SPEC AG ! ( ( s t a t e 1 = working ) & ( s t a t e 0 = check ing ) )SPEC AG ! ( ( s t a t e 0 = working ) & ( s t a t e 1 = working ) )SPEC AG(( s t a t e 0 = ent e r i ng ) −> AF( s t a t e0 = check ing ) )SPEC AG(( s t a t e 1 = ent e r i ng ) −> AF( s t a t e1 = check ing ) )SPEC AG(( s t a t e 0 = check ing ) −> AF( s t a t e0 = i d l e ) )SPEC AG(( s t a t e 1 = check ing ) −> AF( s t a t e1 = i d l e ) )SPEC AG(( s t a t e 0 = check ing ) −> EF( s t a t e 0 = working ) )SPEC AG(( s t a t e 1 = check ing ) −> EF( s t a t e 1 = working ) )SPEC AG(( s t a t e 0 = working ) −> AF( s t a t e0 = i d l e ) )SPEC AG(( s t a t e 1 = working ) −> AF( s t a t e1 = i d l e ) )

MODULE termina l ( s tate_sa jat , state_masik , turn , turn_sajat )

VARnum : {0 . . 9 9} ;

ASSIGNi n i t ( s t a t e_sa ja t ) := i d l e ;i n i t (num) := 0 ;next ( s t a t e_sa ja t ) :=

case( s t a t e_sa ja t = i d l e ) & (num > 0) : en t e r i ng ;

( s t a t e_sa ja t = ent e r i ng ) & ( state_masik = i d l e ) : check ing ;( s t a t e_sa ja t = ent e r i ng ) & ( state_masik = ent e r i ng ) & ( turn = turn_sajat ) :

check ing ;( s t a t e_sa ja t = check ing ) & (num <= 14) & ( turn = turn_sajat ) : working ;( s t a t e_sa ja t = check ing ) & (num > 14) & ( turn = turn_sajat ) : i d l e ;( s t a t e_sa ja t = working ) & ( turn = turn_sajat ) : {working , i d l e } ;

1 : s t a t e_sa ja t ;e sac ;

next (num) :=case

(num < 99) : num + 1 ;1 : 0 ;

e sac ;

48

Page 57: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

next ( turn ) :=case

( turn = turn_sajat ) & ( ( s ta t e_sa ja t = check ing ) | ( s t a t e_sa ja t = working ) ) :! turn ;

1 : turn ;e sac ;

FAIRNESSrunning

Here the constraints are not violated, either. However, strictly for educational pur-poses some of the constraints can be changed because the counterexample generatedby NuSMV can help understand concurrent programming, for instance.The next question is whether it is always necessary to check the entire system modelor it is su�cient if the constraints satis�ed in the base component are matchedagainst the constraints in the extension.A simpli�ed model of the ABM extended from the previous model in such a waycan be seen in Figure 17.In our example the original betting machine consists of two components interactingwith each other. The terminal components have one exit state (ex1) when Enter ispressed and one reentry state (re1) when the two-digit number entered is greaterthan 14 and the terminal returns to the initial state. The generator component hasone exit state (ex2) when a ticket is returned to be printed at the terminal, seeFigure 16. The extended betting machine consists of two terminal components, thegenerator and a scheduler, which we will not consider as it has no e�ect on thefunctionality of the machine, see Figure 17. There is no direct connection betweenany of the terminal components and the generator anymore as the scheduler takesover as the mediator between the parties. The two constraints below (and the closurefor each) can easily be checked at the the exit state ex1.

SPEC AG(( s t a t e = check ing ) −> AF( s t a t e = i d l e ) )SPEC AG(( s t a t e = working ) −> AF( s t a t e = i d l e ) )

In the next step the extension must be checked with respect to the properties de-scribed above and their closure sets. The same properties appear twice in the listbelow as there are two terminal components in the extended system.

SPEC AG(( s t a t e 0 = check ing ) −> AF( s t a t e0 = i d l e ) )SPEC AG(( s t a t e 1 = check ing ) −> AF( s t a t e1 = i d l e ) )SPEC AG(( s t a t e 0 = working ) −> AF( s t a t e0 = i d l e ) )SPEC AG(( s t a t e 1 = working ) −> AF( s t a t e1 = i d l e ) )

The properties in connection with the scheduler component are not considered asthey do not a�ect the interoperability between the terminals and the generator.These are listed here.

SPEC AG ! ( ( s t a t e 0 = check ing ) & ( s t a t e 1 = check ing ) )SPEC AG ! ( ( s t a t e 0 = check ing ) & ( s t a t e 1 = working ) )SPEC AG ! ( ( s t a t e 1 = working ) & ( s t a t e 0 = check ing ) )SPEC AG ! ( ( s t a t e 0 = working ) & ( s t a t e 1 = working ) )SPEC AG(( s t a t e 0 = ent e r i ng ) −> AF( s t a t e0 = check ing ) )SPEC AG(( s t a t e 1 = ent e r i ng ) −> AF( s t a t e1 = check ing ) )

49

Page 58: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 17: The model of the extended ABM

There are two properties present in the original betting machine that do not need tobe checked again as they refer to a state transition within the generator component,not at any exit or reentry states. These are the following:

SPEC AG(( s t a t e 0 = check ing ) −> EF( s t a t e 0 = working ) )SPEC AG(( s t a t e 1 = check ing ) −> EF( s t a t e 1 = working ) )

Finally, the algorithm compares whether the truth values of the closure sets of theproperties at the exit states are equivalent or not. In the case of the ABM it isrelatively easy to see that the algorithm ends with a successful comparison of thetruth values [30]. In more complex systems the number of properties that do notneed to be re-checked is expected to increase.

50

Page 59: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

4.5 Another sample system: An Airport

4.5.1 The basic version

The basic version of the original model is presented in 3.3.1. In the global speci�ca-tion of the airport the formula SPEC AG(tower = 0 xor tower = 1) should guaranteethat the value of tower is always 0 or 1. It is quite obvious in this case, but in real-lifesituations there might be an occurring distortion of information which can lead toa possible breakdown of the air tra�c control. An example will be given in Section4.5.2.Formula SPEC AG(tower = 1 -> !(plane1.state = taking_o� xor plane1.state =landing xor plane2.state = taking_o� xor plane2.state = landing)) and formulaSPEC AG(tower = 0 -> (plane1.state = taking_o� xor plane1.state = landing xorplane2.state = taking_o� xor plane2.state = landing)) ensure that there are nomisunderstood messages during the synchronization of the airplanes so that onlyone of them can be on the runway of the airport either taking o� or landing (in thiscase when tower = 0).In the module speci�cation of the airplane the fairness constraints are meant toignore all those sequences where the tower does not guarantee that each eligibleairplane will eventually be chosen for running [17]. This means that a fairness con-straint restricts the attention only to fair execution paths. The model checker doesnot consider path quanti�ers not applying to fair paths when there are evaluat-ing speci�cations. We note that NuSMV supports two types of fairness constraints,namely justice constraints and compassion constraints. A justice constraint consistsof a formula f which is assumed to be true in�nitely often in all the fair paths.A compassion constraint consists of a pair of formulas (p, q); if property p is truein�nitely often in a fair path, then also formula q has to be true in�nitely often inthe fair path.Formula SPEC AG !(state = on_ground & state = �ying) within the module air-plane ensures that a nonsense such as a plane in the air and on the ground atthe same time is not possible. Formula SPEC AG (state = �ying -> AF (state =landing)) should check that all planes having taken o� will eventually land.The following global speci�cation formulas are situated within the module airplanefor simply technical reasons. Otherwise, there should be as many of them as thenumber of airplanes in the system.Formula SPEC AG((state = req_takeo� & tower = 1) -> AF(state = taking_o�))guarantees that any plane requesting a takeo� will eventually get the permission ifthe runway is not used by another plane (when tower = 1).Formula SPEC AG((state = req_takeo� & tower = 0) -> AX(!(state = taking_o�)))ensures that none of the airplanes can take o� in the next moment if the runwayis currently in use. The description of the two formulas concerning landing can begiven analogously.The result of the model checking for this speci�c case of one tower and two airplanescan be seen in Figure 18. The total number of allocated BDD nodes in this case is

51

Page 60: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 18: Screenshot of the successful completion of model checking

4, 242. The example above could also be speci�ed by using LTL formulas. For more�exibility, the extension of LTL with past temporal operators may be used to expresscertain properties of the airport (e.g. checking whether the doors are locked beforetakeo� or the wheels are out before landing).

4.5.2 A (faulty) variant of the airplane

Let us take a look at the following variant of the airport system. The occupation ofthe runway can be interpreted in di�erent ways. For example, the opposite meaningcan be associated with the truth values of tower. It can be easily seen that thisrequires only a slight modi�cation of the airplane module presented in Section 3.3.2.The necessary modi�cations within the model of the airplane are the following:

. . .i n i t ( tower ) := 0 ;. . .next ( tower ) :=case( s t a t e = req_takeo f f ) | ( s t a t e = req_land ) : 1 ;( s t a t e = tak ing_of f ) | ( s t a t e = land ing ) : 0 ;1 : tower ;e sac ;. . .

The global speci�cation formulas situated in the module airplane can be left outas we might consider a COTS with no knowledge of the outside world. The totalnumber of allocated nodes in this case is 367. The screenshot of a successful executionof checking the model of this component can be seen in Figure 19.A system consisting of airplanes of this type which communicate with a tower byusing opposite meaning messages compared to the one in the previous example is

52

Page 61: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 19: Model checking results of a single airplane component

also functioning properly as it can be proved by using NuSMV, however it is notdetailed here for lack of space.Let us now consider a situation in which the airport described in Section 4.5.2 isextended with a new airplane of this latter type. The necessary modi�cations to thespeci�cation are the following:

SPEC AG( tower = 0 xor tower = 1)SPEC AG( tower=1 −> ! ( plane1 . s t a t e = tak ing_of f |p lane1 . s t a t e = landing | plane2 . s t a t e = tak ing_of f |p lane2 . s t a t e = landing | plane3 . s t a t e = tak ing_of f |p lane3 . s t a t e = landing ) )SPEC AG( tower=0 −> ( plane1 . s t a t e = tak ing_of f xorplane1 . s t a t e = landing xor plane2 . s t a t e = tak ing_of f xorplane2 . s t a t e = landing xor plane3 . s t a t e = tak ing_of f xorplane3 . s t a t e = landing ) )

The �rst formula is not violated because even with opposite meaning values theinterval is still the same. The second and third formulas are violated, and this factis shown by counterexamples generated with the execution of a standard modelchecking process.However, for educational purposes it would be interesting to see how importantit is to properly de�ne the su�cient conditions for a minimally safe system. Sowhat happens if the second and third formulas are �forgotten� and left out of theglobal speci�cation accidentally? The third (faulty) airplane will misinterpret themessages of the tower. In case tower = 1, it will wait either on the ground or in theair though the runway is actually empty. In case tower = 0, it will not be aware thatanother plane is using the runway and this mix-up will result in a possible crash.The following screenshot in Figure 20 illustrates that the model checking process willstill be successful, though the system is not trustable. This situation is dangerousand unacceptable.This phenomenon sheds light on some of the problems of modeling a system asan insu�cient speci�cation or the use of bad formulas may lead to unsafe systemsundermining the main advantage of formal methods, namely the guarantee thatthere are no hidden errors left in the model and in the code.

4.5.3 A correct solution improved with OIMC

Now let us consider a situation in which the airport described in Section 4.5.1 isextended with an airplane originating from the very same plane type. This newthird plane does not contain the global speci�cation formulas within the module asopposed to the existing aircrafts. After checking the model of this extended system

53

Page 62: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 20: A faulty system not recognized by model checking because of the insuf-�cient global speci�cation

we get the following results shown in Figure 21.The total number of allocated nodes is 21, 075 in case there are three airplanescontrolled by the tower. This is signi�cantly greater than the number of nodes inthe case of two airplanes.The scalability of extending the system with more airplanes can be easily guaranteedby forcing the same structure in the subformulas as it can be seen below:

SPEC AG( tower = 1 −> ! ( plane1 . s t a t e = tak ing_of f |p lane1 . s t a t e = landing | plane2 . s t a t e = tak ing_of f |p lane2 . s t a t e = landing | plane3.state = taking_off | plane3.state = landing ) )SPEC AG( tower = 0 −> ( plane1 . s t a t e = tak ing_of f xorplane1 . s t a t e = landing xor plane2 . s t a t e = tak ing_of f xorplane2 . s t a t e = landing xor plane3.state = taking_off xor plane3.state = landing ) )

Introducing new airplanes requires a small number of changes in the global speci�ca-tion. These changes are based on the same structure, so it may be done mechanicallyby the model checker in the future.The need to reduce the number of states and the recognition of similarity betweenthe components of a system led to a method exploiting the similarities betweenmodules, described in [29].Unfortunately, the notion of similarity was too restrictive, so a more general solutionhad to be found.Consequently, the relatively new approach of OIMC has become the center of ourattention. The entire theoretical background and the algorithm are beyond the scopeof this work, but an overview can be found in [110, 111, etc.]. In the followingparagraphs the informal algorithm of OIMC is described exclusively.In the beginning a property p (in the form of a CTL formula) is assumed to hold inthe base component B. Then the extension component E must be checked whether itviolates p. By using the incremental model checking algorithm it is su�cient to know

54

Page 63: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 21: Result screen of NuSMV showing that the extended system preserves thedesired properties

whether all the respective pairs of the exit points of B and E preserve the propertyp. At the end of the execution of the algorithm components B and E consistentlypreserve the desired property if the truth values of their closures for the property pare the same. There is no need to recheck the entire model of the extended systemin addition to the actual veri�cation of the base and the extension.The closures for the global speci�cation formulas in the base component (one towerand two planes) are the sets of subformulas below:

ClB1= (AG( tower = 0 xor tower = 1) ; ( tower = 0 xor tower = 1) ; tower = 0 ; tower =1)

ClB2= (AG( tower = 1 −> ! ( plane1 . s t a t e = tak ing_of f | p lane1 . s t a t e = landing |

plane2 . s t a t e = tak ing_of f | p lane2 . s t a t e = land ing ) ) ; tower = 1 ;p lane1 . s t a t e = tak ing_of f ; p lane1 . s t a t e = landing ; plane2 . s t a t e =

tak ing_of f ;p lane2 . s t a t e = landing )

ClB3= (AG( tower = 0 −> ( plane1 . s t a t e = tak ing_of f xor plane1 . s t a t e = land ing xor

plane2 . s t a t e = tak ing_of f xor plane2 . s t a t e = land ing ) ) ; tower = 0 ;p lane1 . s t a t e = tak ing_of f ; p lane1 . s t a t e = landing ; plane2 . s t a t e =

tak ing_of f ;p lane2 . s t a t e = landing )

It is quite obvious that in the case of a faulty airplane ClB1 = ClE1 as the newmodule will use the same values of 0 and 1, meaning that interoperation betweenthe base and the extension is possible. However, the respective pairs of ClB2 , ClE2

and ClB3 , ClE3 will not be equal since the highlighted atomic formulas will havetheir negated counterparts in their respective pairs.On the other hand, by extending the airport with an aircraft of the original class

55

Page 64: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

plane will result in the same closures for the properties above at the exit points inthe extension, making it possible for them to interoperate with each other.The cost of this type of model checking will be signi�cantly lower than the standardprocess as the number of allocated nodes in this case is approximately 4, 242 for thebase and 367 for the extension, resulting in a roughly 78% reduction in the statespace. But the cost of determining the exit points, then generating and comparingthe respective closures of the base and the extension should also be calculated withsome measurement techniques.The real situation is quite ambiguous as the results of the OIMC algorithm arepromising, but the algorithm has not been implemented yet, therefore almost theentire process needs to be done manually. In practice, there is currently no matchfor standard model checking techniques.From an educational point of view it could be a cornerstone in shifting the atten-tion of students from coding to the incremental architecture of systems by usingcomponents.

4.6 Comparing OIMC with our method

It is not easy to compare the method we have proposed in 3.2 with OIMC as neitherof these approaches have been implemented in practice yet. Although we can relyon the number of calculated nodes of a system model to some extent, there are alsoother factors to consider:

� Cost of calculation: On the one hand OIMC �rst requires the model check-ing for both the base component and the extension, then the closures of therelevant formulas at the exit and reentry points must be generated and com-pared. On the other hand, the method we have proposed requires the analysisand restructuring of the formulas based on whether they are local or global.Subsequently a regular model checking takes place in a reduced state space.

� Performance: As OIMC only considers formulas at the exit and reentrypoints, the performance of the algorithm is steady even if the system is highlyscaled. The method we have proposed, on the other hand, is scalable to acertain extent, but more and more global speci�cation formulas are needed toensure interoperability between components.

� Educational aspect: We consider it important to demonstrate to the stu-dents that through our method the risk of state space explosion can be reducedeven with the use of relatively simple methods.

Based on our experimental statistics from the previous sections we suspect thatthere is no signi�cant di�erence between the e�ciency of these two algorithms inthe case of system models consisting of similar or identical components. The reasonfor that is quite simple; while OIMC uses a more complicated algorithm to generate

56

Page 65: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 22: The main screen of JanKo

and compare the closures, our method requires more accurate preparatory job whenanalyzing and restructuring the formulas.But it is also important to point out that OIMC is a more generally applicablesolution as it has no prerequisites for the components such as whether they haveto be similar or identical. Open Incremental Model Checking has lots of potentialto improve the scalability of component-based software systems, but an appropriatetool is needed to implement the algorithm. Our contribution to this research hasbeen the development of such a simple software application, JanKo.

4.7 JanKo, a tool supporting the use of OIMC

The algorithm of OIMC has not been implemented yet, therefore we have developeda simple tool named JanKo, which is able to support the use of the aforementionedincremental model checking method. Although the tool is fully functional, it shouldstill be considered a work in progress. The ultimate goal is to integrate the func-tionality of our tool into the NuSMV model checker.JanKo is a Java application which can process either two input �les containing CTLor LTL formulas. These input �les are usually NuSMV source �les or output �les

57

Page 66: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 23: The comparison screen of JanKo

generated with the interactive mode of the model checker. The tool also features thepaste of supported formulas directly from the clipboard as an option.

JanKo automatically extracts and displays only the valid formulas from the input�les. It recognizes both CTL and LTL formulas, but allows only one type to be pro-cessed at a time (with the help of a radio button on the central panel). A screenshotof the main screen can be seen in Figure 22.

Clicking on the Closure of the formulae! button will generate the closure of theavailable formula set by using an algorithm we have developed.

The left and right panel of the main screen is basically identical. One side shouldbe used to generate the closure of formulas for the base component, while the otherside should do the very same for the extension.

When both closures are available on the screen, clicking on the Compare! takes theuser to a new window where di�erences and matches can both be visually highlightedby using the buttons on the central panel. A screenshot of this so-called comparisonscreen can be seen in Figure 23.

Although JanKo still requires human interaction to decide whether interoperabilityis possible between two components (represented by the input �les or formula setsmanually entered), the tool is already a signi�cant step to automatize the use ofOIMC in practice.

We are currently working on the integration of JanKo into the NuSMV modelchecker. As a �rst step the tool is being prepared to support input �les as com-mand line parameters. We have also contacted the research & development groupfeaturing Roberto Cavada et al. to initiate a joint research on this topic [17]. Thesource code of JanKo can be found in Appendix A.

58

Page 67: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

4.8 Future work

OIMC is a relatively new approach which emphasizes the changes to a system ratherthan model checking the entire system. OIMC was brought to life by the need toreduce the state space signi�cantly in order to make this new generation of modelchecking techniques applicable in large and complex real life applications.Currently there are three major problems with the usage of the OIMC algorithm.

� First, it is not able to handle circular dependency between the interface statesof the base and the extension.

� Secondly, it supports only the CTL temporal logic language.

� Thirdly, to our best knowledge, the algorithm has not been implemented inan open-source, close-to-standards model checking tool yet.

We are addressing the �rst problem with a greatest �xed point approach. A possiblesolution to the second problem is currently underway, the algorithm is modi�ed byintroducing new rules to handle LTL formulas and also Past Tense operators. Weare also working on the third problem as we �rmly believe these results can help inthe formal veri�cation of larger and more complex software systems, not only froma practical but also from an educational aspect.Although de�ning contracts for the component is still our job, there are remarkableresults in this �eld as the authors of [4] created a tool that is capable of extract-ing contracts from components automatically, but only in the .NET environment.A similar tool for the Java platform would not only be appreciated by componentdevelopers and assemblers but it would also provide an opportunity to compare thecontracts extracted by di�erent tools. A tool should be developed which is able totransform these contracts to CTL temporal constraints for model checking (espe-cially OIMC).An educational framework with a library of veri�ed components outlined in [40]needs to be created for providing an environment for IT students to practice designdecisions.

4.9 Conclusions

We must not forget about the educational aspect of contracts either, as the e�ective-ness of veri�ed components developed for the same purpose but by using di�erenttools also becomes comparable based on measurable data (e.g. execution time). Theexample of the ABM is also suitable to illustrate the design decisions concerningthe granularity of components. If we assume that our client needs an automaticgambling machine supporting not only betting on sports events but also di�erentlottery games, then the developer has to decide which case is the most suitable forthe speci�c task.

59

Page 68: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

� The �rst alternative is to develop the remaining components from scratchwithout paying the least attention to the already existing component.

� The second solution is to try to adapt the existing component to the mod-i�ed situation. The developer may recognize the similarity between bettingon sports events and a lottery game with �ve numbers in the following way.A lottery number can be considered a sports event, the number of all sportsevents is 90 and the number of bets placed on sports events is always �ve. Thebet itself is not important in this scenario.

� The third alternative is to restructure the entire component, for example therandom number generator becomes an independent component as it is themost reusable part of the software in other gambling games as well.

The best solution depends on the speci�c situation but it is notable that theremay be another aspect to compare component e�ciency for educational purposes.Hopefully this research can result in the better use of formal methods in practicalapplications, the better understanding of speci�cations, and �nally less debuggingwork for developers. The ultimate goal is to make the processes of integration testingand checking the entire system model unnecessary for large and complex systems inthe case of replaced or modi�ed components. As a consequence of that third-partycomponents formally veri�ed by model checking techniques become more reliableand trustable in practice.

5 Formal veri�cation of network protocols

Computer networks have undergone remarkable development in the past years anddecades [62]. This process led not only to the development of the physical compo-nents of networks as a result of continuously modernizing manufacturing technolo-gies, but also to the emergence of protocols enabling communication and controlbetween the di�erent devices [63]. Consequently, in all walks of life successful ande�ciently functioning activity can be conceived only with network support. TheChief Executive O�cer (CEO) of a leading company manufacturing network equip-ment has pertinently summarized the role of networking, which by now is highlydetermining how we work, live, play and learn. The change is strikingly visible onwebsites, as well as on social networks, as the young generation use it as a maintool to talk over school matters, organize joint programs where they take picturesand shoot videos which they upload on the net. Presently huge amounts of data arecirculating on the information highways, amount that is exponentially increasing asvideo communication gains ground. By 2015, 91% of the network tra�c is estimatedto be yielded by video communication, in addition around 30 million employees areexpected to work from home at least a day a week.Although the networking infrastructure is judged to be generally ready to meetthe needs of increased data tra�c, major concerns are raised by issues related to

60

Page 69: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

the protection of network circulated data. Fortunately, nowadays not only Smalland Medium Enterprises (SMEs) but also large companies lay considerable stresson developing proper network security. As a result user account control, �rewalls,Demilitarized Zones (DMZs), Intrusion Detection Systems (IDSs) and Intrusion Pre-vention Systems (IPSs) are being employed on a large scale.With the spread of computer crimes network attacks have become more sophisticatedand more subtle [79]. These no longer require user interaction as they are targetingthe lower layers of the network. On these layers routing and transport protocols areresponsible for the proper and safe data tra�c. If an attack is successful, all furtherdata may be captured or hijacked.

5.1 The relationship between formal methods and protocols

The sections below describe brie�y the relationship between formal methods andcommunication networks.Network protocols have all the characteristics of large and complex software systems,therefore they are organized into hierarchical layers (e.g. ISO/OSI reference model)built on each other. The layered structure enables the independent de�nition ofspeci�c communication functions, and the separate development of these, based ondi�erent standards. A protocol belonging to a speci�c layer operates similarly to ablack box that provides services to the layer above, communicates with entities ofthe same layer, meanwhile using services provided by the layer below. The actualprotocol consists of the communication rules of the given layer, and the servicesprovided to the layer above (service speci�cation). The description of the entities ofthe protocol together with the service speci�cation is called protocol speci�cation.As the speci�cation of protocols with informal techniques and natural languagesbecame insu�cient, formal methods have been placed into the focus [71]. One ofthe advantages of using formal speci�cations is that they can be strictly analyzedfrom completeness and consistency aspects. This is indispensable when fostering thecooperation between the di�erent realizations of protocols used in case of distributedsystems.The formal methods used for protocol speci�cation are based on three models [105]:

1. State Transition Model � The network protocol is an event-driven entity, whichoperates with message exchanges. The speci�c unit can be described on thebasis of transitions with which it reacts in internal or external situations. Thisallows the creation of the simplest model which enables the examination ofa large number of general characteristics. If a protocol is too complex, statespace explosion might occur.

2. Programming language based model � A network protocol performs algorith-mic processes that can be described with the elements of a higher level pro-gramming language. The proper operation of these types of models is di�cultto study.

61

Page 70: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

3. Hybrid model � To describe the protocol it combines the features of statetransition and programming language based models. In order to increase itsexpressing power the state transition model is complemented with variablesand program units, which thus turns it into an extended �nite state machine.

5.1.1 Formal veri�cation of protocols

The primary aim of protocol veri�cation before its actual implementation is to checkwhether the protocol is free of errors from the design phase. The protocol has tobe compared with the protocol speci�cation in the following way: Let P be a set ofevent sequences suggested by the service speci�cation, and let Q be a set of eventsequences exported to the service interface (towards the layer above), which aregenerated by the entity-entity operations of the protocol. Based on this the protocolveri�cation means proving the following:

� Q ⊂ P , where all possible executions of the primitives available on the serviceinterface are enabled by the service speci�cation, and

� P ⊂ Q, where all possible executions of the service primitives meeting therequirements of the service speci�cation can be implemented with the entity-entity operations of the protocol.

With the derivation of Q the entity-entity operations of the protocol can be exam-ined, namely general characteristics such as completeness (the protocol can acceptall input data in each system state), deadlock-free operation (the protocol shouldnever reach a system state � with the exception of the �nal state � from which thereis no further transition). In the case of �nite state protocols this means that a �nalstate can always be reached from the initial state, while in the case of in�nite stateprotocols the cyclical behavior can be checked which means that the process canmove on from each system state.

5.1.2 Formal veri�cation methods

The protocol veri�cation methods are generally employing two approaches, namelysynthesis and analysis. As a rule, synthesis is used when the protocol is designedwith the help of planning rules (from the informal speci�cation), which guaranteesthat the resulting protocol will have certain characteristics. Thus the existence ofthe desired characteristics will be built in the planning rules.Analysis is employed when there is a given protocol speci�cation and the existenceof certain expected characteristics has to the veri�ed. This includes both the exam-ination of the state space (model checking) and the proof correctness of programs.

62

Page 71: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

5.2 Characteristics related to routing protocol veri�cation

Generally speaking, the routing protocols are characterized by the following features,which a�ect the usability of formal veri�cation methods:

� Essentially this is a simple concurrent process operating in an inde�nite num-ber of several copies.

� Dynamic links are presumed and fault tolerance is required.

� The processes contain modestly complex and discreet reactive systems withinterfaces.

� Real-time operation is a basic requirement, as some activities can timeout, oron the contrary they have to react to these timeout limitations.

As testing cannot cover all potential instances (opposite to mathematical evidence),reliability of the protocol and its implementation could exponentially decrease. In-creased reliability could be provided by the usage of a system which can be veri�edon the basis of automatic analysis. This means that a device (model veri�cation)automatically generates all the implementation branches (tests), which prove theexistence of a correct protocol [76].The demand for verifying network protocols is not new. So far, there have beenseveral occasions when small errors went undiscovered during the design phase of aprotocol, errors which caused serious operational problems in production networks.

5.3 An example: the Open Shortest Path First routing pro-

tocol

We have taken as an example the Open Shortest Path First (OSPF) protocol, whichis an internal routing protocol used on the largest scale. OSPF is a link-state routingprotocol that was originally developed as a replacement for the Routing InformationProtocol (RIP). RIP is a distance vector routing protocol that had been acceptablein the early days of networking, but its reliance on hop count as the only measure forchoosing the best route quickly became unacceptable in larger networks that neededa more robust solution. OSPF is a classless routing protocol that has introducedthe concept of areas for scalability. OSPF generally uses bandwidth as cost metric.The major advantages of OSPF over RIP are its fast convergence and scalabilityto much larger network implementations. Internet Engineering Task Force (IETF)chose OSPF as their recommended Interior Gateway Protocol (IGP).The speci�cation of OSPFv1 dates back to 1989, when it was published in RequestFor Comments (RFC) 1131 [98]. In 1991 OSPFv2 was introduced in RFC 1247by John Moy [99]. OSPFv2 o�ered signi�cant technical improvements over OSPFv1.The RFC 2328 model already includes an updated version of OSPFv2, which de�nesthe IPv4 based version [100]. In Sections 9 and 10 of the RFC 2328 document

63

Page 72: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

the description of a state machine can be found, namely that of an interface statemachine and of an adjacency state machine. In this section OSPF refers to theOSPFv2 protocol speci�ed in RFC 2328.The RFC fully documents all the states, events, interface types, and also de�nesthe transitions. In our example the open source software NuSMV is used for mod-eling and veri�cation. The formal statements specifying the expected behavior ofa model use CTL syntax. But let us examine the models derived from the RFCdocumentation �rst.

• Interface state machine:

� Interface types:

∗ Point-to-point∗ Broadcast∗ NBMA∗ Point-to-MultiPoint∗ Virtual-link

� States:

∗ Down: initial state, no protocol tra�c is forwarded.∗ Loopback: normal tra�c is not forwarded by the interface, only forgetting information.∗ Point-to-point: the interface is fully operational, creating point-to-point or virtual-link connections.∗ Waiting: the router is trying to discover the Designated Router (DR)and the Backup Designated Router (BDR) of the network by listeningto Hello packages.∗ DROther: the interface is connected to a broadcast or Non-BroadcastMulti-Access (NBMA) network, so the DR and the BDR are notelected. Adjacency relationship is created with the DR and BDRrouters.∗ Backup: the interface is selected as the BDR of the network. Adja-cency relationship is created with all the other devices on the net-work.∗ DR: the interface is selected as the Designated Router of the network,and similarly to the Backup state, adjacency relationship is createdwith all the other devices on the network.

� Events:

∗ InterfaceUp: the network interface is fully operational.∗ WaitTimer: the wait timer is activated, at the end of the countdownthe DR and the BDR are elected.

64

Page 73: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 24: Interface State Machine Source: RFC 2328

∗ BackupSeen: a BDR is discovered by the interface using Hello mes-sages.∗ NeighborChange: a change has occurred in the adjacency relationshipassociated with the interface. The DR and the BDR must be re-elected.∗ LoopInd: indicates that the state of the interface is changed to Loop-back.∗ UnloopInd: indicates that the interface exits from Loopback state.∗ InterfaceDown: the interface is not able to operate any more due tothe indication of lower level protocols.

MODULE i n t e r f a c eVARevent : { inter face_up , wait_timer , backup_seen , neighbor_change , loop_ind ,

unloop_ind , interface_down } ;s t a t e : {down , loopback , wait ing , point−to−point , drother , backup , dr } ;type : { point−to−point , broadcast , nbma , point−to−mult ipo int , v i r t ua l_ l i nk } ;

ASSIGNi n i t ( type ) := {broadcast , point−to−point , nbma , point−to−mult ipo int , v i r t ua l_ l i nk

} ;

65

Page 74: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

next ( type ) := type ;i n i t ( event ) := inter face_up ;next ( event ) := case

s t a t e = loopback : {unloop_ind , interface_down } ;s t a t e = down : { inter face_up , loop_ind } ;s t a t e = point−to−point : { interface_down , loop_ind } ;s t a t e = wait ing : {wait_timer , backup_seen , interface_down , loop_ind } ;s t a t e = drother : {neighbor_change , interface_down , loop_ind } ;s t a t e = backup : {neighbor_change , interface_down , loop_ind } ;s t a t e = dr : {neighbor_change , interface_down , loop_ind } ;TRUE : event ;

e sac ;i n i t ( s t a t e ) := down ;next ( s t a t e ) := case

s t a t e = down & event = inter face_up & type in {point−to−point , point−to−mult ipo int , v i r t ua l_ l i nk } : point−to−point ;

s t a t e = down & event = inter face_up & type in {nbma , broadcast } : wa i t ing ;s t a t e = wait ing & event = backup_seen : { drother , backup , dr } ;s t a t e = wait ing & event = wait_timer : { drother , backup , dr } ;s t a t e in { drother , backup , dr} & event = neighbor_change : { drother , backup , dr

} ;s t a t e in {down , loopback , wait ing , point−to−point , drother , backup , dr} & event

= loop_ind : loopback ;s t a t e = loopback & event = unloop_ind : down ;s t a t e in {down , loopback , wait ing , point−to−point , drother , backup , dr} & event

= interface_down : down ;TRUE : s t a t e ;e sac ;

• Adjacency state machine:

� States:

∗ Down: initial state, no available information from any neighbors.

∗ Attempt: no available information from the neighbors, so direct con-nection is needed (only in NBMA networks).

∗ Init: Hello packet has arrived from the neighbor, but no two-waycommunication yet (the router is not present in the Hello messagesent by the neighbor).

∗ 2-Way: this state allows two-way communication.

∗ ExStart: this is the �rst step of creating an adjacency relationship.The so-called �master� router is determined in this state based onthe initial Database Description (DD) sequence number.

∗ Exchange: the entire Link-State Database (LSDB) is sent to theneighbor by the router using DD packets.

∗ Loading: in this state Link-State Requests (LSRs) are sent to theneighbor by the router in exchange for the latest Link-State Ad-vertisements (LSAs) not yet received but discovered in the previousstate.

∗ Full: this state means the adjacency relationship is full(y functional).

� Events:

66

Page 75: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

∗ HelloReceived: a Hello packet has arrived from the neighbor.

∗ Start: Starting with this state hello packets are sent to the neighborafter every HelloInterval.

∗ 2-WayReceived: two-way connection is built with an adjacent router.

∗ NegotiationDone: the master/slave relationship is established and theexchange of DD sequence numbers has been completed with the ad-jacent router.

∗ ExchangeDone: all DD packets have been received by both routers.

∗ LoadingDone: all the Link-State Updates (LSUs) have been receivedfrom the neighbor.

∗ BadLSReq: an LSR has arrived to an LSA not in the database, whichindicates an error during database synchronization.

∗ AdjOk?: a decision has to be made by the router whether it is nec-essary to create/maintain the adjacency relationship.

∗ SeqNumberMismatch: a DD packet has been received with an unex-pected DD sequence number, an Init bit set, or with an Options �elddi�ering from the previous DD packet. This also indicates an errorin the creation of the adjacency relationship.

∗ 1-Way: a Hello packet has arrived from the neighbor in which therouter is not identi�ed, so the two-way connection is not availableyet.

∗ KillNbr: indicates that communication with the neighbor is not pos-sible, state is changed to Down.

∗ InactivityTimer: the Inactivity Timer is activated, which means thatno Hello packet has been received from the neighbor for a while, sostate is changed to Down.

∗ LLDown: unreachability of the neighbor is indicated by lower levelprotocols.

MODULE ne ighbor_re l a t i on sh ipVARs t a t e : {down , attempt , i n i t_s ta t e , two−way , exs ta r t , exchange , loading , f u l l } ;event : { he l l o_rece ived , s t a r t , two−way_received , negotiat ion_done , exchange_done

, bad_lsr_req , loading_done , adj_ok_question , seq_number_mismatch , one−way ,k i l l_nbr , inac t iv i ty_t imer , ll_down } ;

ASSIGNi n i t ( event ) := { he l l o_rece ived , s t a r t } ;next ( event ) := case

s t a t e = down : { s ta r t , he l l o_rece ived , k i l l_nbr , ll_down , inac t i v i t y_t imer } ;s t a t e = attempt : { he l l o_rece ived , k i l l_nbr , ll_down , inac t i v i t y_t imer } ;s t a t e = in i t_s t a t e : {two−way_received , one−way , he l l o_rece ived , k i l l_nbr ,

ll_down , inac t i v i t y_t imer } ;s t a t e = two−way : { he l l o_rece ived , adj_ok_question , k i l l_nbr , ll_down ,

inac t iv i ty_t imer , two−way_received , one−way} ;s t a t e = ex s t a r t : { negotiat ion_done , he l l o_rece ived , adj_ok_question , k i l l_nbr ,

ll_down , inac t iv i ty_t imer , two−way_received , one−way} ;

67

Page 76: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Figure 25: Adjacency FSM Source: RFC 2328

s t a t e = exchange : {exchange_done , he l l o_rece ived , adj_ok_question ,seq_number_mismatch , bad_lsr_req , k i l l_nbr , ll_down , inac t iv i ty_t imer , two−way_received , one−way} ;

s t a t e = load ing : { loading_done , he l l o_rece ived , adj_ok_question ,seq_number_mismatch , bad_lsr_req , k i l l_nbr , ll_down , inac t iv i ty_t imer , two−way_received , one−way} ;

s t a t e = f u l l : { he l l o_rece ived , adj_ok_question , seq_number_mismatch ,bad_lsr_req , k i l l_nbr , ll_down , inac t iv i ty_t imer , two−way_received , one−way} ;

TRUE : event ;e sac ;i n i t ( s t a t e ) := down ;next ( s t a t e ) := case

s t a t e = down & event = s t a r t : attempt ;s t a t e = attempt & event = he l l o_rec e i v ed : i n i t_ s t a t e ;s t a t e = down & event = he l l o_rec e i v ed : i n i t_ s t a t e ;s t a t e in { in i t_s ta t e , two−way , exs ta r t , exchange , f u l l , l oad ing } & event =

he l l o_rec e i v ed : s t a t e ;s t a t e = in i t_s t a t e & event = two−way_received : { exs ta r t , two−way} ;s t a t e = in i t_s t a t e & event = one−way : s t a t e ;

68

Page 77: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

s t a t e = ex s t a r t & event = negot iat ion_done : exchange ;s t a t e = exchange & event = exchange_done : { f u l l , l oad ing } ;s t a t e = load ing & event = loading_done : f u l l ;s t a t e = two−way & event = adj_ok_question : {two−way , e x s t a r t } ;s t a t e in { exs ta r t , exchange , f u l l , l oad ing } & event = adj_ok_question : { s ta te ,

two−way} ;s t a t e in {exchange , f u l l , l oad ing } & event = seq_number_mismatch : e x s t a r t ;s t a t e in {exchange , f u l l , l oad ing } & event = bad_lsr_req : e x s t a r t ;s t a t e in {down , in i t_s ta t e , attempt , ex s ta r t , two−way , exchange , f u l l , l oad ing }

& event = k i l l_nbr : down ;s t a t e in {down , in i t_s ta t e , attempt , ex s ta r t , two−way , exchange , f u l l , l oad ing }

& event = ll_down : down ;s t a t e in {down , in i t_s ta t e , attempt , ex s ta r t , two−way , exchange , f u l l , l oad ing }

& event = inac t i v i t y_t imer : down ;s t a t e in {two−way , exs ta r t , exchange , f u l l , l oad ing } & event = two−way_received

: s t a t e ;s t a t e in {two−way , exs ta r t , exchange , f u l l , l oad ing } & event = one−way :

i n i t_ s t a t e ;TRUE : s t a t e ;

e sac ;

The given modules can be instantiated in NuSMV, speci�ed by statements with CTLsyntax. These statements are then veri�ed by the software. In the case of a returnedfalse result, a counterexample is also provided. In this example four statements areprovided for the interface state machine, while one is provided for the adjacencystate machine. Based on the output the �rst and third statements are true, whileall the rest seem to be false.

CTLSPEC !EF( ( i n t e r f a c e . type = point−to−point xor i n t e r f a c e . type = point−to−mult ipo int xor i n t e r f a c e . type = v i r tua l_ l i nk ) & ( i n t e r f a c e . s t a t e = dr xori n t e r f a c e . s t a t e = drother xor i n t e r f a c e . s t a t e = backup ) ) ;

CTLSPEC !EF( ( i n t e r f a c e . type = point−to−point xor i n t e r f a c e . type = point−to−mult ipo int xor i n t e r f a c e . type = v i r tua l_ l i nk ) & ( i n t e r f a c e . s t a t e = point−to−point ) ) ;

CTLSPEC !EF( ( i n t e r f a c e . type = broadcast xor i n t e r f a c e . type = nbma) & ( i n t e r f a c e .s t a t e = point−to−point ) ) ;

CTLSPEC !EF( ( i n t e r f a c e . type = broadcast xor i n t e r f a c e . type = nbma) & ( i n t e r f a c e .s t a t e = dr xor i n t e r f a c e . s t a t e = drother xor i n t e r f a c e . s t a t e = backup ) ) ;

CTLSPEC !EF( neighbor . s t a t e = f u l l ) ;

Based on the NuSMV model three statements were found to be false (in accordancewith our preliminary anticipations), while two were considered true as illustrated bythe following output:

−− s p e c i f i c a t i o n ! (EF ( ( ( i n t e r f a c e . type = point−to−point xor i n t e r f a c e . type = point−to−mult ipo int ) xor i n t e r f a c e . type = v i r t ua l_ l i nk ) & ( ( i n t e r f a c e . s t a t e = dr xori n t e r f a c e . s t a t e = drother ) xor i n t e r f a c e . s t a t e = backup ) ) ) i s t rue

−− s p e c i f i c a t i o n ! (EF ( ( ( i n t e r f a c e . type = point−to−point xor i n t e r f a c e . type = point−to−mult ipo int ) xor i n t e r f a c e . type = v i r t ua l_ l i nk ) & i n t e r f a c e . s t a t e = point−to−point ) ) i s f a l s e

−− as demonstrated by the f o l l ow i n g execut ion sequenceTrace Desc r ip t i on : CTL CounterexampleTrace Type : Counterexample−> State : 1 . 1 <−

i n t e r f a c e . event = inter face_upi n t e r f a c e . s t a t e = downi n t e r f a c e . type = point−to−mult ipo intne ighbor . s t a t e = downneighbor . event = he l l o_rec e i v ed

−> Input : 1 . 2 <−

69

Page 78: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

_process_selector_ = i n t e r f a c erunning = FALSEneighbor . running = FALSEi n t e r f a c e . running = TRUE

−> State : 1 . 2 <−i n t e r f a c e . s t a t e = point−to−point

−− s p e c i f i c a t i o n ! (EF ( ( i n t e r f a c e . type = broadcast xor i n t e r f a c e . type = nbma) &i n t e r f a c e . s t a t e = point−to−point ) ) i s t rue

−− s p e c i f i c a t i o n ! (EF ( ( i n t e r f a c e . type = broadcast xor i n t e r f a c e . type = nbma) & ( (i n t e r f a c e . s t a t e = dr xor i n t e r f a c e . s t a t e = drother ) xor i n t e r f a c e . s t a t e =backup ) ) ) i s f a l s e

−− as demonstrated by the f o l l ow i n g execut ion sequenceTrace Desc r ip t i on : CTL CounterexampleTrace Type : Counterexample−> State : 2 . 1 <−

i n t e r f a c e . event = inter face_upi n t e r f a c e . s t a t e = downi n t e r f a c e . type = broadcastne ighbor . s t a t e = downneighbor . event = he l l o_rec e i v ed

−> Input : 2 . 2 <−_process_selector_ = i n t e r f a c erunning = FALSEneighbor . running = FALSEi n t e r f a c e . running = TRUE

−> State : 2 . 2 <−i n t e r f a c e . s t a t e = wait ing

−> Input : 2 . 3 <−−> State : 2 . 3 <−

i n t e r f a c e . event = wait_timer−> Input : 2 . 4 <−−> State : 2 . 4 <−

i n t e r f a c e . s t a t e = backup− s p e c i f i c a t i o n ! (EF neighbor . s t a t e = f u l l ) i s f a l s e−− as demonstrated by the f o l l ow i n g execut ion sequenceTrace Desc r ip t i on : CTL CounterexampleTrace Type : Counterexample−> State : 3 . 1 <−

i n t e r f a c e . event = inter face_upi n t e r f a c e . s t a t e = downi n t e r f a c e . type = point−to−pointne ighbor . s t a t e = downneighbor . event = he l l o_rec e i v ed

−> Input : 3 . 2 <−_process_selector_ = neighborrunning = FALSEneighbor . running = TRUEi n t e r f a c e . running = FALSE

−> State : 3 . 2 <−neighbor . s t a t e = in i t_s t a t e

−> Input : 3 . 3 <−−> State : 3 . 3 <−

neighbor . event = two−way_received−> Input : 3 . 4 <−−> State : 3 . 4 <−

neighbor . s t a t e = ex s t a r tne ighbor . event = he l l o_rec e i v ed

−> Input : 3 . 5 <−−> State : 3 . 5 <−

neighbor . event = negot iat ion_done−> Input : 3 . 6 <−−> State : 3 . 6 <−

neighbor . s t a t e = exchangene ighbor . event = adj_ok_question

−> Input : 3 . 7 <−

70

Page 79: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

−> State : 3 . 7 <−neighbor . event = exchange_done

−> Input : 3 . 8 <−−> State : 3 . 8 <−

neighbor . s t a t e = f u l lne ighbor . event = bad_lsr_req

Consequently our anticipations were proved, which can be supported by the following�ndings:

� It is true that there is no single FSM state where the type of the interface ispoint-to-point, point-to-multipoint or virtual-link, when the state of the inter-face is set to DR, BDR or DROther.

� It is false that there is no single FSM state (which thus proves that there is sucha state) where the type of the interface is point-to-point, point-to-multipointor virtual-link, when the state of the interface is set to point-to-point.

� It is true that there is no single FSM state where the type of interface is eitherbroadcast or NBMA, when the state of the interface is set to point-to-point.

� It is false that there is no single FSM state (meaning there is such a state)where the type of the interface is either broadcast or NBMA, when the stateof the interface is set to DR, BDR or DROther.

� It is false that there is no single FSM state (which thus proves that this stateis reachable from the initial setup) where the adjacency state is FULL.

Finally, an NuSMV con�guration is created in which there are two routers intercon-nected through a broadcast interface on each. The OSPF priorities are intentionallyset to be di�erent to demonstrate the state transitions.

MODULE mainDEFINEr1_pr i o r i t y := 1 ;r 2_pr i o r i t y := 2 ;

VARr1 : p roce s s ospf_router ( r1_pr io r i ty , r 2_pr i o r i t y ) ;r2 : p roc e s s ospf_router ( r2_pr io r i ty , r 1_pr i o r i t y ) ;

FAIRNESSrunning ;

CTLSPEC !EF( r1 . i n t1 . s t a t e = dr & r2 . i n t1 . s t a t e = backup ) ;

MODULE ospf_router ( own_priority , o the r_pr i o r i t y )VARint1 : p roce s s i n t e r f a c e ( own_priority , o the r_pr i o r i t y ) ;

The statement we analyze is that there is no such an end state where R1 is theDR and R2 is the BDR. This statement is expected to be false as R1 has a higherpriority, supported by the following NuSMV output.

71

Page 80: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

−− s p e c i f i c a t i o n ! (EF ( r1 . i n t1 . s t a t e = dr & r2 . i n t1 . s t a t e = backup ) ) i s f a l s e−− as demonstrated by the f o l l ow i n g execut ion sequenceTrace Desc r ip t i on : CTL CounterexampleTrace Type : Counterexample−> State : 1 . 1 <−

r1 . i n t1 . event = inter face_upr1 . i n t1 . s t a t e = downr1 . i n t1 . type = broadcastr2 . i n t1 . event = inter face_upr2 . i n t1 . s t a t e = downr2 . i n t1 . type = broadcastr 2_pr i o r i t y = 2r1_pr i o r i t y = 1

−> Input : 1 . 2 <−_process_selector_ = r1 . i n t1running = FALSEr2 . running = FALSEr2 . i n t1 . running = FALSEr1 . running = FALSEr1 . i n t1 . running = TRUE

−> State : 1 . 2 <−r1 . i n t1 . s t a t e = wait ing

−> Input : 1 . 3 <−−> State : 1 . 3 <−

r1 . i n t1 . event = wait_timer−> Input : 1 . 4 <−−> State : 1 . 4 <−

r1 . i n t1 . s t a t e = e l e c t i o n−> Input : 1 . 5 <−−> State : 1 . 5 <−

r1 . i n t1 . s t a t e = dr−> Input : 1 . 6 <−

_process_selector_ = r2 . i n t1r2 . i n t1 . running = TRUEr1 . i n t1 . running = FALSE

−> State : 1 . 6 <−r2 . i n t1 . s t a t e = wait ing

−> Input : 1 . 7 <−−> State : 1 . 7 <−

r2 . i n t1 . event = wait_timer−> Input : 1 . 8 <−−> State : 1 . 8 <−

r2 . i n t1 . s t a t e = e l e c t i o n−> Input : 1 . 9 <−−> State : 1 . 9 <−

r2 . i n t1 . s t a t e = backup

5.4 Conclusions

In this section we have presented a model which has been successfully describedon the basis of o�cially available data, and which proves the existence of an ade-quately functioning OSPF routing protocol. The veri�cation of the protocol has beenillustrated by statements which supported the hypothesis and yielded the expectedresults.This model can be extended in the future by building con�gurations with more in-terconnected routers to verify and demonstrate additional features of authenticationor LSA synchronization processes/state machines. These features � among others �can target to answer the following issues:

72

Page 81: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

� Is defense su�cient against non-authenticated advertisements generated bythird-party attackers?

� How is the LSDB synchronized with LSA advertisements?

In order to create the NuSMV model of the OSPF protocol we had to examinethoroughly its behavior on real devices. During our research we have used Cisco 2811routers running the c2800nm-advipservicesk9-mz.124-20.T3 version of InternetworkOperating System (IOS). Although we concluded that the model we created wascorrect with the current speci�cation of OSPF, in an entirely di�erent area wediscovered a security issue worth considering. Most documentations refer to thecommand privilege level 15 as a solution to restrict Telnet or Secure Shell (SSH)connectivity to the router. This command is supposed to compare the privilege levelof the connecting user � stored either in a local database or on an authenticationserver � with the parameter 15 used in the command. If the privilege level is lessthan the required value in the parameter, the user will not be allowed to accessthe device through Telnet or SSH. However, reality proved to be di�erent. Anyoneconnecting successfully to the router (which has nothing to do with the commandissued) will automatically be logged in to the highest privilege level, thus obtainingbasically root privileges. This is a serious security concern. There are two possibleexplanations for this occurrence:

� Most documentations provide false information regarding the command (theoriginal purpose is possibly di�erent).

� In another scenario the command does not function properly with respect tothe speci�cation.

Unfortunately, neither did we have enough time to check this phenomenon on othertypes of the 2800 series, nor were we able to analyze this anomaly formally yet.Nevertheless we are hoping to complete this investigation in the near future.

6 Related works

The authors of [60] surveyed the recent progress in software model checking, which� in their opinion � is the key to close the gap between the programmer's intent andthe actual code. However, the authors point out that the current generation of soft-ware model checking tools work best only for control dominated protocol properties,so the everyday programmers are still far away from proving functional propertiesof complex software systems, such as data invariants. There are many remainingproblems to be addressed both in scaling current techniques to large programs, andin devising algorithmic analyses for modern software systems. The examples of openproblems provided by the authors are whether veri�cation techniques are scalablein the presence of expressive heap abstractions and concurrent interactions.

73

Page 82: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

The authors of [85] show another important aspect of model-based software devel-opment based on studying a wide body of literature. More attention is paid to thequality of models along with the growing importance of modeling in software de-velopment. They performed a systematic review of studies discussing model qualitypublished since 2000 to identify what model quality means and how it can be im-proved. From forty studies covered in the review, six model quality goals were identi-�ed, such as correctness, completeness, consistency, comprehensibility, con�nementand changeability. The authors also present practices proposed for developing high-quality models together with examples of empirical evidence. The contributions ofthe article are identifying and classifying de�nitions of model quality and identifyinggaps for future research.A formal approach for the speci�cation and veri�cation of trustworthy component-based systems is presented in [86]. According to them software systems are increas-ingly becoming ubiquitous a�ecting the way we experience the world. Embeddedsoftware systems � especially those used in smart devices � have become an essen-tial constituent of the technological infrastructure of modern societies. Such systems,in order to be trusted in society, must prove to be trustworthy. Trustworthiness isa composite non-functional property that implies safety, timeliness, security, avail-ability, and reliability. Their approach involves a formal component model for thespeci�cation of component's structure, functional and non-functional (trustworthi-ness) properties, a model transformation technique for the automatic generationof component behavior using the speci�ed structure and restricted by the speci�edproperties, and by a uni�ed formal veri�cation method for safety, security, reliabilityand availability properties using model checking.Behavior models are often used to describe behaviors of the system-to-be during re-quirements analysis or design phases. Model checkers provide counterexamples if themodel does not satisfy the given property. However, the tasks to analyze counterex-amples and identify the model errors require manual labor because counterexamplesdo not directly indicate where and why the errors exist, and when liveness proper-ties are checked, counterexamples have in�nite trace length, which makes it moredi�cult to automatize the analysis. In [67] the authors propose a novel automatizedapproach to �nd errors in a behavior model using an in�nite counterexample. They�nd similar witnesses to the counterexample then compare them to elicit errors.Their approach reduces the problem to a single-source shortest path search problemon directed graphs and is applicable to liveness properties.Formal methods and testing are two important approaches that assist in the de-velopment of high-quality software. While traditionally these approaches have beenseen as rivals, in recent years a new consensus has developed in which they areseen as complementary as Hans Gerhard Gross recommends in [51]. The authors of[55] review the state of the art regarding ways in which the presence of a formalspeci�cation can be used to assist testing.Programs are increasingly organized around features which are encapsulated byusing aspects and other linguistic mechanisms. Despite their growing popularity

74

Page 83: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

amongst developers, there is a shortage of techniques for computer-aided veri�ca-tion of programs that employ these mechanisms. The authors in [65] present thetheoretical underpinnings for applying model checking to programs (in the form ofstate machines) written by using these mechanisms. The analysis is incremental,as it examines only components that change rather than veri�es the entire systemevery time one of its parts changes. So the underlying idea is very similar to that ofthe OIMC algorithm. The technique in this article assumes that the set of pointcutdesignators is known statically, but the actual advice can vary. It handles both staticand dynamic pointcut designators. The authors do not only present the algorithm,but also address several issues that arise, including cascading advice applicationand problems of circular reasoning. We note that the OIMC algorithm has a similarproblem referred to as �circular dependency� in Section 4.Another incremental aspect of model checking is presented in [102]. The so-calledglass box software model checking incorporates novel techniques to identify simi-larities in the state space of a model checker and safely prune large numbers ofredundant states without explicitly checking them. The authors consider it signif-icantly more e�cient than other software model checking approaches for checkingcertain kinds of programs and program properties. They introduce Pipal, a systemfor modular glass box software model checking. Extending glass box software modelchecking to perform modular checking is important to further improve its scalabil-ity. It is nontrivial because unlike traditional software model checkers such as JavaPath Finder (JPF) and Compositional Model Checking (CMC), a glass box softwaremodel checker does not check each state separately. Instead, it checks a large set ofstates together in each step. The e�ectiveness of Pipal on a variety of programs isalso presented in the paper.In [114] the authors present a graphical approach to component-based and extensi-ble model checking platforms. Their proposal is based on the recognition that modelchecking is usually applied for veri�cation of concurrent systems by users with dif-ferent skills and background. This ranges from researchers with detailed knowledgeof the inner workings of the tools to engineers who are mostly interested in applyingthe technology as a black-box. Their paper proposes JoSEL, a graphical languagefor speci�cation of executable model checking jobs. JoSEL makes it possible to workat di�erent levels of abstraction when interacting with the underlying componentsof a model checking tool and thereby supports the di�erent kinds of users in a uni-form manner. A veri�cation job in JoSEL consists of tasks, ports and connectionsdescribing the models to verify, the behavioral properties to be checked and themodel checking techniques to apply. A job can then be mapped onto components ofan underlying model checking tool for execution. The authors introduce the syntaxof JoSEL, de�ne its semantics, and show how JoSEL has been used as a basis forthe user interface of the ASAP model checking platform.Since models were �rst used in software technology the following question has beenraised. If a model is created by a human and possibly it contains errors, is there anymethod to �x these errors (preferably automatically)? The authors of [16] review

75

Page 84: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

the e�orts in the past decade on developing model repair algorithms in di�erentdomains. These domains include distributed computing, fault-tolerance and self-stabilization and real-time systems. Model repair is a formal method that aims at�xing bugs in models automatically. Typically, these models are �nite state automatathat can be compactly represented using guarded commands or variations thereof.The bugs in these models can be identi�ed using traditional techniques such asveri�cation, testing, or runtime monitoring. However, these techniques do not assistin �xing bugs automatically. The goal in model repair is to automatically transforman input model into another model that satis�es additional properties. Moreover,such transformation should preserve the existing speci�cation of the input model.The techniques and tools discussed in this article demonstrate the feasibility ofautomated synthesis of well-known protocols such as Byzantine agreement, tokenring, fault-tolerant mutual exclusion, etc.In 2006 there was a very interesting question raised by Wolgang J. Paul duringhis lecture on the German Verisoft Project, whether we can trust model checkingtools. According to him model checkers � like any complex software � are subject tobugs. Unlike ordinary software, model checkers are often used to verify safety crit-ical systems. Their correctness is thus vital. Verifying model checkers is extremelychallenging because they are always complicated in logic and highly optimized. In[108] the authors propose a code contract combined approach for checking modelcheckers and apply it to the Process Analysis Tool (PAT) model checker developedby them. In their approach programming contracts (e.g. pre- or postconditions andinvariants) are embedded �rst into the source code, which can capture correctnessof model checking algorithms, underlying data structures, consistency between dif-ferent model checking parameters, etc. Then interface models of complicated datastructures and GUI are built and model checked. By linking the interface modelswith actual source codes and exhausting all execution sequences of interface modelsusing PAT, the authors basically model checked PAT using itself. They summarizetheir experience showing that the approach is e�ective in identifying common bugsor subtle �aws that result from extremely improbable events.In [10] the authors investigate change-driven model transformations, a novel class oftransformations, which are directly triggered by complex model changes carried outby arbitrary transactions on the model (e.g. editing operation, transformation). Aftera classi�cation of relevant change scenarios they identify challenges for change-driventransformations. They also de�ne an expressive, high-level language for specifyingchange-driven transformations as an extension of graph patterns and graph transfor-mation rules. This language generalizes previous results on live model transforma-tions by o�ering trigger events for arbitrarily complex model changes and dedicatedreactions for speci�c kinds of changes, making this way the concept of change tobe a �rst-class citizen of the transformation language. The authors discuss how theunderlying transformation engine needs to be adapted in order to use the same lan-guage uniformly for di�erent change scenarios. The technicalities of their approachare illustrated with a model synchronization case study with non-materialized target

76

Page 85: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

models, and another case study on detecting the violation of evolutionary (temporal)constraints in the security requirements engineering domain.The authors of [21] point out that most existing model checkers are specialized forlimited aspects of a system, where each of them requires a certain level of expertiseto use the tool in the right domain in the right way. Hardly any guideline is availableon choosing the right model checker for a particular problem domain, which makesadopting the technique di�cult in practice, especially for verifying software withhigh complexity.In this research the authors investigate the relative pitfalls and bene�ts of usingthe explicit model checker Spin on commercial Flight Guidance Systems (FGSs)at Rockwell-Collins, based on the author's prior experience with the use of thesymbolic model checker NuSMV on the same systems. The challenge includes thee�cient use of Spin for the complex synchronous mode logic with a large number ofstate variables, where Spin is known to be not particularly e�cient. They presentthe way the Spin model is optimized to avoid the state space explosion problem anddiscuss the implication of the result.

7 Conclusion

The present thesis endeavors to examine and analyze the veri�cation of CBSD mod-els.In Section 1 the basic concepts and conditions of the CBSD paradigm have been re-vised, followed by an analytic inventory of currently existing model checking methodsof component-based software. Subsequently we have de�ned the syntax and seman-tics of the LTL employed in newly and personally created and presented models ofsoftware systems. The following section of the thesis has tackled the key features ofmodel veri�cation, with special focus on potential problems and concerns or threats.Finally an analysis method of the correctness of data type classes based on contractshas been presented.Section 2 examines the granularity of the components of software systems by usingformal methods. These formal methods on the one hand have highlighted that im-proper granularity can yield faults hidden on conceptual levels; on the other handtheir prudent yet comprehensive usage can provide software developers with toolsthat lead to diminishing the risks of state explosion in complex systems. Concur-rently, employing the synthesis method we have created the producer-consumer spec-i�cation and its general and scalable NuSMV model with which we could prove theproper functioning of the system.Section 3 is tackling the model checking possibilities of a system consisting of manysimilar components. The novelty of this approach consists in our restructuring thespeci�cation formulas of formal system models with regard to their exclusive refer-ence to component internal states. The formulas having met the set conditions andparameters have been temporarily removed from the scope of model control and

77

Page 86: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

veri�ed on one single occasion at the end of the process. This step actually resultedin raising the model checking at class level, which consequently leads to economizingon time and resources. The method is presented through plain examples backed-upand supported by published experiment results. We should also stress that in thepresent thesis similarity is drawn exclusively from entities belonging to the sameclass, which is a considerable limitation.Section 4 explores the extending possibilities of component-based systems. In �rstplace we have examined the OIMC approach concentrating on whether the modelchecking process and resource needs can be simpli�ed provided we use the resultsgained by verifying the extendable basis system while verifying the extension. Asbased on our current knowledge the OIMC algorithm has not been implemented yet,our two research goals have been the following. On the one hand we have endeavoredto support with research data the empirical usability and e�ciency of the method,meanwhile also highlighting its current limits. Such a constraint is for instance themutual exclusion within real system models, which we propose to overcome by sug-gesting an approach using the greatest �xed point, a tool we are currently in theprocess of developing. In addition we are presenting a new implementation toolwhich partially supports the functioning of the OIMC algorithm. The tool we havedeveloped automatically completes the �rst steps of the OIMC algorithm by using�les as an input containing the model checking results of both the base componentand the extension, then it extracts the speci�cation formulas, and �nally generatestheir respective closures. The algorithm generating the closures has also been devel-oped by us. The tool enables the visual comparison of the closures of formula setsderived from the two components. It is important to point out that our tool canprocess LTL formulas as well, though the original OIMC does only support CTLtemporal logic language.In Section 5 we approach the formal veri�cation of network protocols from a newperspective. According to our method we consider the OSI/ISO multilayered refer-ence model a component-based software system, as each layer behaves as a blackbox and communicates with another layer exclusively through its interfaces. Everysingle layer can use the services of the layer below and o�er services only to thelayer above. Building on this analogy we have created a model of the widespreadrouting protocol OSPF model based of the ever since standardized RFC document.Subsequently we have proved that the protocol functions properly and meets all therequirements of the original service speci�cation. Ironically, in the process of exam-ining the routing protocol, in one of the router families running the IOS operatingsystem we have discovered a serious security exploit, whose modeling by using for-mal instruments has not been completed yet. We expect to be able to publish theresearch results in the near future.Section 6 gives an overview of the related works, highlighting the points of possibleconnection.The summary of the carried out research concludes the thesis.In the end we would like to stress that at all instances our research topic had been

78

Page 87: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

approached mainly to high quality educational ends, therefore we have strived toillustrate all our experiments with relevant explanatory examples.

79

Page 88: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

8. Összefoglalás

Jelen dolgozatban a komponens-alapú szoftverek modellellen®rzéssel történ® veri�-kációját vizsgáltuk.Az 1. fejezetben a komponens-alapú szoftverfejlesztés paradigmájának alapfogalma-it és feltételeit tekintettük át, majd a napjainkban használatos szoftververi�kációsmódszereket vettük sorra. Ezt követ®en az általunk készített és ismertetett szoft-verrendszerek modelljeinél használt LTL temporális logikai nyelv szintaktikáját ésszemantikáját de�niáltuk. A modellellen®rzés kulcsfontosságú tulajdonságait tár-gyaltuk a következ® részben, nem megfeledkezve a felmerül® problémákról és ag-gályokról. Végül az adatok típusosztályának helyességét kontraktusokkal vizsgálómódszert ismertettük.A 2. fejezetben a komponensek, illetve a komponensekb®l építkez® szoftverrend-szerek granularitását vizsgáltuk formális eszközökkel. Formális eszközök segítségé-vel rámutattunk arra, hogy a komponensek nem megfelel® szemcsézettsége koncep-cionális szinten rejtve maradó hibákat eredményezhet, ugyanakkor körültekint®enalkalmazva eszközt ad a fejleszt®k kezébe, hogy csökkentsék az összetett rendsze-rek esetében jelentkez® állapotrobbanás kockázatát. Szintézis módszer segítségévela termel®-fogyasztó probléma speci�kációját hoztuk létre, majd elkészítettük ennekáltalános és jól skálázható NuSMV modelljét, amellyel igazoltuk a rendszer megfelel®m¶ködését.A 3. fejezetben a sok hasonló komponensb®l felépül® szoftverek modellellen®rzési le-het®ségeit vizsgáltuk. új megközelítésmódot alkalmaztunk, amikor az ilyen rendsze-rek formális modelljénél megadott speci�kációs formulákat átstrukturáltuk aszerint,hogy kizárólag az adott komponensen belüli állapotokra hivatkozik-e. A feltételnekeleget tev® formulákat ideiglenesen kivettük a modellellen®rzés hatálya alól, és csakegyetlen alkalommal értékeltük ki. Ezzel tulajdonképpen a modellellen®rzést az osz-tályok szintjére emeltük, id®t és er®forrást takarítva meg. Módszerünket egyszer¶példákon keresztül mutatjuk be, és kísérleti eredményeket is közlünk. Fontos azon-ban leszögezni, hogy jelen dolgozatban a hasonlóságot kizárólag azonos osztálybólszármazó egyedekre értjük, ami elég komoly korlátozás.A 4. fejezetben a komponens-alapú rendszerek b®vítésének lehet®ségeit járjuk körbe.Az OIMC inkrementális módszer alapötletét vizsgáltuk: egyszer¶síthet®-e a modell-ellen®rzés folyamata, illetve er®forrásigénye, ha a b®vítend® alaprendszer veri�káci-ója során kapott eredményeket felhasználjuk a b®vítmény ellen®rzése során. Mivelaz OIMC algoritmust jelen tudásunk szerint még nem implementálták, két dolgotszerettünk volna elérni. Egyrészt kísérleti adatokkal alátámasztani a módszer gya-korlati alkalmazhatóságát és hatékonyságát, másrészt rámutatni a módszer jelenlegikorlátaira. Ilyen például a valós rendszerek modelljeinél viszonylag gyakran el®for-duló körkörös függ®ség esete, amelynek megfelel® kezeléséhez a legnagyobb �xpont-tal történ® közelítést javasoljuk, de ezen jelen pillanatban is dolgozunk. Ezen felülbemutatunk egy új implementációs eszközt, amely az OIMC algoritmus m¶ködé-sét támogatja részlegesen. Feladata, hogy a báziskomponens és a b®vítmény fájlba

80

Page 89: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

történ® ellen®rzési eredményeit bemenetként használva elvégzi az algoritmus els® lé-péseit, kinyeri a speci�kációban szerepl® formulákat, majd el®állítja ezek lezártjait.Az eszköz végül lehet®séget kínál a két komponens formulahalmazaiból el®állítottlezártjainak vizuális összehasonlítására. Fontos kiemelni, hogy bár az eredeti OIMCalgoritmus csak a CTL temporális logikai nyelvet támogatja, az általunk kifejlesztetteszköz az LTL formulákat is kezeli.Az 5. fejezetben új megközelítésb®l tárgyaljuk a hálózati protokollok ellen®rzésilehet®ségeit. Az általunk bemutatott módszer szerint az OSI/ISO rétegmodelljétkomponens-alapú rendszernek tekinthetjük, mivel az egyes rétegek fekete doboz-ként m¶ködnek, és kizárólag az interfészeiken keresztül kommunikálnak egymással.Minden egyes réteg kizárólag az alatta lév® réteg szolgáltatásait veheti igénybe, éskizárólag a felette lév® rétegnek nyújthat szolgáltatást. Erre az analógiára építve egykonkrét irányítóprotokoll, az OSPF modelljét hoztuk létre a kés®bb szabvánnyá válóRFC dokumentum alapján. Formális eszközökkel igazoltuk, hogy a protokoll mindentekintetben az eredeti speci�kációnak megfelel®en m¶ködik. A sors iróniája, hogy azirányítóprotokoll vizsgálata során az egyik útválasztó családon futó IOS operációsrendszerben egy komoly biztonsági rést fedeztünk fel. Ennek formális eszközökkeltörtén® modellezése, illetve vizsgálata még nem zárult le. Reményeink szerint ezt akés®bbiekben publikáljuk.Végül a témához kapcsolódó jelenlegi kutatási irányokat tekintjük át, az esetlegeskapcsolódási pontokat kiemelve.Az elvégzett munka rövid összefoglalója zárja a dolgozatot.Külön szeretnénk jelezni, hogy az általunk vizsgált téma oktatási aspektusait igyekez-tünk minden esetben megfelel®en hangsúlyozni, szemléletes példákkal illusztrálni.

81

Page 90: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

References

[1] Amla, N., Du, X., Kuehlmann, A., Kurshan, R. P., McMillan, K. L. (2005), �AnAnalysis of SAT-Based Model Checking Techniques in an Industrial Environ-ment�, LNCS 3725, pp. 254-268.

[2] Andrews, G. R. (1989), �A Method for Solving Synchronization Problems�, Sci-ence of Computer Programming, 13 1989/90, pp. 1-21.

[3] Anido-Rifón, L., Fernández-Iglesias, M. J., Llamas-Nistal, M., Caeiro-Rodríguez,M., Santos-Gago, J., Rodrígues-Estévez, J. S. (2001), �A Component Model forStandardized Web-based Education�, ACM Journal of Educational Resources inComputing, Vol. 1.

[4] Arnout, K. and Meyer, B. (2002), �Finding Implicit Contracts in .NET Com-ponents�, Proceedings of FMCO 2002 (Formal Methods for Components andObjects), Leiden, The Netherlands, 5-8 November 2002, LNCS 2852, Springer-Verlag.

[5] Attie, P. C., Emerson, E. A. (2001), �Synthesis of concurrent programs for anatomic read/write model of computation�, ACM TOPLAS, , 23 (2), pp. 187-242.

[6] Bachman, F., Bass, L., Buhman, S., Comella-Dorda, S., Long, F., Seacord, R.C.,Wallnau, K.C. (2000), �Technical Concepts of Component-Based Software En-gineering�, Tech. Rep. CMU/SEI-2000-TR-008, Software Engineering Institute,Carnegie Mellon University.

[7] Bass, L., Clements, P., Kazmar, R. (2003), Software Architecture in Practice(Second Edition), Addison-Wesley.

[8] Bensalem, S., Bouajjani, A., Loiseaux, L., Sifakis, J. (1993), �Property preservingsimulations�, LNCS 663, pp. 260-273.

[9] Berard, B., Bidoit, M., Finkel, A., Laroussinie, F., Petit, A., Petrucci, L., Schnoe-belen, P. (2001), Systems and Software Veri�cation: Model-Checking Techniquesand Tools, Springer.

[10] Bergmann, G., Ráth, I., Varró, G., Varró, D. (2012), �Change-driven modeltransformations�, Software and Systems Modeling (SoSyM), Vol. 11, Issue 3, pp.431-461.

[11] Bertolino A., Polini A. (2003), �A Framework for Component Deployment Test-ing�, Proceedings of the 25th International Conference on Software Engineering,pp. 221-231.

82

Page 91: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

[12] Beszédes, Á., Faragó, Cs., Szabó, Zs. M., Csirik, J., Gyimóthy, T. (2002), �UnionSlices for Program Maintenance�, Proceedings of the IEEE International Con-ference on Software Maintenance (ICSM 2002), pp. 12-21, Montreal, Canada,October 3-6, 2002, published by IEEE Computer Society.

[13] Beugnard A., Jézéquel J. M., Plouzeau N., Watkins D. (1999), �Making com-ponents contract aware�, IEEE Software, Volume 32, Issue 7, pp. 38-44.

[14] Bhargavan, K., Obradovic, D., Gunter, C. A. (2002), �Formal Veri�cation ofStandards for Distance Vector Routing Protocols�, Journal of the ACM (JACM),Volume 49, Issue 4, pp. 538-576.

[15] Biere, A., Cimatti, A., Clarke, E. M., Strichman, O., Zhu, Y. (2003), �BoundedModel Checking�, Advances in Computers, Vol. 58, Academic Press (pre-print).

[16] Bonakdarpour, B., Kulkarni, S. S. (2012), �Automated model repair for dis-tributed programs�, ACM SIGACT News, Vol. 43, Issue 2, pp. 85-107.

[17] Cavada, R., Cimatti, A., Olivetti, E., Keighren, G., Pistore, M.,Roveri, M., Semprini, S., Tchaltsev, A.: NuSMV 2.5 User Manual,http://nusmv.fbk.eu/NuSMV/userman/v25/nusmv.pdf

[18] Chandy, K. M., Misra, J. (1989), Parallel Program Design: A Foundation,Addison-Wesley.

[19] Chillarege, R. (1999), �Software Testing Best Practices�, IBM Research � Tech-nical Report RC 21457 Log 96856 4/26/99.

[20] Chin, W., David, C., Nguyen, H. H., Qin, S. (2008), �Enhancing modular OOveri�cation with separation logic�, POPL '08: ACM SIGPLAN Notices, Vol. 43,Issue 1.

[21] Choi, Y. (2007), �From NuSMV to SPIN: Experiences with model checking �ightguidance systems�, Formal Methods in System Design, Vol. 30, Issue 3, pp. 199-216.

[22] Clarke, E. M., Grumberg, O., Long, D. E. (1994), �Model checking and abstrac-tion�, ACM Transactions on Programming Languages and Systems (TOPLAS),Vol. 16, Issue 5, pp. 1512-1542.

[23] Clarke, E., Grumberg, O., Peled, D. (2000), Model Checking, MIT Press.

[24] COM+ Architecture, http://msdn.microsoft.com/en-us/library/ms973484.aspx, retrieved on Sep 10, 2012.

[25] CORBA/IIOP Speci�cation, http://www.omg.org/spec, retrieved on Sep 10,2012.

83

Page 92: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

[26] Crnkovic, I., Hnich, B., Jonsson, T., Kiziltan, Z. (2002), �Speci�cation, Imple-mentation and Deployment of Components�, Communications of the ACM, Vol.45, pp. 35-40.

[27] Dams, D., Gerth, R., Grumberg, O. (1993), �Generation of reduced models forchecking fragments of CTL�, Proceedings of the 5th Conference on Computer-Aided Veri�cation, LNCS 697, pp. 479-490.

[28] Dams, D., Gerth, R., Grumberg, O. (1997), �Abstract interpretation of re-active systems�, ACM Transactions on Programming Languages and Systems(TOPLAS), Vol. 19, Issue 2, pp. 253-291.

[29] Dávid, Á., Kozma, L., Pozsgai, T. (2008), �On the model checking of a sys-tem consisting of many similar components�, Annales Univ. Sci. Budapest, Sect.Comp. 28, pp. 183-195.

[30] Dávid, Á., Pozsgai, T., Kozma, L. (2007), �Extending a system with veri�edcomponents�, Periodica Polytechnica, Vol 51, Issue 3-4, pp. 133-139.

[31] Dávid, Á., Kozma, L., Varga, L. (2006), �On the correctness of data type classesbased on contracts�, Pure Mathematics and Applications, Volume 17, Issue 3-4,pp. 251-261, ISSN 1788-800X.

[32] Dávid, Á., Kozma, L. (2009), �Educational aspects of incremental model check-ing�, Proceedings of the 3rd International Multi-Conference on Society, Cyber-netics and Informatics, Vol 2, pp. 190-194, Jul 10-13, 2009, Orlando, Florida,USA, ISBN-10: 1-934272-73-6, ISBN-13: 978-1-934272-73-2.

[33] Dávid, Á., Pozsgai, T., Kozma, L. (2007), �On the granularity of components�,7th International Conference on Applied Informatics, pp. 219-228, Jan 28-31,2007, Eger, Hungary.

[34] Dávid Á., Csatári J., Beleznay P. (2012), �Hálózati protokollok formális szem-mel�, Networkshop 2012 (konferenciakiadvány), Veszprém, 2012. április 10-13.,ISBN: 978-963-88335-1-8.

[35] Dávid, Á., Kozma, L. (2011), �Hálózatbiztonság formális szemmel�, Informatikaa fels®oktatásban (konferenciakiadvány), 608-612. o., 2011. augusztus 24-26., De-brecen, ISBN 978-963-473-461-1.

[36] Dávid, Á. (2008), �Formális szoftververi�kációs eszközök alkalmazásának ne-hézségei a gyakorlatban�, Informatika a fels®oktatásban (konferenciakiadvány),2008. augusztus 27-29., Debrecen.

[37] Dávid, Á., Gál, B. (2008), �A modellellen®rzés kihívásai�, Informatika Korszer¶Technikái Konferencia (konferenciakiadvány), 2008. március 7-8., Dunaújváros.

84

Page 93: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

[38] Dávid, Á. (2007), �Inkrementális modellellen®rzés a gyakorlatban�, Fels®oktatásimatematika-, �zika- és számítástechnika oktatók XXXI. Konferenciája (konfer-enciakiadvány), 2007. augusztus 23-25., Dunaújváros.

[39] Dávid, Á., Pozsgai, T., Kozma, L. (2005), �Environment for concurrent pro-gramming�, Proceedings of the 5th International Conference of PhD Students,Aug 14-20, 2005, Miskolc, Hungary.

[40] Dávid, Á., Pozsgai, T., Kozma, L. (2005), �Educational framework for develop-ing applications built from veri�ed components�, Proceedings of the Ninth Sym-posium on Programming Languages and Software Tools, pp. 7-18, Aug 13-14,2005, Tartu, Estonia, published by Tartu University Press.

[41] Dijkstra, E. W. (1976), �A Discipline of Programming�, Prentice Hall.

[42] Ehring, H. and Mahr, B. (1990), Fundamentals of Algebraic Speci�cation 2:Module Speci�cation and Constraints, Springer-Verlag.

[43] Enterprise JavaBeans, http://www.oracle.com/technetwork/java/javaee/ejb,retrieved on Sep 10, 2012.

[44] Emerson, E. A., Clarke E. M. (1982), �Using branching time temporal logic tosynthesize synchronization skeletons�, Science of Computer Programming, 2, pp.241-266

[45] Emerson, E. A., Sistla, A. P. (1996), �Symmetry and model checking�, FormalMethods in System Design � Special issue on symmetry in automatic veri�cation,Vol. 9, Issue 1-2, pp. 105-131.

[46] Fayad, M. E., Hamu, D. S., Brugali, D. (2000), �Enterprise frameworks � Char-acteristics, criteria and challenges�, Communications of the ACM, Vol. 43, pp.39-46.

[47] Feijs, L. M. G., Qian, Y. (2002), �Component algebra�, Science of ComputerProgramming, Vol. 42, pp. 173-228.

[48] Frankl, P., Hamlet, D., Littlewood, B., Strigini, L. (1997), �Choosing a TestingMethod to Deliver Reliability�, ACM, pp. 68-78, May 1997.

[49] Godefroid, P., Pirottin, D. (1993), �Re�ning dependencies improves partial-order veri�cation methods�, Proceedings of the 5th Conference on Computer-Aided Veri�cation, LNCS 697, pp. 438-449.

[50] Goldberg, S., Schapira M., Hummon, P., Rexford, J. (2010), �How secure aresecure interdomain routing protocols?�, SIGCOMM'10, New Delhi, India, ISBN:978-1-4503-0201-2, pp. 87-98.

85

Page 94: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

[51] Gross, H. G. (2005), Component-Based Software Testing with UML, Springer.

[52] Hajdara, Sz., Kozma, L., Ugron, B. (2003), �Synthesis of a System Composedby Many Similar Objects�, Annales Univ. Sci. Budapest., Sect. Comp. 22, pp.127-150

[53] Hamlet, R. (1989), �Theoretical Comparison of Testing Methods�, ACM, Vol.28, pp. 28-37.

[54] Hatcli�, J., Deng, W., Dwyer, M., Jung, G., Prasad, V. (2003), �Cadena: AnIntegrated Development, Analysis, and Veri�cation Environment for Component-based Systems�, Proceedings of the 25th International Conference on SoftwareEngineering, pp. 160-173.

[55] Hierons, R. M., Bogdanov, K., Bowen, J. P., Cleaveland, R., Derrick, J., Dick,J., Gheorghe, M., Harman, M., Kapoor, K., Krause, P., Lüttgen, G., Simons, A.J. H., Vilkomir, S., Woodward, M. R., Zedan, H. (2009), �Using formal speci�-cations to support testing�, ACM Computing Surveys (CSUR), Vol. 41, Issue 2,Art. 9.

[56] Hopkins, J. (2000), �Component primer�, Communications of the ACM, Vol.43, pp. 27-30.

[57] Horváth, Z. (1993), �The Weakest Precondition and the Speci�cation of Paral-lel Programs�, Proc. of the Third Symposium on Programming Languages andSoftware Tools, pp. 24-34.

[58] Huber, P., Jensen, A., Jepsen, L., Jensen, K. (1985), �Towards reachability treesfor high-level Petri nets�, LNCS 188, pp. 215-233.

[59] Ip, C. W., Dill, D. L. (1996), �Better veri�cation through symmetry�, FormalMethods in System Design � Special issue on symmetry in automatic veri�cation,Vol. 9, Issue 1-2, pp. 41-75.

[60] Jhala, R., Majumdar, R. (2009), �Software model checking�, ACM ComputingSurveys (CSUR), Vol. 41, Issue 4, Art. 21.

[61] Johnson, R. E. (1997) �Frameworks = (Components + patterns)�, Communica-tions of the ACM, Vol. 40.

[62] Karlin, J., Forrest, S., Rexford, J. (2008), �Autonomous security for autonomoussystems�, Computer Networks, Oct. 2008.

[63] Kent, S., Lynn, C., Seo, K. (2000), �Secure border gateway protocol (S-BGP)�,J. Selected Areas in Communications, Vol. 18, pp. 582-592.

[64] Kobryn, C. (2000), �Modeling components and frameworks with UML�, Com-munications of the ACM, Vol. 43, pp. 31-38.

86

Page 95: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

[65] Krishnamurthi, S., Fisler, K. (2007), �Foundations of incremental aspectmodel-checking�, ACM Transactions on Software Engineering and Methodology(TOSEM), Vol. 16, Issue 2, pp. 1-36.

[66] Kroger, F. (1987), Temporal Logic of Programs, Springer-Verlag.

[67] Kumazawa, T., Tamai, T. (2011), �Counter example-based error localization ofbehavior models�, NFM'11: Proceedings of the Third international conference onNASA Formal methods, LNCS 6617, pp. 222-236.

[68] Kurshan, R. P. (1990), �Analysis of discrete event coordination�, REX workshopProceedings on Stepwise re�nement of distributed systems: models, formalisms,correctness, pp. 414-453.

[69] Lamsweerde, A., Sintzo�, M. (1979), �Formal Derivation of Strongly CorrectConcurrent Programs�, Acta Informatica Vol. 12, Fasc. 1, pp. 1-31.

[70] Larsen, G. (2000), �Component-based enterprise frameworks�, Communicationsof the ACM, Vol. 43, pp. 25-26.

[71] Lécz, B., Zömbik, L. (2004), �Hálózati protokollok biztonsági tesztelése�,Híradástechnika, 2004/3: 2-6.

[72] Lee, S. C., Shirani, A. I. (2004), �A component based methodology for web ap-plication development�, Journal of Systems and Software, Volume 71, Issue 1-2,pp. 177-187.

[73] Liskov B. H., Wing, J. M. (1994), �A Behavioral Notion of Subtyping�, ACMTransactions on Programming Languages and Systems, pp. 1811-1841, Vol. 16,Issue 6.

[74] Model checkers, http://en.wikipedia.org/wiki/List_of_model_checking_tools,retrieved on Sep 10, 2012.

[75] Long, D. E. (1993), �Model Checking, Abstraction and Compositional Veri�ca-tion�, Ph.D. Thesis, Carnegie Mellon University.

[76] Maag, S., Zaidi, F. (2006), �Testing methodology for an ad hoc routing protocol�,PM2HW2N'06, Torremolinos , Malaga, Spain, ISBN:1-59593-502-9, pp. 48-55.

[77] Manna, Z., Wolper, P. (1984), �Synthesis of Communicating Processes fromTemporal Logic speci�cations�, ACM TOSEM, 6, pp. 68-93.

[78] Manna, Z., Pnueli, A. (1995), Temporal Veri�cation of Reactive Systems-Safety,Springer.

[79] McDaniel, P., Aiello, W., Butler, K., Ioannidis, J. (2006), �Origin authenticationin interdomain routing�, Computer Networks, Nov. 2006.

87

Page 96: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

[80] McIver, A., Morgan, C. (eds.): Programming Methodology, Springer-Verlag,2003.

[81] McMillan, K. L. (1993), Symbolic Model Checking: An Approach to the StateExplosion Problem, Kluwer Academic.

[82] McMillan, K. L. (2003), �Methods for exploiting SAT solvers in unbounded modelchecking�, MEMOCODE'03 Proceedings of the First ACM and IEEE Interna-tional Conference on Formal Methods and Models for Co-Design, pp. 135-144.

[83] Meyer B. (1997), Object-Oriented Software Construction Second Edition, Pren-tice Hall.

[84] Miller, A., Donaldson, A., Calder, M. (2006), �Symmetry in temporal logic modelchecking�, ACM Computing Surveys (CSUR), Vol. 38, Issue 3, Art. 8.

[85] Mohagheghi, P, Dehlen, V., Neple, T. (2009), �De�nitions and approaches tomodel quality in model-based software development � A review of literature�,Information and Software Technology, Vol. 51, Issue 12, pp. 1646-1669.

[86] Mohammad, M., Alagar, V. (2011), �A formal approach for the speci�cationand veri�cation of trustworthy component-based systems�, Journal of Systemsand Software , Vol. 84, Issue 1, pp. 77-104.

[87] Morisio, M., Torchiano, M. (2002), �De�nition and Classi�cation of COTS:A Proposal�, ICCBSS'02 Proceedings of the First International Conference onCOTS-Based Software Systems, pp. 165-175.

[88] Müller-Olm M., Schmidt, D. A., Ste�en, B. (1999), �Model checking: a tutorialintroduction�, Proc. of the 6th Static Analysis Symposium, G. File and A. Cortesi(eds.), LNCS 1694, pp. 330â��354.

[89] Németh, L. Z. (2011), �Model Checking of the Slotted CSMA/CA MAC Pro-tocol of the IEEE 802.15.4 Standard�, MATCOS-10, Proceedings of the 2010Mini-Conference on Applied Theoretical Computer Science, A. Brodnik and G.Galambos (eds.), University of Primorska Press, pp. 121-126.

[90] Nguyen, T. T. and Katayama, T. (2004), �Handling consistency of softwareevolution in an e�cient way�, Proceedings of the IWPSE, pages 121-130.

[91] Owicki, S., Gries, D. (1976), �An Axiomatic Proof Technique for Parallel Pro-grams�, Acta Informatica 6, pp. 319-340.

[92] Parkinson, M. J., Bierman, G. M. (2008), �Separation logic, abstraction andinheritance�, POPL '08: ACM SIGPLAN Notices, Vol. 43, Issue 1.

[93] Pásztorné Varga Katalin (1992), Logikai alapozás alkalmazásokhoz (Matem-atikai logika � Számítástudomány) Egyetemi jegyzet, ELTE Budapest.

88

Page 97: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

[94] Peled, D. (1994), �Combining partial order reductions with on-the-�y modelchecking�, LNCS 818, pp. 377-390.

[95] Peterson, G. L. (1983), �A new Solution to Lamport's Concurrent ProgrammingProblem Using Small Shared Variables�, ACM TOPLAS, Vol. 5, pp. 56-65.

[96] Rees, D. Ll. L., Stephenson, K., Tucker, J. V. (2003), �The algebraic structureof interfaces�, Science of Computer Programming, Vol. 49, Issue 1-3, pp. 47-88.

[97] Reussner R. H. (2001), �The use of parameterised contracts for architectingsystems with software components�, 6th Intl. Workshop on Component-OrientedProgramming, Budapest, Hungary, 2001.

[98] RFC 1131: The OSPF Speci�cation, http://tools.ietf.org/html/rfc1131, re-trieved on Sep 10, 2012.

[99] RFC 1247: OSPF Version 2, http://tools.ietf.org/html/rfc1247, retrieved onSep 10, 2012.

[100] RFC 2328: OSPF Version 2, http://tools.ietf.org/html/rfc2328, retrieved onSep 10, 2012.

[101] Robby, Dwyer, M. B., Hatcli�, J. (2003), �Bogor: An Extensible and Highly-Modular Software Model Checking Framework�, ACM SIGSOFT Software Engi-neering Notes, Proceedings of the 9th European software engineering conferenceheld jointly with 11th ACM SIGSOFT international symposium on Foundationsof software engineering, Volume 28.

[102] Roberson, M., Boyapati, C. (2010), �E�cient modular glass box software modelchecking�, ACM SIGPLAN Notices - OOPSLA '10, Vol. 45, Issue 10, pp. 4-21.

[103] Rosenblum, D. S. (1996), �Formal Methods and Testing: Why the State-of-theArt is Not the State-of-the Practice�, ACM SIGSOFT, Vol. 21, pp. 64-66.

[104] Shankar, N. (2000), �Combining Theorem Proving and Model Checking throughSymbolic Analysis�, LNCS 1877, Springer-Verlag, pp. 1-16.

[105] Sidhu, D., Chung, A., Blumer, T. P. (1991), �Experience with formal methodsin protocol development�, ACM SIGCOMM Computer Communication Review,Volume 21, Issue 2, pp. 81-101.

[106] Sparling M. (2000), �Lessons learned through six years of component-baseddevelopment�, Communications of the ACM, pp. 47-53, Vol. 43.

[107] SPIN: on-the-�y, LTL model checking, http://spinroot.com, retrieved on Sep10, 2012.

89

Page 98: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

[108] Sun, J., Liu, Y., Cheng, B. (2010), �Model checking a model checker: a codecontract combined approach�, ICFEM'10: Proceedings of the 12th internationalconference on Formal engineering methods and software engineering, LNCS 6447,pp. 518-533.

[109] Szyperski, C. (2002), Component Software � Beyond Object-Oriented Program-ming (Second Edition), Addison-Wesley/ACM Press.

[110] Thang N. T., Katayama T. (2004), �Open Incremental Model Checking (Ex-tended Abstract)�, Proceedings of ACM SIGSOFT Symposium on the Founda-tions of Software Engineering, pp. 134-137, Oct 31-Nov 1, 2004, Newport Beach,California, USA.

[111] Thang, N. T., Katayama, T. (2005), �Speci�cation and veri�cation of inter-component constraints in CTL�, ACM SIGSOFT Software Engineering Notes,pp. 1-8, Vol. 31, Issue 2.

[112] Valmari, A. (1990), �A stubborn attack on state space explosion�, Proceedingsof the 2nd Workshop on Computer-Aided Veri�cation, LNCS 531, pp. 156-165.

[113] Vitharana, P. (2003), �Risks and Challenges of Component-based Software De-velopment�, Communications of the ACM, Vol. 46, pp. 67-72.

[114] Westergaard, M., Kristensen, L. M. (2012), �A graphical approach tocomponent-based and extensible model checking platforms�, Transactions on PetriNets and Other Models of Concurrency V, LNCS 6900, pp. 265-291.

[115] Yang, J (2003), �Web Service Componentization�, Communications of theACM, Vol. 46, pp. 35-40.

90

Page 99: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

A The source code of JanKo

A.1 Connectivity

A.1.1 Binary.java

package c onne c t i v i t y ;

pub l i c enum Binary {IMPLICATION("−>") , EQUIVALENCE("<−>") , EQUAL("=") , AND("&") , OR( " | " ) , XOR(

"xor ") , XNOR(" xnor ") , INEQUAL("!=") , LT("<") , GT(">") , LE("<=") , GE(">=") ;

p r i va t e f i n a l S t r ing name ;p r i va t e Binary ( S t r ing name) {

t h i s . name = name ;}pub l i c S t r ing toS t r i ng ( ) {

re turn name ;}

}

A.1.2 CTL.java

package c onne c t i v i t y ;

pub l i c enum CTL {EG("EG") , EX("EX") , EF("EF") , AG("AG") , AX("AX") , AF("AF") , E("E") , A("A") , NOT

( " ! " ) ;

p r i va t e f i n a l S t r ing name ;p r i va t e CTL( St r ing name) {

t h i s . name = name ;}pub l i c S t r ing toS t r i ng ( ) {

re turn name ;}

}

A.1.3 Unary.java

package c onne c t i v i t y ;

pub l i c enum Unary {NOT(" ! " ) ;

p r i va t e f i n a l S t r ing name ;p r i va t e Unary ( S t r ing name) {

t h i s . name = name ;}pub l i c S t r ing toS t r i ng ( ) {

re turn name ;}

}

91

Page 100: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

A.2 Formula

A.2.1 Formula.java

package formula ;

import java . u t i l . ArrayList ;

import l o g i c . Logic ;

pub l i c c l a s s Formula {p r i va t e St r ing formula ;p r i va t e boolean l t l ;p r i va t e ArrayList<Formula> subformulae ;

pub l i c Formula ( S t r ing formula , boolean l t l ) {t h i s . formula = formula ;t h i s . l t l = l t l ;

}

// s e t s to normal ized form ://F in s t ead o f (F)/∗ pr i va t e void normal ize ( ) {

whi l e ( formula . charAt (0 ) == ' ( ' ) {char [ ] c = formula . toCharArray ( ) ;char [ ] n = new char [ c . length −2] ;f o r ( i n t i = 0 ; i < n . l ength ; i++) {n [ i ] = c [ i +1] ;

}formula = new St r ing (n) ;normal ize ( ) ;

}formula = formula . tr im ( ) ;

}∗/

// s p l i t s the formula to one or two par t sp r i va t e ArrayList<Formula> ca l cu la teSub fo rmulae ( ) {

ArrayList<Str ing> l i s t = Logic . getSubformulae ( t h i s ) ;ArrayList<Formula> r e t = new ArrayList<Formula>() ;f o r ( S t r ing s t r : l i s t ) {

r e t . add (new Formula ( s t r , l t l ) ) ;}

re turn r e t ;/∗ArrayList<Formula> r e t = new ArrayList<Formula>() ;boolean s p l i t t e d = f a l s e ;

i f ( ! s p l i t t e d ) {f o r (CTL l : CTL. va lue s ( ) ) {

i f ( formula . s tartsWith ( l . t oS t r i ng ( ) ) ) {Formula add = new Formula ( formula . sub s t r i ng ( l . t oS t r i ng ( ) . l ength ( ) ) , l t l ) ;add . normal ize ( ) ;r e t . addAll ( add . getFormula ( ) ) ;s p l i t t e d = true ;break ;

}}

}

i f ( ! s p l i t t e d ) {f o r ( Binary b : Binary . va lue s ( ) ) {

i f ( formula . conta in s (b . t oS t r i ng ( ) ) ) {St r ing subs t r = formula . sub s t r i ng (0 , formula . indexOf (b . t oS t r i ng ( ) ) ) ;i f ( ( new Formula ( substr , l t l ) . ca l cu la teSub fo rmulae ( ) ) . isEmpty ( ) ) {

92

Page 101: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

Formula add1 = new Formula ( formula . sub s t r i ng (0 , formula . indexOf (b .t oS t r i ng ( ) ) ) , l t l ) ;

Formula add2 = new Formula ( formula . sub s t r i ng ( formula . indexOf (b . t oS t r i ng( ) )+b . t oS t r i ng ( ) . l ength ( ) , formula . l ength ( ) ) , l t l ) ;

add1 . normal ize ( ) ;add2 . normal ize ( ) ;r e t . addAll ( add1 . getFormula ( ) ) ;r e t . addAll ( add2 . getFormula ( ) ) ;

}}

}}re turn r e t ;∗/

}

pub l i c S t r ing getFormula ( ) {re turn formula ;

}

pub l i c void setFormula ( S t r ing formula ) {t h i s . formula = formula ;

}

pub l i c S t r ing toS t r i ng ( ) {re turn formula ;

}

pub l i c boolean isLTL ( ) {re turn l t l ;

}

pub l i c void setLTL ( boolean l t l ) {t h i s . l t l = l t l ;

}

pub l i c ArrayList<Formula> getSubformulae ( ) {i f ( subformulae == nu l l ) {subformulae = ca l cu la teSub fo rmulae ( ) ;

}re turn subformulae ;

}}

A.3 GUI

A.3.1 ComparePanel.java

package gui ;

import java . awt . BorderLayout ;import java . awt . Container ;import java . awt . Dimension ;import java . awt . I n s e t s ;import java . awt . event . ActionEvent ;import java . awt . event . Act i onL i s t ene r ;import java . u t i l . ArrayList ;

import javax . swing . BorderFactory ;import javax . swing . BoxLayout ;import javax . swing . JButton ;import javax . swing . JFrame ;import javax . swing . JLabel ;

93

Page 102: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

import javax . swing . JPanel ;import javax . swing . JTextArea ;

import main . Runner ;

import formula . Formula ;import java . awt . Component ;import javax . swing . JToggleButton ;

pub l i c c l a s s ComparePanel {

p r i va t e f i n a l I n s e t s textFie ldMarg in = new In s e t s (5 , 5 , 5 , 5) ;p r i va t e f i n a l Dimension textFie ldDimens ion = new Dimension (400 , 300) ;p r i va t e f i n a l Dimension buttonDimension = new Dimension (95 , 100) ;

p r i va t e JFrame frame ;p r i va t e JPanel l e f t ;p r i va t e JLabel l e f tTex t ;p r i va t e JPanel middle ;p r i va t e JToggleButton on lyLe f t ;p r i va t e JToggleButton common ;p r i va t e JToggleButton onlyRight ;p r i va t e JPanel r i g h t ;p r i va t e JLabel r ightText ;

p r i va t e ArrayList<Formula> subformulaA ;p r i va t e ArrayList<Formula> subformulaB ;

/∗∗∗ @wbp. par s e r . entryPoint∗/pub l i c void c r e a t e ( ) {

frame = new JFrame ("Compare ! " ) ;frame . s e tDe fau l tC lo seOperat i on ( JFrame .DISPOSE_ON_CLOSE) ;

Container pane = frame . getContentPane ( ) ;

c r ea t eLe f tPane l ( ) ;

createMiddlePane l ( ) ;

c reateRightPane l ( ) ;

pane . add ( l e f t , BorderLayout .LINE_START) ;pane . add (middle , BorderLayout .CENTER) ;pane . add ( r ight , BorderLayout .LINE_END) ;

loadFormulaA ( ) ;loadFormulaB ( ) ;

r e f r e s hTex tF i e l d s ( ) ;

frame . pack ( ) ;}

p r i va t e void loadFormulaA ( ) {subformulaA = new ArrayList<Formula>() ;subformulaA . addAll (Runner . getGUI ( ) . getSubformulaA ( ) ) ;

}

p r i va t e void loadFormulaB ( ) {subformulaB = new ArrayList<Formula>() ;subformulaB . addAll (Runner . getGUI ( ) . getSubformulaB ( ) ) ;

}

94

Page 103: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

pr i va t e void c r ea t eLe f tPane l ( ) {l e f t = new JPanel ( ) ;l e f t . se tBorder ( BorderFactory . c reateRaisedBeve lBorder ( ) ) ;

l e f tTex t = new JLabel ( ) ;// l e f tTex t . s e tEd i t ab l e ( f a l s e ) ;// l e f tTex t . setMargin ( textFie ldMarg in ) ;l e f tTex t . s e tP r e f e r r e dS i z e ( textFie ldDimens ion ) ;// l e f tTex t . setLineWrap ( t rue ) ;l e f t . add ( l e f tText , BorderLayout .LINE_START) ;

}

p r i va t e void createMiddlePane l ( ) {middle = new JPanel ( ) ;middle . setBorder ( BorderFactory . c reateRaisedBeve lBorder ( ) ) ;

JPanel buttonPanel = new JPanel ( ) ;buttonPanel . setBorder ( BorderFactory . createEtchedBorder ( ) ) ;on lyLe f t = new JToggleButton (" on lyLe f t ") ;on lyLe f t . setAlignmentX (Component .CENTER_ALIGNMENT) ;on lyLe f t . s e t S i z e ( buttonDimension ) ;on lyLe f t . addAct ionLis tener (new Le f tC l i ck ( ) ) ;common = new JToggleButton ("common") ;common . setAlignmentX (Component .CENTER_ALIGNMENT) ;common . s e t S i z e ( buttonDimension ) ;common . addAct ionLis tener (new CommonClick ( ) ) ;onlyRight = new JToggleButton (" onlyRight ") ;onlyRight . setAlignmentX (Component .CENTER_ALIGNMENT) ;onlyRight . s e t S i z e ( buttonDimension ) ;onlyRight . addAct ionLis tener (new RightCl ick ( ) ) ;middle . setLayout (new BoxLayout (middle , BoxLayout .X_AXIS) ) ;buttonPanel . setLayout (new BoxLayout ( buttonPanel , BoxLayout .Y_AXIS) ) ;

buttonPanel . add ( on lyLe f t ) ;buttonPanel . add (common) ;buttonPanel . add ( onlyRight ) ;

middle . add ( buttonPanel ) ;}

p r i va t e void createRightPane l ( ) {r i g h t = new JPanel ( ) ;r i g h t . setBorder ( BorderFactory . c reateRaisedBeve lBorder ( ) ) ;

r ightText = new JLabel ( ) ;// r ightText . setMargin ( textFie ldMarg in ) ;r ightText . s e tP r e f e r r e dS i z e ( textFie ldDimens ion ) ;// r ightText . s e tEd i t ab l e ( f a l s e ) ;// r ightText . setLineWrap ( t rue ) ;r i g h t . add ( r ightText ) ;

}

pub l i c void show ( ) {frame . s e tV i s i b l e ( t rue ) ;

}

p r i va t e void r e f r e s hTex tF i e l d s ( ) {// bal o l d a l i mez�St r ing l e f t = new St r ing ( ) ;l e f t = "<html><p>";f o r ( Formula f : subformulaA ) {

boolean conta in s = conta insLis tFormula ( f , subformulaB ) ;i f ( on lyLe f t . i s S e l e c t e d ( ) && ! conta in s ) {

l e f t += ("< font c o l o r ='blue '>"+ f . getFormula ( )+"</font><br>") ;} e l s e {

95

Page 104: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

i f (common . i s S e l e c t e d ( ) && conta in s ) {l e f t += ("< font c o l o r ='red '>"+ f . getFormula ( )+"</font><br>") ;

} e l s e {l e f t +=("<font c o l o r ='black '>"+ f . getFormula ( )+"</font><br>") ;

}}

}l e f t += ("</p></html>") ;l e f tTex t . setText ( l e f t ) ;// jobb o l d a l i mez�St r ing r i g h t = new St r ing ( ) ;r i g h t = ("<html><p>") ;f o r ( Formula f : subformulaB ) {

boolean conta in s = conta insLis tFormula ( f , subformulaA ) ;i f ( onlyRight . i s S e l e c t e d ( ) && ! conta in s ) {

r i g h t += ("< font c o l o r ='green '>"+ f . getFormula ( )+"</font><br>") ;} e l s e {

i f (common . i s S e l e c t e d ( ) && conta in s ) {r i g h t += ("< font c o l o r ='red '>"+ f . getFormula ( )+"</font><br>") ;

} e l s e {r i g h t += ("< font c o l o r ='black '>"+ f . getFormula ( )+"</font><br>") ;

}}

}r i g h t += ("</p></html>") ;r ightText . setText ( r i g h t ) ;

}

p r i va t e boolean conta insLis tFormula ( Formula f , ArrayList<Formula> l i s t ) {f o r ( Formula g : l i s t ) {

i f ( g . getFormula ( ) . equa l s ( f . getFormula ( ) ) ) {re turn true ;

}}re turn f a l s e ;

}

p r i va t e c l a s s Le f tC l i ck implements Act i onL i s t ene r {

pub l i c void act ionPerformed ( ActionEvent e ) {r e f r e s hTex tF i e l d s ( ) ;

}

}

p r i va t e c l a s s CommonClick implements Act i onL i s t ene r {

pub l i c void act ionPerformed ( ActionEvent e ) {r e f r e s hTex tF i e l d s ( ) ;

}

}

p r i va t e c l a s s RightCl ick implements Act i onL i s t ene r {

pub l i c void act ionPerformed ( ActionEvent e ) {r e f r e s hTex tF i e l d s ( ) ;

}

}

}

96

Page 105: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

A.3.2 GUI.java

package gui ;import java . awt . BorderLayout ;import java . awt . Container ;import java . awt . event . ActionEvent ;import java . awt . event . Act i onL i s t ene r ;import java . u t i l . ArrayList ;

import javax . swing . BorderFactory ;import javax . swing . BoxLayout ;import javax . swing . ButtonGroup ;import javax . swing . JButton ;import javax . swing . JFrame ;import javax . swing . JLabel ;import javax . swing . JPanel ;import javax . swing . JRadioButton ;

import formula . Formula ;

pub l i c c l a s s GUI {

p r i va t e JFrame frame ;p r i va t e Sp l i t t e rPan e l l e f t ;p r i va t e JPanel middle ;p r i va t e Sp l i t t e rPan e l r i g h t ;p r i va t e JButton compareButton ;p r i va t e JRadioButton l t l ;p r i va t e JRadioButton c t l ;p r i va t e ButtonGroup log i cChoose r ;p r i va t e JPanel panel ;

pub l i c GUI( ) {

}

/∗∗∗ @wbp. par s e r . entryPoint∗/pub l i c void c r e a t e ( ) {

frame = new JFrame ("Compare") ;frame . s e tDe fau l tC lo seOperat i on ( JFrame .EXIT_ON_CLOSE) ;

c r ea t eLe f tPane l ( ) ;

createMiddlePane l ( ) ;

c reateRightPane l ( ) ;

Container pane = frame . getContentPane ( ) ;

pane . add ( l e f t , BorderLayout .LINE_START) ;pane . add (middle , BorderLayout .CENTER) ;pane . add ( r ight , BorderLayout .LINE_END) ;

frame . pack ( ) ;}

p r i va t e void createRightPane l ( ) {r i g h t = new Sp l i t t e rPane l ( ) ;

r i g h t . setBorder ( BorderFactory . c reateRaisedBeve lBorder ( ) ) ;}

p r i va t e void createMiddlePane l ( ) {middle = new JPanel ( ) ;

97

Page 106: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

middle . setBorder ( BorderFactory . c reateRaisedBeve lBorder ( ) ) ;l og i cChoose r = new ButtonGroup ( ) ;middle . setLayout (new BoxLayout (middle , BoxLayout .X_AXIS) ) ;

panel = new JPanel ( ) ;middle . add ( panel ) ;panel . setLayout (new BoxLayout ( panel , BoxLayout .X_AXIS) ) ;

JPanel buttonPanel = new JPanel ( ) ;panel . add ( buttonPanel ) ;buttonPanel . setLayout (new BoxLayout ( buttonPanel , BoxLayout .Y_AXIS) ) ;JLabel l a b e l = new JLabel (" Ava i l ab l e formulae : " ) ;l t l = new JRadioButton ("LTL") ;l t l . addAct ionLis tener (new ChooseFormulae ( ) ) ;c t l = new JRadioButton ("CTL") ;c t l . addAct ionLis tener (new ChooseFormulae ( ) ) ;c t l . s e t S e l e c t e d ( t rue ) ;l og i cChoose r . add ( l t l ) ;l og i cChoose r . add ( c t l ) ;buttonPanel . add ( l a b e l ) ;buttonPanel . add ( l t l ) ;buttonPanel . add ( c t l ) ;

compareButton = new JButton ("Compare ! " ) ;buttonPanel . add ( compareButton ) ;compareButton . addAct ionLis tener (new CompareAction ( ) ) ;

}

p r i va t e void c r ea t eLe f tPane l ( ) {l e f t = new Sp l i t t e rPane l ( ) ;

l e f t . se tBorder ( BorderFactory . c reateRaisedBeve lBorder ( ) ) ;}

pub l i c void show ( ) {frame . s e tV i s i b l e ( t rue ) ;

}

pub l i c boolean getLTLSett ings ( ) {i f ( l t l . i s S e l e c t e d ( ) ) {

re turn true ;}i f ( c t l . i s S e l e c t e d ( ) ) {

re turn f a l s e ;}re turn f a l s e ;

}

pub l i c ArrayList<Formula> getSubformulaA ( ) {re turn l e f t . getSubformulaLis t ( ) ;

}

pub l i c ArrayList<Formula> getSubformulaB ( ) {re turn r i gh t . getSubformulaLis t ( ) ;

}

p r i va t e c l a s s CompareAction implements Act i onL i s t ene r {pub l i c void act ionPerformed ( ActionEvent e ) {

ComparePanel cpane l = new ComparePanel ( ) ;cpane l . c r e a t e ( ) ;cpane l . show ( ) ;

}}

p r i va t e c l a s s ChooseFormulae implements Act i onL i s t ene r {pub l i c void act ionPerformed ( ActionEvent arg0 ) {

98

Page 107: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

l e f t . r e f r e shFormulaL i s t ( ) ;r i g h t . r e f r e shFormulaL i s t ( ) ;

}}

}

A.3.3 MyTextArea.java

package gui ;import javax . swing . JTextArea ;

pub l i c c l a s s MyTextArea extends JTextArea {

p r i va t e s t a t i c f i n a l long se r ia lVers ionUID = 1L ;

pub l i c MyTextArea ( St r ing s t r i n g ) {super ( s t r i n g ) ;

}

pub l i c void append ( St r ing text ) {super . append ( text ) ;// t h i s . s e tCa r e tPo s i t i on ( t h i s . g e tCare tPos i t i on ( )+1) ;

}}

A.3.4 SplitterPanel.java

package gui ;import java . awt . BorderLayout ;import java . awt . Dimension ;import java . awt . GridLayout ;import java . awt . I n s e t s ;import java . awt . event . ActionEvent ;import java . awt . event . Act i onL i s t ene r ;import java . i o . BufferedReader ;import java . i o . F i l e ;import java . i o . Fi leReader ;import java . i o . IOException ;import java . u t i l . ArrayList ;import javax . swing . JButton ;import javax . swing . JFi leChooser ;import javax . swing . JPanel ;import javax . swing . JScro l lPane ;import javax . swing . JTextArea ;

import formula . Formula ;

pub l i c c l a s s Sp l i t t e rPan e l extends JPanel {

p r i va t e f i n a l I n s e t s textFie ldMarg in = new In s e t s ( 5 , 5 , 5 , 5 ) ;p r i va t e f i n a l Dimension textFie ldDimens ion = new Dimension (400 ,300) ;// p r i va t e f i n a l Dimension scro l lPaneDimens ion = new Dimension (350 ,310) ;p r i va t e s t a t i c f i n a l long se r ia lVers ionUID = 1L ;

p r i va t e JTextArea input ;p r i va t e JScro l lPane scrol lPaneUp ;p r i va t e JFi leChooser f i l e ;p r i va t e JButton openFi l e ;p r i va t e JTextArea subFormulas ;p r i va t e JScro l lPane scrollPaneDown ;

99

Page 108: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

pr i va t e JButton sp l i tFormula ;p r i va t e JPanel middle ;

//Datap r i va t e ArrayList<Formula> f L i s t ;p r i va t e ArrayList<Formula> s f L i s t ;

pub l i c Sp l i t t e rPan e l ( ) {t h i s . setLayout (new BorderLayout ( ) ) ;

// Fent i részcreateTop ( ) ;

//Középs� részc reateCenter ( ) ;

//Alsó részcreateBottom ( ) ;

//Dataf L i s t = new ArrayList<Formula>() ;s f L i s t = new ArrayList<Formula>() ;

}

p r i va t e void createTop ( ) {input = new JTextArea (" Input formulae ( put the t rue formulae here , one f o r each

l i n e ) ") ;input . s e tP r e f e r r e dS i z e ( textFie ldDimens ion ) ;input . setMargin ( textFie ldMarg in ) ;input . setLineWrap ( t rue ) ;input . s e tEd i t ab l e ( f a l s e ) ;input . setWrapStyleWord ( t rue ) ;JScro l lPane jSc ro l lPane1 = new JScro l lPane ( input ) ;scro l lPaneUp = new JScro l lPane ( input ) ;

scro l lPaneUp . s e tVe r t i c a l S c r o l lB a rPo l i c y ( JScro l lPane .VERTICAL_SCROLLBAR_AS_NEEDED) ;

//( ( Defaul tCaret ) input . getCaret ( ) ) . setUpdatePol icy ( DefaultCaret .ALWAYS_UPDATE);

// scrol lPaneUp . s e tP r e f e r r e dS i z e ( textFie ldDimens ion ) ;t h i s . add ( scrol lPaneUp , BorderLayout .PAGE_START) ;

}

p r i va t e void createCente r ( ) {middle = new JPanel (new GridLayout (1 , 2 ) ) ;

f i l e = new JFi leChooser ( ) ;openFi l e = new JButton ("Read an NuSMV− f i l e ") ;openFi l e . addAct ionLis tener (new OpenAction ( ) ) ;middle . add ( openFi l e ) ;sp l i tFormula = new JButton (" Closure o f the formulae ! " ) ;sp l i tFormula . addAct ionLis tener (new Sp l i tAc t i on ( ) ) ;middle . add ( sp l i tFormula ) ;t h i s . add (middle , BorderLayout .CENTER) ;

}

p r i va t e void createBottom ( ) {subFormulas = new JTextArea (" Subformulae o f input ") ;

subFormulas . s e tP r e f e r r e dS i z e ( textFie ldDimens ion ) ;subFormulas . setMargin ( textFie ldMarg in ) ;subFormulas . setLineWrap ( t rue ) ;subFormulas . s e tEd i t ab l e ( f a l s e ) ;subFormulas . setWrapStyleWord ( t rue ) ;JScro l lPane jSc ro l lPane1 = new JScro l lPane ( subFormulas ) ;scrollPaneDown = new JScro l lPane ( subFormulas ) ;scrollPaneDown . s e tVe r t i c a l S c r o l lB a rPo l i c y ( JScro l lPane .

VERTICAL_SCROLLBAR_AS_NEEDED) ;

100

Page 109: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

// scrollPaneDown . s e tP r e f e r r e dS i z e ( textFie ldDimens ion ) ;t h i s . add ( scrollPaneDown , BorderLayout .PAGE_END) ;

}

pub l i c ArrayList<Formula> g e t f L i s t ( ) {re turn f L i s t ;

}

p r i va t e c l a s s OpenAction implements Act i onL i s t ene r {pub l i c void act ionPerformed ( ActionEvent e ) {

i n t r e t v a l = f i l e . showOpenDialog ( nu l l ) ;i f ( r e t v a l == JFi leChooser .APPROVE_OPTION) {

F i l e i nF i l e = f i l e . g e t S e l e c t e dF i l e ( ) ;t ry {

Fi leReader f r = new Fi leReader ( i nF i l e ) ;BufferedReader bufRdr = new BufferedReader ( f r ) ;input . setText ("") ;S t r ing l i n e = nu l l ;whi l e ( ( l i n e = bufRdr . readLine ( ) ) != nu l l ) {

i f ( l i n e . conta in s ("−− s p e c i f i c a t i o n ") && l i n e . conta in s (" t rue ") ){

// l i n e = l i n e . sub s t r i ng ("−− s p e c i f i c a t i o n " . l ength ( ) , l i n e .l ength ( )−" i s f a l s e " . l ength ( ) ) ;

//FormulaList . getFormulaList ( ) . add (new Formula ( l i n e ) ) ;}i f ( l i n e . conta in s ("CTLSPEC") ) {

l i n e = l i n e . sub s t r i ng ("CTLSPEC " . l ength ( ) ) ;f L i s t . add (new Formula ( l i n e , f a l s e ) ) ;

}i f ( l i n e . conta in s ("LTLSPEC") ) {

l i n e = l i n e . sub s t r i ng ("LTLSPEC " . l ength ( ) ) ;f L i s t . add (new Formula ( l i n e , t rue ) ) ;

}}bufRdr . c l o s e ( ) ;r e f r e shFormulaL i s t ( ) ;

} catch ( IOException ioex ) {System . e r r . p r i n t l n ( i oex ) ;System . e x i t (1 ) ;

}}

}}

p r i va t e c l a s s Sp l i tAc t i on implements Act i onL i s t ene r {pub l i c void act ionPerformed ( ActionEvent e ) {

f o r ( Formula f : f L i s t ) {f o r ( Formula g : f . getSubformulae ( ) ) {

boolean match = f a l s e ;f o r ( i n t i = 0 ; i < s f L i s t . s i z e ( ) ; i++) {

i f ( s f L i s t . get ( i ) . getFormula ( ). equa l s ( g . getFormula ( ) ) ) {

match = true ;}

}i f ( ! match ) {

s f L i s t . add ( g ) ;}

}}re f r e shSubformulae ( ) ;

}}

pub l i c void re f r e shFormulaL i s t ( ) {

101

Page 110: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

input . setText ("") ;boolean l t l = main . Runner . getGUI ( ) . getLTLSett ings ( ) ;f o r ( Formula f : f L i s t ) {

i f ( f . isLTL ( ) == l t l ) {input . append (" − " + f + "\n") ;

}}

}

p r i va t e void re f r e shSubformulae ( ) {subFormulas . setText ("") ;boolean l t l = main . Runner . getGUI ( ) . getLTLSett ings ( ) ;f o r ( Formula f : s f L i s t ) {

i f ( f . isLTL ( ) == l t l ) {subFormulas . append (" − "+f+"\n") ;

}}

}

pub l i c ArrayList<Formula> getSubformulaLis t ( ) {re turn s f L i s t ;

}}

A.4 Logic

A.4.1 Logic.java

package l o g i c ;

import java . u t i l . ArrayList ;

import formula . Formula ;

pub l i c c l a s s Logic {

p r i va t e s t a t i c S t r ing [ ] ops = {" ! " , " : : " , " −", " ∗ " , " / " , " mod " , " + " , " −" ,

"<<", ">>", "union " , " in " , "!=" , " < " , " > " , "<=", ">=", "&"," | " , " xor " , "xnor " , "x ? y : z " , "<−>", "−>" } ;

p r i va t e s t a t i c ArrayList<Str ing> items ;

pub l i c s t a t i c ArrayList<Str ing> getSubformulae ( Formula formula ) {i n t count = sign_counter ( formula ) ;

ArrayList<Integer> open = new ArrayList<Integer >() ;ArrayList<Integer> c l o s e = new ArrayList<Integer >() ;i n t l ength = formula . getFormula ( ) . l ength ( ) ;

f o r ( i n t i = 0 ; i < formula . getFormula ( ) . l ength ( ) ; i++) {i f ( formula . getFormula ( ) . charAt ( i ) == ' ( ' ) {open . add ( i ) ;

}}

f o r ( i n t i = open . s i z e ( ) − 1 ; i >= 0 ; i−−) {f o r ( i n t j = open . get ( i ) + 1 ; j < formula . getFormula ( ) . l ength ( ) ; j++) {

i f ( formula . getFormula ( ) . charAt ( j ) == ' ) ' && ! c l o s e . conta in s ( j ) ) {phpAdd( c l o s e , j , i ) ;

}

102

Page 111: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

}}

// p r in t "<br><br>Close :<br >";items = new ArrayList<Str ing >() ;i tems . add ( formula . getFormula ( ) ) ;i f ( count != 0) {

f o r ( i n t j = count − 1 ; j >= 0 ; j−−) {S t r ing he lpe r = new St r ing ( ) ;he lpe r = c l ean ( subs t r ( formula . getFormula ( ) , open . get ( j ) ,

c l o s e . get ( j ) − open . get ( j ) ) ) ;

i s_explode ( he lpe r ) ;i tems . add ( he lpe r ) ;

}} e l s e {

is_explode ( formula . getFormula ( ) ) ;}

// r e t = choose_unique ( r e t ) ;ArrayList<Str ing> r e t = new ArrayList<Str ing >() ;f o r ( S t r ing s t r : i tems ) {

r e t . add ( s t r . tr im ( ) ) ;}

re turn r e t ;}

p r i va t e s t a t i c S t r ing c l ean ( St r ing subs t r ) {re turn subs t r . s ub s t r i ng (1 ) ;

}

p r i va t e s t a t i c S t r ing subs t r ( S t r ing formula , I n t eg e r in t ege r , i n t i ) {i f ( i < 0) {

St r ing r e t = formula . sub s t r i ng ( in t ege r , formula . l ength ( ) − i ) ;r e turn r e t ;

}i f ( ( i n t e g e r + i ) > formula . l ength ( ) ) {

St r ing r e t = formula . sub s t r i ng ( i n t e g e r ) ;r e turn r e t ;

}i f ( i > 0) {

St r ing r e t = formula . sub s t r i ng ( in t ege r , i n t e g e r + i ) ;r e turn r e t ;

}re turn nu l l ;

}

p r i va t e s t a t i c void is_explode ( S t r ing text ) {ArrayList<Str ing> sub_arr = new ArrayList<Str ing >() ;f o r ( S t r ing op : ops ) {

i f ( op_search ( op , t ex t ) ) {i f ( op == "&" && text . matches ( " / ( . ∗ ) /") ) {

i n t c en te r = text . indexOf ( '& ') ;i n t l enc = text . l ength ( ) ;i n t s t a r t = 0 , end = 0 ;f o r ( i n t i = cente r ; i >= 0 ; i−−){

i f ( t ex t . charAt ( i ) == ' ( ' ) {s t a r t = i ;break ;

}}

f o r ( i n t i = cente r ; i <= lenc ; i++) {

103

Page 112: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

i f ( t ex t . charAt ( i ) == ' ) ' ) {end = i ;break ;

}}

St r ing textb = subs t r ( text , s t a r t , end ) ;f o r ( S t r ing s t r : textb . s p l i t ( op ) ) {

sub_arr . add ( s t r ) ;}S t r ing t ex t e = subs t r ( text , end + 1 , l enc ) ;i s_explode ( t ex t e ) ;

} e l s e {f o r ( S t r ing s t r : t ex t . s p l i t ( op ) ) {

sub_arr . add ( s t r ) ;}

}

i f ( sub_arr . s i z e ( ) > 0) {f o r ( S t r ing sub : sub_arr ) {

i f ( array_item_in_string ( sub ) ) {is_explode ( sub ) ;

} e l s e {i f ( ! i tems . conta in s ( sub ) ) {items . add ( sub ) ;

}}items . add ( sub ) ;

}}

}}

}

p r i va t e s t a t i c boolean array_item_in_string ( S t r ing text ) {i n t e r r = 1 ;f o r ( S t r ing op : ops ) {

i n t op_len = op . l ength ( ) ;i n t text_len = text . l ength ( ) ;f o r ( i n t i = 0 ; i <= text_len ; i++) {

i f ( subs t r ( text , i , op_len ) . equa l s ( op ) ) {e r r = 0 ;i f ( subs t r ( text , i +2 ,1) . equa l s (">") && op . equa l s (" −") ) {

e r r = 1 ;}

}}

}i f ( e r r == 0) {

re turn true ;} e l s e {

re turn f a l s e ;}

}

p r i va t e s t a t i c boolean op_search ( St r ing op , S t r ing text ) {i n t e r r = 1 ;i n t op_len = op . l ength ( ) ;i n t text_len = text . l ength ( ) ;f o r ( i n t i = 0 ; i < text_len ; i++) {

i f ( subs t r ( text , i , op_len ) . equa l s ( op ) ) {e r r = 0 ;i f ( subs t r ( text , i +2 ,1) . equa l s (">") && op . equa l s (" −") ) {

e r r = 1 ;}

104

Page 113: Ákos Dávid Veri cation of Component-Based Software with ... · BMC Bounded Model Checking CBSD Component-Based Software Development CCM CORBA Component Model ... SME Small and Medium

Veri�cation of Component-Based Software with Model Checking

}}i f ( e r r == 0) {

re turn true ;} e l s e {

re turn f a l s e ;}

}

p r i va t e s t a t i c i n t s ign_counter ( Formula formula ) {St r ing [ ] p i e c e s = formula . t oS t r i ng ( ) . s p l i t ("\\(" ) ;S t r ing [ ] p i e c e s s = formula . t oS t r i ng ( ) . s p l i t ("\\) ") ;i n t count = p i e c e s . l ength ;i n t countt = p i e c e s s . l ength ;i f ( count == countt ) {

re turn count − 1 ;} e l s e {

System . e r r . p r i n t l n (" Error in formule ! − Pai r s ?") ;r e turn 0 ;

}}

p r i va t e s t a t i c <T> void phpAdd( ArrayList<T> l i s t , T element , i n t p o s i t i o n ) {i f ( p o s i t i o n > l i s t . s i z e ( ) ) {

i f ( l i s t . s i z e ( ) == 0) {l i s t . add ( element ) ;

}f o r ( i n t i = l i s t . s i z e ( ) − 1 ; i <= po s i t i o n ; i++) {

l i s t . add ( i , e lement ) ;}

} e l s e {l i s t . add ( po s i t i on , element ) ;

}}

}

A.5 Main

A.5.1 Runner.java

package main ;

import gui .GUI ;

pub l i c c l a s s Runner {

p r i va t e s t a t i c GUI gui ;

pub l i c s t a t i c void main ( S t r ing [ ] a rgs ) {gui = new GUI( ) ;gu i . c r e a t e ( ) ;gu i . show ( ) ;

}

pub l i c s t a t i c GUI getGUI ( ) {re turn gui ;

}

}

105