1 Intro to Finite Automata Chapter 2 introduces the concept of a Finite Automata (or FA). An FA has several properties: It is theoretical. It allows computer.

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
Advertisements

CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
CS 461 – Oct. 21 Begin chapter 3 We need a better (more encompassing) model of computation. Ex. { 1 n 2 n 3 n } couldn’t be accepted by PDA. –How could.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
YES-NO machines Finite State Automata as language recognizers.
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
Finite Automata with Output
Chapter Two: Finite Automata
Finite state machines.
Introduction to Computability Theory
Introduction to Computability Theory
CS5371 Theory of Computation
61 Nondeterminism and Nodeterministic Automata. 62 The computational machine models that we learned in the class are deterministic in the sense that the.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
Finite State Machines Data Structures and Algorithms for Information Processing 1.
CS5371 Theory of Computation Lecture 10: Computability Theory I (Turing Machine)
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
COMS 3261, Lecture 2 Strings, Languages, Automata September 6, 2001.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
Regular Expressions and Automata Chapter 2. Regular Expressions Standard notation for characterizing text sequences Used in all kinds of text processing.
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
CPSC 388 – Compiler Design and Construction Scanners – Finite State Automata.
Functions Definition & purpose Notation Functions on binary / returning binary values Finite automaton model We haven’t completely left the world of counting.
Finite-State Machines with No Output
Lecture 03: Theory of Automata:08 Finite Automata.
CMPS 3223 Theory of Computation
Compiler Construction Lexical Analysis. The word lexical means textual or verbal or literal. The lexical analysis implemented in the “SCANNER” module.
An ordered n-tuple is a set of n objects with an order associated with them. If n objects are represented by x 1, x 2,..., x n, then we write the ordered.
Lecture 07: Formal Methods in SE Finite Automata Lecture # 07 Qaisar Javaid Assistant Professor.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Computabilty Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos +
13-Nov-1513-Nov-1513-Nov-15 State Machines. What is a state machine? A state machine is a different way of thinking about computation A state machine.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
2. Regular Expressions and Automata 2007 년 3 월 31 일 인공지능 연구실 이경택 Text: Speech and Language Processing Page.33 ~ 56.
SM2220 – Class 06 Finite Automata. SM2220 – Class 06 Topic in theoretical computing. A subset of computation machines. Closely related to formal language.
CS 203: Introduction to Formal Languages and Automata
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Finite Automata Chapter 1. Automatic Door Example Top View.
Lecture 04: Theory of Automata:08 Transition Graphs.
Theory of computation Introduction theory of computation: It comprises the fundamental mathematical properties of computer hardware, software,
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
LECTURE 5 Scanning. SYNTAX ANALYSIS We know from our previous lectures that the process of verifying the syntax of the program is performed in two stages:
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
CompSci Today’s Topics Computer Science Noncomputability Upcoming Special Topic: Enabled by Computer -- Decoding the Human Genome Reading Great.
Theory of Computation Automata Theory Dr. Ayman Srour.
Lecture 14: Theory of Automata:2014 Finite Automata with Output.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
Theory of Computation Automata Theory Dr. Ayman Srour.
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Finite Automata.
CSE202: Introduction to Formal Languages and Automata Theory
Finite State Machines Dr K R Bond 2009
Lexical analysis Finite Automata
Modeling Arithmetic, Computation, and Languages
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Recognizer for a Language
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Chapter Two: Finite Automata
Principles of Computing – UFCFA3-30-1
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Introduction to Finite Automata
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
State Machines 6-Apr-196-Apr-19.
State Machines 8-May-19.
State Machines 16-May-19.
Lecture 5 Scanning.
Presentation transcript:

1 Intro to Finite Automata Chapter 2 introduces the concept of a Finite Automata (or FA). An FA has several properties: It is theoretical. It allows computer scientists to talk about general mathematical properties of computers. It is tied to what are called formal languages. A formal language is also theoretical, and is used to think mathematically about programming languages (like Java). It can be quite useful in real life applications. We will look at one such application shortly.

2 Basics of Finite Auotmata Let’s start with an example FA drawn using a state-transition diagram. States are represented as numbered circles. There is always one initial state. There must be one or more accepting states (also called final states). Arrows between states represent state-transition. They are labeled with an input token from the problem alphabet (0 and 1 in this case). A ? Means an incomplete piece – have to fill it in sooner or later.

3 “Running” a FA Make the initial state the current state While current state is not an accepting state or a failure state do the following { Read the next input (must be from alphabet; 0 or 1 in this example). Choose the arc that corresponds to the token read and follow it. Make the resulting state the new current state. } If current state is an accepting state, print “ACCEPT” else print “REJECT”.

4 An FA used as a language recognizer You can feed an FA a series of “sentences” from an alphabet. A sentence is a combination of tokens from the alphabet. Given an alphabet of 0 and 1, here are four sentences: 0, 1, , 1010 I hope you see that there are an infinite number of sentences for any non-empty alphabet. A language is defined as some subset of all sentences. So for any given sentence, we can say that it is either in the language or not in the language. Our goal is to use an FA to make this “in or not in” decision. Thus, the FA will accept or not accept a sentence depending on whether it is in the language. Before going further, here is some useful notation for describing sentences: A * (star), left paren and right paren are special symbols that cannot be in the alphabet. They allow you to define a repeating sequence. For example: (b)* means zero or more occurrences of the token b (assumes b is in the alphabet). (aba)* means zero or more occurrences of the sequence aba. ab(a)*b means the sequence ab followed by zero or more occurences of a followed by a single b.

5 Example from book The problem the book sets up is to “reverse engineer” a FA that will accept strings in some language L A. You are given some example strings above. Any ideas on how to characterize the language using (…)* notation? See any patterns? How about 01(001)*01? Why might this be a wrong guess? Well, maybe is not in the language. Hmmmm. Let’s try to build an FA for 01(001)*01 in any case.

6 First cut at an FA Let’s try on board. You can use a question mark for places you are not sure about.

7 So have we found the answer? Is this the only FA that will accept these strings?

8 Before we go over end-of-chapter problems … Let’s look at another way to view an FA, i.e., as a state-transition table (as opposed to a state-transition diagram). state/input

9 Ok, now let’s try Problem 1b (page 12) Define an FA that accepts the language 0+1. Definition: + means OR. So will accept either 0 or 1. Let’s draw it first, then do table. state/input reject 2

10 Finally, let’s look at practical use Chapter 2 lays out a theoretical problem: given a black-box, figure out the language that it accepts. Use an FA to represent a parser of the language. Let’s look at an alternative, forward engineering, approach. Define an FA for some problem we have. Use it to define the black box.

11 A soda machine  All drinks cost 50 cents. (Yeah, right.)  The machine will accept quarters and half- dollars.  The user must select the soda she wants.  The machine never runs out of soda.  The machine has a coin-return button. Let’s think about the alphabet first: {Deposit-25, Deposit-50, select, coin-return}

12 A soda machine Now let’s draw the FA:

13 A soda machine How about the table version: State/input 2550CRSel 013Rej 13?

14 A soda machine Practical issues: Error messages on most rejects? Should states 2 and 4 wrap to state 0? How do we show actions, e.g., give change, dispense soda? State/input 2550CRSel 013Rej 13?

15 State Machines are what we want When trying to model a problem, we can use a state machine to help us think about behavior, before we code. Different from FA as follows: No real notion of sentence recognition. Alphabet is set of events as opposed to tokens. Typically no “acceptance” state, but instead infinite loop. Add actions to arcs.

16 Let’s try programming it public static void main( String [] args ){ int current_state = 0; while( true ){ int event = readSide(); if( current_state == 0 && event = 0 ) //row 0 current_state = 1; else if (current_state == 0 && event = 1 ) current_state = 3; else if( current_state == 0 && event = 2 ) printMsg(“Put in money first!”); else if( current_state == 0 && event = 3 ) printMsg(“Put in money first!”); else if( current_state == 1 && event = 0 ) //row 1 current_state = 3; etc. else break; //must be stop event } //while } //main State/input25 (0) 50 (1) CR (2) Sel (3) 013Rej (0) 13?2Rej (1) 2Rej