Embedded systems specification and design

Similar documents
Equivalence of Regular Expressions and FSMs

Introduction to Turing Machines

Formal Definition of a Finite Automaton. August 26, 2013

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Automata: a short introduction

Finite State Machines 2

Finite-State Machines (Automata) lecture 12

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Theory of Computation

The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc.

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

CS4026 Formal Models of Computation

Inf2A: Converting from NFAs to DFAs and Closure Properties

Nondeterministic Finite Automata

Alan Bundy. Automated Reasoning LTL Model Checking

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Automata Theory (2A) Young Won Lim 5/31/18

Chapter Five: Nondeterministic Finite Automata

MA/CSSE 474 Theory of Computation

Turing machines COMS Ashley Montanaro 21 March Department of Computer Science, University of Bristol Bristol, UK

Introduction to Finite-State Automata

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

CMSC 330: Organization of Programming Languages

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Peter Wood. Department of Computer Science and Information Systems Birkbeck, University of London Automata and Formal Languages

ECS 120 Lesson 15 Turing Machines, Pt. 1

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Chapter 5. Finite Automata

Finite Automata. Mahesh Viswanathan

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Theory of computation: initial remarks (Chapter 11)

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

Lecture 3: Nondeterministic Finite Automata

Turing Machines Part II

Finite-state machines (FSMs)

Chapter Two: Finite Automata

Formal Definition of Computation. August 28, 2013

Further discussion of Turing machines

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Chapter 1. Formal Definition and View. Lecture Formal Pushdown Automata on the 28th April 2009

Automata-based Verification - III

Part I: Definitions and Properties

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

September 7, Formal Definition of a Nondeterministic Finite Automaton

Finite State Machines Transducers Markov Models Hidden Markov Models Büchi Automata

1 Showing Recognizability

Computational Models Lecture 2 1

Decision, Computation and Language

Büchi Automata and their closure properties. - Ajith S and Ankit Kumar

Theory of Computation

Logic Model Checking

Deterministic Finite Automata (DFAs)

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Finite Automata. Finite Automata

T Reactive Systems: Temporal Logic LTL

Theory of Computation

Deterministic Finite Automata (DFAs)

The State Explosion Problem

Busch Complexity Lectures: Turing s Thesis. Costas Busch - LSU 1

Advanced Automata Theory 7 Automatic Functions

Pushdown Automata: Introduction (2)

CSCC63 Worksheet Turing Machines

Lecture 2 Automata Theory

Einführung in die Computerlinguistik

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5.

Automata-based Verification - III

CSE 105 THEORY OF COMPUTATION

7.2 Turing Machines as Language Acceptors 7.3 Turing Machines that Compute Partial Functions

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Timo Latvala. February 4, 2004

Automata and Languages

Introduction to Formal Languages, Automata and Computability p.1/51

CSCE 551: Chin-Tser Huang. University of South Carolina

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal

Fundamentele Informatica II

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

Design and Analysis of Distributed Interacting Systems

Chapter 8. Turing Machine (TMs)

Sri vidya college of engineering and technology

Busch Complexity Lectures: Turing Machines. Prof. Busch - LSU 1

CMSC 330: Organization of Programming Languages. Regular Expressions and Finite Automata

Computational Models Lecture 2 1

Lecture 2 Automata Theory

Lecture 1: Finite State Automaton

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata

CMSC 330: Organization of Programming Languages

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Language Stability and Stabilizability of Discrete Event Dynamical Systems 1

CpSc 421 Homework 9 Solution

CA320 - Computability & Complexity

Transcription:

Embedded systems specification and design David Kendall David Kendall Embedded systems specification and design 1 / 21

Introduction Finite state machines (FSM) FSMs and Labelled Transition Systems FSMs and Formal Languages Modelling a system as a FSM Specifying system properties with FSMs David Kendall Embedded systems specification and design 2 / 21

Finite State Machine (FSM) O c g I r O t p c t p R c R t David Kendall Embedded systems specification and design 3 / 21

Finite State Machine (FSM) O c g I r O t p c t p R c State R t David Kendall Embedded systems specification and design 3 / 21

Finite State Machine (FSM) O c g I r O t p c t p Edge R c R t David Kendall Embedded systems specification and design 3 / 21

Finite State Machine (FSM) O c g I r O t p c Action t p R c R t David Kendall Embedded systems specification and design 3 / 21

Finite State Machine (FSM) O c Initial State g I r O t p c t p R c R t David Kendall Embedded systems specification and design 3 / 21

Finite State Machine (FSM) O c g I Acceptance State r O t p c t p R c R t David Kendall Embedded systems specification and design 3 / 21

Finite State Machine (FSM) Finite State Machines (FSM) are also known as Finite State Automata (FSA). We ll use these names to mean the same thing. Formally, a FSM is a tuple M = (S, s 0, A, E, F) where S is a set of states s 0 is a distinct state called the initial state A is an alphabet (also called a set of actions or labels or symbols) E S A S is a set of edges F S is a set of acceptance states (also called final states) David Kendall Embedded systems specification and design 4 / 21

Finite State Machine (FSM) Write down the formal statement of the example FSM David Kendall Embedded systems specification and design 5 / 21

Finite State Machine (FSM) Write down the formal statement of the example FSM S = {I, O c, O t, R c, R t } David Kendall Embedded systems specification and design 5 / 21

Finite State Machine (FSM) Write down the formal statement of the example FSM S = {I, O c, O t, R c, R t } s 0 = I David Kendall Embedded systems specification and design 5 / 21

Finite State Machine (FSM) Write down the formal statement of the example FSM S = {I, O c, O t, R c, R t } s 0 = I A = {c, g, p, r, t} David Kendall Embedded systems specification and design 5 / 21

Finite State Machine (FSM) Write down the formal statement of the example FSM S = {I, O c, O t, R c, R t } s 0 = I A = {c, g, p, r, t} E = {(I, g, O c ), (I, r, O t ), (O c, p, R c ), (O t, p, R t ), (R c, c, I), (R t, t, I)} David Kendall Embedded systems specification and design 5 / 21

Finite State Machine (FSM) Write down the formal statement of the example FSM S = {I, O c, O t, R c, R t } s 0 = I A = {c, g, p, r, t} E = {(I, g, O c ), (I, r, O t ), (O c, p, R c ), (O t, p, R t ), (R c, c, I), (R t, t, I)} F = {I} David Kendall Embedded systems specification and design 5 / 21

Labelled Transition System Sometimes, we omit the acceptance states F from the statement of a FSM in this case, we assume that F = S, i.e. all the states are acceptance states Such a FSM corresponds directly to a labelled transition system (LTS) A different notation for a LTS may be used where the alphabet is called the set of labels and is noted L the set of edges is called the transition relation and is noted if (s, a, s ) we may write s s a So, a LTS is a tuple (S, s 0, L, ) where the components correspond to the FSM components, with notational changes as above David Kendall Embedded systems specification and design 6 / 21

Labelled Transition System An execution or run or trace of a LTS is a finite or infinite sequence of alternating states and labels s 0 a 0 s1 a 1 s2 a 2 s3... a i where s i si+1, i.e. the sequence respects the transition relation of the LTS David Kendall Embedded systems specification and design 7 / 21

Formal Language Given an alphabet, A, a string (or word) over A is a sequence of zero or more symbols a 0 a 1... a n where each a i A There is only one zero-length string, called the empty string, usually written as ɛ A formal language is a set of strings over some alphabet A The notation A n is used for the set of all strings of length n over A The notation A is used for the set of all strings over A, i.e. A 0 A 1 A 2 A 3... David Kendall Embedded systems specification and design 8 / 21

Formal Language Exercise Make up some alphabets and check understanding of the notation. David Kendall Embedded systems specification and design 9 / 21

Running a FSM to accept a string A FSM M = (S, s 0, A, E, F) accepts (recognises) a set of strings (a language) To determine if M accepts a string w = a 0 a 1... a n, construct a run of M as follows: Start in the initial state s 0 and consider the symbol a 0 If M is in a state s, considering symbol a, and s t, a move M into state t and consume a; repeat If a run consumes all symbols in the string w and terminates with M in an acceptance state, then the run accepts w If any run of M accepts w, then M accepts w David Kendall Embedded systems specification and design 10 / 21

The Language of a FSM The language of M is written L(M) and is the set of all strings accepted by M. Notice that L(M) A a 0 a 1 a 2... a n 1 L(M) iff there is a run a s 0 a 1 a 2 a n 1 0 s1 s2... s n where s 0 = s 0 and s n F. David Kendall Embedded systems specification and design 11 / 21

FSM Language Exercise O c g I r O t p c t p R c R t Work through the recognition process with this machine and some example strings David Kendall Embedded systems specification and design 12 / 21

Finite State Machine (FSM) a s 1 a s 0 b s 2 a b a s 3 s 4 a a Write down the formal statement of this FSM Check if the following strings are accepted by this FSM: (1) aba, (2) aaba, (3) aaaba, (4) abb, (5) a, (6) aaa, (7) ba David Kendall Embedded systems specification and design 13 / 21

Deterministic and Complete FSM Definition (Deterministic FSM) A FSM M = (S, s 0, A, E, F) is deterministic if for every s S and every a A there is at most one s S such that (s, a, s ) E Definition (Complete FSM) A FSM M = (S, s 0, A, E, F) is complete if for every s S and every a A there is at least one s S such that (s, a, s ) E The previous example is not deterministic (i.e. it is non-deterministic) and is not complete David Kendall Embedded systems specification and design 14 / 21

A Complete FSM a A a b s 1 s 0 s 2 b e b a b a a b e b s 3 s 4 a A a David Kendall Embedded systems specification and design 15 / 21

Notes on a complete FSM A complete FSM can never get stuck when run on an input string the string will be consumed and the machine will halt An incomplete FSM can be made complete by adding an additional state to act as the target of all missing edges e acts as a sink (or error) state, i.e. any missing edges are directed to e (duplicated to reduce clutter in the diagram) Labelling an edge with a set such as A is a shorthand for several edges, each labelled with a label from the set. Sometimes, the notation A \ B is used to mean the set of all labels in A except those that are also in B, e.g. A \ {a} = {b} David Kendall Embedded systems specification and design 16 / 21

Modelling an embedded system as a FSM An embedded system can be modelled using a FSM States of the FSM are the states of the system Alphabet of the FSM models the atomic actions of the system Edges of the FSM show what actions are possible in any given state and what state change is caused when the action is taken A string of the FSM gives a possible sequence of actions of the system David Kendall Embedded systems specification and design 17 / 21

FSM Modelling Example O c g I r O t p c t p R c R t This FSM can model a drinks machine I idle, O c coffee ordered, O t tea ordered, R c coffee ready, R t tea ready g press green button, r press red button, p prepare drink, c fill cup with coffee, t fill cup with tea g I O c means when the system is idle, the green button can be pressed and the system enters the coffee ordered state. The word gpcrpt is a possible run of the system David Kendall Embedded systems specification and design 18 / 21

Embedded systems do not terminate Embedded systems are assumed to interact continuously with their environment. Their executions are regarded as non-terminating How does this fit with our idea of the language of a FSM and the acceptance of strings? David Kendall Embedded systems specification and design 19 / 21

Embedded systems do not terminate Embedded systems are assumed to interact continuously with their environment. Their executions are regarded as non-terminating How does this fit with our idea of the language of a FSM and the acceptance of strings? It doesn t. David Kendall Embedded systems specification and design 19 / 21

Embedded systems do not terminate Embedded systems are assumed to interact continuously with their environment. Their executions are regarded as non-terminating How does this fit with our idea of the language of a FSM and the acceptance of strings? It doesn t. Definition (Büchi Acceptance) An infinite word w (execution) is accepted by a FSM M if there is some run of M over w that visits an acceptance state infinitely often. David Kendall Embedded systems specification and design 19 / 21

Specifying system properties Given a model of a system, we would like to check that it behaves properly, i.e. that it only does what it should do For the drinks machine, we might want to check that It does not dispense a drink unless a button has been pressed If the green button is pressed, eventually a cup of coffee is produced If the red button is pressed, eventually a cup of tea is produced... How do we specify the properties of the system that are permissible? Use another FSM. David Kendall Embedded systems specification and design 20 / 21

Checking system properties Let M sys be the FSM that models the actual behaviour of the system. Let M spec be a FSM that specifies permissible behaviour of the system. Then, to check that the system satisfies its specification, we check that L(M sys ) L(M spec ) i.e. all actual behaviours are permissible We will see how this can be automated next. David Kendall Embedded systems specification and design 21 / 21