G 53 FSP Formal Specification Dr Rong Qu

  • Slides: 29
Download presentation
G 53 FSP Formal Specification Dr. Rong Qu Introduction to Formal Specification http: //www.

G 53 FSP Formal Specification Dr. Rong Qu Introduction to Formal Specification http: //www. cs. nott. ac. uk/~rxq/g 53 fsp School of Computer Science G 53 FSP Formal Specification 1

Background n A specification may have many uses, in many forms n Management n

Background n A specification may have many uses, in many forms n Management n n Programmers n n Specification in English Written in a pseudo (or real) programming language CS & Management n n Improve quality of software systems Provide proof & verifications School of Computer Science G 53 FSP Formal Specification 2

Background n Need to be precise n Management n Must be able to agree

Background n Need to be precise n Management n Must be able to agree what is to be implemented School of Computer Science G 53 FSP Formal Specification 3

Background n Need to be precise n Programming n Written in language is probably

Background n Need to be precise n Programming n Written in language is probably no use n Expensive to create n Long n Include un-necessary details n Performance not effect of operation n Difficult to understand School of Computer Science G 53 FSP Formal Specification 4

Background n Precise definition of n n n Effects of various operations rather than

Background n Precise definition of n n n Effects of various operations rather than its performance details Information to be displayed to users No need of How the operations are to be done n How the data is to be stored Etc n The details is no use of specify the effect of the system School of Computer Science G 53 FSP Formal Specification 5

Background n Also may need a specification to n n Prove certain properties Prove

Background n Also may need a specification to n n Prove certain properties Prove that certain combinations of states never occur Value of a given variable never go outside certain bounds Correctness of system can be proven School of Computer Science G 53 FSP Formal Specification 6

Purpose of Formal Specification n n To state what system should do without describing

Purpose of Formal Specification n n To state what system should do without describing how to do it To reduce faults in systems n n Invest more effort is early stage of system development Requirement errors can be discovered as early as possible and resolved School of Computer Science G 53 FSP Formal Specification 7

Specification Parts n A specification need to include n Details of the system n

Specification Parts n A specification need to include n Details of the system n n n The states it can occupy Invariants which will always hold Dynamic aspects n n n All operations which are possible The relations of inputs to outputs Changes of state that can occur School of Computer Science G 53 FSP Formal Specification 8

Specification Parts n A specification will include n Functional requirements n n n The

Specification Parts n A specification will include n Functional requirements n n n The effect of xxx will be The output of command yyy will be as specified in standard zzz The system will produce a report on salesman effectiveness School of Computer Science G 53 FSP Formal Specification 9

Specification Parts n A specification will include n Non-functional requirements (properties) n n n

Specification Parts n A specification will include n Non-functional requirements (properties) n n n All data access should be via company supplied subroutines The system should be immune to power failures The response time must be … School of Computer Science G 53 FSP Formal Specification 10

Specification Parts n A specification will include n Design directives n n n The

Specification Parts n A specification will include n Design directives n n n The system will collect data from … The VDU display will be in the form … The designer will use SSADM School of Computer Science G 53 FSP Formal Specification 11

Specification Parts n A specification will include n Goals n n n Response times

Specification Parts n A specification will include n Goals n n n Response times should be minimised It should run in 748 kb of memory Data statements n The system must maintain the average temperature over the preceding … School of Computer Science G 53 FSP Formal Specification 12

Definition – Formal Specification n The specification will be n A strict mathematical definition

Definition – Formal Specification n The specification will be n A strict mathematical definition of the effect of the required operation n n Usually expressed in mathematical notions with precisely defined vocabulary, syntax and semantics Definition is not necessarily in the form in which it can be programmed School of Computer Science G 53 FSP Formal Specification 13

Definition – Formal Specification n In computer science, formal methods refers to mathematically based

Definition – Formal Specification n In computer science, formal methods refers to mathematically based techniques for the specification, development and verification of software and hardware systems. From Wikipedia, the free encyclopedia. http: //en. wikipedia. org/wiki/Main_Page School of Computer Science G 53 FSP Formal Specification 14

Definition – Formal Specification n The approach is especially important in high-integrity systems, for

Definition – Formal Specification n The approach is especially important in high-integrity systems, for example where safety or security is important, to help ensure that errors are not introduced into the development process. From Wikipedia, the free encyclopedia. http: //en. wikipedia. org/wiki/Main_Page School of Computer Science G 53 FSP Formal Specification 15

Definition n Formal methods are particularly effective early in development at the requirements and

Definition n Formal methods are particularly effective early in development at the requirements and specification levels. From Wikipedia, the free encyclopedia. http: //en. wikipedia. org/wiki/Main_Page School of Computer Science G 53 FSP Formal Specification 16

Formal Methods Parts n n Program specification Program verification Automated theorem proving Model checking

Formal Methods Parts n n Program specification Program verification Automated theorem proving Model checking School of Computer Science G 53 FSP Formal Specification 17

Program Specification n n A program specification is the definition of what a computer

Program Specification n n A program specification is the definition of what a computer program is expected to do It can be n n informal, in which case it can be considered as a blueprint or user manual from a developer point of view, or formal, in which case it has a definite meaning defined in mathematical or programmatic terms. School of Computer Science G 53 FSP Formal Specification 18

Program Verification n n In computer science, program verification is the process of formally

Program Verification n n In computer science, program verification is the process of formally proving that a computer program does exactly what is stated in the program specification it was written to realize Program verification is more specific in that it aims to verify the code itself, not only some abstract model of the program. n n Intel, AMD: verify chips BMW: automotive system School of Computer Science G 53 FSP Formal Specification 19

Automated Theorem Proving n Automated theorem proving is the proving of mathematical theorems by

Automated Theorem Proving n Automated theorem proving is the proving of mathematical theorems by a computer program. Depending on the underlying logic, the problem of deciding the validity of a theorem varies from trivial to impossible. School of Computer Science G 53 FSP Formal Specification 20

Model checking n Model checking is a method to algorithmically verify formal systems. This

Model checking n Model checking is a method to algorithmically verify formal systems. This is achieved by verifying if the model, often deriving from a hardware or software design, satisfies a formal specification. The specification is often written as temporal logic formulas. School of Computer Science G 53 FSP Formal Specification 21

Formal vs. Informal Methods n Formal specification vs. SSADM n n n now government

Formal vs. Informal Methods n Formal specification vs. SSADM n n n now government standard Widely used in industry Semester 5 of CSi. T School of Computer Science G 53 FSP Formal Specification 22

Formal vs. Informal Methods n Lots of possible inconsistencies Decision tables To prove that,

Formal vs. Informal Methods n Lots of possible inconsistencies Decision tables To prove that, if you use “don’t care” entries, the result is completely and uniquely defined? n n Computer tools to help overcome the difficulties, but are still basic problems School of Computer Science G 53 FSP Formal Specification 23

Mathematics vs. Natural Language for System Specification n Deficiencies of natural language n n

Mathematics vs. Natural Language for System Specification n Deficiencies of natural language n n n Can be vague Can be ambiguous Can be self-contradictory Can be incomplete Encourages imprecise thinking Cannot easily handle abstractions School of Computer Science G 53 FSP Formal Specification 24

Mathematics – good features n Easily handle abstractions n Can be used for reasoning

Mathematics – good features n Easily handle abstractions n Can be used for reasoning about, and describing a system n Is concise n Is non-ambiguous School of Computer Science G 53 FSP Formal Specification 25

Mathematics – good features n n n Is applied widely to the real world

Mathematics – good features n n n Is applied widely to the real world Can approximate where exactness is unnecessary Changes slower than computing School of Computer Science G 53 FSP Formal Specification 26

Formal Notation – drawbacks n n n The customer cannot easily understand the specification

Formal Notation – drawbacks n n n The customer cannot easily understand the specification The mathematics used is unfamiliar to many of the staff In real world, getting user requirements document is a problem School of Computer Science G 53 FSP Formal Specification 27

Z n n A formal specification technique developed at Oxford Uses very mathematical notation

Z n n A formal specification technique developed at Oxford Uses very mathematical notation to provide exact definitions of a system System is described in a number of small Z modules, which can cross-refer each other Each module is expected to have some descriptive English text to help users to understand it School of Computer Science G 53 FSP Formal Specification 28

Summary n n n Background of formal specification Parts of specification Formal specification vs.

Summary n n n Background of formal specification Parts of specification Formal specification vs. n n SSADM Natural language Formal method advantages and drawbacks Z specification language School of Computer Science G 53 FSP Formal Specification 29