Formal Specifications Guide Development and Testing of Software Components

Size: px
Start display at page:

Download "Formal Specifications Guide Development and Testing of Software Components"

Transcription

1 Tamkang Journal of Science and Engineering, vol. 2, No. 1 pp (1999) 1 Formal Specifications Guide Development and Testing of Software Components R. E. Davis Computer Engineering Department Santa Clara University Santa Clara, CA 95053, U.S.A. rdavis@scu.edu Abstract Formal specifications provide many benefits to software developers. It has long been recognized that formal methods are required in safety critical applications, where it may even be necessary to perform formal proofs of correctness to increase confidence in the reliability of the system. However, not all uses of formal methods require the same level of detail, or even formality. We can design formal specifications of software components, and then use the specifications in an informal way to guide the development of an implementation as well as to provide a blueprint for testing of the finished component. In this paper we use the Larch Shared Language (LSL) to specify abstract data types, and show how the specification can be used both to guide implementation in Ada95 and to develop a testing plan. This approach increases both the quality of documentation and confidence in the correctness of reusable components providing abstract data structures. Key words: formal methods, formal specification, Larch, LSL, testing, software components, abstract data types, Ada. 1. Introduction Too often the use of formal methods is seen as an alternative to the way software is really developed. At best formal methods are seen to be of value only for safety critical applications; often they are an anomaly studied in a separate course for the express purpose of studying formal methods; at worst they are seen to be only of theoretical interest and no practical value. We believe that use of formal methods is appropriate in most software courses in the computer science/engineering curriculum, although we do not insist on a strictly formal approach to the entire software engineering process. For example, it is reasonable to make use of formal specifications for some but not all parts of a software system. The specifications may be written for a variety of reasons: to enable derivation of programs, to permit verification, to guide implementation, to document interfaces, to provide guidelines for reuse, or simply to clarify the requirements in the minds of designers. The specification, representation and implementation of abstract data structures present the ideal opportunity to introduce formal methods of specification. In addition, the formal specification fits nicely with the separation of interface and implementation required by the encapsulation and object-oriented features of programming languages. These features, in turn, enable the implementation of reliable reusable software components. In this paper we present our approach to the informal, practical use of formal specifications as a guide to implementation and testing of software components, which increases both the quality of documentation and confidence in the correctness of the implementation. Section 2 describes abstract data structures and their formal specification in an enhanced subset of the Larch Shared Language (LSL [7]), the language we use to write algebraic specifications. We note how reuse can be employed in the specification as well as later in the

2 2 Tamkang Journal of Science and Engineering, vol. 2, No. 1 (1999) implementation of abstract data types. In Section 3 we explore the difference between the notions of value and object, and its impact on the implementation of data structures. Section 4 provides a representation for a Table abstract data type. Section 5 shows how the implementation of objects can be guided by the specification of their associated values, and Section 6 describes how the formal specification can be used informally to guide testing and increase one's confidence in the correctness of the implementation. In Section 7 we note that this approach can have a significant effect on the production of high quality reusable software components. 2. Formal Specification of Abstract Data Structures 2.1 Abstract Data Structures There is more to an abstract data structure (or Abstract Data Type, ADT) 1 than a set of elements. A data structure is defined by the elements of its domain together with primitives that describe how these elements are related to each other and to elements of other data structures. We use the following definition to express this more formally. DEFINITION: A data structure is a 4-tuple consisting of a set of domains D, a designated domain d D, a set of functions F, and a set of axioms A. The 4-tuple ( D, d, F, A) denotes the data structure d and is usually abbreviated by writing d. It is important to distinguish between data structures, which are abstract entities, and the storage structures provided in a programming language, even though they may use the same name. A data structure is specified to describe what it is (its elements and the relationships among its elements and those of other data structures). A specification is intended to accurately define the one ADT of interest. It is abstract in that it describes the values and relationships without concern for how they might be represented and implemented. A concrete representation denotes elements of an ADT by combinations of storage structures in a specific programming language. There can be many possible representations for a given data 1 We use the terms abstract data structure and ADT interchangeably. We refer to concrete programmatic representations of ADTs as storage structures. structure. A representation tells us how a given element of the data structure looks so we can recognize it and work with it. An implementation is a set of programs that provide the capabilities of the primitive functions of the data structure while operating on concrete representations. Given a specific representation, there can be many possible implementations using different algorithms to accomplish the same task. An implementation tells us how the primitive operations work with the chosen representation to supply the capabilities of the specified data structure. We refer to the implementation of the capabilities of functions of an ADT to emphasize that one need not implement each function of a specification as a function (returning a value). For example, the capabilities of the functions Top and Pop on an ADT Stack might reasonably be implemented by a single procedure Pop producing two values, or a function returning a top value and having a side-effect on a stack object, or. The strict division of the tasks of specification, representation, and implementation of data structures helps to clarify distinct issues that are raised at each step. Emphasizing this division encourages programmers to address design issues before plunging into coding. 3. An Enhanced Subset of LSL To specify an ADT we need a convention for defining the domain of elements, primitive functions, and the axioms defining constraints that must be satisfied. We use the Larch 2 Shared Language (LSL) [7,8], to describe high-level, programming language independent specifications. The specification of ADTs requires only a small subset of the language. We have added a few category labels to this subset to suggest which primitives may be necessary, and what their purpose is in the ADT. 2 Larch is in fact a family of specification languages and tools (see [7]}) that support a two-tiered approach to specification of software and hardware. The Larch Shared Language is used to write a programming-language independent specification describing mathematical abstractions. The second tier of specification is supported by Larch Interface Languages that have been designed for several programming languages (Ada, C, Modula, CLU, Smalltalk, ML, ), allowing one to specify resource allocation, state changes, and exceptions in a way that depends heavily on the specifics of a particular implementation language. Larch tools include several syntax checkers and the Larch Prover for analyzing semantics of specifications.

3 R. E. Davis: Formal Specifications Guide Development and Testing of Software Components 3 LSL provides a specification unit called a trait that can be used (among other options) to specify abstract data structures. For example, we can specify the data structure Table as an LSL trait. Using the definition above, the elements of the 4-tuple are d = Table, D = {Table, Key, Contents, Boolean}, F = {New, Add, Retrieve, IsEmpty, }, and A is the set of axioms (equations) following the asserts below. Each trait is given a name. The introduces section specifies the set of functions F and provides the types of their arguments and values. The functions F specify the elements of the data domain of the structure being defined as well as the primitive operations and relationships involving those elements. There is no fixed correct set of primitives for a data structure, and there is a tradeoff between the simplicity of a small set and the utility of a larger set of primitives. We use a slight variation on the LSL notation, adding labelled categories of primitives to the introduces section of a trait. These categories, described below, provide a guide to designers in their choice of primitives. 1. Specify the elements of the domain --- often this is an inductive definition. (a) basis element(s) --- the 0-ary function New in the example above. (b) constructors --- Add in the example above. This class of functions generate compound elements of the domain. (c) The external clause of an inductive definition, which states that the only elements of the domain are those that can be generated from a finite number of applications of (a) and (b), can be made explicit by including a generated by axiom in the asserts section of the trait. 2. Selectors are primitives for decomposing compound elements of the domain --- usually one considers providing selectors corresponding to the arguments of the constructor functions. In Table, since a table is constructed by applying Add to a Key, a Contents and an existing Table, we consider providing selectors that produce the parts of such a construction. Above, we chose to provide only the selector Retrieve, which selects the Contents added at a given Key in a Table. (One can imagine another selector, say Find, that locates a Key bound to a given Contents in a Table.) 3. Testers are primitives that test elements of the domain --- for example, testing that an element is a basis element, IsEmpty in the example above. 4. Utilities --- in addition to the constructors, selectors, and testers mentioned above, we may wish to provide a set of primitives expected to be necessary, or just useful, to anyone writing an application using the data structure. For example, we might have chosen to include a function, size, that provided the number of bindings in a table. The equations following the asserts specify constraints or conditions that must be satisfied by any correct implementation of the data structure. The LSL declaration that Table is generated by New, Add states that there are no hidden ways for an element to slip into the domain. If it cannot be generated by the operators given then it is not in the domain. The LSL clause Table partitioned by IsEmpty, Retrieve states that two tables are different if and only if they can be distinguished by some application of these operators. Note that we did not completely specify the selector Retrieve, since we did not say what happens if Retrieve is applied to New. It is left up to the implementor whether this should signal an

4 4 Tamkang Journal of Science and Engineering, vol. 2, No. 1 (1999) error or return some other value. The clause stating that we are exempting specific applications of an operator explicitly points out the fact that the operator is not completely defined on all elements of the domain by the equations in the trait, and thus the implementor is free to choose how to handle these cases. We can reuse specifications in a couple of ways. It is possible to explicitly include information from other traits via the include declaration, which has the effect of treating the new specification as if it contained all of the introduces and asserts clauses of the included trait. Another means of modularizing specifications is the definition of parameterized traits. For example, we can anticipate that the TableSpec trait will be useful for several different Key and Contents types and parameterize the trait as follows: TableSpec(Key, Contents) : trait We might then refer to a trait specifying a symbol table as TableSpec(Symbol, Value). Since we don't always anticipate every way we may later want to parameterize a trait, we can also refer to a trait with an explicit renaming for any of the types and/or functions introduced by the trait. Thus, assuming that we have already specified a StackOfItems trait, which introduced a Stack type and the operators MtStk, Push, Pop, and Top, we might specify the ADT Environment as a stack of symbol tables by: Note that LSL allows us to overload operators, so we can use the same symbol for the operator to check whether a symbol is in an environment or in an individual frame. The syntax we use for LSL specifications of ADTs can be summarized in Appendix A. 3. Objects and Values We use LSL to describe the values of an abstract data structure and how they are related to other values. Most programmers have a preconceived notion of data structures as objects --- things with identity and state that are side-effected by operations. Our formal specifications however, with semantics based on the mathematics of first-order logic, view data structures as values, which can be constructed, viewed, tested, and have their components selected, but have no more claim to identity than does an integer. When writing formal specifications for data structures we take this mathematical view in order to abstract away from our experience with the accidental (and intentional) details of specific implementations. We want to specify the essence of the data structure values. However, before we proceed to represent and implement a data structure we must consider whether it is more appropriately viewed as value or object. The fundamental distinction between the concepts of object and value is the notion of identity. Every object has a value, but two objects are distinguishable even if they have the same value. Many objects are mutable, they can change their values, but they do not lose their identity. Philosophically, the notion of identity is quite complex; however, we take a very simple-minded view. We assume that every object is endowed with identity upon creation, and that identity (whatever it is) never changes. One important question to ask when deciding whether the elements of an ADT are objects or values is whether or not it makes sense to say you can have two different elements of the ADT whose values (at a given time) are equal. For example, it makes no sense to say we have two fours. Numbers are values, there is no need to distinguish between this four and that four; all that is important is its fourness. On the other hand, it makes perfect sense to distinguish between two queues, even when the same items appear in the same order in each queue. (Perhaps one is a list of customers waiting to buy strawberries, and the other is a list of customers waiting to buy steaks. If

5 R. E. Davis: Formal Specifications Guide Development and Testing of Software Components 5 you happen to be vegetarian you might like to enter one queue and not the other.) The choice of value or mutable object has impact on both the representation and the implementation of a data structure. Values can be safely shared, but with objects we must worry about side-effects. There are new primitives to be considered for objects that made no sense for values. Mutators are primitive operations that change the state of an object. Also among the utilities and testers we provide we may need to consider multiple versions; for example, sometimes we want to test equality (of values) and other times we must check identity (of objects). To make this discussion concrete, let us proceed with the ADT Table. Choosing to implement tables as values with no concept of identity would imply that we intend to distinguish tables only by the values we can Retrieve from them. That is, if we had two table variables, A and B, bound to the same table value, it would be immaterial whether or not they were programmatically bound to the same object representing that value. This would complicate our implementation by requiring that we ensure that the values are immutable, and thus we can share without fear of side-effects. However, most people do not think of tables as pure values but as objects that have operations performed on them that change their state. Thus we distinguish this table from that table even though they may have the same retrievable contents for every key. For example, considering the environment example above, we may have a table (frame) associated with a call to a procedure P(x, y), and another table associated with a call to a procedure Q(x, y). If they were called with the same actual arguments, the two tables would initially have the same value, however, in the process of evaluating the respective bodies of the procedures we may change the value of one or both tables. This affects the implementation of operations, since if we consider a table to have an identity, then Add may become a procedure that changes the state of a table instead of a function that produces a new table value from an old value. It also affects the interface to the data structure, since an implementation as objects may require both primitive functions that sample the state of an object (for its value, e.g. Retrieve) and primitive procedures that change the state in specified ways (e.g., Add). Based on this discussion, we choose to implement tables as objects. 4. Representation Once we have specified the values of a data structure, and decided whether its domain of implementation is most naturally populated by objects or values, we can consider alternatives for representing it. That is, we need to establish a convention for denoting elements of the data structure so there is no ambiguity about which element is intended. We can imagine both bounded and unbounded representations for the ADT TableSpec, reflecting whether or not we choose to set a limit on the number of entries a table can hold. If we choose to allow tables to grow dynamically without a predefined limit, we might consider an unbounded\label{unbounded} representation based on linked lists. A table of entries can be represented as a singly linked list, each of whose elements represents a single entry (a binding of a key to contents) and a link to the rest of the table. An empty list (or null pointer) would represent an empty table. Using Ada as an implementation language, we can define such a representation using access and record types as follows. We assume that the Key and Contents types are define elsewhere. type Node; type Table is access Node; type Node is record TheKey : Key; TheContents : Contents; Next : Table; end record This describes the storage structure used to represent a table, but it doesn't implement the table. To accomplish the implementation we need to choose and implement primitive table operations that provide all the functionality specified by the trait TableSpec while operating on the chosen representation. These operations comprise the concrete interface to the ADT. The separation of interface from implementation is reinforced in Ada with the notions of package specification and body. We make the representation and interface to the ADT explicit in the package specification, and provide the details of the implementation in the package body. 5. Implementation Once the representation is chosen, we still have several options for implementation. Two

6 6 Tamkang Journal of Science and Engineering, vol. 2, No. 1 (1999) major considerations when designing components for reuse are the flexibility of the component (range of variations it covers) and the degree of protection it provides. In Ada, flexibility is increased by making appropriate use of generics and discriminants (perhaps making the interface more complex). Safety is provided in varying degrees by limiting access to the representation via private and limited private types. To enhance the modularity and safety of programs using our table module, we do not allow the user access to the representation of the table. Anyone using tables must do so through a well-defined interface of primitive table operations. The first impulse is to treat the introduces section of a trait specification as a rough outline of a package specification providing this interface, and to a large extent it is just that. We must, of course, be careful to satisfy the axioms of the trait specification when providing an implementation of an ADT. However, this does not constrain us to supply each primitive as a function and to implement each as if the axioms provided an operational specification. The implementation decisions we make affect both the mechanism (procedure or function) used to implement a primitive, and which primitives must be provided. For example, we may choose to hide the details of the representation by making the Table an Ada limited private type. This means assignment will not be available from the system and we will not be able to initialize tables outside the implementing package. In order to create a table with the New value we need to provide a primitive operation that will empty a table. We also provide an assignment equivalent --- a Copy operation that can make one table contain a copy of the value of another (thus creating two tables who happen to have the same value). Similarly, we must consider whether representations of objects can be shared, and which primitive procedures (mutators) we will provide to change the state of an object. If sharing is allowed, we must provide another primitive MkSame that will allow one table to share the same value as another (creating two names for the same table). Also, since objects have identity, we may need the ability to test for identity (sameness) as well as for equality of state (value) of objects. Another useful capability provided by Ada is the exception handling mechanism. Whenever we implement a data structure we should consider what might go wrong and decide how to deal with it. For example, the TableSpec trait specification put no constraints on the value of Retrieve(K, New). Even though the trait leaves the behavior unspecified, an implementation cannot. We must decide whether to return a designated null value, signal an error, or allow a client the opportunity to provide the desired behavior. In Ada we define exceptions that can be raised at appropriate times and can be handled by clients of our implementation. We saw how the TableSpec trait could be parameterized by the types Key and Contents that are entered in the table. Ada allows us a similar flexibility in defining generic packages parameterized by types that are required within them. Factoring in all of these considerations leads to the specification of the generic package TableSpec given below. generic type Key is private; type Contents is private; package TableSpec is type Table is limited private; - - exceptional conditions that we wish to recognize - - within the package Overflow, Underflow, EntryNotFound : exception; - - running out of room for a table to grow, - - trying to access parts of a table that don't exist, - - or trying to retrieve the contents for a key - - not bound in the table - - procedures that modify tables procedure MkNew( T : in out Table); - - make the table T the empty table procedure Add(K in Key; C : in Contents; T : in out Table); - - add the entry binding K to C in table T procedure Copy( T1 : in Table; T2 : in out Table); - - make the table T2 a copy of the table T1 procedure MkSame( T1 : in Table; T2 : in out Table); - - make the table T2 the same table as T1 - - functions that select components of, or test, tables function Retrieve( K : in Key; T : in Table) return Contents; - - returns the contents bound to K in table T function IsEmpty( T : in Table) return Boolean; - - checks whether the table T is empty function IsBound( K : in Key; T : in Table)

7 R. E. Davis: Formal Specifications Guide Development and Testing of Software Components 7 return Boolean; - - checks if there is a binding for K in table T function IsSame( T1, T2 : in Table) return Boolean; - - checks if T1 and T2 refer to the same table private type Node; type Table is access Node; type Node is record TheKey : Key; TheContents : Contents; Next : Table; end record; end TableSpec; The package body defines each of the primitives in terms of operations on the chosen representation. We haven't space to present here the details of the package body. 6. Testing the Implementation The TableSpec trait described table values and constraints on operations involving them. Our TableSpec package implements tables as objects whose states represent table values as specified in the trait. We need to provide some way of mapping the constraints on the primitive operations of the trait to constraints on the procedures and functions of the package. We proceed by considering each equation, and translating it into the world of objects by replacing references to values with references to variables whose values should meet the constraint expressed by the equation. Function applications may have to be replaced by variables whose values have been modified by corresponding procedures. The equations, which were stated for all values of the variables used in stating them, become program constraints, which should also be understood to hold for all values of the variables used. 1. The equation constraining Retrieve: Retrieve(x, Add(y,c,t)) = = if x=y then c else Retrieve(x, t) becomes the program constraint: Let Old = Retrieve(K1, T). Then, after executing Add(K2, C, T), the value of Retrieve(K1, T) is: if K1=K2 then C else Old 2. The equations constraining IsEmpty: IsEmpty( New ) = = true; IsEmpty(Add(x, c, t)) = = false become program constraints: After executing MkNew(T), the value of IsEmpty(T) must be TRUE; After executing Add(K, C, T), the value of IsEmpty(T) must be FALSE. 3. The equations constraining : x New = = false x Add(y,c,t) = = (x = y) V ( x t) become program constraints: After executing MkNew(T), the value of IsBound(K,T) is FALSE; Let WasIn = IsBound(K1, T). Then after executing Add(K2, T), the value of IsBound(K1,T) is: WasIn V K1 = K2. We might also note that we have chosen to raise an exception in the case left unspecified by the trait, Retrieve(K, New). These are clearly informal program constraints, and they do not prove that an implementation satisfies a specification. Our intent is simply to provide a guide for moving from the world of values to that of program objects with state in such a way that one can informally argue that an implementation meets the ADT specifications. These constraints can be used to guide the development of test programs. For example, from the first constraint above we would develop a test program fragment that (assuming the appropriate declarations and initializations provide the context): 1. defines a table, T, containing a binding for K1, Add(K1, Old, T); 2. sets Old to the value bound to K1 in T, Old := Retrieve(K1, T); 3. Adds the new binding to the table, Add(K2, C, T); 4. and finally, tests the constraint, if K1=K2 then if C = Retrieve(K1, T) then put ( Retrieve axiom met ); else put ( Retrieve axiom fails ); end if; else if Old = Retrieve(K1, T); then put ( Retrieve axiom met ); else put ( Retrieve axiom fails ); end if; end if; Of course this test should be run for cases

8 8 Tamkang Journal of Science and Engineering, vol. 2, No. 1 (1999) in which K1 and K2 are equal as well as when they are not. 7. Reuse in Software Engineering There are many aspects of reuse worthy of study. The legal, ethical, managerial, economical, and organizational issues are among many that we do not address here. The study of reuse of software artifacts of many kinds is well-described in [11]. We approach only a small part of the problem. Our goal is to provide programmers the ability to design, recognize, and use high quality reusable software components. As pointed out in [2], design reuse has the greatest payoff potential, but code reuse is a reasonable first step. Reuse does not come easily, as documented in [13], where it was found that software designers who were not trained in reuse were unable to accurately assess the value of reusing software components. The programmers were over-influenced by unimportant features (such as size) and under-influenced by important ones (such as amount of modification required). While many of the qualities we look for in reusable components are the same we would require of any well-designed software, reuse requires something more than general program quality. We borrowed our criteria for evaluation of reusable components from Sindre et. al. [12]: portability, flexibility, understandability of interface, and confidence (the subjective probability that a component satisfactorily performs its defined purpose under reuse). These qualities are enhanced by clear separation of concerns in the specification, representation, and implementation of ADTs, and careful testing of implementations, guided by the formal specifications. 8. Conclusion clarify requirements and interface. The transition from specification of values to implementation of objects is dealt with directly; the problems raised by dealing with identity vs. equality and their effect on issues of representation and implementation are illuminated. The formal specifications are used in an informal way to guide design rather than to derive programs. The intention is not to produce formal proofs of correctness, but to demonstrate the value of formal specifications in the software development process. The specifications help describe the desired properties of a data structure, often making explicit the boundary conditions that might otherwise be left to default. Although formal proofs that each implementation satisfies its specification are not required, a specification can still serve as a guide in the testing of an implementation, and provide a framework within which one can argue that a program is correct. The specification also provides valuable documentation of the structure implemented in a package. We use Ada because of the advantages associated with its facilities for hiding details which, while providing protection, also make it easier to read package specifications produced by someone else.. There is a close match between the introduces section of the Larch specification and Ada's package specifications, which helps to bridge the transition from representation-independent formal specification to actual implementation. By emphasizing formal specification as a guide in software design and development we hope to establish a foundation for growth in the use of formal methods, making them less mysterious and more standard as practical techniques at the disposal of software engineers. Data structures provide the ideal context for addressing the creation and use of formal specifications in software development. While large software systems can be built in components in many ways using different design strategies (eg., object-oriented design or functional decomposition), data structures can be very clearly delineated, with interfaces easily understood (even agreed upon) by a large community of users. The production of high quality reusable components requires formal specification, choices of representation and implementation, and actual practice in reuse of ADTs implemented by others. The specifications are a design aid, helping to

9 R. E. Davis: Formal Specifications Guide Development and Testing of Software Components 9 A Grammar for enhanced subset of LSL In the above, the notation Item + indicates a sequence of one or more occurrences of Item, separated by commas. Reference 1. Barnes, J. G. P., Programming in Ada, Addison-Wesley Publishing Company, Menlo Park, CA. (1994). 2. Biggerstaff, T. and Richter, C., Reusability Framework, Assessment, and Directions, IEEE Software, Vol. 4, No. 2, pp (1987). 3. Booch, G., Software Components with Ada. Benjamin/Cummings, Menlo Park, CA. (1987). 4. Davis, R. E. and Danielson, R. L., LSL + Ada Reusable Data Structures, In Proceedings of the Tenth Annual Washington Ada Symposium, pp (1993). 5. Garlan, D., Formal Methods for Software Engineers: Tradeoffs in Curriculum Design, In C. Sledge, editor, Software Engineering Education, volume 640 of Lecture Notes in Computer Science, pp Springer-Verlag (1992). 6. Garland, S. J., Guttag, J. V. and Horning, J. J., Debugging Larch Shared Language Specifications, IEEE Transactions on Software Engineering, Vol. 16, No. 9, pp (1990). 7. Guttag, J. V., Horning, J. J. and Modet, A., Report on the Larch Shared Language, version 2.3. Technical Report DEC/SRC SRC-58, Digital Equipment Corporation Systems Research Center Report, April, (1990). 8. Guttag, J. V. and Horning, J. J. and Wing, J. M., The Larch Family of Specification Languages, IEEE Software, Vol. 2, No. 5, pp (1985). 9. Guttag, J. V. and Modet, A. and Horning, J. J. (eds.) with Garland, S. J. and Jones, K. D. and Wing, J. M., Larch: Languages and Tools for Formal Specification, Texts and Monographs in Computer Science. Springer-Verlag (1993). 10. Jefferson, O. A. and Roland, H. U., Software Reuse in an Educational Perspective, In C. Sledge, editor, Software Engineering Education, volume 640 of Lecture Notes in Computer Science, pp Springer-Verlag (1992). 11. Krueger, C. W., Software Reuse, ACM Computing Surveys, Vol. 24, No. 2, pp (1992). 12. Sindre, G. and Karlsson, E. A. and Stålhane, T., Software Reuse in an Educational Perspective, In C. Sledge, editor, Software Engineering Education, volume 640 of

10 10 Tamkang Journal of Science and Engineering, vol. 2, No. 1 (1999) Lecture Notes in Computer Science, pp Springer-Verlag (1992). 13. Woodfield, S. N., Embley, D. W. and Scott D. T., Can Programmers Reuse Software?, IEEE Software, Vol. 4, No. 4, pp (1987). Manuscript Received: May. 04, 1999 Revision Received: May. 28, 1999 and Accepted: Jun. 21, 1999

6.001 Notes: Section 8.1

6.001 Notes: Section 8.1 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything

More information

6.001 Notes: Section 6.1

6.001 Notes: Section 6.1 6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of

More information

Lecture 7: Data Abstractions

Lecture 7: Data Abstractions Lecture 7: Data Abstractions Abstract Data Types Data Abstractions How to define them Implementation issues Abstraction functions and invariants Adequacy (and some requirements analysis) Towards Object

More information

CS 242. Fundamentals. Reading: See last slide

CS 242. Fundamentals. Reading: See last slide CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language

More information

Software Design. Levels in Design Process. Design Methodologies. Levels..

Software Design. Levels in Design Process. Design Methodologies. Levels.. Design Software Design Design activity begins with a set of requirements Design done before the system is implemented Design is the intermediate language between requirements and code Moving from problem

More information

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Semantics via Syntax. f (4) = if define f (x) =2 x + 55. 1 Semantics via Syntax The specification of a programming language starts with its syntax. As every programmer knows, the syntax of a language comes in the shape of a variant of a BNF (Backus-Naur Form)

More information

Lecture 2: SML Basics

Lecture 2: SML Basics 15-150 Lecture 2: SML Basics Lecture by Dan Licata January 19, 2012 I d like to start off by talking about someone named Alfred North Whitehead. With someone named Bertrand Russell, Whitehead wrote Principia

More information

MITOCW watch?v=kz7jjltq9r4

MITOCW watch?v=kz7jjltq9r4 MITOCW watch?v=kz7jjltq9r4 PROFESSOR: We're going to look at the most fundamental of all mathematical data types, namely sets, and let's begin with the definitions. So informally, a set is a collection

More information

Coding and Unit Testing! The Coding Phase! Coding vs. Code! Coding! Overall Coding Language Trends!

Coding and Unit Testing! The Coding Phase! Coding vs. Code! Coding! Overall Coding Language Trends! Requirements Spec. Design Coding and Unit Testing Characteristics of System to be built must match required characteristics (high level) Architecture consistent views Software Engineering Computer Science

More information

Introduction to Formal Methods

Introduction to Formal Methods 2008 Spring Software Special Development 1 Introduction to Formal Methods Part I : Formal Specification i JUNBEOM YOO jbyoo@knokuk.ac.kr Reference AS Specifier s Introduction to Formal lmethods Jeannette

More information

3 ADT Implementation in Java

3 ADT Implementation in Java Object-Oriented Design Lecture 3 CS 3500 Spring 2010 (Pucella) Tuesday, Jan 19, 2010 3 ADT Implementation in Java Last time, we defined an ADT via a signature and a specification. We noted that the job

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

A Small Interpreted Language

A Small Interpreted Language A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that

More information

Type Checking and Type Equality

Type Checking and Type Equality Type Checking and Type Equality Type systems are the biggest point of variation across programming languages. Even languages that look similar are often greatly different when it comes to their type systems.

More information

An Introduction to Subtyping

An Introduction to Subtyping An Introduction to Subtyping Type systems are to me the most interesting aspect of modern programming languages. Subtyping is an important notion that is helpful for describing and reasoning about type

More information

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5 Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5 [talking head] This lecture we study theory design and implementation. Programmers have two roles to play here. In one role, they

More information

6.001 Notes: Section 1.1

6.001 Notes: Section 1.1 6.001 Notes: Section 1.1 Slide 1.1.1 This first thing we need to do is discuss the focus of 6.001. What is this course all about? This seems quite obvious -- this is a course about computer science. But

More information

Lecture 2: Analyzing Algorithms: The 2-d Maxima Problem

Lecture 2: Analyzing Algorithms: The 2-d Maxima Problem Lecture 2: Analyzing Algorithms: The 2-d Maxima Problem (Thursday, Jan 29, 1998) Read: Chapter 1 in CLR. Analyzing Algorithms: In order to design good algorithms, we must first agree the criteria for measuring

More information

6.001 Notes: Section 4.1

6.001 Notes: Section 4.1 6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,

More information

6.001 Notes: Section 17.5

6.001 Notes: Section 17.5 6.001 Notes: Section 17.5 Slide 17.5.1 Now, let's look at one example in which changing the evaluation model allows us to explore a very different kind of computational problem. Our goal is to show how

More information

7. Introduction to Denotational Semantics. Oscar Nierstrasz

7. Introduction to Denotational Semantics. Oscar Nierstrasz 7. Introduction to Denotational Semantics Oscar Nierstrasz Roadmap > Syntax and Semantics > Semantics of Expressions > Semantics of Assignment > Other Issues References > D. A. Schmidt, Denotational Semantics,

More information

Types and Type Inference

Types and Type Inference CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of

More information

JOURNAL OF OBJECT TECHNOLOGY

JOURNAL OF OBJECT TECHNOLOGY JOURNAL OF OBJECT TECHNOLOGY Online at www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2002 Vol. 1, No. 2, July-August 2002 The Theory of Classification Part 2: The Scratch-Built

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter

More information

1: Introduction to Object (1)

1: Introduction to Object (1) 1: Introduction to Object (1) 김동원 2003.01.20 Overview (1) The progress of abstraction Smalltalk Class & Object Interface The hidden implementation Reusing the implementation Inheritance: Reusing the interface

More information

AJAX: Automating an Informal Formal Method for Systematic JUnit Test Suite Generation

AJAX: Automating an Informal Formal Method for Systematic JUnit Test Suite Generation AJAX: Automating an Informal Formal Method for Systematic JUnit Test Suite Generation David Stotts Dept. of Computer Science Univ. of North Carolina at Chapel Hill stotts@cs.unc.edu Abstract The JUnit

More information

A Michael Jackson presentation. CSE503: Software Engineering. The following slides are from his keynote at ICSE 1995

A Michael Jackson presentation. CSE503: Software Engineering. The following slides are from his keynote at ICSE 1995 A Michael Jackson presentation CSE503: Software Engineering The following slides are from his keynote at ICSE 1995 David Notkin University of Washington Computer Science & Engineering Spring 2006 1 2 3

More information

4.2 Variations on a Scheme -- Lazy Evaluation

4.2 Variations on a Scheme -- Lazy Evaluation [Go to first, previous, next page; contents; index] 4.2 Variations on a Scheme -- Lazy Evaluation Now that we have an evaluator expressed as a Lisp program, we can experiment with alternative choices in

More information

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Notation. The rules. Evaluation Rules So Far.

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Notation. The rules. Evaluation Rules So Far. Lecture Outline Operational Semantics of Cool COOL operational semantics Motivation Adapted from Lectures by Profs. Alex Aiken and George Necula (UCB) Notation The rules CS781(Prasad) L24CG 1 CS781(Prasad)

More information

Programmiersprachen (Programming Languages)

Programmiersprachen (Programming Languages) 2016-05-13 Preface Programmiersprachen (Programming Languages) coordinates: lecturer: web: usable for: requirements: No. 185.208, VU, 3 ECTS Franz Puntigam http://www.complang.tuwien.ac.at/franz/ps.html

More information

Sub- PPL Unit-I Class-SE Comp

Sub- PPL Unit-I Class-SE Comp 1. We describe the basic concepts for structuring large programs (encapsulation, interfaces, information hiding) and the mechanisms provided by languages to support it (packaging, separate compilation).

More information

Unit-3 Software Design (Lecture Notes)

Unit-3 Software Design (Lecture Notes) Unit-3 Software Design (Lecture Notes) Prepared by Jay Nanavati, Assistant Professor, SEMCOM Topics Software Design - Introduction Design Principles Module Level concepts Overview of Structured design

More information

G Programming Languages Spring 2010 Lecture 8. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 8. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 8 Robert Grimm, New York University 1 Review Last time Types Fun with O Caml 2 Outline Modules Sources: PLP, 3.3.4, 3.3.5, 3.7 Barrett. Lecture notes,

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Operational Semantics. One-Slide Summary. Lecture Outline

Operational Semantics. One-Slide Summary. Lecture Outline Operational Semantics #1 One-Slide Summary Operational semantics are a precise way of specifying how to evaluate a program. A formal semantics tells you what each expression means. Meaning depends on context:

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing

More information

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful? Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2004 1 Why are there so many programming languages? Evolution -- we've learned better ways of doing things over time Socio-economic

More information

Chapter 11 Object and Object- Relational Databases

Chapter 11 Object and Object- Relational Databases Chapter 11 Object and Object- Relational Databases Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Outline Overview of Object Database Concepts Object-Relational

More information

Software re-use assessment for quality M. Ramachandran School of Computing and Mathematical Sciences, Jo/m Moores C/mrerszZ?/,

Software re-use assessment for quality M. Ramachandran School of Computing and Mathematical Sciences, Jo/m Moores C/mrerszZ?/, Software re-use assessment for quality M. Ramachandran School of Computing and Mathematical Sciences, Jo/m Moores C/mrerszZ?/, ABSTRACT Reuse of software components can improve software quality and productivity

More information

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242 Spring 2013 Foundations Yu Zhang Acknowledgement: modified from Stanford CS242 https://courseware.stanford.edu/pg/courses/317431/ Course web site: http://staff.ustc.edu.cn/~yuzhang/fpl Reading Concepts

More information

Object Oriented Programming

Object Oriented Programming Binnur Kurt kurt@ce.itu.edu.tr Istanbul Technical University Computer Engineering Department 1 Version 0.1.2 About the Lecturer BSc İTÜ, Computer Engineering Department, 1995 MSc İTÜ, Computer Engineering

More information

Part I Logic programming paradigm

Part I Logic programming paradigm Part I Logic programming paradigm 1 Logic programming and pure Prolog 1.1 Introduction 3 1.2 Syntax 4 1.3 The meaning of a program 7 1.4 Computing with equations 9 1.5 Prolog: the first steps 15 1.6 Two

More information

Lecture Notes on Programming Languages

Lecture Notes on Programming Languages Lecture Notes on Programming Languages 85 Lecture 09: Support for Object-Oriented Programming This lecture discusses how programming languages support object-oriented programming. Topics to be covered

More information

(Refer Slide Time: 4:00)

(Refer Slide Time: 4:00) Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional

More information

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction Lecture 13: Object orientation Object oriented programming Introduction, types of OO languages Key concepts: Encapsulation, Inheritance, Dynamic binding & polymorphism Other design issues Smalltalk OO

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

Unit 1 Introduction to Software Engineering

Unit 1 Introduction to Software Engineering Unit 1 Introduction to Software Engineering João M. Fernandes Universidade do Minho Portugal Contents 1. Software Engineering 2. Software Requirements 3. Software Design 2/50 Software Engineering Engineering

More information

Chapter 3. Semantics. Topics. Introduction. Introduction. Introduction. Introduction

Chapter 3. Semantics. Topics. Introduction. Introduction. Introduction. Introduction Topics Chapter 3 Semantics Introduction Static Semantics Attribute Grammars Dynamic Semantics Operational Semantics Axiomatic Semantics Denotational Semantics 2 Introduction Introduction Language implementors

More information

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far Lecture Outline Operational Semantics of Cool Lecture 13 COOL operational semantics Motivation Notation The rules Prof. Aiken CS 143 Lecture 13 1 Prof. Aiken CS 143 Lecture 13 2 Motivation We must specify

More information

CSE 505: Concepts of Programming Languages

CSE 505: Concepts of Programming Languages CSE 505: Concepts of Programming Languages Dan Grossman Fall 2003 Lecture 6 Lambda Calculus Dan Grossman CSE505 Fall 2003, Lecture 6 1 Where we are Done: Modeling mutation and local control-flow Proving

More information

One of the most important areas where quantifier logic is used is formal specification of computer programs.

One of the most important areas where quantifier logic is used is formal specification of computer programs. Section 5.2 Formal specification of computer programs One of the most important areas where quantifier logic is used is formal specification of computer programs. Specification takes place on several levels

More information

CSCC24 Functional Programming Scheme Part 2

CSCC24 Functional Programming Scheme Part 2 CSCC24 Functional Programming Scheme Part 2 Carolyn MacLeod 1 winter 2012 1 Based on slides from Anya Tafliovich, and with many thanks to Gerald Penn and Prabhakar Ragde. 1 The Spirit of Lisp-like Languages

More information

Programming Language Pragmatics

Programming Language Pragmatics Chapter 10 :: Functional Languages Programming Language Pragmatics Michael L. Scott Historical Origins The imperative and functional models grew out of work undertaken Alan Turing, Alonzo Church, Stephen

More information

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN NOTES ON OBJECT-ORIENTED MODELING AND DESIGN Stephen W. Clyde Brigham Young University Provo, UT 86402 Abstract: A review of the Object Modeling Technique (OMT) is presented. OMT is an object-oriented

More information

Outline. Introduction. 2 Proof of Correctness. 3 Final Notes. Precondition P 1 : Inputs include

Outline. Introduction. 2 Proof of Correctness. 3 Final Notes. Precondition P 1 : Inputs include Outline Computer Science 331 Correctness of Algorithms Mike Jacobson Department of Computer Science University of Calgary Lectures #2-4 1 What is a? Applications 2 Recursive Algorithms 3 Final Notes Additional

More information

Lecture Notes on Program Equivalence

Lecture Notes on Program Equivalence Lecture Notes on Program Equivalence 15-312: Foundations of Programming Languages Frank Pfenning Lecture 24 November 30, 2004 When are two programs equal? Without much reflection one might say that two

More information

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference Type Checking Outline General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time

More information

Concepts of Programming Languages

Concepts of Programming Languages Concepts of Programming Languages Lecture 10 - Object-Oriented Programming Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages

More information

The design of a programming language for provably correct programs: success and failure

The design of a programming language for provably correct programs: success and failure The design of a programming language for provably correct programs: success and failure Don Sannella Laboratory for Foundations of Computer Science School of Informatics, University of Edinburgh http://homepages.inf.ed.ac.uk/dts

More information

Abstract Data Types. Lecture notes accompanying COL106 (Data Structures), Semester I, , IIT Delhi

Abstract Data Types. Lecture notes accompanying COL106 (Data Structures), Semester I, , IIT Delhi Abstract Data Types Lecture notes accompanying COL106 (Data Structures), Semester I, 2018-19, IIT Delhi Amitabha Bagchi Department of CS&E, IIT Delhi August 13, 2018 1 What is an abstract data type Abstract

More information

Handout 10: Imperative programs and the Lambda Calculus

Handout 10: Imperative programs and the Lambda Calculus 06-02552 Princ of Progr Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 10: Imperative programs and the Lambda Calculus

More information

RSL Reference Manual

RSL Reference Manual RSL Reference Manual Part No.: Date: April 6, 1990 Original Authors: Klaus Havelund, Anne Haxthausen Copyright c 1990 Computer Resources International A/S This document is issued on a restricted basis

More information

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré Hoare Logic COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Slides courtesy of Ranald Clouston) COMP 2600 Hoare Logic 1 Australian Capital

More information

14.1 Encoding for different models of computation

14.1 Encoding for different models of computation Lecture 14 Decidable languages In the previous lecture we discussed some examples of encoding schemes, through which various objects can be represented by strings over a given alphabet. We will begin this

More information

Chapter 11 :: Functional Languages

Chapter 11 :: Functional Languages Chapter 11 :: Functional Languages Programming Language Pragmatics Michael L. Scott Copyright 2016 Elsevier 1 Chapter11_Functional_Languages_4e - Tue November 21, 2017 Historical Origins The imperative

More information

Conformance Requirements Guideline Version 0.1

Conformance Requirements Guideline Version 0.1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Editors: Conformance Requirements Guideline Version 0.1 Aug 22, 2001 Lynne Rosenthal (lynne.rosenthal@nist.gov)

More information

Informatica 3 Syntax and Semantics

Informatica 3 Syntax and Semantics Informatica 3 Syntax and Semantics Marcello Restelli 9/15/07 Laurea in Ingegneria Informatica Politecnico di Milano Introduction Introduction to the concepts of syntax and semantics Binding Variables Routines

More information

Lecture Notes on Ints

Lecture Notes on Ints Lecture Notes on Ints 15-122: Principles of Imperative Computation Frank Pfenning Lecture 2 August 26, 2010 1 Introduction Two fundamental types in almost any programming language are booleans and integers.

More information

Programming Languages Third Edition. Chapter 7 Basic Semantics

Programming Languages Third Edition. Chapter 7 Basic Semantics Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol

More information

Software Architectures

Software Architectures Software Architectures Richard N. Taylor Information and Computer Science University of California, Irvine Irvine, California 92697-3425 taylor@ics.uci.edu http://www.ics.uci.edu/~taylor +1-949-824-6429

More information

Object-Oriented Software Construction

Object-Oriented Software Construction 1 Object-Oriented Software Construction Bertrand Meyer Reading assignment 2 OOSC2 Chapter 10: Genericity 3 Lecture 4: Abstract Data Types Abstract Data Types (ADT 4 Why use the objects? The need for data

More information

Testing! Prof. Leon Osterweil! CS 520/620! Spring 2013!

Testing! Prof. Leon Osterweil! CS 520/620! Spring 2013! Testing Prof. Leon Osterweil CS 520/620 Spring 2013 Relations and Analysis A software product consists of A collection of (types of) artifacts Related to each other by myriad Relations The relations are

More information

Chapter 19: Program Design. Chapter 19. Program Design. Copyright 2008 W. W. Norton & Company. All rights reserved.

Chapter 19: Program Design. Chapter 19. Program Design. Copyright 2008 W. W. Norton & Company. All rights reserved. Chapter 19 Program Design 1 Introduction Most full-featured programs are at least 100,000 lines long. Although C wasn t designed for writing large programs, many large programs have been written in C.

More information

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 4 Robert Grimm, New York University 1 Review Last week Control Structures Selection Loops 2 Outline Subprograms Calling Sequences Parameter Passing

More information

AADL Graphical Editor Design

AADL Graphical Editor Design AADL Graphical Editor Design Peter Feiler Software Engineering Institute phf@sei.cmu.edu Introduction An AADL specification is a set of component type and implementation declarations. They are organized

More information

Leslie Lamport: The Specification Language TLA +

Leslie Lamport: The Specification Language TLA + Leslie Lamport: The Specification Language TLA + This is an addendum to a chapter by Stephan Merz in the book Logics of Specification Languages by Dines Bjørner and Martin C. Henson (Springer, 2008). It

More information

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1 Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Infix to Postfix Example 1: Infix to Postfix Example 2: Postfix Evaluation

More information

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS 1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism Block 1: Introduction to Java Unit 4: Inheritance, Composition and Polymorphism Aims of the unit: Study and use the Java mechanisms that support reuse, in particular, inheritance and composition; Analyze

More information

Scope. Chapter Ten Modern Programming Languages 1

Scope. Chapter Ten Modern Programming Languages 1 Scope Chapter Ten Modern Programming Languages 1 Reusing Names Scope is trivial if you have a unique name for everything: fun square a = a * a; fun double b = b + b; But in modern languages, we often use

More information

Introduction to Scheme

Introduction to Scheme How do you describe them Introduction to Scheme Gul Agha CS 421 Fall 2006 A language is described by specifying its syntax and semantics Syntax: The rules for writing programs. We will use Context Free

More information

such a manner that we are able to understand, grasp and grapple with the problem at hand in a more organized fashion.

such a manner that we are able to understand, grasp and grapple with the problem at hand in a more organized fashion. Programming and Data Structure Dr.P.P.Chakraborty Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 32 Conclusions Hello everybody. Today, we come to the

More information

CS321 Languages and Compiler Design I Winter 2012 Lecture 13

CS321 Languages and Compiler Design I Winter 2012 Lecture 13 STATIC SEMANTICS Static Semantics are those aspects of a program s meaning that can be studied at at compile time (i.e., without running the program). Contrasts with Dynamic Semantics, which describe how

More information

CS4215 Programming Language Implementation. Martin Henz

CS4215 Programming Language Implementation. Martin Henz CS4215 Programming Language Implementation Martin Henz Thursday 26 January, 2012 2 Chapter 4 The Language simpl In this chapter, we are exting the language epl in order to provide a more powerful programming

More information

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE

More information

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules. Outline Type Checking General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time

More information

C311 Lab #3 Representation Independence: Representation Independent Interpreters

C311 Lab #3 Representation Independence: Representation Independent Interpreters C311 Lab #3 Representation Independence: Representation Independent Interpreters Will Byrd webyrd@indiana.edu February 5, 2005 (based on Professor Friedman s lecture on January 29, 2004) 1 Introduction

More information

Modules. Cardelli, 1996

Modules. Cardelli, 1996 SDI LC90 E Dot Inc Modules Program modularization arose from the necessity of splitting large programs into fragments in order to compile them.... It was soon realized that modularization had great advantages

More information

Topic Formal Methods. ICS 121 Lecture Notes. What are Formal Methods? What are Formal Methods? Formal Specification in Software Development

Topic Formal Methods. ICS 121 Lecture Notes. What are Formal Methods? What are Formal Methods? Formal Specification in Software Development Lecture Notes What are? 1 Formal Method (FM) = specification language + formal reasoning Body of techniques supported by precise mathematics powerful analysis tools Rigorous effective mechanisms for system

More information

Programming Languages

Programming Languages Programming Languages As difficult to discuss rationally as religion or politics. Prone to extreme statements devoid of data. Examples: "It is practically impossible to teach good programming to students

More information

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122 Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122 I. Logic 101 In logic, a statement or proposition is a sentence that can either be true or false. A predicate is a sentence in

More information

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions) By the end of this course, students should CIS 1.5 Course Objectives a. Understand the concept of a program (i.e., a computer following a series of instructions) b. Understand the concept of a variable

More information

Software Design and Analysis for Engineers

Software Design and Analysis for Engineers Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 1 Date:

More information

Object-Oriented Theories for Model Driven Architecture

Object-Oriented Theories for Model Driven Architecture Object-Oriented Theories for Model Driven Architecture Tony Clark 1, Andy Evans 2, Robert France 3 1 King s College London, UK, anclark@dcs.kcl.ac.uk, 2 University of York, UK, andye@cs.york.ac.uk, 3 University

More information

Q Body of techniques supported by. R precise mathematics. R powerful analysis tools. Q Rigorous, effective mechanisms for system.

Q Body of techniques supported by. R precise mathematics. R powerful analysis tools. Q Rigorous, effective mechanisms for system. Introduction to Formal Methods 1 Introduction to Formal Methods 2 Formal Specification Requirements specification R notational statement of system services Software specification R formal abstract depiction

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

Programming Language Concepts, cs2104 Lecture 04 ( )

Programming Language Concepts, cs2104 Lecture 04 ( ) Programming Language Concepts, cs2104 Lecture 04 (2003-08-29) Seif Haridi Department of Computer Science, NUS haridi@comp.nus.edu.sg 2003-09-05 S. Haridi, CS2104, L04 (slides: C. Schulte, S. Haridi) 1

More information