MA/CSSE 474 Theory of Computation Computation FSM Intro.

Slides:



Advertisements
Similar presentations
Turing Machines Memory = an infinitely long tape Persistent storage A read/write tape head that can move around the tape Initially, the tape contains only.
Advertisements

Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
The Big Picture Chapter 3. We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear.
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
Finite State Machines Chapter 5. Languages and Machines.
CMPS 3223 Theory of Computation
Deterministic Finite State Machines Chapter 5. Languages and Machines 2.
TM Design Universal TM MA/CSSE 474 Theory of Computation.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
Pushdown Automata Part I: PDAs Chapter Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2)
MA/CSSE 474 Theory of Computation Enumerability Reduction.
MA/CSSE 474 Theory of Computation Decision Problems DFSMs.
Turing Machines Chapter 17. Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing.
TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
Languages and Strings Chapter 2.
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
The Big Picture Chapter 3.
The Big Picture Chapter 3. A decision problem is simply a problem for which the answer is yes or no (True or False). A decision procedure answers a decision.
Nondeterministic Finite State Machines Chapter 5.
Finite State Machines Chapter 5. Languages and Machines.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
MA/CSSE 474 Theory of Computation Languages, prefixes, sets, cardinality, functions.
MA/CSSE 474 Theory of Computation Decision Problems, Continued DFSMs.
Chapters 11 and 12 Decision Problems and Undecidability.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesTuring.
Decidability and Undecidability Proofs
Part VI NP-Hardness.
CSE 105 theory of computation
MA/CSSE 474 Decision Problems Languages, Machines, Computation
Turing Machines Chapter 17.
Languages, prefixes, sets, cardinality, functions
Pumping Lemma Revisited
Pushdown Automata.
Pushdown Automata.
(Universal Turing Machine)
CSE 105 theory of computation
Turing Machines 2nd 2017 Lecture 9.
MA/CSSE 474 Decision Problems about Regular Languages
CSE 105 theory of computation
Turing Machines Acceptors; Enumerators
Summary.
Turing Machines Chapter 17.
CSE 105 theory of computation
How Hard Can It Be?.
Decidable Languages Costas Busch - LSU.
CS21 Decidability and Tractability
MA/CSSE 474 Theory of Computation
Languages, prefixes, sets, cardinality, functions
MA/CSSE 474 Theory of Computation
Decidability and Tractability
MA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation Nondeterminism NFSMs.
More on showing L non-regular
CSE 105 theory of computation
CSE 105 theory of computation
Instructor: Aaron Roth
CSE 105 theory of computation
MA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation
More About Nondeterminism
MA/CSSE 474 Theory of Computation
Computation Chapter 4.
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

MA/CSSE 474 Theory of Computation Computation FSM Intro

Trying Another PDA A PDA to accept strings of the form: AnBnCn = {anbncn : n  0} We’ll see later that it is impossible. Q1

Turing Machines A read/write head and a tape that is infinite in both directions. Based on current state and symbol it sees on the tape, it writes a symbol (possibly the same one) to the tape and moves one position left or right. If it reaches an accepting state or rejecting state, it halts. The (finite) input string is originally written consecutively on a portion of the tape; the rest is initially blank, but the read/write head can write things on any square. At any given time, only a finite part of the tape is non-blank. The head starts at the square to the left of the first input symbol.

Turing Machines A Turing Machine to accept AnBnCn: Q2

Decidable and Semidecidable Languages A language L is decidable iff there exists a Turing machine M that halts on all inputs, accepts all strings that are in L, and rejects all strings that are not in L. In other words, M can always say yes or no, as appropriate.

Decidable and Semidecidable Languages A language L is semidecidable iff there exists a Turing machine M that accepts all strings that are in L and does not accept any string that is not in L. Given a string that is not in L, M may reject or it may loop forever. M can always recognize a string in L and say yes, but it may not know when it should give up looking for a solution and say no. A language L is undecidable iff it is not semidecidable. Q3

Languages and Machines Rule of Least Power: “Use the least powerful language suitable for expressing information, constraints or programs on the World-wide web.” --Tim Berners-Lee and Noah Mendelsohn(2006)

Some "Canonical" Languages AnBn = {anbn : n >= 0} Bal = { strings of balanced parentheses} WW = {ww : w  *} PalEven {wwR : w  *} AnBnCn = {anbncn : n >= 0} HPALL = {<T> : T is a Turing machine that eventually halts, no matter what input it is given} PRIMES = {w : w is the binary encoding of a prime integer} Go really fast here

Nondeterminism A nondeterministic machine in a given state, looking at a given symbol (and with a given symbol on top of the stack if it is a PDA), has a choice of multiple possible moves that it can make. If there is a move that leads toward acceptance, it makes that move.

Nondeterminism Given a string in {a, b}*, is it in PalEven = { wwR : w  {a,b}*} ? PDA Choice: Continue pushing, or start popping? This language can be accepted by a nondeterministic PDA but not by any deterministic one.

Nondeterministic value-added? Ability to recognize additional languages? FSM: no PDA : yes TM: no Ease of designing a machine for a particular language Yes in all cases We will prove these later

Nondeterministic Computation First case: Each action will return True, return False, or run forever. If any of the actions returns TRUE, choose returns true. If all of the actions return FALSE, choose returns FALSE. If none of the actions return TRUE, and some do not halt, choose does not halt. 1. choose (action 1;; action 2; … action n ) 2. choose(x from S: P(x)) First case: Each action will return True, return False, or run forever. If any of the actions returns TRUE, choose returns true. If all of the actions return FALSE, choose returns FALSE. If none of the actions return True, and some do not halt, choose does not halt. Second case: S may be finite or infinite (with a generator(enumerator)). If P returns true on some x, so does Choose If it can be determined that P(x) is false for all x in P, return False. Otherwise, fail to halt. Second case: S may be finite, or infinite with a generator (enumerator). If P returns true on some x, so does Choose If it can be determined that P(x) is false for all x in P, return False. Otherwise, fail to halt.

Implementing Nondeterminism before the first choice choose makes first call to choose first call to choose choice 1 choice 2 second call to choose second call to choose choice 1 choice 2

Sample Decision Problems Example: Given two strings s and t, does s occur anywhere as a substring of t? It's easy to see that this is decidable. A decision problem is a problem that has a yes/no answer for each instance. A decision problem may be decidable, undecidable, or semidecidable. A decision procedure is an algorithm to solve a decision problem. Must always halt and return an answer. Q4

Sample Decision Problems Prime Fermat Numbers Fermat numbers: Fn = + 1, n  0 F0 = 3, F1 = 5, F2 = 17, F3 = 257, F4 = 65,537, F5 = 4,294,967,297 • Are there any prime Fermat numbers less than 1,000,000? • Are there any prime Fermat numbers greater than The first one is clearly decideable: Sketch the algorithm. What about the second one? Why won't the same approach work? But there is a decision procedure for this problem: Return yes Or Return No. One of these is the correct algorithm, but we just don't know which one. Q5

Sample Decision Problems Given a Java program P, is there some input string on which P halts? Given a Java program P, and a value v, is v the shortest input string on which P halts? These turn out not to be decidable.

SAT Decision Problem Given a Boolean (propositional) wff, is it satisfiable? Examples: 1. (P  Q)  Q  P 2. P  R This and next 2 slides hidden because of time shortage in 201220. Pick up later? I unhid for summer.

Nondeterministically Deciding SAT decideSAT(w: Boolean wff) = If there are no variables in w then: Simplify w until it is either True or False. Return w. Else: Find P, the first variable in w. /* Let w/P/x mean the wff w with every instance of P replaced by x. */ Return choose (decideSAT(w/P/True);; decideSAT(w/P/False)).

A Tractability Hierarchy P NP PSPACE P  NP  PSPACE P contains those languages that can be decided in time that grows as some polynomial function of the length of the input string NP contains those languages that can be decided by a nondeterministic machine (one that can conduct a search by correctly guessing which move to make) with the property that the amount of time required to explore one sequence of guesses ( one path) grows as some polynomial function of the length of the input PSPACE contains those languages that can be decided by a machine whose space requirement grows as some polynomial function of the length of the input.

Functions on Languages Functions whose domains and ranges are languages maxstring(L) = {w  L: z  * (z    wz  L)}. Examples: • maxstring( AnBn ) • maxstring( {a}* ) Let INF be the set of infinite languages. Let FIN be the set of finite languages. Are the language classes FIN and INF closed under maxstring? maxstring(AnBn) = AnBn - { } maxstring(a*) =  FIN, yes, because every subset of a finite set is finite. INF, no, see {a}* example Q6

Functions on Languages chop(L) = {w : xL (x = x1cx2, x1  L*, x2  L*, c  L, |x1| = |x2|, and w = x1x2)}. What is chop(AnBn)? What is chop(AnBnCn)? Are FIN and INF closed under chop? Empty set {a2n+1b2nc2n+1} Yes (FIN) No (INF) If we don't have much time left, we'll skip this in class

Functions on Languages firstchars(L) = {w : yL (y = cx  c  L  x  L*  w  {c}*)}. . What is firstchars(AnBn)? What is firstchars({a, b}*)? Are FIN and INF closed under firstchars? firstchars(AnBn) = {a}* firstchars({a, b}*) = {a}*  {b}* FIN, no. firstchars({a}) = {a}* INF, yes. If we don't have much time left, we'll skip this in class

Representing Languages as Machines Compute union using descriptions like: {w  {a, b}* : w has odd length} {w  {a, b}* : all a’s in w precede all b’s} Much easier to do union, concatenation, etc. with machines.

Finite State Machine Intro

Languages and Machines

Regular Languages Regular Language Regular Expression Represents Regular Language Regular Expression Accepts Finite State Machine

Finite State Machines An (ancient) Soda Machine FSM to accept $.25 in change: (Note that a couple of the dime transitions are incorrect, but you get the idea).

Another FSM Example A C B D But it is more complicated, because time is also an input. But the use of the buttons can be modeled as an FSM. B D

Definition of a DFSM The D is for Deterministic M = (K, , , s, A), where: K is a finite set of states  is a (finite) alphabet s  K is the initial state (a.k.a. start state) A  K is the set of accepting states : (K  )  K is the transition function Sometimes we will put an M subscript on K, , , s, or A (for example, sM), to indicate that this component is part of machine M.

Acceptance by a DFSM Informally, M accepts a string w iff M winds up in some element of A after it has finished reading w. The language accepted by M, denoted L(M), is the set of all strings accepted by M. But we need more formal notations if we want to prove things about machines and languages.

Configurations of a DFSM A configuration of a DFSM M is an element of: K  * It captures the two things that affect M’s future behavior: • its current state • the remaining input to be read. The initial configuration of a DFSM M, on input w, is: (sM, w)

The "Yields" Relations 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* |-M * is the reflexive, transitive closure of |-M . Q7

Computations Using FSMs 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)

An Example Computation An FSM M that accepts decimal representations of odd integers: even odd even q0 q1 odd On input 235, the configurations are: (q0, 235) |-M (q0, 35) |-M Thus (q0, 235) |-M* (q1, )

Accepting and Rejecting A DFSM M accepts a string w iff: (sM, w) |-M* (q, ), for some q  AM A DFSM M rejects a string w iff: (sM, w) |-M* (q, ), for some q  AM The language accepted by M, denoted L(M), is the set of all strings accepted by M. Theorem: Every DFSM M, in configuration (q, w), halts in |w| steps. 201020: We got to this slide but not to the quiz question/proof. If time, have them do FSM diagram for "divisible by 3" Base case: If w is , it halts in 0 steps. Assume true for strings of length n and show for strings of length n+1. Let w  *, w   |w| = n+1 for some n  ℕ. Then w is ax for some a , x*, |x| = n. Let q' be (q, a). Then (q,w) |-M (q', x) By induction, from configuration (q', x), M halts in n steps. So, starting from the original configuration, M halts in n+1 steps. Q8-10