Algebraic Specification - Software Engineering - Lecture Slides | CS 3773, Papers of Software Engineering

Material Type: Paper; Class: Software Engineering; Subject: Computer Science; University: University of Texas - San Antonio; Term: Unknown 1989;

Typology: Papers

Pre 2010

Uploaded on 07/30/2009

koofers-user-sli
koofers-user-sli 🇺🇸

10 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
CS3773
Software Engineering
Lecture 8
Algebraic Specification
UTSA CS3773
2
Specifying Data Types
¾We want to specify interfaces of components to facilitate
system decomposition
¾We need to specify interesting data types sometimes
Sets
Arrays
Records
New data types with operations
¾We want to avoid making design decisions, such as how a data
type is implemented (algorithm and data structure)
UTSA CS3773
3
Prose Specification of Data Types
¾Strategy #1: write a prose specification
A stack of integers supports three operations : push, pop, and
size. Pushing adds an element. Popping returns the most recently
added element. Size returns the number of elements.
¾Problems: it is ambiguous
What happens when you pop an empty stack?
Does “return” imply removes as well or just peeks?
How to add elements?
What are the precise signatures of the operations?
UTSA CS3773
4
Structured Prose of Data Types
¾Strategy #2: write a careful and structured prose
¾That is what most specifications look like
¾Problems
Suffers from the same problem as prose
pf3
pf4
pf5

Partial preview of the text

Download Algebraic Specification - Software Engineering - Lecture Slides | CS 3773 and more Papers Software Engineering in PDF only on Docsity!

CS

Software Engineering

Lecture 8

Algebraic Specification

UTSA CS

Specifying Data Types

¾^ We want to specify interfaces of components to facilitatesystem decomposition ¾^ We need to specify interesting data types sometimes– Sets

-^ Arrays -^ Records -^ New data types with operations ¾^ We want to avoid making design decisions, such as how a datatype is implemented (algorithm and data structure) UTSA CS

Prose Specification of Data Types

¾^ Strategy #1: write a prose specification A stack of integers supports three operations: push, pop, andsize. Pushing adds an element. Popping returns the most recentlyadded element. Size returns the number of elements. ¾^ Problems: it is ambiguous– What happens when you pop an empty stack?

-^ Does “return” imply removes as well or just peeks? -^ How to add elements? -^ What are the precise signatures of the operations? UTSA CS

Structured Prose of Data Types

¾^ Strategy #2: write a careful and structured prose ¾^ That is what most specifications look like ¾^ Problems–^ Suffers from the same problem as prose

UTSA CS

Operational Specification of Data Types

¾^ Strategy #3: give an operational specification, i.e., writesome code as the specification– Formal

-^ Lots of supporting tools, such as compilers ¾^ Problems– Over constraining -^ Committing to representation and algorithm strategy z^ Java ints are 4 bytes z^ … -^ Too much inessential detail UTSA CS

Algebraic Specification

¾^ ADT = Abstract Data Type–^ Sort: set of values (an abstract view of data)

-^ Description: informal specification which is easy to understand -^ Literals: constants of the data type -^ Signature: operators’ names, domains, and ranges ¾^ Algebraic specification = ADT + axioms ¾^ Algebraic specification describes–^ Name of the sort -^ Signatures of operators -^ Properties of the operators as relationships between operators UTSA CS

An Example: A Stack of Integers

UTSA CS

An Example: A Stack of Integers

¾^ All stacks start out empty, and then have various operationsperformed on them ¾^ What is returned after a sequence of function calls on theIntStack ADT–^ new; push 5; push 8; topapplying axiom #4top (push (8, push (5, ES))) =?

-^ new; push 3; push 7; push 9; pop; popapplying axiom #2pop (pop (push (9, push (7, push (3, ES))))) =?

UTSA CS

Disadvantages of Algebraic Specification

¾^ Algebraic specification are hard to read and write ¾^ Algebraic specification are hard to change ¾^ It is hard to tell if your algebraic specification is– Correct

-^ Complete -^ Consistent UTSA CS

Process for Building Algebraic Specification

¾^ Determine what operations and literals you need ¾^ Categorize operations and literals into three groups–^ Generators

-^ Manipulators -^ Inspectors ¾^ Define result of applying non-generator operations aftereach generator operation UTSA CS

An Example: A Stack of Integers

UTSA CS

An Example: A Bounded Stack of Integers

UTSA CS

An Example: A Bounded Stack of Integers

UTSA CS

An Example: A Bounded Stack of Integers

UTSA CS

An Example: A Queue of Integers

A queue of integers supports four operations: enQ, deQ,front and isEmpty. enQ adds an element to a the end ofthe queue. deQ returns the queue without the frontelement. front returns the element at the front of thequeue. isEmpty returns true if the queue is empty. UTSA CS

Reading Assignments

Sommerville’s Book–^ Chapter 10, “Formal Specification”10.2 Sub-system interface specification