CSE 105 THEORY OF COMPUTATION

Similar documents
CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

V Honors Theory of Computation

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

1 Showing Recognizability

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Intro to Theory of Computation

Decidability (What, stuff is unsolvable?)

CpSc 421 Final Exam December 15, 2006

Turing Machines Part III

Theory of Computation (IX) Yijia Chen Fudan University

Decidability and Undecidability

Intro to Theory of Computation

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Further discussion of Turing machines

CS20a: Turing Machines (Oct 29, 2002)

CSE 105 THEORY OF COMPUTATION

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

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

CPSC 421: Tutorial #1

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

Final exam study sheet for CS3719 Turing machines and decidability.

Languages, regular languages, finite automata

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

CS20a: Turing Machines (Oct 29, 2002)

Finite Automata and Regular languages

UNIT-VIII COMPUTABILITY THEORY

CSE 105 Theory of Computation Professor Jeanne Ferrante

ACS2: Decidability Decidability

MA/CSSE 474 Theory of Computation

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computability Theory

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Exam Computability and Complexity

Properties of Context-Free Languages. Closure Properties Decision Properties

CSE 105 Theory of Computation

Introduction to Turing Machines. Reading: Chapters 8 & 9

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

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

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

CSE 105 Theory of Computation

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

Harvard CS 121 and CSCI E-121 Lecture 14: Turing Machines and the Church Turing Thesis

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

SCHEME FOR INTERNAL ASSESSMENT TEST 3

CSE 105 THEORY OF COMPUTATION

Decidability (intro.)

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

Automata and Computability. Solutions to Exercises

Foundations of

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

CSE 105 THEORY OF COMPUTATION

Notes for Comp 497 (Comp 454) Week 12 4/19/05. Today we look at some variations on machines we have already seen. Chapter 21

Reducability. Sipser, pages

Automata and Computability. Solutions to Exercises

Theory Bridge Exam Example Questions

CSE 105 THEORY OF COMPUTATION

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

CS 455/555: Finite automata

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Turing Machines Part II

Part I: Definitions and Properties

CSE 105 THEORY OF COMPUTATION

10. The GNFA method is used to show that

Equivalence of DFAs and NFAs

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

Computability Theory

CS 154, Lecture 3: DFA NFA, Regular Expressions

Fooling Sets and. Lecture 5

Homework Assignment 6 Answers

Chap. 4,5 Review. Algorithms created in proofs from prior chapters

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

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Computability Theory. CS215, Lecture 6,

Introduction to Languages and Computation

Theory of Computation

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,

DM17. Beregnelighed. Jacob Aae Mikkelsen

Computational Models Lecture 8 1

Transcription:

CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/

Today's learning goals Sipser Ch 3.3, 4.1 State and use the Church-Turing thesis. Give examples of decidable problems. Review for exam 2 Wednesday May 11 8pm-10pm Bring photo ID, 3inch by 5inch note card, seat assignment Office hours available

Deciders and recognizers Sipser p. 144 Defs 3.5 and 3.6 L is Turing-recognizable if some Turing machine recognizes it. M is a decider TM if it halts on all inputs. L is Turing-decidable if some Turing machine that is a decider recognizes it.

Variants of TMs Scratch work, copy input, Multiple tapes Parallel computation Nondeterminism Printing vs. accepting Enumerators More flexible transition function Can "stay put" Can "get stuck" lots of examples in exercises to Chapter 3 Also: wildly different models λ-calculus, Post canonical systems, URMs, etc.

Algorithm Wikipedia "self-contained step-by-step set of operations to be performed" CSE 20 textbook "An algorithm is a finite sequence of precise instructions for performing a computation or for solving a problem." Church-Turing thesis Each algorithm can be implemented by some Turing machine.

Encoding input for TMs Sipser p. 159 By definition, TM inputs are strings To define TM M: "On input w 1... 2... 3. For inputs that aren't strings, we have to encode the object (represent it as a string) first Notation: <O> is the string that represents (encodes) the object O <O 1,, O n > is the single string that represents the tuple of objects O 1,, O n < > means. tostring()

Encoding input for TMs Payoff: problems we care about can be reframed as languages of strings e.g. "Recognize whether a string is a palindrome." { w w in {0,1}* and w = w R } e.g. "Recognize Pythagorean triples." { <a,b,c> a,b,c integers and a 2 + b 2 = c 2 } e.g. "Check whether a string is accepted by a DFA." { <B,w> B is a DFA over Σ, w in Σ*, and w is in L(B) } e.g. "Check whether the language of a PDA is infinite." { <A> A is a PDA and L(A) is infinite}

Computational problems A computational problem is decidable iff the language encoding the problem instances is decidable

Computational problems Sample computational problems and their encodings: A DFA "Check whether a string is accepted by a DFA." { <B,w> B is a DFA over Σ, w in Σ*, and w is in L(B) } E DFA "Check whether the language of a DFA is empty." { <A> A is a DFA over Σ, L(A) is empty } EQ DFA "Check whether the languages of two DFA are equal." { <A, B> A and B are DFA over Σ, L(A) = L(B)} FACT: all of these problems are decidable!

Proving decidability Claim: A DFA is decidable Proof: WTS that { <B,w> B is a DFA over Σ, w in Σ*, and w is in L(B) } is decidable. Step 1: construction How would you check if w is in L(B)?

Proving decidability What kind of construction is this? A. Formal definition of TM B. Implementation-level description of TM Claim: A DFA is decidablec. High-level description of TM Proof: WTS that { <B,w> D. I B don't is a know. DFA over Σ, w in Σ*, and w is in L(B) } is decidable. Step 1: construction Define TM M by: M 1 = "On input <B,w> 1. Check whether B is a valid encoding of a DFA and w is a valid input for B. If not, reject. 2. Simulate running B on w (by keeping track of states in B, transition function of B, etc.) 3. When the simulation ends, by finishing to process all of w, check current state of B: if it is final, accept; if it is not, reject."

Proving decidability Step 1: construction Define TM M by M 1 = "On input <B,w> 1. Check whether B is a valid encoding of a DFA and w is a valid input for B. If not, reject. 2. Simulate running B on w (by keeping track of states in B, transition function of B, etc.) 3. When the simulation ends, by finishing to process all of w, check current state of B: if it is final, accept; if it is not, reject." Step 2: correctness proof WTS (1) L(M 1 ) = A DFA and (2) M 1 is a decider.

Proving decidability Claim: E DFA is decidable Proof: WTS that { <A> A is a DFA over Σ, L(A) is empty } is decidable. Idea: give high-level description Step 1: construction What condition distinguishes between DFA that accept *some* string and those that don't accept *any*? A. <A> is in E DFA iff A's initial state is accepting. B. <A> is in E DFA iff A' set of accepting states is empty. C. <A> is in E DFA iff A is the empty set. D. None of the above. E. I don't know.

Proving decidability Claim: E DFA is decidable Proof: WTS that { <A> A is a DFA over Σ, L(A) is empty } is decidable. Idea: give high-level description Step 1: construction Breadth first search in transition diagram to look for path from state state to an accepting state What condition distinguishes between DFA that accept *some* string and those that don't accept *any*?

Proving decidability Claim: E DFA is decidable Proof: WTS that { <A> A is a DFA over Σ, L(A) is empty } is decidable. Idea: give high-level description Step 1: construction Define TM M 2 by: M 2 = "On input <A>: 1. Check whether A is a valid encoding of a DFA; if not, reject. 2. Mark the start state of A. 3. Repeat until no new states get marked: i. Loop over states of A and mark any unmarked state that has an incoming edge from a marked state. 4. If no final state of A is marked, accept; otherwise, reject.

Proving decidability M will mark A. all the states of the DFA A B. all the states of the DFA A that are reachable from the start state Step 1: construction Define TM M 2 by: M 2 = "On C. some input states <A>: in the DFA more than once D. I don't know. 1. Check whether A is a valid encoding of a DFA; if not, reject. 2. Mark the state state of A. 3. Repeat until no new states get marked: i. Loop over states of A and mark any unmarked state that has an incoming edge from a marked state. 4. If no final state of A is marked, accept; otherwise, reject. Step 2: correctness proof WTS (1) L(M 2 ) = E DFA and (2) M 2 is a decider.

Proving decidability Claim: EQ DFA is decidable Proof: WTS that { <A, B> A, B are DFA over Σ, L(A) = L(B) } is decidable. Idea: give high-level description Step 1: construction Will we be able to simulate A and B? What does set equality mean? Can we use our previous work?

Proving decidability Claim: EQ DFA is decidable Proof: WTS that { <A, B> A, B are DFA over Σ, L(A) = L(B) } is decidable. Idea: give high-level description Step 1: construction Will we be able to simulate A and B? What does set equality mean? Can we use our previous work?

Proving decidability Claim: EQ DFA is decidable Proof: WTS that { <A, B> A, B are DFA over Σ, L(A) = L(B) } is decidable. Idea: give high-level description Step 1: construction Very high-level: Build new DFA recognizing symmetric difference of A, B. Check if this set is empty.

Proving decidability Claim: EQ DFA is decidable Proof: WTS that { <A, B> A, B are DFA over Σ, L(A) = L(B) } is decidable. Idea: give high-level description Step 1: construction Define TM M 3 by: M 3 = "On input <A,B>: 1. Check whether A,B are valid encodings of DFA; if not, reject. 2. Construct a new DFA, D, from A,B using algorithms for complementing, taking unions of regular languages such that L(D) = symmetric difference of A and B. 3. Run machine M 2 on <D>. 4. If it accepts, accept; if it rejects, reject."

Proving decidability Step 1: construction Define TM M 3 by: M 3 = "On input <A,B>: 1. Check whether A,B are valid encodings of DFA; if not, reject. 2. Construct a new DFA, D, from A,B using algorithms for complementing, taking unions of regular languages such that L(D) = symmetric difference of A and B. 3. Run machine M 2 on <D>. 4. If it accepts, accept; if it rejects, reject." Step 2: correctness proof WTS (1) L(M 3 ) = EQ DFA and (2) M 3 is a decider.

Techniques Subroutines: can use decision procedures of decidable problems as subroutines in other algorithms A DFA E DFA EQ DFA Constructions: can use algorithms for constructions as subroutines in other algorithms Converting DFA to DFA recognizing complement (or Kleene star). Converting two DFA/NFA to one recognizing union (or intersection, concatenation). Converting NFA to equivalent DFA. Converting regular expression to equivalent NFA. Converting DFA to equivalent regular expression.

Regular Context- Free Decidable Turing- Recognizable

Review: Closure Theorem: The class of recognizable languages over fixed alphabet Σ is closed under union. Proof: Let L 1 and L 2 be languages and suppose M 1 and M 2 are TMs deciding these languages. Construct the TM M as "On input w, 1. Run M 1 on input w. If M 1 accepts w, accept. Otherwise, go to 2. 2. Run M 2 on input w. If M 2 accepts w, accept. Otherwise, reject." Correctness of construction: WTS L(M) = L 1 U L 2

Review: Closure Theorem: The class of recognizable languages over fixed alphabet Σ is closed under union. Proof: Let L 1 and L 2 be languages and suppose M 1 and M 2 are TMs deciding these languages. Construct the TM M as "On input w, 1. Run M 1 in parallel with M 2 on input w. 2. If either accepts, accept. If both reject, reject. Correctness of construction: WTS L(M) = L 1 U L 2

Review: Closure Run in parallel? 1. Nondeterministically pick either M 1 or M 2 to run. 2. For integer i=1, i. Run M 1 on w for i many steps. ii. Run M 2 on w for i many steps. iii. Increment i.

Review: Closure Theorem: The class of recognizable languages over fixed alphabet Σ is closed under concatenation. Proof: Let L 1 and L 2 be languages and suppose M 1 and M 2 are TMs recognizing these languages. " Correctness of construction: WTS L(M) = L 1 L 2

Review: Closure Theorem: The class of recognizable languages over fixed alphabet Σ is closed under concatenation. Proof: Let L 1 and L 2 be languages and suppose M 1 and M 2 are TMs recognizing these languages. To build nondeterministic machine N: On input w: 1. Read w and nondeterministically guess a division w = xy. 2. Run M 1 on input x. If it rejects, reject. If it accepts, go to next step. 3. Run M 2 on input y. If it rejects, reject. If it accepts, accept." Correctness of construction: WTS L(N) = L 1 L 2

Review: Closure Theorem: The class of recognizable languages over fixed alphabet Σ is closed under concatenation. Proof: Let L 1 and L 2 be languages and suppose M 1 and M 2 are TMs recognizing these languages. To build deterministic machine M: On input w: 1. For each positive integer value of i: i. For each split w = xy a. Run M 1 on input x for i steps. If it rejects, go to next split. If it accepts, go to step b. b. Run M 2 on input y for i steps. If it rejects, go to next split. If it accepts, accept." c. If none of the splits accepted after i steps of the computation, incrememnt i. Correctness of construction: WTS L(M) = L 1 L 2

Closure properties Closed under Turingrecognizable Turingdecidable CFL Regular Union Intersection Complement Star Concatenation

Review: CFG Design a CFG for L = { w in {0,1}* w contains at least three 1s} What's the shortest string? How do you build onto strings?

Review: CFG Design a CFG for L = { w in {0,1}* w contains at least three 1s} S guarantee that there are 3 1s R pad between those 1s with any string

Review: CFG Design a CFG for L = { w in {0,1}* w contains at least three 1s} S R1R1R1R R 0R 1R ε Formal definition?

Review: CFG What's the language of the CFG G = ( {S, A, B, C}, {a,b,c}, R, S ) with R S ABC A aa ε B bb ε C cc ε

Review: PDA Give informal English description and state diagram for PDA that recognizes L = { w in {0,1}* w has more 0s than 1s}

Review: PDA Give informal English description and state diagram for PDA that recognizes L = { w in {0,1}* w has more 0s than 1s} Use stack to record "excess" of one bit or another Description: 1. If the input is the empty string, reject. 2. If the stack is empty or if the top symbol matches current input symbol, push input symbol to stack. 3. Otherwise, pop symbol from stack. 4. When finish reading the input: if top of stack is 0, accept; otherwise, reject.