Chapter Two: Finite Automata

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
Advertisements

Lecture 6 Nondeterministic Finite Automata (NFA)
YES-NO machines Finite State Automata as language recognizers.
Pushdown Systems Koushik Sen EECS, UC Berkeley Slide Source: Sanjit A. Seshia.
Chapter Two: Finite Automata
Finite Automata Course: Theory of Computation Date: Nov 16 th, 2011 Lin Liu lliu AT cs.kent.edu.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
CS5371 Theory of Computation
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections: September 1, 2006.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Topics Automata Theory Grammars and Languages Complexities
CSC 361Finite Automata1. CSC 361Finite Automata2 Formal Specification of Languages Generators Grammars Context-free Regular Regular Expressions Recognizers.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
Finite Automata Costas Busch - RPI.
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Rosen 5th ed., ch. 11 Ref: Wikipedia
CPSC 388 – Compiler Design and Construction Scanners – Finite State Automata.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Languages Given an alphabet , we can make a word or string by concatenating the letters of . Concatenation of “x” and “y” is “xy” Typical example: 
Lecture Notes 
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Theory of Computation Automata Theory Dr. Ayman Srour.
Costas Busch - LSU1 Deterministic Finite Automata And Regular Languages.
Theory of Computation Automata Theory Dr. Ayman Srour.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Introduction to Automata Theory Theory of Computation Lecture 3 Tasneem Ghnaimat.
CSCI 2670 Introduction to Theory of Computing
Lexical analysis Finite Automata
Lecture2 Regular Language
CSE 105 theory of computation
Chapter 2 Finite Automata
G. Pullaiah College of Engineering and Technology
Deterministic Finite Automata
Two issues in lexical analysis
Deterministic Finite Automata
Hierarchy of languages
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
Principles of Computing – UFCFA3-30-1
Non-Deterministic Finite Automata
Non Deterministic Automata
Chapter Nine: Advanced Topics in Regular Languages
Finite Automata.
4b Lexical analysis Finite Automata
Chapter Five: Nondeterministic Finite Automata
Deterministic Finite Automaton (DFA)
4b Lexical analysis Finite Automata
Chapter 1 Regular Language
Finite-State Machines with No Output
AUTOMATA THEORY.
CSE 105 theory of computation
Formal Languages and Automata Theory BODDEDA HARITHA LAKSHMI,
CHAPTER 1 Regular Languages
What is it? The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled.
Automata theory and formal languages COS 3112 – AUTOMATA THEORY PRELIM PERIOD WEEK 1 AND 2.
Nondeterminism The Chinese University of Hong Kong Fall 2010
CSE 105 theory of computation
Presentation transcript:

Chapter Two: Finite Automata Formal Language, chapter 2, slide 1

One way to define a language is to construct an automaton—a kind of abstract computer that takes a string as input and produces a yes- or-no answer. The language it defines is the set of all strings for which it says yes. The simplest kind of automaton is the finite automaton. The more complicated automata we discuss in later chapters have some kind of unbounded memory to work with; in effect, they will be able to grow to whatever size necessary to handle the input string they are given. But in this chapter, we begin with finite automata, and they have no such power. A finite automaton has a finite memory that is fixed in advance. Whether the input string is long or short, complex or simple, the finite automaton must reach its decision using the same fixed and finite memory. Formal Language, chapter 2, slide 2

Outline 2.1 Man Wolf Goat Cabbage 2.2 Not Getting Stuck 2.3 Deterministic Finite Automata 2.4 The 5-Tuple 2.5 The Language Accepted by a DFA Formal Language, chapter 2, slide 3

A Classic Riddle A man travels with wolf, goat and cabbage Wants to cross a river from east to west A rowboat is available, but only large enough for the man plus one possession Wolf eats goat if left alone together Goat eats cabbage if left alone together How can the man cross without loss? Formal Language, chapter 2, slide 4

Solutions As Strings Four moves can be encoded as four symbols: Man crosses with wolf (w) Man crosses with goat (g) Man crosses with cabbage (c) Man crosses with nothing (n) Then a sequence of moves is a string, such as the solution gnwgcng: First cross with goat, then cross back with nothing, then cross with wolf, … Formal Language, chapter 2, slide 5

Moves As State Transitions Each move takes our puzzle universe from one state to another For example, the g move is a transition between these two states: Formal Language, chapter 2, slide 6

Transition Diagram Showing all legal moves All reachable states Start state and goal state Formal Language, chapter 2, slide 7

The Language Of Solutions Every path gives some x ∈ {w,g,c,n}* The diagram defines the language of solutions to the problem: {x ∈ {w,g,c,n}* | starting in the start state and following the transitions of x ends up in the goal state} This is an infinite language (The two shortest strings in the language are gnwgcng and gncgwng) Formal Language, chapter 2, slide 8

Outline 2.1 Man Wolf Goat Cabbage 2.2 Not Getting Stuck 2.3 Deterministic Finite Automata 2.4 The 5-Tuple 2.5 The Language Accepted by a DFA Formal Language, chapter 2, slide 9

Diagram Gets Stuck On many strings that are not solutions, the previous diagram gets stuck Automata that never get stuck are easier to work with We'll need one additional state to use when an error has been found in a solution Formal Language, chapter 2, slide 10

Formal Language, chapter 2, slide 11

Complete Specification The diagram shows exactly one transition from every state on every symbol in Σ It gives a computational procedure for deciding whether a given string is a solution: Start in the start state Make one transition for each symbol in the string If you end in the goal state, accept; if not, reject Formal Language, chapter 2, slide 12

Outline 2.1 Man Wolf Goat Cabbage 2.2 Not Getting Stuck 2.3 Deterministic Finite Automata 2.4 The 5-Tuple 2.5 The Language Accepted by a DFA Formal Language, chapter 2, slide 13

DFA: Deterministic Finite Automaton An informal definition (formal version later): A diagram with a finite number of states represented by circles An arrow points to one of the states, the unique start state Double circles mark any number of the states as accepting states For every state, for every symbol in Σ, there is exactly one arrow labeled with that symbol going to another state (or back to the same state) Formal Language, chapter 2, slide 14

DFAs Define Languages Given any string over Σ, a DFA can read the string and follow its state-to-state transitions At the end of the string, if it is in an accepting state, we say it accepts the string Otherwise it rejects The language defined by a DFA is the set of strings in Σ* that it accepts Formal Language, chapter 2, slide 15

Example This DFA defines {xa | x ∈ {a,b}*} No labels on states (unlike man-wolf-goat-cabbage) Labels can be added, but they have no effect, like program comments: Formal Language, chapter 2, slide 16

A DFA Convention We don't draw multiple arrows with the same source and destination states: Instead, we draw one arrow with a list of symbols: Formal Language, chapter 2, slide 17

Outline 2.1 Man Wolf Goat Cabbage 2.2 Not Getting Stuck 2.3 Deterministic Finite Automata 2.4 The 5-Tuple 2.5 The Language Accepted by a DFA Formal Language, chapter 2, slide 18

The 5-Tuple A DFA M is a 5-tuple M = (Q, Σ, δ, q0, F), where: Q is the finite set of states Σ is the alphabet (that is, a finite set of symbols) δ ∈ (Q × Σ → Q) is the transition function q0 ∈ Q is the start state F ⊆ Q is the set of accepting states Q is the set of states Drawn as circles in the diagram We often refer to individual states as qi The definition requires at least one: q0, the start state F is the set of all those in Q that are accepting states Drawn as double circles in the diagram Formal Language, chapter 2, slide 19

The 5-Tuple A DFA M is a 5-tuple M = (Q, Σ, δ, q0, F), where: Q is the finite set of states Σ is the alphabet (that is, a finite set of symbols) δ ∈ (Q × Σ → Q) is the transition function q0 ∈ Q is the start state F ⊆ Q is the set of accepting states δ is the transition function A function δ(q,a) that takes the current state q and next input symbol a, and returns the next state Represents the same information as the arrows in the diagram Formal Language, chapter 2, slide 20

Example: This DFA defines {xa | x ∈ {a,b}*} Formally, M = (Q, Σ, δ, q0, F), where Q = {q0,q1} Σ = {a,b} F = {q1} δ(q0,a) = q1, δ(q0,b) = q0, δ(q1,a) = q1, δ(q1,b) = q0 Names are conventional, but the order is what counts in a tuple We could just say M = ({q0,q1}, {a,b}, δ, q0, {q1}) Formal Language, chapter 2, slide 21

Outline 2.1 Man Wolf Goat Cabbage 2.2 Not Getting Stuck 2.3 Deterministic Finite Automata 2.4 The 5-Tuple 2.5 The Language Accepted by a DFA Formal Language, chapter 2, slide 22

The δ* Function The δ function gives 1-symbol moves We'll define δ* so it gives whole-string results (by applying zero or more δ moves) A recursive definition: δ*(q,ε) = q δ*(q,xa) = δ(δ*(q,x),a) That is: For the empty string, no moves For any string xa (x is any string and a is any final symbol) first make the moves on x, then one final move on a Formal Language, chapter 2, slide 23

M Accepts x Now δ*(q,x) is the state M ends up in, starting from state q and reading all of string x So δ*(q0,x) tells us whether M accepts x: A string x ∈ Σ* is accepted by a DFA M = (Q, Σ, δ, q0, F) if and only if δ*(q0, x) ∈ F. Formal Language, chapter 2, slide 24

Regular Languages For any DFA M = (Q, Σ, δ, q0, F), L(M) denotes the language accepted by M, which is L(M) = {x ∈ Σ* | δ*(q0, x) ∈ F}. A regular language is one that is L(M) for some DFA M. To show that a language is regular, give a DFA for it; we'll see additional ways later To show that a language is not regular is much harder; we'll see how later Formal Language, chapter 2, slide 25