ArticleslgStudy

science

Formal specification

Formal specification is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Formal specification rather than just read about it. In short: In computer science, formal specifications are mathematically based techniques whose purpose is to help with the implementation of systems and software. They are used to describe a system, to analyze its behavior, and to aid in its design by verifying key properties of interest through rigorous and effective reasoning tools.

Key takeaways

  • Formal specification belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Formal specification to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Formal specification from memory before moving on to harder problems.

Reference excerpt

In computer science, formal specifications are mathematically based techniques whose purpose is to help with the implementation of systems and software. They are used to describe a system, to analyze its behavior, and to aid in its design by verifying key properties of interest through rigorous and effective reasoning tools. These specifications are formal in the sense that they have a syntax, their semantics fall within one domain, and they are able to be used to infer useful information.

Motivation In each passing decade, computer systems have become increasingly more powerful and, as a result, they have become more impactful to society. Because of this, better techniques are needed to assist in the design and implementation of reliable software. Established engineering disciplines use mathematical analysis as the foundation of creating and validating product design. Formal specifications are one such way to achieve this in software engineering reliability as once predicted. Other methods such as testing are more commonly used to enhance code quality.

Uses Given such a specification, it is possible to use formal verification techniques to demonstrate that a system design is correct with respect to its specification. This allows incorrect system designs to be revised before any major investments have been made into an actual implementation. Another approach is to use provably correct refinement steps to transform a specification into a design, which is ultimately transformed into an implementation that is correct by construction. A formal specification is not an implementation, but rather it may be used to develop an implementation. Formal specifications describe what a system should do, not how the system should do it. A good specification must have some of the following attributes: adequate, internally consistent, unambiguous, complete, satisfied, minimal. A good specification will have:

Constructability, manageability and evolvability Usability Communicability Powerful and efficient analysis One of the main reasons there is interest in formal specifications is that they will provide an ability to perform proofs on software implementations. These proofs may be used to validate a specification, verify correctness of design, or to prove that a program satisfies a specification.

Limitations A design (or implementation) cannot ever be declared “correct” on its own. It can only ever be “correct with respect to a given specification.” Whether the formal specification correctly describes the problem to be solved is a separate issue. It is also a difficult issue to address since it ultimately concerns the problem constructing abstracted formal representations of an informal concrete problem domain, and such an abstraction step is not amenable to formal proof. However, it is possible to validate a specification by proving “challenge” theorems concerning properties that the specification is expected to exhibit. If correct, these theorems reinforce the specifier's understanding of the specification and its relationship with the underlying problem domain. If not, the specification probably needs to be changed to better reflect the domain understanding of those involved with producing (and implementing) the specification. Formal methods of software development are not widely used in industry. Most companies do not consider it cost-effective to apply them in their software development processes. This may be for a variety of reasons, some of which are:

Time High initial start-up cost with low measurable returns Flexibility A lot of software companies use agile methodologies that focus on flexibility. Doing a formal specification of the whole system up front is often perceived as being the opposite of flexible. However, there is some research into the benefits of using formal specifications with "agile" development Complexity They require a high level of mathematical expertise and the analytical skills to understand and apply them effectively A solution to this would be to develop tools and models that allow for these techniques to be implemented but hide the underlying mathematics Limited scope They do not capture properties of interest for all stakeholders in the project They do not do a good job of specifying user interfaces and user interaction Not cost-effective This is not entirely true; by limiting their use to only core parts of critical systems they have shown to be cost-effective Other limitations:

Isolation Low-level ontologies Poor guidance Poor separation of concerns Poor tool feedback

Paradigms Formal specification techniques have existed in various domains and on various scales for quite some time. Implementations of formal specifications will differ depending on what kind of system they are attempting to model, how they are applied, and at what point in the software life cycle they have been introduced. These types of models can be categorized into the following specification paradigms:

History-based specification behavior based on system histories assertions are interpreted over time State-based specification behavior based on system states series of sequential steps, (e.g. a financial transaction) languages such as Z, VDM or B rely on this paradigm Transition-based specification behavior based on transitions from state-to-state of the system best used with a reactive system languages such as Statecharts, PROMELA, STeP-SPL, RSML or SCR rely on this paradigm Functional specification specify a system as a structure of mathematical functions OBJ, ASL, PLUSS, LARCH, HOL or PVS rely on this paradigm Operational Specification early languages such as Paisley, GIST, Petri nets, or process algebras rely on this paradigm Multi-paradigm languages FizzBee is a multi-paradigm specification language that allows for transition/action-based specification, and behavioral specifications with non-atomic transitions and also has an actor model. In addition to the above paradigms, there are ways to apply certain heuristics to help improve the creation of these specifications. The paper referenced here best discusses heuristics to use when designing a specification. They do so by applying a divide-and-conquer approach.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Formal specification

Start with the simplest possible case. Write down what Formal specification claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Formal specification before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Formal specification ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Formal specification

In research
Formal specification appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Formal specification in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Formal specification is common in secondary-school and first-year university syllabi. It links to neighbouring topics Formal methods, Formal specification, Formal specification languages, so understanding it makes those chapters shorter.
In everyday life
Look for Formal specification outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Formal specification” →

How to study Formal specification in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Formal specification means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Formal specification out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Formal specification in simple terms?

In computer science, formal specifications are mathematically based techniques whose purpose is to help with the implementation of systems and software. They are used to describe a system, to analyze its behavior, and to aid in its design by verifying key properties of interest through rigorous and…

Why does Formal specification matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Formal specification?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Formal specification.

Tags

  • Formal methods
  • Formal specification
  • Formal specification languages

Keep exploring