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

Similar documents
Finite Automata Part One

Finite Automata Part One

Finite Automata Part One

Finite Automata Part One

Turing Machines Part III

Finite Automata Part Two

Chapter Two: Finite Automata

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

Finite Automata Part Two

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

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

Decision, Computation and Language

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

CSCI 2670 Introduction to Theory of Computing

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

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

CSE 105 THEORY OF COMPUTATION

Finite Automata. Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

Finite-state machines (FSMs)

Chapter Five: Nondeterministic Finite Automata

Decidability and Undecidability

Nonregular Languages

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

Turing Machines Part One

Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Final Exam Version A December 16, 2014 Name: NetID: Section: # Total Score

Nondeterministic Finite Automata

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Computability Theory

Finite Automata (contd)

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

Complexity Theory Part I

Deterministic Finite Automaton (DFA)

CS 581: Introduction to the Theory of Computation! Lecture 1!

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

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

Final Exam (Version B) December 16, 2014 Name: NetID: Section: 1 2 3

Computational Tasks and Models

Formal Definition of Computation. August 28, 2013

Join. Visit us at the HMC club fair and the 5c turf dinner. Company sponsored tech talks and events Resume Workshops / Interview Prep

Theory of Computation

(Refer Slide Time: 0:21)

Introduction to Theoretical Computer Science. Motivation. Automata = abstract computing devices

CS 154 Introduction to Automata and Complexity Theory

3130CIT Theory of Computation

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

Computation Histories

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

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

A Note on Turing Machine Design

CHAPTER 1 Regular Languages. Contents

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

Computational Models - Lecture 1 1

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

Deterministic Finite Automata

ACS2: Decidability Decidability

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

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

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

1 More finite deterministic automata

Nondeterministic Finite Automata and Regular Expressions

CSC236 Week 11. Larry Zhang

CSE 105 THEORY OF COMPUTATION

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

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

ECS 120 Lesson 15 Turing Machines, Pt. 1

NP-Completeness Part II

Deterministic Finite Automata (DFAs)

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

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

Nondeterminism. September 7, Nondeterminism

Non-emptiness Testing for TMs

(Note that these points are to give a relative sense of the weights on the final exam and have no bearing on extra credit points)

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

Deterministic Finite Automata (DFAs)

Computability and Complexity

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

Theory of Computation Lecture 1. Dr. Nahla Belal

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!

CISC4090: Theory of Computation

Author: Vivek Kulkarni ( )

Approximation Algorithms

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

Quantum Computing Lecture 8. Quantum Automata and Complexity

Course 4 Finite Automata/Finite State Machines

Languages, regular languages, finite automata

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Optimizing Finite Automata

CS 154, Lecture 3: DFA NFA, Regular Expressions

3515ICT: Theory of Computation. Regular languages

Part I: Definitions and Properties

UNIT-VIII COMPUTABILITY THEORY

Deterministic finite Automata

Transcription:

Finite Automata

Announcements Problem Set Four due Thursday at 7:PM (right before the midterm). Stop by OH with questions! Email cs3@cs.stanford.edu with questions! Review session tonight, 7PM until whenever people are done asking questions, in 37-37. Covers practice midterm questions. Alternate time tomorrow as well; we'll announce a location once we have a room reserved.

Problem Set 2 Scores 7 6 5 4 3 2 5 5 25 35 45 55 65 75 85 95 5 5 25 35 4 Mean: 8 Median: 2 Stdev: 6

Midterm Details Midterm is Thursday, 7:-:PM in Hewlett 2 (right next door). Alternate: Wednesday, 7: :PM, room TBA Alternate: Thursday, 9:AM Noon, room TBA Open-book, open-note, open-computer, closed-network. Feel free to download lecture slides. Do not Google the answers, email your friends, read xkcd, etc. If you can disable your network connection, please do so. Material is up through and including Wednesday's lecture. Don't panic; any question on this week's material will be extremely easy and should not require much thought.

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.

Automata make it possible to reason about computability by abstracting away the implementation complexity of real computing systems.

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? The models of computation we will explore in this class correspond to different conceptions of what a computer could do. Finite automata (this week) 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.

Decision Problems In this class, we will consider decision problems, problems with yes/no answers. Examples: Does 37 + 42 have 3 as a divisor? Is P the shortest path from u to v? If the velociraptors can run at 3m/s, will I survive for more than ten minutes? Do we have to get down on Friday?

Decision Problems are Powerful Many questions that are not decision problems can be phrased as decision problems. Example: What is 33 + 44? can be phrased as a decision problem Is 33 + 44 = 77? There are much better ways to do this; we'll see them later on. In this sense, decision problems are at least as hard as any other problem. If we can't solve decision problems, we certainly can't solve these other problems.

Strings An alphabet is a finite set Σ of characters. A string is a finite sequence of characters drawn from some alphabet. Example: Σ = {, }, some valid strings include The empty string contains no characters and is denoted ε.

Languages A formal language is a set of strings. We say that L is a language over Σ if it is a set of strings formed from the characters of Σ. Example: The language of palindromes over Σ = {,, 2} is the set {ε,,, 2,,, 22,,, 2,,, } The set of all strings composed from letters in Σ is denoted Σ*.

Decision Problems and Languages Languages give a compact and flexible way to encode decision problems. Consider these examples: { p p is an encoding of a prime number } { w w is an encoding of (x, y), where x < y } { x x is an encoding of a graph G and a path P, where P is the longest path in G } Any decision problem can be represented by a language of strings encoding inputs to which the answer is yes. All the automata we will discuss in this class will be machines for answering the question is string x in language L?

To Summarize An automaton is an idealized mathematical computing machine. A language is a set of strings. A decision problem is a yes/no question (though it can be quite complex). The automata we will study will accept as input a string and (attempt to) output whether that string is contained in a particular language.

Finite Automata

A finite automaton is a 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 circle represents a state of the automaton.

A Simple Finite Automaton q q

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

A Simple Finite Automaton q q

A Simple Finite Automaton q q

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

A Simple Finite Automaton q q

A Simple Finite Automaton q q

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

A Simple Finite Automaton q q

A Simple Finite Automaton q q

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

A Simple Finite Automaton q q

A Simple Finite Automaton q q

A Simple Finite Automaton q q Each arrow in this diagram represents a transition. The automaton always follows the transition corresponding to the current symbol being 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 transitioning, the automaton considers the next symbol in the 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 q q Now that the automaton has looked at all this input, it can decide whether to say yes or no.

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

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

A Simple Finite Automaton q q The double circle Now that the automaton has looked at all this input, it can decide whether to say yes or no. indicates that this state is an accepting state, so the automaton outputs 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 This state is not q q an accepting state, so the automaton says no.

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

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

A Simple Finite Automaton q q

A Simple Finite Automaton q q Try it yourself! Does the automaton accept (say yes) or reject (say 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 processing 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.

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

Accepting States, Revisited q q q 5

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

What Does This Accept? q q q 5

What Does This Accept? q q q 5

What Does This Accept? q q q 5

What Does This Accept? q q q 5

What Does This Accept? q q q 5

What Does This Accept? q q q 5

What Does This Accept? q q q 5

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

What Does This Accept? q q q 5

What Does This Accept? q q q 5

What Does This Accept? q q q 5

What Does This Accept? q q q 5

What Does This Accept? q q q 5

What Does This Accept? q q q 5

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

What Does This Accept? q q q 5

What Does This Accept? q q This automaton accepts any string ending in or. q 5

The language of an automaton is the set of strings that it accepts. We denote this L(A)

A language L is called a regular language if there is some finite automaton A for which L(A) = L

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 Problem?

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, Problem?

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 the alphabet. This is the deterministic part of DFA. There is a unique state. There may be multiple accepting states.

Is this a DFA?

Is this a DFA? q q

Is this a DFA?

Is this a DFA? q q q 5

Is this a DFA?

Is this a DFA? q q

Is this a DFA? q q

Is this a DFA?

Is this a DFA? q, q,, q,

Is this a DFA?

Is this a DFA?, q, q,

Is this a DFA?, q, q,

Is this a DFA?

Is this a DFA?

Is this a DFA? Deadly Futuristic Assassin

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 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 every even character of w is a }

Recognizing Languages with DFAs L = { w every even character of w is a } YES NO

Recognizing Languages with DFAs L = { w every even character of w is a }

Recognizing Languages with DFAs L = { w every even character of w is a } q

Recognizing Languages with DFAs L = { w every even character of w is a } q q

Recognizing Languages with DFAs L = { w every even character of w is a } q q

Recognizing Languages with DFAs L = { w every even character of w is a } q q,

Recognizing Languages with DFAs L = { w every even character of w is a } q q,,

Recognizing Languages with DFAs L = { w every even character of w is a } q q, This state is sometimes called a dead state.,

Recognizing Languages with DFAs L = { w every even character of w is a } q q,,

More Elaborate DFAs L = { w w is a legal email address }

More Elaborate DFAs L = { w w is a legal email address } @,. @,. a, @,. @,. q 8 q 7. a @., @ @ @,.. a q a q @ a q 4. q 5 a q 6 a a a

More Elaborate DFAs L = { w w is a C-style comment }

More Elaborate DFAs L = { w w is a C-style comment } a, *, / a, * q 5 a, *, / /, a q / q * * a / q 4 a, / *

More Elaborate DFAs L = { w w is a C-style comment } a, *, / a, * q 5 a, *, / /, a q / q * * a / q 4 a, / *

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

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