Automata and Languages

Similar documents
FINITE STATE MACHINES (AUTOMATA)

Automata and Languages

Nondeterministic Finite Automata

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Chapter Five: Nondeterministic Finite Automata

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

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Automata and Languages

Chapter 6: NFA Applications

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

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Lecture 1: Finite State Automaton

Finite Automata. Finite Automata

Computational Models #1

CS243, Logic and Computation Nondeterministic finite automata

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

CS 322 D: Formal languages and automata theory

(Refer Slide Time: 0:21)

CS 154, Lecture 3: DFA NFA, Regular Expressions

Nondeterministic Finite Automata

Extended transition function of a DFA

CMSC 330: Organization of Programming Languages

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

Finite Automata (contd)

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

Lecture 3: Nondeterministic Finite Automata

Finite Automata. Seungjin Choi

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

Theory of Computation (I) Yijia Chen Fudan University

Sri vidya college of engineering and technology

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

Theory of Computation Lecture 1. Dr. Nahla Belal

Deterministic Finite Automata (DFAs)

Decision, Computation and Language

Deterministic Finite Automata (DFAs)

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Inf2A: Converting from NFAs to DFAs and Closure Properties

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

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

Introduction to Computers & Programming

Finite-State Machines (Automata) lecture 12

Intro to Theory of Computation

Closure under the Regular Operations

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

Nondeterminism and Epsilon Transitions

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Computational Models - Lecture 1 1

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

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

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

CSE 105 Theory of Computation Professor Jeanne Ferrante

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

Deterministic Finite Automata (DFAs)

Constructions on Finite Automata

Constructions on Finite Automata

CISC 4090 Theory of Computation

CSC173 Workshop: 13 Sept. Notes

September 7, Formal Definition of a Nondeterministic Finite Automaton

Finite-state machines (FSMs)

NFA and regex. the Boolean algebra of languages. regular expressions. Informatics 1 School of Informatics, University of Edinburgh

Deterministic Finite Automaton (DFA)

Lecture 4 Nondeterministic Finite Accepters

CPS 220 Theory of Computation REGULAR LANGUAGES

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

3515ICT: Theory of Computation. Regular languages

Applied Computer Science II Chapter 1 : Regular Languages

Nondeterministic Finite Automata

Nondeterminism. September 7, Nondeterminism

Finite Automata and Languages

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Nondeterministic Finite Automata and Regular Expressions

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack

Equivalence of DFAs and NFAs

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CSC236 Week 11. Larry Zhang

Finite Automata. Warren McCulloch ( ) and Walter Pitts ( )

CS 455/555: Finite automata

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

Nondeterministic Finite Automata

Theory of Computation (IV) Yijia Chen Fudan University

Further discussion of Turing machines

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

Fooling Sets and. Lecture 5

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

Lecture 3: Finite Automata

Nondeterministic finite automata

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Uses of finite automata

Automata: a short introduction

Critical CS Questions

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

Transcription:

Automata and Languages Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan

FINITE STATE MACHINES (AUTOMATA)

Switch Example Think about the On/Off button

Switch Example The corresponding Automaton Off Push Push Input: Push Push Push Push

Vending Machine Example 2 Vending machine dispenses Cola for $.45

Vending Machine Example 2 Input: D Q Q D 45 is final state Input Accepted

Example 3, The machine accepts a string if the process ends in a final state

Example 3 states Input Symbols final states (F) q, q q 2 start state (q ) q 3 states

Definitions An alphabet Σ is a finite set of symbols (in Ex3, Σ = {,}) A string over Σ is a finite sequence of elements of Σ (e.g. ) For a string s, s is the length of s The unique string of length will be denoted by λ and will be called the empty string The reversal of a string u is denoted by u R. Example: (banana) R = ananab

Definitions The concatenation of two strings is the string resulting from putting them together from left to right. Given strings u and v, denote the concatenation by u.v, or just uv. Example: jap. an = japan, QQ. DD = QQDD Q: What s the Java equivalent of concatenation? The + operator on strings Q2: Find a formula for u.v? u.v = u + v

Definitions If Σ is an alphabet, Σ * denotes the set of all strings over Σ. A language over Σ is a subset of Σ * i.e. a set of strings each consisting of sequences of symbols in Σ.

Example: in our vending machine we have Σ = { D, Q } Σ * = {λ, D, Q, DD, DQ, QD, QQ, DDD, DDQ, DQD, DQQ, QDD, QDQ, QQD, QQQ, DDDD, DDDQ, } L = { u Σ * u successfully vends } Examples Example2: in our switch example we have Σ = { Push} Σ * = {λ, Push, Push Push, Push Push Push, Push Push Push Push, } L = { Push n n is odd }

Definitions A finite automaton is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set of states Σ is the alphabet δ is the transition function q Q is the start state F Q is the set of final states L(M) = the language of machine M = set of all strings machine M accepts

Definitions State Diagram and Table a b q q a b q 2 a b δ a b q q q q q q 2 Q = { q Σ = { a, b} F = { q 2, q }, q 2 } q 2 q 2 q 2

FINITE STATE MACHINES (AUTOMATA) Deterministic Finite Automata (DFA) Non-Deterministic Finite Automata with empty move (λ-nfa) Non-Deterministic Finite Automata (NFA)

Deterministic & Nondeterministic Deterministic Non-Deterministic B B E E A H A H C C D F G D F G G I G I E E One choice Multi choice è Backtrack

Deterministic & Nondeterministic Deterministic Non-Deterministic a B A a C A a a C D From ONE state machine can go to another ONE state on one input One choice From ONE state machine can go to MANY states on one input Multi choice

Deterministic Computation Non-Deterministic Computation reject accept or reject accept

DETERMINISTIC FINITE AUTOMATA (DFA)

Q is the set of states Σ is the alphabet Definitions A DFA is a 5-tuple M = (Q, Σ, δ, q, F) δ : Q Σ Q is the transition function q Q is the start state F Q is the set of accept states L(M) = the language of machine M = set of all strings machine M accepts

Deterministic Finite Automata (DFA) Example is not final state Input Rejected

Deterministic Finite Automata (DFA) Example Q: What kinds of bit-strings are accepted? A: Bit-strings that represent binary even numbers.

Deterministic Finite Automata (DFA) Example 2 q q 2 q 3 reject accept λ reject accept reject,

Exercise q, L(M) = {,}*

Exercise q, L(M) =

Exercise q q L(M) = { w w has an even number of s}

Exercise Build an automaton that accepts all and only those strings that contain, q q q q

Exercise Strings over {a,b} containing even number of a s and odd number of b s. q = Even(a).Even(b) q = Even(a).Odd(b) Even(a) Σ* Odd(a) q 2 = Odd(a).Even(b) q 3 = Odd(a).Odd(b) Even(b) Odd(b) Even(b) Odd(b) a q b b a b b a q q 2 q 3 a

Exercise Strings over {a,b,c} that has the form (ab)*c q = End(b) q = End(a) valid prefix Σ* invalid prefix q 2 = End(c) q 3 = Error End(a) End(b) End(c) c b a q q q 2 q 3 a,b,c b a,c a,b,c

Exercise Design with a friend a machine that tells us when a base- number is divisible by 3. What should your alphabet be? How can you tell when a number is divisible by 3?

Answer,3,6,9,4,7 mod 3 mod 3 2,5,8,3,6,9,4,7 2,5,8 2,5,8 2 mod 3,4,7,3,6,9

Exercise,3,6,9 mod 3,4,7 Find the formal description of this automaton.,3,6,9,4,7 2,5,8 mod 3 2,5,8 2,5,8,4,7 2 mod 3,3,6,9

Answer Q = { mod 3, mod 3, 2 mod 3 } ( rename: {q, q, q 2 } ) Σ = {,, 2, 3, 4, 5, 6, 7, 8, 9 } q = mod 3 F = { mod 3 } δ : Q Σ Q δ( q δ( q,2),7) = = q q 2 2,, δ( q δ( q 2,9) =,3) = q q 2,δ( q,δ( q 2,2),5) = = q q., Question : δ( q δ( i, j) =? q i, j) = q( i + j) mod 3