CISC 4090 Theory of Computation

Similar documents
CISC 4090 Theory of Computation

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

CHAPTER 1 Regular Languages. Contents

Theory of Languages and Automata

CS 154, Lecture 3: DFA NFA, Regular Expressions

Closure under the Regular Operations

Theory of Computation (I) Yijia Chen Fudan University

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

CPS 220 Theory of Computation REGULAR LANGUAGES

Critical CS Questions

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

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Nondeterministic Finite Automata

CS 455/555: Finite automata

Computational Models #1

Introduction to Languages and Computation

Theory of Computation (II) Yijia Chen Fudan University

CS 154. Finite Automata, Nondeterminism, Regular Expressions

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

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

UNIT-III REGULAR LANGUAGES

CISC 4090 Theory of Computation

Computational Models - Lecture 1 1

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

Computer Sciences Department

Finite Automata. Seungjin Choi

CISC4090: Theory of Computation

UNIT-I. Strings, Alphabets, Language and Operations

Formal Definition of Computation. August 28, 2013

Sri vidya college of engineering and technology

CISC 4090 Theory of Computation

Closure under the Regular Operations

Chapter Five: Nondeterministic Finite Automata

Inf2A: Converting from NFAs to DFAs and Closure Properties

Finite Automata Part Two

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Applied Computer Science II Chapter 1 : Regular Languages

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

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

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

How do regular expressions work? CMSC 330: Organization of Programming Languages

Lecture 17: Language Recognition

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

Intro to Theory of Computation

Fooling Sets and. Lecture 5

Computational Models: Class 1

Nondeterminism. September 7, Nondeterminism


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

CSE 105 THEORY OF COMPUTATION

CPS 220 Theory of Computation

CS21 Decidability and Tractability

Lecture 3: Nondeterministic Finite Automata

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

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Time Magazine (1984)

Computational Models - Lecture 4

V Honors Theory of Computation

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

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

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

Automata: a short introduction

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

What we have done so far

September 7, Formal Definition of a Nondeterministic Finite Automaton

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

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

CMSC 330: Organization of Programming Languages

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

Finite Automata and Regular languages

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

CS243, Logic and Computation Nondeterministic finite automata

Deterministic Finite Automata (DFAs)

CPS 220 Theory of Computation Pushdown Automata (PDA)

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

Introduction to Computers & Programming

Deterministic Finite Automata (DFAs)

CSC173 Workshop: 13 Sept. Notes

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CSE 105 THEORY OF COMPUTATION

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Chapter 5. Finite Automata

CSE 105 Theory of Computation Professor Jeanne Ferrante

CSE 105 THEORY OF COMPUTATION

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

Nondeterminism and Epsilon Transitions

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

Finite Automata. Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computational Models - Lecture 3

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Nondeterministic Finite Automata

Formal Definition of a Finite Automaton. August 26, 2013

Push-down Automata = FA + Stack

Equivalence of DFAs and NFAs

Context-Free Languages

Transcription:

9/2/28 Stereotypical computer CISC 49 Theory of Computation Finite state machines & Regular languages Professor Daniel Leeds dleeds@fordham.edu JMH 332 Central processing unit (CPU) performs all the instructions Memory stores data and instructions for CPU Input collects information from the world Output provides information to the world Input Output CPU 2 Super-simple computers Small number of potential inputs Small number of potential outputs/actions Thermostat Elevator Vending machine Automatic door Automatic door Desired behavior Person approaches entryway, door opens Person goes through entryway, door stays open Person is no longer near entryway, door closes Nobody near entryway, door stays closed Two states: Open, Closed Two inputs: Front-sensor, Back-sensor 3 Finite state machine 4

9/2/28 Graph and table representations Neither Front, Back, Both Front, Back, Both More finite state machine applications Text parsing Closed Neither Open Front Back Neither Both Closed Open Open Closed Open Open Open Open Closed Open 5 Traffic light Pac-Man Electronic locks 6 Coding a combination lock q q 3, A finite automaton M with 3 states Start state q; accept state q2 (double circle) Example accepted string: What are all strings that this model will accept? String ending with or string end with followed by even number of s 8 Formal definition of Finite State Automaton Finite state automaton is a 5-tuple Q, Σ, δ, q, F Q is a finite set called states Σ is a finite set called the alphabet δ: Q Σ Q is the transition function q Q is the start state F Q is the set of accept states 9 2

9/2/28 Describe M using formal definition q q 3 M = Q, Σ, δ, q, F, Q = q,, q 3 δ = Σ =, Start state: q F = q q 3 q q 3 Language of M If A is set of all strings accepted by M, A is language of M L(M)=A A machine may accept many strings, but only one language M accepts a string M recognizes a language Describe L(M)=A A={w w ends with or w end with one followed by even number of s} 3 Describe M2 using formal definition Describe M2 using formal definition q q M2 = Q,,, δ, q, M2 = Q,,, δ, q, Q = Start state: δ = Q = {q, } Start state: q δ = q q q2 q2 q q2 4 5 3

9/2/28 What is the language of M2? L(M2)={w } What is the language of M2? L(M2)={w w ends with at least one } 6 7 CFG practice G -> AB A -> xxa y B -> wbw z What is the language of M4? (page 38, Ex..) a q a s b r b L(M4)={w } a b b a G 2 -> D D -> nd o b r 2 a 8 9 4

9/2/28 Perform modulo arithmetic Let Σ={RESET,,, 2} Construct M5 to accept a string only if the sum of each input symbol is multiple of 3, and RESET sets the sum back to (.3, page 39) More modulo arithmetic Generalize M5 to accept if sum of symbols is a multiple of i instead of 3 q, q, q2, q3,, q i,,,2, RESET, δ, q, F 2 23 Definition of M accepting a string Let M = Q, Σ, δ, q, F be a finite automaton and let w = w w 2 w n Then M accepts w if a sequence of states r, r,, r n in Q exists with 3 conditions r =q δ r i, w i+ = r i+ for i =,,, n r n F Regular languages Definition: a language is called a regular language if some finite automaton recognizes it equivalently All of the strings in a regular language are accepted by some finite automaton 25 26 5

9/2/28 Designing finite automata (FAs) Determine what you need to remember How many states needed for your task? Set start and finish states Assign transitions Check your solution Should accept w L Should reject w L Be careful about ε! 27 FA design practice! FA to accept language where number of s is odd (page 43) FA to accept string with as substring (page 44) FA to accept string with substring abab 28 Regular operations Let A and B be languages. We define 3 regular operations: Union: A B = x x A or x B Concatenation: A B = xy x A and y B Star: A = x x 2 x k k and each x i A Repeat a string or more times Examples of regular operations Let A = good, bad and B = boy, girl What is: A B = A B = A = 32 33 6

9/2/28 Express CFG as RegEx? G 2 -> D D -> nd o Closure A collection of objects is closed under an operation if applying that operation to members of the collection returns an object in the collection G -> AB A -> xxa y B -> wbw z Regular languages are closed under,, 35 36 Closure of Concatenation Theorem.26: The class of regular languages is closed under the concatenation operation If A and A2 are regular languages, then so is A A2 Challenge: How do we know when M ends and M2 begins? Determinism vs. non-determinism Determinism: Single transition allowed given current state and given input Non-determinism: multiple transitions allowed for current state and given input transition permitted for null input ε,,,ε q q 3 q 4 37 38 7

9/2/28 NFA in action When there is a choice, follow all paths like cloning If there is no forward arrow, path terminates and clone dies (no accept) NFA will accept if at least one path terminates at accept Alternative thought: Magically pick best path from the set of options The language of M,,,ε q q 3 q 4 List some accepted strings What is L(M)? 39 4 NFA construction practice Build an NFA that accepts all strings over {,} with in the third position from the end NFA -> DFA Build an NFA that accepts all strings over {,} with in the third position from the end Can we construct a DFA for this? 42 44 8

9/2/28 Formal definition of Nondeterministic Finite Automaton Similar to DFA: a 5-tuple Q, Σ, δ, q, F Q is a finite set called states Σ is a finite set called the alphabet δ: Q Σε P(Q) is the transition function q Q is the start state F Q is the set of accept states 45 Describe M using formal definition, M = Q, Σ, δ, q, F Q = Σ = Start state: F = q q δ =,, q 3 q q q 3 ε 46 Consider NFA N q q Convert NFA N to DFA M q q N Language: L(N)={w w begins with, ends with, every in w is preceded by a } 47 9

9/2/28 Equivalence of NFAs and DFAs NFAs and DFAs recognize the same class of languages Two machines are equivalent if they recognize the same language Every NFA has an equivalent DFA Union Closure with NFAs Proofs by construction fewer states! Any NFA proof applies to DFA Given two regular languages A and A 2 recognized by N and N2 respectively, construct N to recognize A A 2 52 54 Let s consider two languages L: start with, end with L2: start with, end with Let s consider two languages L: start with, end with N, q q Construct machines for each languages Construct machines N3 to recognize L U L2 L2: start with, end with N2, r r r 2 55 56

9/2/28 N3 recognizes L U L2 ε N, q q Closure under concatenation Given two regular languages A and A 2 recognized by N and N2 respectively, construct N to recognize A A 2 s ε N2, r r r 2 57 59 Closure of Union Theorem.25: The class of regular languages is closed under the union operation Proof by construction 62