Skip to content

Instantly share code, notes, and snippets.

@stvhwrd
Created March 21, 2017 21:18
Show Gist options
  • Save stvhwrd/a5a16fe5e2e91de60f9b30f57534e0e1 to your computer and use it in GitHub Desktop.
Save stvhwrd/a5a16fe5e2e91de60f9b30f57534e0e1 to your computer and use it in GitHub Desktop.
formal languages and specifications

Formal Languages and Specifications

Validation criteria is to discover and understand all requirements and domain properties.

Verification criteria is to verify that the program satisfies the specification, and the specification, given the domain properties, satisfies the requirements.

Definition and overview of formal methods

A broad view of formal methods includes all applications of discrete mathematics to software engineering problems. This application usually involves modelling and analysis where the models and analysis procedures are derived from or derived by an underlying mathematically-precise foundation.

A formal method in software development is a method that provides formal language for describing a software artifact (eg. specifications, designs, or source code) such that formal proofs are possible in principle, about properties of the artifact so expressed.

Use of formal methods

• Reasoning about a formal description

• The requirements problem – Verification does not eliminate the need for validation; However, the discipline of producing a formal specification can result in fewer specification errors.

When to use formal methods?

  • When most of the requirements are functional requirements

  • For critical components of the system

Formal Requirements Specification

• Formal requirements specifications are specifications that have formal semantics and syntax

• Allows a specification to be precise, unambiguous, and verifiable

• Can be verified automatically

Formal specifications in RE

• Useful in reasoning about the relationships between domain properties, requirements and specifications

• Prove properties of requirements and specs

• Good news: very useful when applied properly

• Paris metro line 14 entirely controlled by software formally developed by Matra Transport using the B abstract machine method

Formalizing SDC in Predicate Logic

• A ≡ a person comes close to the door

• B ≡ the door opens

• C ≡ motion sensor is triggered

• D ≡ OPEN signal to motor

The specification, given the domain properties, satisfies the requirements

• Requirements: { A → B }

• Domain: { A → C, D → B }

• Specification: { C → D }

• Prove that Domain ∧ Specification → Requirements

Types of Formal Specifications

• Property-oriented languages

– System is described by a set of axiomatic properties

• Model-oriented languages

– System is described by a state, and operations

– An operation is a function which maps the value of the state and the value of input parameters to a new state

Automated verification

• One major benefit for formal methods is automated verification

• Two methods: Theorem proving and Model checking

Theorem Proving

• System is described with a set of formulas Γ

• Specification is described with another set of formulas ϕ

• The verification method is to discover a proof that Γ ⊢ ϕ (i.e. ϕ is provable from Γ)

Theorem Proving Example:

x is a book

A(x): book x exists in the library

B(x): book x is checked out

• Property of this system may be, “If a book x exists in the library, then book x can not be checked out”, i.e. A(x) → !B(x)

Model-oriented languages

• The easiest way to consider a model-oriented language is as a state machine

• When the system is in a certain state, and is given a particular input, it will turn into another state

• Properties of the system are usually given using a temporal logic

• Want to verify that the model always holds the properties true

Model-checking

An example of a statement that can be expressed in temporal logic may be:

“if p is true, then it is always the case that q will eventually be true”

• You can verify this behaviour by stepping through a model M and checking that the statement above holds.

Challenges in applying formal specification methods

• Limited scope (to functional requirements)

• Isolation from other software products and processes in organizations

• Cost (require high expertise in formal systems and mathematical logic)

Example of well-known formal methods and languages

• Language Z

• Communicating sequential processes (CSP)

• Vienna Development Method (VDM)

• Larch

• Formal development methodology (FDM)

• Software Cost Reduction (SCR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment