VDM-SL Assignment

Question 1.

This question concerns a banking application, to be modelled formally using VDM-SL. Read the following information and answer the questions which follow.

Bank customers have unique identifiers of type CustId. Each customer can have more than one account. Accounts are represented by unique identifiers of type AcctNo. Both types are modelled as character strings:

CustId = seq of char;

AcctNo = seq of char;

Customers are related to accounts using a customer database represented as a mapping type

CustDb = map CustId to AcctInfo;

Information about accounts is recorded using a mapping between AcctNo and Account. The Account is represented as a record type recording the balance and the type of account (Current or Savings):

AcctInfo = map AcctNo to Account;

Account :: balance : real

type : <Current> | <Savings>;

  1. Customer identifiers and account numbers are both limited to a maximum of 40 characters. Show how you would specify these constraints in the model. [8 marks]
  2. The following datatype invariant has been added to the Customer Database. Give an English language description, for the benefit of a user who is not familiar with VDM, of the constraint that is specified by this invariant.

inv cdb == forall accts in set rng cdb &

not exists ac1, ac2 in set dom accts &

ac1 <> ac2 and

accts(ac1).type = <Current> and

accts(ac2).type = <Current>;

[12 marks]
  1. The bank wishes to maintain a record of transactions in each account. Transactions are modelled by the type Transaction as follows:

 

Transaction :: description : seq of char

amount : real;

 

A positive amount field indicates a deposit of money into the account, a withdrawal is indicated by a negative amount. Each day, a sequence of transactions is recorded with the account.

Show how you would modify the type Account to contain a sequence of today’s transactions.                                               [5 marks]

Question 2.

Given the following VDM-SL expressions, answer the questions below

  1. What does function f compute? Provide valid values for input parameters and output result (e.g. f(x,y) = RESULT)

f: nat * seq of nat -> nat

f(x, y) == len [ 0 | i in set inds y & y(i) = x];

[10 marks]
  1. What does function g compute? Provide valid values for input parameters and output result (e.g. g(a, b) = RESULT)

g: seq of nat * seq of nat -> bool

g(a, b) ==

len a = len b and

(forall i in set inds a &

f(a(i), a) = f(a(i),b));

[15 marks]

END

Calculate the price of your order

Simple Order Process

Fill in the Order Form

Share all the assignment information. Including the instructions, provided reading materials, grading rubric, number of pages, the required formatting, deadline, and your academic level. Provide any information and announcements shared by the professor. Choose your preferred writer if you have one.

Get Your Order Assigned

Once we receive your order form, we will select the best writer from our pool of experts to fit your assignment.

Share More Data if Needed

You will receive a confirmation email when a writer has been assigned your task. The writer may contact you if they need any additional information or clarifications regarding your task

Let Our Essay Writer Do Their Job

Once you entrust us with your academic task, our skilled writers embark on creating your paper entirely from the ground up. Through rigorous research and unwavering commitment to your guidelines, our experts meticulously craft every aspect of your paper. Our process ensures that your essay is not only original but also aligned with your specific requirements, making certain that the final piece surpasses your expectations.

Quality Checks and Proofreading

Upon the completion of your paper, it undergoes a meticulous review by our dedicated Quality and Proofreading department. This crucial step ensures not only the originality of the content but also its alignment with the highest academic standards. Our seasoned experts conduct thorough checks, meticulously examining every facet of your paper, including grammar, structure, coherence, and proper citation. This comprehensive review process guarantees that the final product you receive not only meets our stringent quality benchmarks but also reflects your dedication to academic excellence.

Review and Download the Final Draft

If you find that any part of the paper does not meet the initial instructions, send it back to us with your feedback, and we will make the necessary adjustments.