Functions on languages:

Similar documents
THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

MA/CSSE 474 Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

DM17. Beregnelighed. Jacob Aae Mikkelsen

MA/CSSE 474 Theory of Computation

Final exam study sheet for CS3719 Turing machines and decidability.

CPSC 421: Tutorial #1

The Unsolvability of the Halting Problem. Chapter 19

Context Free Languages: Decidability of a CFL

Turing Machines. Chapter 17

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

Decidability (What, stuff is unsolvable?)

THEORY OF COMPUTATION

V Honors Theory of Computation

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)

Context-Free and Noncontext-Free Languages

Solution Scoring: SD Reg exp.: a(a

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Foundations of Informatics: a Bridging Course

DD2371 Automata Theory

Computational Models - Lecture 4

Introduction to Turing Machines. Reading: Chapters 8 & 9

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Properties of Context-Free Languages. Closure Properties Decision Properties

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars

Context-Free Languages (Pre Lecture)

UNIT-VIII COMPUTABILITY THEORY

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

1 Acceptance, Rejection, and I/O for Turing Machines

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

The View Over The Horizon

CSE 355 Test 2, Fall 2016

6.8 The Post Correspondence Problem

Theory of Computation (IX) Yijia Chen Fudan University

NPDA, CFG equivalence

This lecture covers Chapter 7 of HMU: Properties of CFLs

Computability and Complexity

Automata and Computability. Solutions to Exercises

Theory Bridge Exam Example Questions

Automata and Computability. Solutions to Exercises

Computational Models Lecture 8 1

Decidability: Church-Turing Thesis

Undecidable Problems and Reducibility

Pushdown Automata. Chapter 12

Introduction to Languages and Computation

CS481F01 Solutions 8

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Pumping Lemma for CFLs

Computational Models Lecture 8 1

CISC4090: Theory of Computation

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

Limits of Computability

Parsing. Context-Free Grammars (CFG) Laura Kallmeyer. Winter 2017/18. Heinrich-Heine-Universität Düsseldorf 1 / 26

Introduction to Theory of Computing

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

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

Further discussion of Turing machines

CS154 Final Examination

Computational Models Lecture 8 1

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

Computability and Complexity

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Lecture 17: Language Recognition

Einführung in die Computerlinguistik

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen

CSE 105 THEORY OF COMPUTATION

PUSHDOWN AUTOMATA (PDA)

Non-emptiness Testing for TMs

Ogden s Lemma for CFLs

Homework 8. a b b a b a b. two-way, read/write

Context Free Languages and Grammars

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

CpSc 421 Final Exam December 15, 2006

4.2 The Halting Problem

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

CS 455/555: Finite automata

1 Showing Recognizability

CS154 Final Examination

Theory of Computation

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

CS481F01 Prelim 2 Solutions

Pushdown Automata: Introduction (2)

Part I: Definitions and Properties

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

Languages. Languages. An Example Grammar. Grammars. Suppose we have an alphabet V. Then we can write:

CS154, Lecture 10: Rice s Theorem, Oracle Machines

Theory of Computation 8 Deterministic Membership Testing

q FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) Spring L. Blum. REVIEW for Midterm 2 TURING MACHINE

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

CP405 Theory of Computation

TURING MAHINES

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

CSE 105 THEORY OF COMPUTATION

Transcription:

MA/CSSE 474 Final Exam Notation and Formulas page Name (turn this in with your exam) Unless specified otherwise, r,s,t,u,v,w,x,y,z are strings over alphabet Σ; while a, b, c, d are individual alphabet symbols. DFSM notation: M= (K, Σ, δ, s, A), where: K is a finite set of states, Σ is a finite alphabet s K is start state, A K is set of accepting states δ: (K Σ) K is the transition function Extend δ's definition to δ: (K Σ*) K by the recursive definition δ(q, ε)=q, δ(q, xa) = δ(δ(q, x), a) M accepts w iff δ(s, w) A. L(M) = {w Σ* : δ(s, w) A} Alternate notation: (q, w) is a configuration of M. (current state, remaining input) The yields-in-one-step relation: -M : (q, w) -M (q', w') iff w = a w' for some symbol a Σ, and δ (q, a) = q' The yields-in-zero-or-more-steps relation: -M* is the reflexive, transitive closure of -M. A computation by M is a finite sequence of configurations C0, C1,, Cn for some n 0 such that: C0 is an initial configuration, Cn is of the form (q, ε), for some state q KM, i {0, 1,, n-1} (Ci -M Ci+1) M accepts w iff the state that is part of the last step in w is in A. A language L is regular if L=L(M) for some DFSM M. In an NDFSM, the function δ is replaced by the relation Δ: Δ (K (Σ {ε})) K Equivalent strings relative to a language: Given a language L, two strings w and x in ΣL* are indistinguishable with respect to L, written w Lx, iff z Σ* (xz L iff yz L). [x] is a notation for "the equivalence class that contains the string x". The construction of a minimal-state DSFM based on L: M = (K, Σ, δ, s, A), where K contains n states, one for each equivalence class of L. s = [ε], the equivalence class containing ε under L, A = {[x] : x L}, δ([x], a) = [xa]. Enumerator (generator) for a language: when it is asked, enumerator gives us the next element of the language. Any given element of the language will appear within a finite amount of time. It is allowed that some may appear multiple times. Recognizer: Given a string s, recognizer halts and accepts s if s is in the language. If not, recognizer either halts and rejects s or keeps running forever. This is a semidecision procedure. If recognizer is guaranteed to always halt and (accept or reject) no matter what string it is given as input, it is a decision procedure. The regular expressions over an alphabet Σ are the strings that can be obtained as follows: 1. is a regular expression. 2. ε is a regular expression. Functions on languages: 3. Every element of Σ is a regular expression. firstchars(l) = {w : y L (y = cx, c Σ L, x Σ L*, and w c*)} 4. If α, β are regular expressions, then so is αβ. chop(l) = {w : x L (x = x 1cx 2, x 1 Σ L*, x 2 Σ L*, c Σ L x 1 = x 2, and w = x 1x 2)} 5. If α, β are regular expressions, then so is α β. maxstring(l) = {w: w L, z Σ* (z ε wz L)} 6. If α is a regular expression, then so is α*. mix(l) = {w: x, y, z (x L, x = yz, y = z, w = yz R )} 7. α is a regular expression, then so is α +. middle(l) = {x: y, z Σ* (yxz L)} 8. If α is a regular expression, then so is (α). alt(l) = {x: y,n (y L, y = n, n > 0, y = a 1 an, i n (ai Σ), and x = a 1a 3a 5 ak, where k = (if n is even then n-1 else n))} Recursive formula for constructing a regular expression from a DFSM: rijk is rij(k-1) rik(k-1)(rkk(k-1))*rkj(k-1) The set of regular languages is closed under complement, intersection, union, set difference, concatenation, Kleene * and +, reverse Pumping Theorem and its contrapositive: Formally, if L is regular, then k 1 such that ( strings w L, ( w k ( x, y, z (w = xyz, xy k, y ε, and q 0 (xy q z is in L))))) The contrapositive form: ( k 1 ( a string w L ( w k and ( x, y, z ( (w = xyz xy k y ε) q 0 (xy q z is not in L) ) ) ) )) L is not regular Reg. exp. operator precedence (High to Low): parenthesized expressions, * and +, concatenation, union

CFG definition: G = (V, Σ, R, S) (vocabulary, terminals, rules, start symbol) Derivation and language definition One derivation step: x G y iff α,β,γ V*, A N ((x = αaβ) (A γ R) (y = α γ β)) G* is the reflexive, transitive closure of G The language defined by a grammar: L(G) = {w Σ* : S G* w} L is context-free if there is a context-free grammar G such that L = L(G). A parse tree, derived from a grammar G = (V, Σ, R, S), is a rooted, ordered tree in which: Every leaf node is labeled with an element of Σ {ε}, The root node is labeled S, Every other node is labeled with an element of N, and If m is a non-leaf node labeled X and the (ordered) children of m are labeled x 1, x 2,, x n, then R contains the rule X x 1 x 2, x n. Chomsky Normal Form, in which all rules are of one of the following two forms: X a, where a Σ, or X BC, where B and C are elements of V - Σ. Greibach Normal Form, in which all rules are of the form X a β, where a Σ and β N*. A grammar is ambiguous if some string it generates has two different parse trees Equivalently, two different leftmost derivations, or two different rightmost derivations A CFL is inherently ambiguous if every CFG that generates it is ambiguous. PDA definition: M = (K, Σ, Γ,, s, A), states, input alphabet, tape alphabet, transition relation, start state, accepting states (q 1, cw, γ 1γ) - M (q 2, w, γ 2γ) iff ((q 1, c, γ 1), (q 2, γ 2)). accepting computation of M: (s, w, ε) - M* (q, ε, ε), and q A Top-down PDA from grammar: Production A XYZ becomes (q, ε, A) (q, XYZ) (s, ε, ε) (q, S) [s is the start state of M). A ={q}. For each terminal, (q, a, a) (q, ε) Bottom-up PDA from grammar: The shift transitions: ((p, c, ε), (p, c)), for each c Σ. The reduce transitions: ((p, ε, (s 1s 2 s n.) R ), (p, X)), for each rule X s 1s 2 s n. in G.. The finish-up transition: ((p, ε, S), (q, ε)). A = {q} CFL closure: Union, Concatenation, Kleene Star. Reverse. Intersection with regular language. Not closed under complement, intersection, set difference. We have CFL decision algorithms for membership, emptiness, finiteness. Undecidable questions about CFLs: Is L = Σ*? Is L regular? Is L 1 = L 2? Is L 1 L 2? Is L 1 L 2 =? Is the complement of L context-free? Is L 1 L 2 =? Is L inherently ambiguous? Is G ambiguous? Deterministic PDA M: M contains no pairs of transitions that compete with each other, and whenever M is in an accepting configuration it has no available moves. A language L is deterministic context-free iff L$ can be accepted by some deterministic PDA. Formal TM definition. A deterministic TM M is (K, Σ, Γ, δ, s, H): i) K is a finite set of states; ii) Σ is the input alphabet, which does not contain ; iii) Γ is the tape alphabet, which must contain and have Σ as a subset. iv) s K is the initial state; v) H K is the set of halting states; vi) δ is the transition function: (1) (K - H) Γ to K Γ {, } non-halting tape state tape direction to move state char char (R or L) Yields. (q 1, w 1) - M (q 2, w 2) iff (q 2, w 2) is derivable, via δ, in one step. - M* is the reflexive, transitive closure of - M. Configuration C 1 yields configuration C 2 if: C 1 - M* C 2. contrapositive of CFG Pumping Theorem: If k 1 ( a string w L, where w ( u, v, x, y, z ( (w = uvxyz, vy ε, and vxy k) implies ( q 0 (uv q xy q z is not in L))))), then L is not context-free A path through M is a sequence of configurations C 0, C 1,, C n for some n 0 such that C 0 is the init config and C 0 - M C 1 - M C 2 - M - M C n. A computation by M is a path that halts. If a computation is of length n (has n steps), we write: C 0 - M n C n 2) TMs as language recognizers. Let M = (K, Σ, Γ, δ, s, {y, n}). a) M accepts a string w iff (s, qw) - M* (y, w ) for some string w. b) M rejects a string w iff (s, qw) - M* (n, w ) for some string w. c) M decides a language L Σ* iff for any string w Σ*t: i) if w L then M accepts w, and ii) if w L then M rejects w. d) A language L is decidable iff thewre is a TM M that decides it. e) We define the set D to be the set of all decidable languages. f) M semidecides L iff, for any string w Σ M*: i) w L M accepts w ii) w L M does not accept w. M may reject or not halt. g) A language L is semidecidable iff there is a Turing machine that semidecides it. h) We define the set SD to be the set of all semidecidable languages.

Additions since Exam 3: Notice that the TM's 3) TMs can compute functions. Let M = (K, Σ, Γ, δ, s, {h}). a) M(w) = z iff (s, w) -M* (h, z). b) Let Σ Σ be M s output alphabet, and let f be any function from Σ* to Σ *. function computes with strings (Σ* Σ *), not i) M computes f iff, for all w Σ*: directly with numbers. (1) if w is an input on which f is defined, then M(w) = f(w). (2) otherwise M(w) does not halt. c) A function f is recursive or computable iff there is a Turing machine M that computes it and that always halts. d) Computing numeric functions: i) For any positive integer k, valuek(n) returns the nonnegative integer that is encoded, base k, by the string n. ii) TM M computes a function f from N m to N iff, for some k, valuek(m(n1;n2; nm)) = f(valuek(n1), valuek(nm)). 4) An m-tape TM can be simulated by a 2n-track TM, which can be simulated by a single-track machine. 5) Encoding a TM M = (K, Σ, Γ, δ, s, H) as a string <M>: i) Encoding the states: Let i be log2( K ). (1) Number the states from 0 to K -1 in binary (i bits for each state number): (2) The start state, s, is numbered 0; Number the other states in any order. (3) If t is the binary number assigned to state t, then: (a) If t is the halting state y, assign it the string yt. (b) If t is the halting state n, assign it the string nt. (c) If t is the halting state h, assign it the string ht. (a) If t is any other state, assign it the string qt. ii) Encoding the tape alphabet: Let j be log2( Γ ). (1) Number the tape alphabet symbols from 0 to Γ - 1 in binary. (2) The blank symbol is number 0. (3) The other symbols can be numbered in any order iii) Encoding the transitions: (1) (state, input, state, output, direction to move) (2) Example: (q000,a000,q110,a000, ) iv) Encoding s and H (already included in the above) v) A special case of TM encoding (1) One-state machine with no transitions that accepts only ε is encoded as (q0) vi) Encoding other TMs: It is just a list of the machine's transitions: (1) Detailed example on slide vii) Consider the alphabet Σ = {(, ), a, q, y, n, h, 0, 1, comma,, }. The following question is decidable: (1) Given a string w in Σ*, is there a TM M such that w = <M>? 6) We can enumerate all TMs, so that we have the concept of "the ith TM". 7) Specification of U, the Universal Turing Machine (UTM): a) U starts with <M,w> on its input tape, then simulates M's action when it has input w: b) U halts iff M halts on w. c) If M is a deciding or semideciding machine, then: i) If M accepts, U accepts. If M rejects, U rejects. d) If M computes a function, then U(<M, w>) must equal M(w). 8) A language is in SD iff it is Turing enumerable. A language is in D iff it is lexicographically enumerable. In some sense, means "is no harder than" or "is at least as decidable as" 9) D is closed under complement. SD is not; if L SD-D, L SD. H is an example. 10) Problem P1 is reducible to problem P2 (written P1 P2) if there is a Turing-computable 11) function f that finds, for an arbitrary instance I of P1, an instance f(i) of P2, and a) f is defined such that for every instance I of P1, b) I is a yes-instance of P1 if and only if f(i) is a yes-instance of P2. c) So P1 P2 means "if we have a TM that decides P2, then there is a TM that decides P1. 12) A framework for using reduction to show undecidability. To show language L2 undecidable: a) Choose a language L1 that is already known not to be in D, and show that L1 can be reduced to L2. b) Define the reduction R and show that it can be implemented by a TM. c) Describe the composition C of R with Oracle (the purported TM that decides L1). d) Show that C does correctly decide L1 iff Oracle exists. We do this by showing that C is correct. I.e., i) If x L1, then C(x) accepts, and ii) If x L1, then C(x) rejects. 13) Rice's Theorem: If P is a non-trivial (Boolean) property of DS languages, it is undecidable.

Algorithms and decision problems for regular languages Algorithms and decision problems for context-free languages