Turing Machines Part One

Similar documents
Turing Machines Part One

Finite Automata Part Three

This lecture covers Chapter 8 of HMU: Properties of CFLs

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Lecture 09: Myhill-Nerode Theorem

CSCI FOUNDATIONS OF COMPUTER SCIENCE

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

CS 275 Automata and Formal Language Theory

Finite Automata-cont d

More on automata. Michael George. March 24 April 7, 2014

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Theory of Computation Regular Languages

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

Some Theory of Computation Exercises Week 1

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

State Minimization for DFAs

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

Nondeterminism and Nodeterministic Automata

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

First Midterm Examination

First Midterm Examination

NFAs continued, Closure Properties of Regular Languages

CISC 4090 Theory of Computation

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

Name Ima Sample ASU ID

Lecture 6 Regular Grammars

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

CS375: Logic and Theory of Computing

Chapter 2 Finite Automata

Turing Machines Part One

1.4 Nonregular Languages

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS5371 Theory of Computation. Lecture 20: Complexity V (Polynomial-Time Reducibility)

CMSC 330: Organization of Programming Languages

Non-Deterministic Finite Automata

Convert the NFA into DFA

Minimal DFA. minimal DFA for L starting from any other

Deterministic Finite Automata

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

Part 5 out of 5. Automata & languages. A primer on the Theory of Computation. Last week was all about. a superset of Regular Languages

Lexical Analysis Finite Automate

Non-deterministic Finite Automata

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Recursively Enumerable and Recursive. Languages

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

1 Nondeterministic Finite Automata

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7

Homework 3 Solutions

Worked out examples Finite Automata

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

Formal languages, automata, and theory of computation

Designing finite automata II

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

Formal Language and Automata Theory (CS21004)

1 Structural induction, finite automata, regular expressions

CSC 473 Automata, Grammars & Languages 11/9/10

Harvard University Computer Science 121 Midterm October 23, 2012

E 1 (n) = E 0 (n-1) E 0 (n) = E 0 (n-1)+e 0 (n-2) T(n -1)=2E 0 (n-2) + E 0 (n-3)

Let's start with an example:

NFAs continued, Closure Properties of Regular Languages

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Lecture 08: Feb. 08, 2019

FABER Formal Languages, Automata and Models of Computation

CHAPTER 1 Regular Languages. Contents

CS S-12 Turing Machine Modifications 1. When we added a stack to NFA to get a PDA, we increased computational power

Non-deterministic Finite Automata

DFA Minimization and Applications

CS 188: Artificial Intelligence Spring 2007

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

1 From NFA to regular expression

Handout: Natural deduction for first order logic

a b b a pop push read unread

Formal Languages and Automata

In-depth introduction to main models, concepts of theory of computation:

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Java II Finite Automata I

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

1 Structural induction

1.3 Regular Expressions

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

Section: Other Models of Turing Machines. Definition: Two automata are equivalent if they accept the same language.

Deterministic Finite-State Automata

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

p(t) dt + i 1 re it ireit dt =

Transcription:

Turing Mchines Prt One

Hello Hello Condensed Condensed Slide Slide Reders! Reders! Tody s Tody s lecture lecture consists consists lmost lmost exclusively exclusively of of nimtions nimtions of of Turing Turing mchines mchines nd nd TM TM constructions. constructions. We ve We ve presented presented condensed condensed version version here, here, but but we we strongly strongly recommend recommend reding reding full full version version of of slides slides tody. tody. Hope Hope this this helps! helps! -Keith -Keith

Wht problems cn we solve with computer?

Regulr Lnguges CFLs Lnguges recognizble by ny fesible computing mchine All Lnguges

Tht sme drwing, to scle. All Lnguges

The Problem Finite utomt ccept precisely regulr lnguges. We my need unbounded memory to recognize context-free lnguges. e.g. { n b n n N } requires unbounded counting. How do we build n utomton with finitely mny sttes but unbounded memory?

A Brief History Lesson

A Simple Turing Mchine q cc strt q 0 q 1 This This is is Turing Turing mchine s mchine s finite finite stte stte control. control. It It issues issues commnds commnds tht tht drive drive opertion opertion of of mchine. mchine. q rej

A Simple Turing Mchine q cc strt q 0 q 1 This This is is TM s TM s infinite infinite tpe. tpe. Ech Ech tpe tpe cell cell holds holds tpe tpe symbol. symbol. Initilly, Initilly, ll ll (infinitely (infinitely mny) mny) tpe tpe symbols symbols re re blnk. blnk. q rej

A Simple Turing Mchine q cc strt q 0 q 1 The The mchine mchine is is strted strted with with input input string string written written somewhere somewhere on on tpe. tpe. The The tpe tpe hed hed initilly initilly points points to to first first symbol symbol of of input input string. string. q rej

A Simple Turing Mchine q cc strt q 0 q 1 Like Like DFAs DFAs nd nd NFAs, NFAs, TMs TMs begin begin execution execution in in ir ir strt strt stte. stte. q rej

A Simple Turing Mchine q cc strt q 0 q 1 At At ech ech step, step, TM TM only only looks looks t t symbol symbol immeditely immeditely under under tpe tpe hed. hed. q rej

A Simple Turing Mchine q cc strt q 0 q 1 These These two two trnsitions trnsitions originte originte t t current current stte. stte. We re We re going going to to choose choose one one of of m m to to follow. follow. q rej

A Simple Turing Mchine q cc strt q 0 q 1 Ech Ech trnsition trnsition hs hs form form red red write, write, dir dir nd nd mens mens if if symbol symbol red red is is under under tpe tpe hed, hed, q replce rej replce it it with with write write nd nd move move tpe tpe hed hed in in direction direction dir dir (L (L or or R). R). The The symbol symbol denotes denotes blnk blnk cell. cell.

A Simple Turing Mchine q cc strt q 0 q 1 Ech Ech trnsition trnsition hs hs form form red red write, write, dir dir nd nd mens mens if if symbol symbol red red is is under under tpe tpe hed, hed, q replce rej replce it it with with write write nd nd move move tpe tpe hed hed in in direction direction dir dir (L (L or or R). R). The The symbol symbol denotes denotes blnk blnk cell. cell.

A Simple Turing Mchine q cc strt q 0 q 1 Unlike Unlike DFA DFA or or NFA, NFA, TM TM doesn t doesn t stop stop fter fter reding reding ll ll input input chrcters. chrcters. We We keep keep running running until until mchine mchine explicitly explicitly sys sys to to stop. stop. q rej

A Simple Turing Mchine q cc strt q 0 q 1 This This specil specil stte stte is is n n ccepting ccepting stte. stte. When When TM TM enters enters n n ccepting ccepting stte, stte, it it immeditely immeditely stops stops running running nd nd ccepts ccepts whtever whtever originl originl input input string string ws ws (in (in this this cse, cse, ). ). q rej

A Simple Turing Mchine q cc strt q 0 q 1 This This specil specil stte stte is is rejecting rejecting stte. stte. When When TM TM enters enters rejecting rejecting stte, stte, it it immeditely immeditely stops stops running running nd nd rejects rejects whtever whtever originl originl input input string string ws ws (in (in this this cse, cse, ). ). q rej

A Simple Turing Mchine q cc strt q 0 q 1 If If TM TM is is strted strted on on empty empty string string ε, ε, entire entire tpe tpe is is blnk blnk nd nd tpe tpe hed hed is is positioned positioned t t some some rbitrry rbitrry loction loction on on tpe. tpe. q rej

The Turing Mchine A Turing mchine consists of three prts: A finite-stte control tht issues commnds, n infinite tpe for input nd scrtch spce, nd tpe hed tht cn red nd write single tpe cell. At ech step, Turing mchine writes symbol to tpe cell under tpe hed, chnges stte, nd moves tpe hed to left or to right.

Input nd Tpe Alphbets A Turing mchine hs two lphbets: An input lphbet Σ. All input strings re written in input lphbet. A tpe lphbet Γ, where Σ Γ. The tpe lphbet contins ll symbols tht cn be written onto tpe. The tpe lphbet Γ cn contin ny number of symbols, but lwys contins t lest one blnk symbol, denoted. You re gurnteed Σ. At strtup, Turing mchine begins with n infinite tpe of symbols with input written t some loction. The tpe hed is positioned t strt of input.

Accepting nd Rejecting Sttes Unlike DFAs, Turing mchines do not stop processing input when y finish reding it. Turing mchines decide when (nd if!) y will ccept or reject ir input. Turing mchines cn enter infinite loops nd never ccept or reject; more on tht lter...

Determinism Turing mchines re deterministic: for every combintion of (non-ccepting, non-rejecting) stte q nd tpe symbol Γ, re must be exctly one trnsition defined for tht combintion of q nd. Any trnsitions tht re missing implicitly go stright to rejecting stte. We ll use this lter to simplify our designs. q cc strt q 0 q 1 This This mchine mchine is is exctly exctly sme sme s s previous previous one. one.

Designing Turing Mchines Despite ir simplicity, Turing mchines re very powerful computing devices. Tody's lecture explores how to design Turing mchines for vrious lnguges.

Designing Turing Mchines Let Σ = {0, 1} nd consider lnguge L = {0 n 1 n n N }. We know tht L is context-free. How might we build Turing mchine for it?

L = {0 n 1 n n N } 0 0 0 1 1 1 0 1 0 1 1 0 0

A Recursive Approch The string ε is in L. The string 0w1 is in L iff w is in L. Any string strting with 1 is not in L. Any string ending with 0 is not in L.

0 0, R 0 0, L 1 1, L Go to strt 1, L Cler 1 strt, L 1 q cc rej Check for 0 0, R Go to end 0 0, R 1 1, R q cc

Anor TM Design We've designed TM for {0 n1 n n N}. Consider this lnguge over Σ = {0, 1}: L = { w Σ* w hs sme number of 0s nd 1s } This lnguge is lso not regulr, but it is context-free. How might we design TM for it?

1 1, R, R strt 1, R Find 0 0, L, R Find 0/1 Go Go home 0 0, L 1 1, L, L, R 0, R Find 1 1, L Accept! 0 0, R, R Remember tht ll ll missing trnsitions implicitly reject.

Constnt Storge Sometimes, TM needs to remember some dditionl informtion tht cn't be put on tpe. In this cse, you cn use similr techniques from DFAs nd introduce extr sttes into TM's finite-stte control. The finite-stte control cn only remember one of finitely mny things, but tht might be ll tht you need!

Time-Out for Announcements!

Problem Set Five Problem Set Five hs been grded. Here s score distribution: (Nice job, everyone!) As lwys, feel free to rech out to us if you hve ny questions!

Problem Sets Problem Set Six ws due t strt of clss tody. You cn use lte dys to extend dedline up through Mondy, but be creful bout doing this given tht midterm is on Tuesdy. Problem Set Seven goes out tody. It s due next Fridy t strt of clss. Ply round with regulr expressions, properties of regulr lnguges, limits of regulr lnguges, nd Myhill-Nerode orem!

Midterm Exm Logistics The second midterm exm is next Tuesdy, My 23rd, from 7:00PM 10:00PM. Loctions re divvied up by lst (fmily) nme: Abb Pg: Go to Hewlett 200. Pr Tk: Go to Spp 114. Tn Vl: Go to Hewlett 101. Vr Yim: Go to Hewlett 102. You Zuc: Go to Hewlett 103. You re responsible for Lectures 00 13 nd topics covered in PS1 PS5. Lter lectures nd problem sets won t be tested. The focus is on PS3 PS5 nd Lectures 06 13. The exm is closed-book, closed-computer, nd limited-note. You cn bring double-sided, 8.5 11 sheet of notes with you to exm, decorted however you d like.

Your Questions

Wht is your fvourite mmticl orem? Wlk us through proof. One One of of my my fvorite orems is is tiny tiny little little one one tht tht I like like not not becuse it s it s super deep, but but becuse setup is is just just so so beutiful. Let Let me me show show you! you!

Recommendtions for thought-provoking short stories nd books, or just stories you hve herd tht mde you chllenge your existence / perception of relity? I ve I ve mentioned Before Lw Lw on on one one of of prctice exms nd nd highly recommend it. it. It s It s gret short red red to to tlk tlk bout. Or ones: Scott nd nd Scurvy, Story of of Your Life, Post-Opertive Check, nd nd Pulitzer-Prize winning rticle The The Fighter from lst lst yer.

Bck to CS103!

Anor TM Design Consider following lnguge over Σ = {0, 1}: L = {0 n 1 m n, m N nd m is multiple of n } Is this lnguge regulr? How might we design TM for this lnguge?

An Observtion We cn recursively describe when one number m is multiple of n: If m = 0, n m is multiple of n. Orwise, m is multiple of n iff m n is multiple of n. Ide: Repetedly subtrct n from m until m becomes zero (good!) or drops below zero (bd!)

strt Edge Cse 0 0, R, L 1 1, L Unmrk, R 0, L, R 0 0, R 1 1, R 0 0, R Check m 0 1 1, L Bck home 0, R Next 0 To End, R 0 0, L, R, L Accept!, L 0 0, L 1 1, L Bck home 1, L Cross off 1 1 1

Concepts from Tody Turing mchines re generliztion of finite utomt equipped with n infinite tpe. It's often helpful to think recursively when designing Turing mchines. It's often helpful to introduce new symbols into tpe lphbet. Wtch for edge cses tht might led to infinite loops though we'll sy more bout tht lter on.

Next Time TM Subroutines Combining multiple TMs toger! The Church-Turing Thesis Just how powerful re Turing mchines?