0% found this document useful (0 votes)
10 views30 pages

FMSE Lecture 09

The document discusses abstract machines and their use in formal system specification. An abstract machine notation (AMN) allows hierarchical specification by combining smaller abstract machines. The key components of an AMN specification are: the machine name, state variables, invariant properties on the variables, operations that modify the state, and an initialization section. An example abstract machine is given for a ticket dispensing system, specifying its variables, invariant, operations to serve customers and dispense tickets, and initialization values.

Uploaded by

Khuraim Asadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views30 pages

FMSE Lecture 09

The document discusses abstract machines and their use in formal system specification. An abstract machine notation (AMN) allows hierarchical specification by combining smaller abstract machines. The key components of an AMN specification are: the machine name, state variables, invariant properties on the variables, operations that modify the state, and an initialization section. An example abstract machine is given for a ticket dispensing system, specifying its variables, invariant, operations to serve customers and dispense tickets, and initialization values.

Uploaded by

Khuraim Asadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

Lecture No 09

Abstract Machines
outline

 Abstract Machines Notation AMN


 Components of AMN
Introducing
Abstract Machines
Formal Specification of a
System
 Formal Specification describes the
 System behavior
 Operations of system
 Problem with formal specification is large amount of
detailed information which is required for accurate system
specification.
 A structured approach is required.
 The basic building block of a specification is abstract
machine.
 Large specification can be constructed from smaller ones.
 AMN (abstract Machine Notation ) is used.
Formal Specification of a
System
 Compositional structuring
 The combination of abstract machine is
also an abstract machine permitting
hierarchical specification.
Abstract Machines Notation (AMN)

 It is the specification of a system.


 Itcontains pieces of information, that
describes various aspects of the
specification.
 Specification must describe what the
component should do?(Operations,
Functions).
Abstract Machines Notation (AMN)

 Operations/Functions
Take inputs from the user
Supply outputs to the user.
Affect any change within the
component.
 Interface
Collection of operations by which
machine interacts with
environment.
Components of AMN
 It is required by the machine to maintain or
process information.
 For this a local state is required.
 State is mentioned by the local variables.
 State variables are listed under VARIABLES
heading.
 INVARIANT
 Their types and any other information are listed.
 The information which must be true of the state.
 For example type of variable must not be
changed during the execution.
Components of AMN contd..
 INITIALISATION
 Represents initial state
 Machine Name
 Machine must have a name ,so that other
machines can refer to it.
 The name is given under the heading MACHINE.
 Machine
 It has a name, internal state, and set of operations as
do objects.
 It may be considered as a black box with buttons on the
side corresponding to the operations, and a set of state
variables inside.
Components of AMN contd..

 Interaction must be through these


buttons.
Example of abstract machine
 Consider the example of ticket dispenser,
which is used in shop to order the queue.
On entry to the shop customer takes a
numbered ticket from the dispenser.
When a sales assistant is ready to serve, a
display indicates the number of the
customer who is to be served next.
Customers wait until it is their turn to be
served. The system is pictured in figure
A ticketing System
Ticket AMN

 The behavior of ticket system can be


represented using abstract machine.
 First of all name the machine as

MACHINE Ticket
Ticket AMN
 VARIABLES
 To maintain the state of a system we define
variables, a variable should be of the type which is
suitable to express kind of value it can store.
 How the systems are understood rather than
implemented.
 In terms of values, sets, relations, sequences .
 A variable can be of the type N, natural numbers
set(0,1,2,…..).
 In the example we have two kind of tickets
 Ticket number being served
 Number of Next ticket to be dispensed.
 We can model with variables:
 next
 serve
Ticket AMN contd..
VARIABLES serve, next
 INVARIANT
 Provides information about the variables of the
machine
 It gives type of values of variable
 Restrictions on their possible values
 Relationships to each other
 Values of variables may change but it describes the
properties of the variables which must be true during
execution process.
 Type of variable is expressed as:
 Either an element of a set var TYPE
 Subset of a set var⊑ TYPE.
 Var=expression
Ticket AMN contd..
 At least one invariant clause should be defined
for each variable. Listed
 Next N
 Sreve N
 Further restrictions imposed by the operation
can also be added
 In Ticket machine number being served must be
less than the number of the ticket to be given
out.
 serve≤next

INVARIANT serve N ⋀ next N ⋀ serve ≤ next


Ticket AMN contd..
 OPERATIONS
 It has following parts
 The name of the operation
 Input parameters
 Output parameters
 What the operation requires.(restrictions, conditions)
 What the operation modifies (variables that are modified)
 The effects or behavior of the operation(what the
operation does).
 In B, operation is described in a structured way
 Name, input, output parameters of an operation are
given by an operation header
 Outputs⃖ name(inputs)
 Where name refers to operation name, outputs is a list of
output and inputs is a list of inputs
Ticket AMN contd..
 Name must be given
 Inputs and outputs are optional parameters.
 Ticket machine will offer two operations
 One to serve customer and update the indicator board
 To provide the customer with the next ticket.
 Ssserve_next

 tt ⃖ take_ticket
Operation has precondition, It states that
what the operation requires in order to
behave correctly.
 Information of all input variables.
 Assumptions/state of the inputs
Ticket AMN contd..
 The requirements on the user to ensure that the
requirements are met whenever the operation is called.
 For example,
 the serve_next operation will be called when the sales
assistant has finished serving a customer.
 In this case serve must be less than next.
 If the shop is empty, then the value of serve will be the same
as next.
 Thus the precondition will be serve ≤next
 Body of the operation, describes what the operation
achieves.
 It must assign some value to one of the outputs.
 Output should be in terms of initial state and input values.
 Update the state of the variable
Ticket AMN contd..
 In case of serve_next,
 Serve should be incremented
 Output should be incremented to show state serve.
 In AMN assignment is written as x:=E (pronounced x
becomes E)
 Serve:= serve+1
 Output of this operation is assigned the same value
 Ss, serve:=serve+1,serve+1.
 Body shows the states, there is no intermediate
statement in the operation, therefore multiple
assignments must be shown in simultaneous assignment,
rather than a sequence of assignments one after the
other.
Ticket AMN contd..

 The complete specification of the operation


serve_next is as follows
Ticket AMN contd..
 Type of the output variable ss is given by the
assignment, there is no need to declare its type.
 It is determined from the operation.
 After the execution of operation it must
guarantee that the invariant is still true on the
updated state.
 Then the operation is consistent.
 Is the operation serve_next consistent with the
inavriant?
 If the precondition is weaker then there will be
the chance of inconsistency with its variant.
Ticket AMN contd..
 Strengthening the precondition of serve_next to
serve<next imposes more constraints on the
user.
 Then the operation becomes consistent.
 Operation take_ticket
Ticket AMN contd..

INVARIANT serve N ⋀ next N ⋀ serve ≤ next and

Next<serv+20
INVARIANT serve N ⋀ next N ⋀ serve ≤ next

Is consistent with the invariant of the Ticket


machine?
Next is decrement
Serve is incremented
Operation is inconsistent when serve<=next,
As Serve>next
Ticket AMN contd..
 INITIALISATION
 Describes possible initial state of the
machine.
 All variables listed must be initialised.
 The Ticket machine should start with 0 on
the display board,
0 is the number of the first ticket to be
taken.
INITIALISATION serve, next:=0,0
 INITILISATION can only be consistent if
initial states are correct with respect to the
invariant.
complete Specification of
Ticket machine
27=26

Serve<=next
26<=26

26+1=27
Exercise
Summary

 Abstract Machine describes system


behavior.
 It has name, variables, invariant,
operations.
Questions

You might also like