Regular Languages and Finite State Machines



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

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

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

Deterministic Finite Automata

Reading 13 : Finite State Automata and Regular Expressions

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

Introduction to Finite Automata

Fundamentele Informatica II

Automata and Formal Languages

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

Lecture I FINITE AUTOMATA

Turing Machines: An Introduction

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

Grade 4 Mathematics Patterns, Relations, and Functions: Lesson 1

Regular Expressions and Automata using Haskell

C H A P T E R Regular Expressions regular expression

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

THEORY of COMPUTATION

Automata and Computability. Solutions to Exercises

The Halting Problem is Undecidable

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

Introduction to Automata Theory. Reading: Chapter 1

3515ICT Theory of Computation Turing Machines

Practice with Proofs

6.080/6.089 GITCS Feb 12, Lecture 3

CAs and Turing Machines. The Basis for Universal Computation

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

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

Finite Automata. Reading: Chapter 2

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, School of Informatics University of Edinburgh als@inf.ed.ac.

Scanner. tokens scanner parser IR. source code. errors

Finite Automata. Reading: Chapter 2

Turing Machines, Part I

Computability Theory

CS5236 Advanced Automata Theory

Introduction to Turing Machines

Regular Languages and Finite Automata

Genetic programming with regular expressions

Automata on Infinite Words and Trees

Computational Models Lecture 8, Spring 2009

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

T Reactive Systems: Introduction and Finite State Automata

MACM 101 Discrete Mathematics I

Finite Automata and Regular Languages

Lecture 17 : Equivalence and Order Relations DRAFT

Lecture 18 Regular Expressions

CS 3719 (Theory of Computation and Algorithms) Lecture 4

ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

24 Uses of Turing Machines

Informatique Fondamentale IMA S8

Regular Languages and Finite Automata

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

1. Prove that the empty set is a subset of every set.

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:

Enforcing Security Policies. Rahul Gera

Automata and Formal Languages. Push Down Automata. Sipser pages Lecture 13. Tim Sheard 1

How To Compare A Markov Algorithm To A Turing Machine

Formal Deænition of Finite Automaton. 1. Finite set of states, typically Q. 2. Alphabet of input symbols, typically æ.

Compiler Construction

Increasing Interaction and Support in the Formal Languages and Automata Theory Course


Notes on Complexity Theory Last updated: August, Lecture 1

You know from calculus that functions play a fundamental role in mathematics.

0 0 such that f x L whenever x a

Predicate Logic. Example: All men are mortal. Socrates is a man. Socrates is mortal.

Basic Concepts of Set Theory, Functions and Relations

Chapter 7. Functions and onto. 7.1 Functions

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

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.

Discrete Mathematics

Hint 1. Answer (b) first. Make the set as simple as possible and try to generalize the phenomena it exhibits. [Caution: the next hint is an answer to

Introduction to Theory of Computation

1 if 1 x 0 1 if 0 x 1

Lecture 2: Universality

6.3 Conditional Probability and Independence

Lecture 16 : Relations and Functions DRAFT

The Optimum One-Pass Strategy for Juliet

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

StateFlow Hands On Tutorial

Overview of E0222: Automata and Computability

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

On Winning Conditions of High Borel Complexity in Pushdown Games

1 Definition of a Turing machine

Omega Automata: Minimization and Learning 1

Logic in Computer Science: Logic Gates

FINITE STATE AND TURING MACHINES

Mathematics Review for MS Finance Students

Theory of Computation Chapter 2: Turing Machines

6 EXTENDING ALGEBRA. 6.0 Introduction. 6.1 The cubic equation. Objectives

The Division Algorithm for Polynomials Handout Monday March 5, 2012

Testing LTL Formula Translation into Büchi Automata

Continued Fractions and the Euclidean Algorithm

Rules of Exponents. Math at Work: Motorcycle Customization OUTLINE CHAPTER

SECTION 10-2 Mathematical Induction

CHAPTER 7 GENERAL PROOF SYSTEMS

Transcription:

Regular Languages and Finite State Machines Plan for the Day: Mathematical preliminaries - some review One application formal definition of finite automata Examples 1

Sets A set is an unordered collection of objects without duplicates. Objects in the set are called elements or members. denotes the empty set, the set with no elements. Note: { }. Definition: For any sets S and T, S is a subset of T, denoted S T, if x[x S x T]. Example: N Z. Note: One way of proving S = T: show S T and T S. Definition: For any sets S, T: S T = {w w S or w T } S T = {w w S and w T } S T = {w w S and w T } 2

Review of Sets Recall: To prove a universally quantified implication with a direct proof, e.g.: x y[p(x, y) Q(x, y)] First: Let x and y be arbitrary elements of the domain. Next: Assume P(x, y) is true. Show: Q(x, y) is true. Prove: For any sets A and B, A (B C) A B c. Proof: in class Exercise: Prove: For all sets A, B and C, A (B C) = (A B) (A C). 3

Strings and Languages Definition: An alphabet is a finite set of symbols. Example: Σ = {0, 1}, Σ = {a, b, c,..., z}. Definition: A string over alphabet Σ is a finite sequence of symbols from Σ. Note: The string of zero symbols is ǫ. Definition: Σ is the set of all strings over Σ. Definition: A language is a set of strings over some alphabet Σ, i.e., a subset of Σ. Example: Let alphabet A = {a, b, c}. Here are some languages over A: L 1 = {a, aab} L 2 = L 3 = {xy x, y {a, b, c}, x = y and the first character in x is a} L 4 = {ǫ, aa, aaaa, aaaaaa,...} 4

L 5 = {w {a, b, c} # a (w) = [# b (w)] 2 } Some strings in L 5 : ǫ, c, cc, cccc, ab, aaaabb, baabaa, abc,... Describe this language in English: L = {0 i 1 j 0 i j} 5

Automatic door controller Consider an automatic door placed at the entrance or exit of a grocery store. The door swings open when its sensors detect an approaching person, and then stays open until the person has passed through and beyond the door. It has two sensor pads - one in front of the door and one to the rear. The controller is always in one of two states: open or closed. The controller moves from state to state, depending on the input it receives. Four possible inputs to the door: front - a person is on the front pad (in front of the door) rear - a person is on the rear pad both - people are standing on both pads neither - no one is standing on either pad 6

Finite Automaton - Automatic Door Controller Transition table for controller: neither front rear both closed closed open closed closed open closed open open open Notes: The door will not open if people are standing on both pads - it might knock over someone standing behind the door. If the door is open, the only input that closes it is neither - that is, if no one is on either pad. 7

Finite Automaton - Door Controller neither both rear front front rear both closed open neither Figure 1: state diagram for door controller 8

One Model of Computation: finite automata Finite automata (or finite state machines) are simple computing machines with severely restricted memories. But a computer with just a little memory can do a lot. Example: A state diagram for finite automaton M. 1 0 0 q 0 q 1 1 M has two states, q 0 and q 1. q 0 is the start state. Arrows represent transitions from one state to another on the specified input symbol. Final (or accepting) states are indicated with a double circle. 9

Processing Strings with a FA Question: Does M accept input string 110? 1. Processing begins in start state q 0. 2. M reads symbols in 110 from left to right - after reading each symbol, M moves to another state. 3. If M is in a final state after processing the last symbol, then M accepts the string. Answer: Yes, 110 is accepted by M. 10

Finite Automaton/Finite State Machine A finite automaton (FA) consists of: set of states start state final states input alphabet (the set of symbols on the transition arrows) rules for going from one state to another, depending on input symbol - defined by a transition function Transition function example: in-class 11

Formal Definition of a Deterministic Finite Automaton (DFA) Definition: A deterministic finite automaton (DFA) is a 5-tuple (Q, Σ, δ, q 0, F) where 1. Q is a finite set of states 2. Σ is a finite input alphabet 3. δ : Q Σ Q is the transition function 4. q 0 Q is the start state 5. F Q is the set of final states Formal definition of M: M = ({q 0, q 1 }, {0, 1}, δ, q 0, {q 1 }), where δ is given by: 0 1 q 0 q 1 q 0 q 1 q 1 q 0 12

The language of a FA Definition: If S is the set of all strings the FA M accepts, then S is the language of M, denoted S = L(M). Terminology: We say that M recognizes S. Question: What is L(M)? Example: FA M 2 a b a b b a s q r Exercise: Write down the formal definition of M 2. Does M 2 accept the following strings: aaba? aaab? Question: What is L(M 2 )? 13

Finite Automata Example: DFA M 3 : b a a s q r b a b Exercise: Write down the formal definition of M 3. What is L(M 3 )? 14

Another FA Example: M 4 1 q 1 r 0 0 0 0 1 t 1 s Question: Does M 4 accept 011? 1011? 001001? Question: What is L(M 4 )? 15

The Language of a DFA Definition: Let M = (Q, Σ, δ, q 0, F) be a DFA, and let w = w 1 w 2...w n be a string over Σ. Then M accepts w if there exists a sequence of states r 0, r 1,..., r n Q such that 1. r 0 = q 0 2. δ(r i, w i+1 ) = r i+1 for i = 0, 1,..., n 1 3. r n F We say M recognizes language L = {w M accepts w}. Definition: A language is regular if some DFA recognizes it. 16

Designing DFAs Problem: Given a language L, define a DFA M that recognizes L. Note: What do you need to remember about a string w as you read it to determine if it s in L? This gives you the states. For a regular language, there will only be a finite amount of information you need to remember. Example: L = {w {0, 1} w ends in 1} As you read a string, one symbol at a time, left to right, what do you need to remember in order to determine if the string is in L? Remember: Last symbol seen was a 1 Last symbol seen not 1 State diagram: (in class) 17