Finite Automata Part Two

Similar documents
Finite Automata Part Two

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

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Intro to Theory of Computation

Closure under the Regular Operations

CS 455/555: Finite automata

CSE 105 THEORY OF COMPUTATION

Theory of Computation (I) Yijia Chen Fudan University

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Lecture 3: Nondeterministic Finite Automata

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Concatenation. The concatenation of two languages L 1 and L 2

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

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

CS 154, Lecture 3: DFA NFA, Regular Expressions

Sri vidya college of engineering and technology

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

CSE 105 Theory of Computation Professor Jeanne Ferrante

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

Inf2A: Converting from NFAs to DFAs and Closure Properties

Announcements. Problem Set Four due Thursday at 7:00PM (right before the midterm).

Finite Automata and Regular languages

CPS 220 Theory of Computation REGULAR LANGUAGES

CSE 105 THEORY OF COMPUTATION

Nondeterministic Finite Automata

CSE 105 THEORY OF COMPUTATION

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Nondeterminism. September 7, Nondeterminism

CSE 105 THEORY OF COMPUTATION

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

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

CSE 105 THEORY OF COMPUTATION

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

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

Chap. 1.2 NonDeterministic Finite Automata (NFA)

CSE 105 THEORY OF COMPUTATION

Equivalence of DFAs and NFAs

CSE 105 THEORY OF COMPUTATION

Complexity Theory Part I

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

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Non-deterministic Finite Automata (NFAs)

Chapter Five: Nondeterministic Finite Automata

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

CISC 4090 Theory of Computation

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

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

Turing Machines Part II

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

Finite Automata Part One

CSE 105 THEORY OF COMPUTATION

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Finite Automata Part One

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

CS243, Logic and Computation Nondeterministic finite automata

CSE 105 THEORY OF COMPUTATION

Finite Automata Part One

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

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

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

Turing Machines Part III

CS 121, Section 2. Week of September 16, 2013

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

CS 154 Introduction to Automata and Complexity Theory

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

Nondeterministic Finite Automata

CMSC 330: Organization of Programming Languages

Nondeterministic Finite Automata and Regular Expressions

Computer Sciences Department

Decision, Computation and Language

False. They are the same language.

Finite Automata. Mahesh Viswanathan

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

MA/CSSE 474 Theory of Computation

Fooling Sets and. Lecture 5

CPSC 421: Tutorial #1

Constructions on Finite Automata

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

UNIT-VIII COMPUTABILITY THEORY

Theory of Languages and Automata

Recap from Last Time

Nondeterministic finite automata

Automata and Languages

Deterministic Finite Automaton (DFA)

September 7, Formal Definition of a Nondeterministic Finite Automaton

Constructions on Finite Automata

CSE 105 THEORY OF COMPUTATION

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

CHAPTER 1 Regular Languages. Contents

CSE 105 THEORY OF COMPUTATION

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

1 More finite deterministic automata

2017/08/31 Chapter 1.2 & 1.3 in Sipser Ø Announcement:

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

UNIT-III REGULAR LANGUAGES

Nondeterminism and Epsilon Transitions

CSE 105 THEORY OF COMPUTATION

Transcription:

Finite Automata Part Two

DFAs A DFA is a Deterministic Finite Automaton A DFA is defined relative to some alphabet Σ. For each state in the DFA, there must be exactly one transition defined for each symbol in the alphabet. There is a unique start state. There are zero or more accepting states.

Recognizing Languages with DFAs L = { w {0, 1}* w contains 00 as a substring } start q 0 1 0 0 q 1 q 2 Σ 1

Recognizing Languages with DFAs L = { w {0, 1}* every other character of w, starting with the first character, is 0 } start 0 q 0 q 1 1 Σ q 2 Σ

More Elaborate DFAs L = { w w is a C-style comment } Suppose the alphabet is Σ = { a, *, / } Try designing a DFA for comments! Some test cases: ACCEPTED REJECTED /*a*/ /** /**/ /**/a /***/ aaa/**/ /*aaa*aaa*/ /*/

More Elaborate DFAs L = { w w is a C-style comment } Σ a, * q 5 Σ /, a start q 0 / q 1 * q 2 * a q 3 / q 4 a, / *

Tabular DFAs start 1 q 0 0 1 0 q 1 q 2 q 3 0 1 Σ 0 1 *q 0 q 1 q 0 The The star star indicates indicates that that this this is is an an accepting accepting state. state. q 1 q 2 q 3 q 3 q2 q 3 q 0 q 3 q 3

Code In a Theory Course int ktransitiontable[knumstates][knumsymbols] = { {0, 0, 1, 3, 7, 1, }, }; bool kaccepttable[knumstates] = { false, true, true, }; bool SimulateDFA(string input) { int state = 0; for (char ch: input) state = ktransitiontable[state][ch]; return kaccepttable[state]; }

A language L is called a regular language iff there exists a DFA D such that L( D) = L.

The Complement of a Language Given a language L Σ*, the complement of that language (denoted L) is the language of all strings in Σ* not in L. Formally: L = Σ* - L L L

Complementing Regular Languages Recall: A regular language is a language accepted by some DFA. Question: If L is a regular language, is L a regular language? If the answer is yes, then there must be some way to construct a DFA for L. If the answer is no, then some language L can be accepted by a DFA, but L cannot be accepted by any DFA.

Complementing Regular Languages L = { w {0, 1}* w contains 00 as a substring } start q 0 1 0 0 q 1 q 2 1 L = { w {0, 1}* w does not contain 00 as a substring } start q 0 1 0 0 q 1 q 2 1 Σ Σ

More Elaborate DFAs L = { w w is not a C-style comment } Σ a, * q 5 Σ /, a start * q 0 q 1 q 2 q 3 q 0 / * a a, / * / q 4

Closure Properties Theorem: If L is a regular language, then L is also a regular language. If we begin with a regular language and complement it, we end up with a regular language. This is an example of a closure property of regular languages. The regular languages are closed under complementation. We'll see more such properties later on.

Time-Out For Announcements!

Solutions Released Solutions released for Problem Set 4 checkpoint. Practice Midterm 1. Practice Midterm 2. Please review the solution sets for the Problem Set 4 checkpoint. There are some common mistakes you probably want to review.

Midterm Logistics Midterm review sessions this weekend. Saturday, 2:15PM 4:15PM: Michael holding an on-campus review session. Sunday, 8PM 10PM: Dilli holding a review session for SCPD students. Neither time works for you? Let us know so we can try to schedule something extra! We have a Google Moderator page to see what questions to answer during the review session; link will be posted later today.

Your Questions

The only difference between predicates and functions is that the first 'returns' booleans and the second 'returns' objects. Are booleans not objects? If they aren't, why aren't they, and if they are, how are predicates and functions different?

NFAs

NFAs An NFA is a Nondeterministic Finite Automaton Conceptually similar to a DFA, but equipped with the vast power of nondeterminism.

(Non)determinism A model of computation is deterministic if at every point in the computation, there is exactly one choice that can make. The machine accepts if that series of choices leads to an accepting state. A model of computation is nondeterministic if the computing machine may have multiple decisions that it can make at one point. The machine accepts if any series of choices leads to an accepting state.

A Simple NFA start q 1 0 q 1 1 q 2 0, 1 0 0, 1 q 3 q 0 has 0 has two two transitions defined defined on on 1! 1! 0, 1

A More Complex NFA start q 0 1 q 1 1 q 2 0, 1 If If a a NFA NFA needs needs to to make make a a transition transition when when no no transition transition exists, exists, the the automaton automaton dies dies and and that that particular particular path path rejects. rejects.

Intuiting Nondeterminism Nondeterministic machines are a serious departure from physical computers. How can we build up an intuition for them? Three approaches: Tree computation Perfect guessing Massive parallelism

Tree Computation q 0 start q 0 0 q 1 1 q 2 q 1 1 1 q 3 0 q 4 0 q 5 q 4 q 2 0, 1 q 4 q 5 0 1 0 1 0 q 4 q 4 q 5

Nondeterminism as a Tree At each decision point, the automaton clones itself for each possible decision. The series of choices forms a directed, rooted tree. At the end, if any active accepting states remain, we accept.

Perfect Guessing We can view nondeterministic machines as having Magic Superpowers that enable them to guess the correct choice of moves to make. Idea: Machine can always guess a path that leads to an accepting state if one exists. No known physical analog for this style of computation.

Massive Parallelism An NFA can be thought of as a DFA that can be in many states at once. Each symbol read causes a transition on every active state into each potential state that could be visited. Nondeterministic machines can be thought of as machines that can try any number of options in parallel. No fixed limit on processors; makes multicore machines look downright wimpy!

So What? We will turn to these three intuitions for nondeterminism more later in the quarter. Nondeterministic machines may not be feasible, but they give a great basis for interesting questions: Can any problem that can be solved by a nondeterministic machine be solved by a deterministic machine? Can any problem that can be solved by a nondeterministic machine be solved efficiently by a deterministic machine? The answers vary from automaton to automaton.

1 ε-transitions NFAs have a special type of transition called the ε-transition. An NFA may follow any number of ε-transitions at any time without consuming any input. 0 start q 0 0 1 q 1 q 2 ε q 3 0 q 4 0 q 5

Designing NFAs When designing NFAs, embrace the nondeterminism! Good model: Guess-and-check: Have the machine nondeterministically guess what the right choice is. Have the machine deterministically check that the choice was correct.

Guess-and-Check L = { w {0, 1}* w ends in 010 or 101 } 1 0 0 start Σ 1 0 1

Guess-and-Check L = { w {a, b, c}* at least one of a, b, or c is not in w } a, b ε a, c start ε ε b, c

Next Time Equivalence of NFAs and DFAs How are DFAs powerful enough to match NFAs? Additional Closure Properties Closure under union, intersection, concatenation, and Kleene star! Regular Expressions I A different formalism for regular languages.