0% found this document useful (0 votes)
3 views

SFS Lab1

The document outlines the use of Formal Methods, specifically VDM-SL, for specifying and modeling software systems to ensure correctness and completeness of requirements. It includes instructions for setting up the Overture Tool, defining data types, operations, and constraints, as well as examples of operations like increment and decrement in a system. Additionally, it presents a task related to transferring airport flight control information to VDM language using the Overture tool.

Uploaded by

salmamaher2323
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

SFS Lab1

The document outlines the use of Formal Methods, specifically VDM-SL, for specifying and modeling software systems to ensure correctness and completeness of requirements. It includes instructions for setting up the Overture Tool, defining data types, operations, and constraints, as well as examples of operations like increment and decrement in a system. Additionally, it presents a task related to transferring airport flight control information to VDM language using the Overture tool.

Uploaded by

salmamaher2323
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Software

Formal
Specificati
Eng/TA Maiada Alaa
What is SFS
Provides a mathematical description of a system's behavior, structure, and
constraints.
It serves as a foundation for ensuring the correctness, consistency, and
completeness of software requirements before implementation.

we define the system using Formal Methods, particularly VDM-SL (Vienna


Development Method Specification Language), which is widely used for specifying
and modeling complex software systems.
Setup Overture Tool
Ensure install overture tool and java jdk, or using Vs code by
install extension of vdm Overture..
Setup Overture Tool
Setup Overture Tool
Setup Overture Tool
Setup Overture Tool
Click Browse then select your
project name then from search you
can select the class name you use in
the code then select Function you
need to run now.
Setup Overture Tool

Need to edit run configuration to the


function that I will use since here I
use increment, so I select it then run
code..
In Code initial value = 3 , since
run the code it increment by 1 to 4
Incubator Monitor
Example
(using VDMSL)
VDM-SL
Types
• N  natural numbers (positive whole numbers)
• N1  natural numbers excluding zero Z integers
• Z  Whole numbers, including positive, negative, and
zero
• R  real numbers (positive and negative numbers that
can include a fractional part)
• B  Boolean values (true or false)
• Char  the set of alphanumeric characters
UML
Specification
Data Types – Defining the important components of the system.
Operations – Describing how the system behaves and what it does.
Constraints – Ensuring the system follows rules.
State Transitions – Modeling how the system’s state changes over
time.
UML
Specification
Declaring

Constants
Constants are specified in VDM-SL using the keyword
values, immediately prior to the state definition
• We will declare MAX and MIN constants for the maximum
and minimum temperatures
State
Invarient &
inv mk-IncubatorMonitor(t) Δ MIN ≤ t ≤
MAX

init
• mk  would create an IncubatorMonitor object using t as
input.

• Δ is read “is defined as”.

init mk-IncubatorMonitor(t) Δ t = 5

Initialization Function: should state


that when the IncubatorMonitor system
is started the temperature is initialised
to 5
Operations in VDM-SL

An operation is specified with the following components:


• An operation header, for example increment()
• An external clause: lists the attributes that will be read (rd)
and/or modified (wr) by the operation
• A precondition clause specifies constraints that need to hold
before the operation can be performed.
• A postcondition clause states the condition that must be met
after the operation has been performed The only state variables
that can be included in a postcondition are those that are
refereed to in the ext clause.
Increment Operation

● The increment operation changes temp; hence in the ext

● 𝑡𝑒𝑚𝑝 (temp with an over-bar) is the previous (the old) value of


clause we state wr (modify)

temperature.
● the post condition is not an assignment.

Since Temperature less than 10 it


will do the post condition by
increase the old temperature
by 1
Decrement Operation

● The decrement operation changes temp; hence in the ext

● 𝑡𝑒𝑚𝑝 (temp with an over-bar) is the previous (the old) value of


clause we state wr (modify)

temperature.
● the post condition is not an assignment.

Since Temperature greater than


-10 it will do the post condition by
decrease the old temperature by
1
Gettemp() Operation

● getTemp operation reads temp; hence we state rd


● In the pre condition clause, TRUE means the getTemp
operation needs no precondition
● The post condition is not an assignment.
Final VDM-
SL
Task
Bank Account(using VDMSL)
values
MinBalance : R = 0

state BankAccount of
Balance : R
inv mk_BankAccount(b) △ b ≥ MinBalance
init mk_BankAccount(b) △ b = 20
end

operations getBalance() currentBalance : R


deposit (amount) ext rd balance : R
ext wr balance : R pre TRUE
pre amount > 0 post currentBalance = balance
post balance = balance + amount;

withdraw (amount)
ext wr balance : R
pre amount > 0 and amount <= balance
post balance = balance - amount;
Assignment 1

Transfer Airport flight control information to VDM language and


write it on overture tool.
Thank
s

You might also like