170 likes | 535 Views
Introduction to Formal and Semi-formal Methods. Based on A Specifier's Introduction to Formal Methods (J. Wing). Formal and Semi-formal Methods. Formal = Have a well defined mathematical basis Can apply to any stage of the life cycle
E N D
Introduction to Formal and Semi-formal Methods Based on A Specifier's Introduction to Formal Methods (J. Wing) SWSE 623: Introduction
Formal and Semi-formal Methods • Formal = Have a well defined mathematical basis • Can apply to any stage of the life cycle • Recast every thing in mathematics and prove relevant properties • Can be used for: • Syntactic analysis • Semantic analysis • The issue here is of computational complexity SWSE 623: Introduction
Semi Formal Methods • Semi-formal= Only partly mathematical • Could mean • Only some aspects formalized • Only syntactic methods available SWSE 623: Introduction
Specification Languages • Syntax, Semantics, Satisfaction, deduction system, soundness and consistency • Examples: • First Order Logic • BNF • Differences in specification languages • Syntactic • Semantic • Satisfaction SWSE 623: Introduction
Programming languages vs. Specification languages • Programming languages are executable. • Have operational semantics. • Have denotational semantics also. • Specification languages do not have to be executable. • Programming Language => Specification Language • Specification Languages =/=> Programming Language SWSE 623: Introduction
Programming languages vs. Specification languages – Cont. • Why have more abstract specification Languages? • Specification languages are at a higher level • May want to specify non-computable facts • Separate specification from implementation • One specification and many implementations in many languages and operational environments • Specifications have a life independent of implementational optimizations SWSE 623: Introduction
Using a Programming Language as a Specification Language • Cons: • Not able to verify before compiling • Low level, no logical derivations • Specification tied to one language • Pros: • No gap between specification and code • Correctness is not an issue – NuPrl. SWSE 623: Introduction
Semantic Domains • Programming language have operational and denotational semantics. Can use satisfaction relation as implementation. • Semantic abstraction function • Divide semantic domain into equivalence classes. • Extend satisfaction relation into equivalence classes. • Can have many semantic abstraction functions • Can impose different constraints • Can specify and verify different aspects SWSE 623: Introduction
Many Specification Languages for Same System Specification 1 • Can specify and verify complementary properties • Specification types • Structure of system • Behavior Specification2 Semantic Domain SWSE 623: Introduction
Structural Specifications • Constraints on internal composition • Class diagrams • Modula interconnection diagrams • Captures • Hierarchies • Associations • Usage • Data and control dependencies SWSE 623: Introduction
Behavioral Specifications • Constraints on observable behavior • Example: • Input-output behavior of modules • Interactions between modules, message passing • Captures • Fault tolerance • Safety, security, • Timing, resource consumption patterns • Quality of service SWSE 623: Introduction
Properties of Specifications • Unamibiguity: Satisfaction relation maps each object in the syntactic domain to a unique object in the semantic domain • Consistency: Satisfaction relation maps each object in the syntactic domain to a non-empty object in the semantic domain • Completeness: If every sentence or its negation is implied by the specification. Difficult to get • Relative completeness • Over-specification Vs. Design freedom • Semantic Bias Vs. Implication Bias SWSE 623: Introduction
Specifications and Proofs • Have a deduction system with proof rules and (possibly) assumptions. • Can be partially automated • Can predict system behavior without execution • Increases confidence and assurance SWSE 623: Introduction
Refinement • Divide and conquer • A higher level specification can be divided into a set of lower level specifications. • Prove components correct, combine them and prove larger specification correct • Breaks down a proof with a goal into sub-proofs with sub-goals • Examples we discuss: • Predicate transformers Dijkstra • Hoare triples for weakest preconditions etc. SWSE 623: Introduction
Types of Formal Methods • Model Oriented: Construct a model of the system behavior using mathematical objects like sets, sequences etc. • Statecharts, SCR, VDM, Z • Petri Nets, CCS, CSP, Automata theoretic models • Property Oriented: Use a set of necessary properties to describe system behavior, such as axioms, rules etc. • Larch, Algebraic semantics • Temporal logic models. SWSE 623: Introduction