Formal methods
- File size
- 7.3KB
- Lines of code
- 147
Formal methods
- Mathematically prove or disprove the correctness of a system's design and behaviour according to formal specifications
- Shows both the presence and absence of specific errors
- For language design, software, hardware, algorithms
Quickstart
Formal methods comprise the following 2 steps
-
Specification
- Describe the desired properties (and behaviors) of a system
- Written in formal languages
- Tempora logic: specifies properties of systems that evolve over time
- Algebraic specification: defines abstract datatypes and their operations
-
Verification
- Model checking
- System is modelled as a finite state model
- Exhaustively explores whether user-specified properties (expressed in temporal logic) hold in every possible model state
- Suitable for hardware verification and concurrent systems
- Pros
- fully automated
- able to handle concurrent systems
- produces counterexamples when a given property does NOT hold
- Cons
- suffers from State Space Explosion (as a system grows, the number of states becomes unmanageably large)
- limited to finite state systems
- Theorem proving
- System is described in a formal language
- Z Notation: used for describing the structure and behavior of software, particularly in safety-critical and high-assurance systems
- TLA+: used for reasoning about concurrent and distributed systems, enabling precise descriptions of software system behaviors
- Alloy: lightweight modeling language for specifying complex structures and constraints in software systems
- VDM: Vienna Development Method is a formal method that provides a set of modeling languages for specifying and verifying software systems in the early stages of design
- VHDL: VHSIC Hardware Description Language describes the behavior and structure of electronic systems, commonly used in the design and simulation of digital circuits and hardware components
- Verilog: hardware description language for modeling electronic systems at various levels of abstraction from gate level to system-level
- PVS: Prototype Verification System used for formal specification and verification of algorithm in areas like automated reasoning
- Coq: formal language and proof assistant for developing and verifying mathematical proofs and algorithms, particularly in functional programming and theorem proving
- Isabelle: generic proof assistant used for formal verification of both software and hardware systems
- System is described in a formal language
- Symbolic execution
- Program is executed with symbolic inputs instead of literal values
- Explores multiple execution paths simultaneously
- KLEE: symbolic execution tool that automatically generates high-coverage tests
- Pros
- capable of analyzing ALL possible execution paths in a program
- finds bugs in code WITHOUT requiring a full formal specification
- checks for errors like division by zero or buffer overflows
- Cons
- suffers from Path Explosion (as program complexity grows, the number of paths quickly becomes unmanageably large)
- limited to certain types of errors
- Model checking
More on
- Formal Methods for Software Specification and Analysis: An Overview
- Lecture 6: Introduction To Formal Methods by Mike Wooldridge
- A Short Introduction to Formal Methods by Manuel Carro
- Introduction to Formal Verification by The Donald O Pederson Center for Electronic Systems Design
- Formal Verification, Casually Explained by Andrew Helwer
- A Gentle Introduction to Formal Verification by sv:io
- Introduction to Formal Verification by EEWeb
- Context-Free Grammars by Stanford University