CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions



Similar documents
Regular Languages and Finite State Machines

Reading 13 : Finite State Automata and Regular Expressions

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Introduction to Finite Automata

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Regular Expressions and Automata using Haskell

Finite Automata. Reading: Chapter 2

Compiler Construction

Finite Automata. Reading: Chapter 2

03 - Lexical Analysis

Compilers Lexical Analysis

Base Conversion written by Cathy Saxton

Number Representation

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Turing Machines: An Introduction

Programming Languages CIS 443

Automata and Formal Languages

The Halting Problem is Undecidable

Scanner. tokens scanner parser IR. source code. errors

Positional Numbering System

Computer Science 281 Binary and Hexadecimal Review

6.080/6.089 GITCS Feb 12, Lecture 3

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Pemrograman Dasar. Basic Elements Of Java

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Introduction to Automata Theory. Reading: Chapter 1

MACM 101 Discrete Mathematics I

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

Automata and Computability. Solutions to Exercises

C H A P T E R Regular Expressions regular expression

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

3515ICT Theory of Computation Turing Machines

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

Section 1.4 Place Value Systems of Numeration in Other Bases

24 Uses of Turing Machines

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

1. True or False? A voltage level in the range 0 to 2 volts is interpreted as a binary 1.

Chapter 4: Computer Codes

Binary Representation

Useful Number Systems

Computability Theory

Lexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar

Arithmetic Coding: Introduction

Lempel-Ziv Coding Adaptive Dictionary Compression Algorithm

The string of digits in the binary number system represents the quantity

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Chapter 2: Elements of Java

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

CSI 333 Lecture 1 Number Systems

Encoding Text with a Small Alphabet

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

NUMBER SYSTEMS. William Stallings

Finite Automata and Regular Languages

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

Computational Models Lecture 8, Spring 2009

csce4313 Programming Languages Scanner (pass/fail)

Decimal Number (base 10) Binary Number (base 2)

C++ INTERVIEW QUESTIONS

CAs and Turing Machines. The Basis for Universal Computation

Lecture 1. Basic Concepts of Set Theory, Functions and Relations

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

Variables, Constants, and Data Types

Cyber Security Workshop Encryption Reference Manual

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Informatique Fondamentale IMA S8

Deterministic Finite Automata

Introduction to Turing Machines

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)

Cardinality. The set of all finite strings over the alphabet of lowercase letters is countable. The set of real numbers R is an uncountable set.

Solution for Homework 2

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Moving from CS 61A Scheme to CS 61B Java

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

Core Components Data Type Catalogue Version October 2011

Chapter 2: Basics on computers and digital information coding. A.A Information Technology and Arts Organizations

Systems I: Computer Organization and Architecture

Notes on Complexity Theory Last updated: August, Lecture 1

Data Storage 3.1. Foundations of Computer Science Cengage Learning

3 Data Properties and Validation Rules

LC-3 Assembly Language

Basics of Counting. The product rule. Product rule example. 22C:19, Chapter 6 Hantao Zhang. Sample question. Total is 18 * 325 = 5850

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005

General Certificate of Education Advanced Subsidiary Examination June 2015

Enforcing Security Policies. Rahul Gera

Ed. v1.0 PROGRAMMING LANGUAGES WORKING PAPER DRAFT PROGRAMMING LANGUAGES. Ed. v1.0

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

PL / SQL Basics. Chapter 3

Regular Languages and Finite Automata

Automata on Infinite Words and Trees

Transcription:

CSC45 AUTOMATA 2. Finite Automata: Examples and Definitions Finite Automata: Examples and Definitions A finite automaton is a simple type of computer. Itsoutputislimitedto yes to or no. It has very primitive memory capabilities. For this chapter, consider that: The input comes in the form of a string of individual input symbols. The computer gives an answer for the current string. 2

A Finite Automaton (FA) or finite state machine is always in one of a finite number of states. At each step it makes a move that depends only on the state it s currently in and the input symbol it gets The move is to enter a particular state. States are either e accepting or nonaccepting Entering an accepting state means answering yes. Entering a nonaccepting state means no. An FA has an initial state, which is an accepting state if and only if the language the FA accepts includes. An FA can be described by the set of states, the input alphabet, the initial state, the set of accepting states, and a transition function. This can be described by a transition diagram or a transition table. q q q 2 q 3 q q 2 q q q 3 q q 2 q q 3 * q 3 q q 2 3 4 2

, states q, accepting states (F) q q 2 The program accepts a string if the process ends in a double circle. start state (q ) q 3 states 5 6 3

This FA accepts the language of strings that end in aa. This FA accepts strings ending with b and not containing aa. 7 8 4

This FA accepts strings that contain abbaab. An FA that accepts binary representation of integers divisible by 3 States,, and 2 represent the current remainder The initial state is non accepting: at least one bit is required Leading zeros are prohibited What do we do when a prefix of abbaab has been read dbut tthe next symbol ld doesn t match? Go back to the state representing the longest prefix of abbaab at the end of the new current string. 9 5

FAs are ideally suited for lexical analysis, the first stage in compiling a computer program. A lexical analyzer takes a string of characters and provides a string of tokens. Tokens: reserved words, punctuation ti symbols, identifiers, operators, numeric literals, separated by spaces. Accepting states represent scanned tokens; each accepting state represents a category of token. Tokens: identifiers, semicolons, =, aa, numerical literals (digits + decimal point) D: any digit L: a lowercase letter other than a M: D or L N: D or L or a :a space All transitions not shown explicitly go to an error state and stay there 2 6

Definition: A finite automaton is a 5 tuple M = (Q,,, q, A, ), where: Q is a finite set of states is a finite input alphabet q Q is the initial state A Q is the set of accepting states : Q Q is the transition function From state q the machine will move to state (q, ) if it receives input symbol. Build an automaton that accepts all and only those strings that contain., q q q q 3 4 7

The notation *(q, x) describes the state the FA is in after starting in state q and receiving input string x. The extended transition function *: Q * Q is defined recursively as follows:. For every q Q, *(q, ) = q 2. For every q Q, every y *, and every, *(q, y ) = ( *(q, y), ) Evaluate *(q, baa) in the following FA *(q, baa) = ( *(q (q, ba), a) = ( ( *(q (q, b), a), a) = ( ( *(q, b), a), a) = ( ( ( *(q, ), b), a), a) = ( ( (q, b), a), a) = ( (q, a), a) = (q, a) ) = q 5 6 8

Definition: Let M=(Q,, q, A, ) be an FA, and let x *. Thenx x is accepted by M if *(q, x) A and rejected otherwise. q, The language accepted by M is L(M) = {x * x is accepted by M} L(M) = {w w is a string of s and s} q, q, L(M) = { } 7 8 9

q q L(M) = { w w has an even number of s} Design an FA to accept the language L={w { w has both an even number of s and an even number of s} M=(Q,, q, A, ) Q={q, q, q 2, q 3 } ={,} A={q } * q q 2 q q q 3 q q q q 2 q 3 q 2 q q 3 q 3 q q 2 9 2