Formal Specification (continued) Lecture 3:

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
Circuits require memory to store intermediate data
Digital Logic Design Lecture 27.
Finite Automata with Output
CS 151 Digital Systems Design Lecture 21 Analyzing Sequential Circuits.
1 Lecture 23 More Sequential Circuits Analysis. 2 Analysis of Combinational Vs. Sequential Circuits °Combinational : Boolean Equations Truth Table Output.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
CS21 Decidability and Tractability
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
Katz Formal Specifications Larch 1 Algebraic Specification and Larch Formal Specifications of Complex Systems Shmuel Katz The Technion.
Context-Free Grammars Lecture 7
Lecture 6 & 7 System Models.
©Ian Sommerville 2000Software Engineering, 6/e, Chapter 91 Formal Specification l Techniques for the unambiguous specification of software.
10/22/2004EE 42 fall 2004 lecture 221 Lecture #22 Truth tables and gates This week: Circuits for digital devices.
Mahapatra-A&M-Sprong'021 Co-design Finite State Machines Many slides of this lecture are borrowed from Margarida Jacome.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 10 Slide 1 Formal Specification.
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 10 Slide 1 Formal Specification.
©Ian Sommerville 2000Software Engineering, 6th edition. Chapter 9 Slide 1 Formal Specification l Techniques for the unambiguous specification of software.
System Models Hoang Huu Hanh, Hue University hanh-at-hueuni.edu.vn Lecture 6 & 7.
©Ian Sommerville 2000Software Engineering, Chapter 10 Slide 1 Chapter 10 Formal Specification.
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
©Ian Sommerville 2000Software Engineering, 6th edition. Chapter 9 Slide 1 Chapter 9 Formal Specifications.
Lecture 23: Finite State Machines with no Outputs Acceptors & Recognizers.
Model-Based Specification CIS 376 Bruce R. Maxim UM-Dearborn.
Overview of Formal Methods. Topics Introduction and terminology FM and Software Engineering Applications of FM Propositional and Predicate Logic Program.
WXGE6103 Software Engineering Process and Practice Formal Specification.
Black Box Testing Techniques Chapter 7. Black Box Testing Techniques Prepared by: Kris C. Calpotura, CoE, MSME, MIT  Introduction Introduction  Equivalence.
CPEN Digital System Design Chapter 5 - Sequential Circuits Sequential Circuit Design C. Gerousis © Logic and Computer Design Fundamentals, 4 rd Ed.,
1 © 2014 B. Wilkinson Modification date: Dec Sequential Logic Circuits Previously, we described the basic building blocks of sequential circuits,
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Copyright © Curt Hill Finite State Machines The Simplest and Least Capable Automaton.
Lecture 5. Sequential Logic 2 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education & Research.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Time Constraints and Types of Tasks By Dr. Amin Danial Asham.
SWEN 5130Requirements Engineering Algebraic Specification Slide 1 Algebraic Specification u Specifying abstract types in terms of relationships between.
1 Version /05/2004 © 2004 Robert Oshana Requirements Engineering Timing Constraints.
CS1Q Computer Systems Lecture 11 Simon Gay. Lecture 11CS1Q Computer Systems - Simon Gay 2 The D FlipFlop The RS flipflop stores one bit of information.
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
Top-down Parsing. 2 Parsing Techniques Top-down parsers (LL(1), recursive descent) Start at the root of the parse tree and grow toward leaves Pick a production.
Boolean Functions and Boolean Algebra Laxmikant Kale.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
Lecture 16: Modeling Computation Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output.
Dynamic Models - Page L M.E. Fayad Lesson 30: Dynamic Models Object- Oriented Modeling & Application s.
©Ian Sommerville 2000Software Engineering, Chapter 10 Slide 1 Chapter 10 Formal Specification.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Lecture 22: Finite State Machines with Output. Moore Machine - A Moore machine is a 6-tuple (Q, , , , q 0,  ) where, (1) Q is a finite set of states.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Lecture 14: Theory of Automata:2014 Finite Automata with Output.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
From requirements to specification Specification is a refinement of requirements Can be included together as Software Requirements Specifications (SRS)
Formal Specification.
Marlon Dumas Institute of Computer Science
Input Space Partition Testing CS 4501 / 6501 Software Testing
Algebraic Specifications
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Cs212: Data Structures Computer Science Department Lecture 6: Stacks.
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Algebraic Specification Software Specification Lecture 34
ECE 352 Digital System Fundamentals
Presentation transcript:

Formal Specification (continued) Lecture 3: (SE 252/502) Dr. RAJIB Mall

Organization of this Lecture Overview of last lecture Algebraic specification: Development technique Rewrite rules Example Pros and cons State machine modelling Summary

Review of last lecture Formal specification techniques: model-oriented property-oriented

Review of last lecture Property-oriented techniques: axiomatic specification algebraic specification Model-oriented techniques: Z, VDM, Petri net, State machine, etc.

Overview of last lecture Axiomatic techniques: based on early work on program verification. Use first-order predicate logic: specify operations through pre and post conditions

Review of last lecture Algebraic technique: data types are viewed as heterogeneous algebra axioms are used to state properties of data type operations

Algebraic Specification Using algebraic specification: the meaning of a set of interface procedures is defined by using equations.

Algebraic Specification Algebraic specifications are usually presented in four parts: types section exceptions section signature section rewrite rules section

Types Section Types Section Lists: sorts (or types) being specified sorts being imported Importing a sort: makes it available in specification.

Exception Section Lists names of exceptional conditions used in later sections: under exceptional conditions error should be indicated.

Signature Section Defines signatures of interface procedures: e.g. PUSH takes a stack and an element and returns a new stack. push: stack  element  stack

Rewrite rules section Lists the properties of the operators: In the form of a set of axioms or rewrite rules. allowed to have conditional expressions

Developing Algebraic Specification The first step in defining an algebraic specification: identify the set of required operations. e.g. for string identify operations: create, compare, concatenate, length, etc.

Developing Algebraic Specification Generally operations fall into 2 classes: Constructor Operations : Operations which create or modify entities of the sort e.g., create, update, add, etc.

Developing Algebraic Specification Inspection Operations : Operations which evaluate attributes of the sort, e.g., eval, get, etc.

Developing Algebraic Specification A rule of thumb for writing algebraic specifications: first establish constructor and inspection operations

Developing Algebraic Specifications Next, write down axioms: compose each inspection operator over each constructor operator.

Developing Algebraic Specifications If there are m constructors and n inspection operators: we should normally have m*n axioms. However, an exception to this rule exists.

Developing Algebraic Specifications If a constructor operation can be defined using other constructors: we need to define inspection operations using only primitive constructors.

Example: Stack Let us specify an unbounded stack supporting: push, pop, newstack, top, empty.

Example: Stack Types: defines stack uses boolean, element Exception: underflow, novalue

Example: stack Syntax: push: pop: stack  element  stack stack  stack+{underflow}

Example: stack top: empty: newstack:   stack stack  element+{novalue} empty: stack  boolean newstack:   stack

Equations: stack pop(newstack)=underflow pop(push(s,e))=s top(newstack)=novalue top(push(s,e))=e empty(newstack)=true empty(push(s,e))=false

Rewrite rules Rewrite rules let you determine: the meaning of any sequence of calls on the stack functions.

Rewrite rules Empty(push(pop(push(newstack,e1)),e2)): you can eliminate the call on pop by observing: it is of the form pop(push(s,e)).

Rewrite rules After simplification: empty(push(newstack,e1)) false

Two important questions Finite termination property: Does application of rewrite rules terminate after a finite number of steps? We might endlessly go on applying rewrite rules without coming to any conclusion?

Two important questions Unique termination property: Can different sequence in application of the rewrite rules always give the same answer? If we choose to simplify different terms of the expression in different experiments: shall we always get the same answer?

Algebraic Specification For arbitrary algebraic equations: convergence is undecidable. If the r.h.s. of each rewrite rule has fewer terms than the left: rewrite process must terminate.

Auxiliary Functions Sometimes development of a specification requires: extra functions not part of the system: to define the meaning of some interface procedures.

Auxiliary Functions: Example To specify bounded stacks: need to add a depth function: push returns either a stack or an exception “overflow” when depth is exceeded.

Bounded stack In order to specify a bounded stack: we need to make changes to different sections to include auxiliary functions.

Auxiliary Functions Syntax: push: depth: stack  element ==> stack stack  integer

Auxiliary Functions Equations: depth(newstack)=0 depth(push(s,e))=depth(s)+1 push(s,e)=overflow if depth(s) >= Max

Example 2: coord Types: sort coord imports integer, boolean

Example: coord Signature: create(integer,integer)  coord X(coord)  integer Y(coord)  integer Eq(coord,coord)  boolean

Example: coord Rewrite rules: X(create(x,y))=x Y(create(x,y))=y Eq(create(x1,y1),create(x2,y2)) = ((x1=x2) and (y1=y2))

Structured Specifications Writing formal specifications is time consuming. To reduce effort, we need to reuse specifications: instantiation of generic specifications incremental development of specifications

Specification Instantiation Take an existing specification: specified with some generic parameter Instantiate with some sort

Incremental Development Develop specifications for simple sorts: using these specify more complex entities.

Pros and Cons Algebraic specifications have a strong mathematical basis: can be viewed as heterogeneous algebra.

Pros and Cons An important shortcoming of algebraic specifications: cannot deal with side effects difficult to use with common programming languages.

Pros and Cons Algebraic specifications are hard to understand: also changing a single property of the system may require changing several equations.

Specification of timing constraints expressed in terms of occurrence of certain events.

Events A stimulus to the system from its environment. Can also be an externally observable response: that the system makes to its environment Events can be instantaneous or assumed to have a duration

Types of timing constraints Performance constraints: constraints imposed on the response of the system. Behavioral constraints: constraints imposed on the action and reaction time of the environment (or the user).

Specification of timing constraints We will specify timing constraints: in terms of stimuli and response modelled as FSMs (Finite State Machines)

State machine modelling Assumes that at any time: the system is in one of a number of possible states. When a stimulus is received, it may cause a transition to a different state.

Finite Automaton with Output A set of states final state: some states designated as final states an alphabet of input symbols an alphabet of output symbols a transition function: maps a combination of states and input symbols to states

Representation Event Action Dial Again Await first digit Timer alarm/ dial-tone Await first digit Await second digit First digit/ start-timer(20) Second digit/ silence Await next digit Action

Types of finite automaton A finite automaton with output may be organized in two ways: A Moore machine is an automaton each state is associated with an output symbol A Mealy machine associates each transition with an output symbol

Classification: Three types of timing constraints: Minimum Maximum Durational

Minimum Between two events: No less than t time units may elapse t1 t2 t2>t1+t

Maximum Between two events: No more than t time units may elapse t1 t2 t2<t1+t

Durational An event must occur for t units of time

Maximum S-S (stimulus-stimulus) S-R (stimulus-response) R-S (response-stimulus) R-R (response - response)

Maximum S-S Maximum time between occurrence of two stimuli: e.g. after dialling first digit, the second digit should be dialled no more than 20 secs later.

FSM Representation To represent timing constraints in an FSM: a timer alarm is used as an artificial stimulus.

Representation Event Action Dial Again Await first digit Timer alarm/ dial-tone Await first digit Await second digit First digit/ start-timer(20) Second digit/ silence Await next digit Action

Maximum S-R Maximum time between stimulus and response: e.g. caller shall receive dial tone no later than 20 secs after lifting the receiver.

Representation Await First Digit Await Second Digit Dial Again Offhook/ Start timer(20) First Digit Second Digit Alarm/ Dial tone Alarm/ Dial tone Start timer (20) Dial Again

Complete Representation Await First Digit Await Second Digit Await Eighth Digit Offhook/ Start timer(20) Second Digit Eighth digit/ Ring tone Alarm/ Dial tone Alarm/ Dial tone Alarm/ Dial tone Start timer (20) Dial Again Dial Complete

Maximum R-S Maximum time between system’s response and the next stimulus from the environment: e.g after receiving the dial tone, the caller shall dial the first digit within 20 sec.

Maximum R-R Maximum time allowed between two responses: after a connection has been made, the caller will receive a ring back tone no more than 0.5 sec after the callee has received the ring tone.

Minimum constraints S-S R-S R-R

Minimum S-S A minimum time is required between two stimuli: e.g. a minimum of 0.5 sec must elapse between the dialling of one digit and the dialling of the next.

Minimum S-S This is an example of behavioral constraints on system users: the complete specification should include response the system should make if the user responds too soon.

Representation Await Next Digit Handle digit Await Caller On hook Second digit/ silence Timer alarm/ Handle digit First digit/ start-timer(0.5) Second digit/ beeping Await Caller On hook

Durational timing constraints To go back to the international operator press the button for at least 15 secs (but no more than 30 secs)

Durational timing constraints To get back to the local operator: press the button for at least 30 secs, but no more than 45 secs To receive a dial tone press the button for at least 45 secs.

Representation A B C D E Timer alarm(15) Set timer 15,30,45

Reference Ian Somerville, Chapter Chapter 10 R. Mall, Chapter 3 B. Dasarathy, “Timing constraints of R-T systems,” IEEE TSE, 1985, pp. 80--86.

Summary We started by discussing some general concepts in: formal specification techniques.

Summary Formal requirements specifications: have several positive characteristics. But the major shortcoming is that they are hard to use.

Summary It is possible that formal techniques will become more usable in future with the development of suitable front-ends.

Summary We discussed a sample specification technique, algebraic specification gives us a flavour of the issues involved in formal specification.

Summary We discussed specification of timing constraints: classification modelling using FSMs

Next Lecture Real-time system design: Structured analysis of system behavior Ward and Mellor technique