Finite Automata Part One

Similar documents
Finite Automata Part One

Finite Automata Part One

Finite Automata Part One

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

Finite Automata Part Two

Nonregular Languages

Turing Machines Part III

Mathematical Induction Part Two

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

Recap from Last Time

Finite Automata Part Two

CSC236 Week 10. Larry Zhang

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CSC173 Workshop: 13 Sept. Notes

(Refer Slide Time: 0:21)

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

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

CSC236 Week 11. Larry Zhang

Automata: a short introduction

Turing Machines Part One

Chapter Two: Finite Automata

Theory of Computation

UNIT-III REGULAR LANGUAGES

Turing machines and linear bounded automata

CS 154 Introduction to Automata and Complexity Theory

Nondeterministic finite automata

A Note on Turing Machine Design

Proving languages to be nonregular

Mathematical Logic Part One

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

Turing Machines Part Two

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Theory of computation: initial remarks (Chapter 11)

Languages, regular languages, finite automata

CS 154, Lecture 3: DFA NFA, Regular Expressions

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

Takeaway Notes: Finite State Automata

CSE 105 THEORY OF COMPUTATION

Author: Vivek Kulkarni ( )

Formal Definition of Computation. August 28, 2013

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

Most General computer?

CISC4090: Theory of Computation

Turing machines and linear bounded automata

Nondeterministic Finite Automata and Regular Expressions

Formal Definition of a Finite Automaton. August 26, 2013

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal

1 More finite deterministic automata

Complexity Theory Part I

CSE 105 THEORY OF COMPUTATION

Announcements. Using a 72-hour extension, due Monday at 11:30AM.

Closure under the Regular Operations

CSCE 551: Chin-Tser Huang. University of South Carolina

Turing machines and linear bounded automata

Announcements. Final exam review session tomorrow in Gates 104 from 2:15PM 4:15PM Final Friday Four Square of the quarter!

UNIT-I. Strings, Alphabets, Language and Operations

Discrete Structures Proofwriting Checklist

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

Theory of computation: initial remarks (Chapter 11)

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

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

Fooling Sets and. Lecture 5

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,

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

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

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

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Computer Sciences Department

CSE 311: Foundations of Computing. Lecture 26: More on Limits of FSMs, Cardinality

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

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata

Context-free grammars and languages

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

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

Notes on State Minimization

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Introduction to the Theory of Computing

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

Deterministic Finite Automata

Finite Automata. Finite Automata

False. They are the same language.

Finite-state machines (FSMs)

Deterministic Finite Automata (DFAs)

Announcements. Problem Set 6 due next Monday, February 25, at 12:50PM. Midterm graded, will be returned at end of lecture.

Before we show how languages can be proven not regular, first, how would we show a language is regular?

CPSC 421: Tutorial #1

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Undecidability and Rice s Theorem. Lecture 26, December 3 CS 374, Fall 2015

What we have done so far

NP-Completeness Part II

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

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

Turing Machines Part Three

CSE 105 Theory of Computation Professor Jeanne Ferrante

Nondeterministic Finite Automata

CS103 Handout 47 Spring 2018 Practice CS103 Final Exam V

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Transcription:

Finite Automata Part One

Computability Theory

What problems can we solve with a computer?

What problems can we solve with a computer? What kind of computer?

Computers are Messy http://www.intel.com/design/intarch/prodbref/27273.htm

Computers are Messy http://www.dharmanitech.com/

Computers are Messy http://techon.nikkeibp.co.jp/article/honshi/299/64259/

Computers are Messy http://en.wikipedia.org/wiki/file:eniac.jpg

We need a simpler way of discussing computing machines.

An automaton (plural: automata) is a mathematical model of a computing device.

Computers are Messy http://www.intel.com/design/intarch/prodbref/27273.htm

Automata are Clean q q

Computers are Messy http://www.dharmanitech.com/

Automata are Clean q q

Computers are Messy http://techon.nikkeibp.co.jp/article/honshi/299/64259/

Automata are Clean q q

Computers are Messy http://en.wikipedia.org/wiki/file:eniac.jpg

Automata are Clean q q

Why Build Models? Mathematical simplicity. It is significantly easier to manipulate our abstract models of computers than it is to manipulate actual computers. Intellectual robustness. If we pick our models correctly, we can make broad, sweeping claims about huge classes of real computers by arguing that they're just special cases of our more general models.

Why Build Models? The models of computation we will explore in this class correspond to different conceptions of what a computer could do. Finite automata (next two weeks) are an abstraction of computers with finite resource constraints. Provide upper bounds for the computing machines that we can actually build. Turing machines (later) are an abstraction of computers with unbounded resources. Provide upper bounds for what we could ever hope to accomplish.

What problems can we solve with a computer?

What problems can we solve with a computer? What is a problem?

Problems with Problems Before we can talk about what problems we can solve, we need a formal definition of a problem. We want a definition that corresponds to the problems we want to solve, captures a large class of problems, and is mathematically simple to reason about. No one definition has all three properties.

Formal Language Theory

Strings An alphabet is a finite, nonempty set of symbols called characters. Typically, we use the symbol Σ to refer to an alphabet. A string over an alphabet Σ is a finite sequence of characters drawn from Σ. Example: If Σ = {a, b}, here are some valid strings over Σ: a aabaaabbabaaabaaaabbb abbababba The empty string has no characters and is denoted ε. Calling attention to an earlier point: since all strings are finite sequences of characters from Σ, you cannot have a string of infinite length.

Languages A formal language is a set of strings. We say that L is a language over Σ if it is a set of strings over Σ. Example: The language of palindromes over Σ = {a, b, c} is the set {ε, a, b, c, aa, bb, cc, aaa, aba, aca, bab, } The set of all strings composed from letters in Σ is denoted Σ*. Formally, we say that L is a language over Σ if L Σ*.

To Recap Languages are sets of strings, and strings are sequences of characters, and characters are elements of an alphabet.

The Model Fundamental Question: For what languages L can you design an automaton that takes as input a string, then decides whether the string is in L? The answer depends on the choice of L, the choice of automaton, and the definition of determines. In answering this question, we ll go through a whirlwind tour of models of computation and see how this seemingly abstract question has very real and powerful consequences.

To Summarize An automaton is an idealized mathematical computing machine. A language is a set of strings, a string is a (finite) sequence of characters, and a character is an element of an alphabet. Goal: Figure out in which cases we can build automata for particular languages.

What problems can we solve with a computer?

Finite Automata

A finite automaton is a simple type of mathematical machine for determining whether a string is contained within some language.

Each finite automaton consists of a set of states connected by transitions.

A Simple Finite Automaton q q

A Simple Finite Automaton q q Each Each circle circle represents represents aa state state of of the the automaton. automaton.

A Simple Finite Automaton q q

A Simple Finite Automaton q q One One special special state state isis designated designated as as the the state. state.

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q The The automaton automaton isis run run on on an an input input string string and and answers answers yes yes or or no. no. q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q The The automaton automaton can can a be in one state at be in one state at a time. time. It It begins begins inin the the state. state. q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q The The automaton automaton now now begins begins processing processing characters characters inin the the order order inin which which they they appear. appear. q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q Each Each arrow arrow inin this this diagram diagram represents represents aa transition. transition. The The automaton automaton always always follows follows the the transition transition corresponding corresponding to to the the current current symbol symbol being being read. read.

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q After After transitioning, transitioning, the the automaton automaton considers considers the the next next symbol symbol inin the the input. input.

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton Now Now that that the the automaton automaton has has q whether whether to to say say yes yes or or no. no. looked looked at at all all this this input, input, itit can can decide decide q

A Simple Finite Automaton Now Now that that the the automaton automaton has has q whether whether to to say say yes yes or or no. no. looked looked at at all all this this input, input, itit can can decide decide q The The double double circle circle indicates indicates that that this this state state isis an an accepting accepting state, state, so so the the automaton automaton outputs outputs yes. yes.

A Simple Finite Automaton Now Now that that the the automaton automaton has has q whether whether to to say say yes yes or or no. no. looked looked at at all all this this input, input, itit can can decide decide q The The double double circle circle indicates indicates that that this this state state isis an an accepting accepting state, state, so so the the automaton automaton outputs outputs yes. yes.

A Simple Finite Automaton Now Now that that the the automaton automaton has has q whether whether to to say say yes yes or or no. no. looked looked at at all all this this input, input, itit can can decide decide q The The double double circle circle indicates indicates that that this this state state isis an an accepting accepting state, state, so so the the automaton automaton outputs outputs yes. yes.

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q This This state state isis not not an an accepting accepting state, state, so so the the automaton automaton says says no. no. q

A Simple Finite Automaton q This This state state isis not not an an accepting accepting state, state, so so the the automaton automaton says says no. no. q

A Simple Finite Automaton q This This state state isis not not an an accepting accepting state, state, so so the the automaton automaton says says no. no. q

A Simple Finite Automaton q q

A Simple Finite Automaton q q Try Try itit yourself! yourself! Does Does the the automaton automaton accept accept (say (say yes) yes) or or reject reject (say (say no)? no)?

The Story So Far A finite automaton is a collection of states joined by transitions. Some state is designated as the state. Some states are designated as accepting states. The automaton processes a string by beginning in the state and following the indicated transitions. If the automaton ends in an accepting state, it accepts the input. Otherwise, the automaton rejects the input.

Time-Out For Announcements!

Problem Sets Problem Set Four was due at the of class today. You have three 24-hour late days to use throughout the quarter however you d like. Problem Set Five goes out today. It s due next Friday at the of class. Play around with just about everything we ve seen so far: graphs, binary relations, functions, cardinality, the pigeonhole principle, and induction! There is no checkpoint problem.

Problem Set Three PS3 has been graded. Here s the distribution: We re happy to chat with you about this problem set, the feedback you received, and how to tune and nudge things going forward. Feel free to stop by OH!

Your Questions

Is there a documentary or book that really changed the way you thought about something? Yes! Yes! The The books books Unlocking Unlocking the the Clubhouse Clubhouse and and Whistling Whistling Vivaldi Vivaldi completely completely changed changed how how II think think about about questions questions of of identity identity and and belonging. belonging. And And Jiro Jiro Dreams Dreams of of Sushi Sushi was was aa surprisingly surprisingly good good exploration exploration of of the the benefits benefits and and drawbacks drawbacks of of aa singleminded singleminded focus focus on on perfection perfection inin one one domain. domain.

Why do you hate philosophy/philosophers so much? I m I m sorry sorry that that I ve I ve given given that that impression! impression! Many Many of of the the foundational foundational ideas ideas inin computer computer science science and and mathematics mathematics are are due due to to philosophers philosophers like like Frege, Frege, Chomsky, Chomsky, and and Russell. Russell. II think think it s it s hugely hugely valuable valuable to to explore explore notions notions of of truth truth and and meaning meaning and and would would definitely definitely recommend recommend taking taking courses courses to to learn learn more more about about that! that!

Why should I or shouldn't I take a gap year if I REALLY love CS but have issues adjusting to the pace here? Taking Taking aa gap gap year year can can be be aa great great experience experience ifif you re you re strategic strategic about about when when you you take take itit and and what what you you want want to to accomplish, accomplish, but but it s it s certainly certainly not not for for everyone. everyone. II typically typically would would not not recommend recommend taking taking aa gap gap year year just just because because of of the the pace pace I m I m not not sure sure that that would would necessarily necessarily fix fix the the underlying underlying issue. issue. If If you re you re inin aa position position like like this this and and want want to to chat, chat, please please let let me me know! know! I m I m happy happy to to offer offer advice. advice.

Why do you use the number 37 everywhere? The The number number 37 37 isis very very close close to to the the reciprocal reciprocal of of the the fine-structure fine-structure constant constant inin physics: physics: It It has has aa fun fun history. history. Plus, Plus, it s it s aa great great nothing-up-my-sleeve nothing-up-my-sleeve number number that that (usually) (usually) indicates indicates that that the the particular particular number number doesn t doesn t have have any any meaning. meaning.

Back to CS3!

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

Accepting States, Revisited q q q4

A finite automaton does not accept as soon as it enters an accepting state. A finite automaton accepts if it ends in an accepting state.

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q No No matter matter where where we we in in the the automaton, automaton, q after after seeing seeing two two 's, 's, we we end end up up in in accepting accepting state state q.3. q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q q q4

What Does This Accept? q No No matter matter where where we we in in the the automaton, automaton, q after after seeing seeing two two 's, 's, we we end end up up in in accepting accepting state state qq5.5. q4

What Does This Accept? q q q4

What Does This Accept? q This This automaton automaton accepts accepts aa string string iff iff q the the string string ends ends in in or or.. q4

The language of an automaton is the set of strings that it accepts. If D is an automaton, we denote the language of D as ℒ(D). ℒ(D) = { w Σ* D accepts w }

A Small Problem q q

A Small Problem q q

A Small Problem q q

A Small Problem q q

A Small Problem q q

A Small Problem q q

A Small Problem q q

A Small Problem q q

A Small Problem q q

Another Small Problem, q, q,

Another Small Problem, q, q,

Another Small Problem, q, q,

Another Small Problem, q, q,

Another Small Problem, q, q,

Another Small Problem, q, q,

Another Small Problem, q, q,

Another Small Problem, q, q,

The Need for Formalism In order to reason about the limits of what finite automata can and cannot do, we need to formally specify their behavior in all cases. All of the following need to be defined or disallowed: What happens if there is no transition out of a state on some input? What happens if there are multiple transitions out of a state on some input?

DFAs A DFA is a Deterministic Finite Automaton DFAs are the simplest type of automaton that we will see in this course.

DFAs, Informally 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 Σ. This is the deterministic part of DFA. There is a unique state. There are zero or more accepting states.

Is this a DFA over {, }?

Is this a DFA over {, }? q q

Is this a DFA over {, }?

Is this a DFA over {, }? q q q4

Is this a DFA over {, }?

Is this a DFA over {, }? q q

Is this a DFA over {, }? q q

Is this a DFA over {, }?

Is this a DFA over {, }? q,, q,,

Is this a DFA over {, }?

Is this a DFA over {, }?, q, q,

Is this a DFA over {, }?, q, q,

Is this a DFA?

Is this a DFA?

Is this a DFA? Drinking Family of Aardvarks

Designing DFAs At each point in its execution, the DFA can only remember what state it is in. DFA Design Tip: Build each state to correspond to some piece of information you need to remember. Each state acts as a memento of what you're supposed to do next. Only finitely many different states only finitely many different things the machine can remember.

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three }

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three } q

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three } q

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three } q q

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three } q q

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three } q q

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three } q q

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three } q q

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three } q q

Recognizing Languages with DFAs L = { w {, }* the number of 's in w is congruent to two modulo three } q q Each Each state state remembers remembers the the remainder remainder of of the the number number of of 's 's seen seen so so far far modulo modulo three. three.

Recognizing Languages with DFAs L = { w {, }* w contains as a substring }

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q q

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q q

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q q

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q q

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q q,

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q q,

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q q Σ

Recognizing Languages with DFAs L = { w {, }* w contains as a substring } q q Σ

More Elaborate DFAs L = { w {a, *, /}* w represents a C-style comment } Let s Let s have have the the aa symbol symbol be be aa placeholder placeholder for for some some character character that that isn t isn t aa star star or or slash. slash. Try Try designing designing aa DFA DFA for for comments! comments! Here s Here s some some test test cases cases to to help help you you check check your your work: work: Accepted: Rejected: /*a*/ /**/ /***/ /*aaa*aaa*/ /*a/a*/ /** /**/a/*aa*/ aaa/**/aa /*/ /**a/ //aaaa

More Elaborate DFAs L = { w {a, *, /}* w represents a C-style comment } Σ a, * Σ q5 /, a q / q * * a a, / / * q4