MA/CSSE 474 Theory of Computation Decision Problems DFSMs.

Slides:



Advertisements
Similar presentations
CMPS 3223 Theory of Computation
Advertisements

Regular Expressions and DFAs COP 3402 (Summer 2014)
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.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
CS5371 Theory of Computation
1 Lecture 2 Topics –Importance of this material Fundamental Limitations –Connecting Problems and Languages Problems –Search, function and decision problems.
MA/CSSE 474 Theory of Computation
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.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
Review Byron Gao. Overview Theory of computation: central areas: Automata, Computability, Complexity Computability: Is the problem solvable? –solvable.
1 CSSE 350 Automata, Formal Languages, and Computability.
TM Design Universal TM MA/CSSE 474 Theory of Computation.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
MA/CSSE 474 Theory of Computation DFSM Canonical Form Proof of NDFSM  DFSM ALGORITHM (as much as we have time for) This version includes the "answers"
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 Functions on Languages, Decision Problems (if time) Logic: Some harder parts.
MA/CSSE 474 Theory of Computation Enumerability Reduction.
Turing Machines Chapter 17. Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
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.
MA/CSSE 474 Theory of Computation Minimizing DFSMs.
Languages and Strings Chapter 2.
Modeling Computation: Finite State Machines without Output
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
The Big Picture Chapter 3.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
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.
Turing Machines Sections 17.6 – The Universal Turing Machine Problem: All our machines so far are hardwired. ENIAC
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,
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
MA/CSSE 474 Theory of Computation Languages, prefixes, sets, cardinality, functions.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
MA/CSSE 474 Theory of Computation Universal Turing Machine Church-Turing Thesis (Winter 2016, these slides were also used for Day 33)
Universal Turing Machine
MA/CSSE 474 Theory of Computation Decision Problems, Continued DFSMs.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
Properties of Regular Languages
MA/CSSE 474 Decision Problems Languages, Machines, Computation
Turing Machines Chapter 17.
Deterministic Finite Automata
(Universal Turing Machine)
The Definition of Algorithm
CSE 105 theory of computation
CSE 105 theory of computation
Quiz questions referenced here are on the Day 3 quiz
Deterministic Finite Automata
Turing Machines Chapter 17.
MA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation Computation FSM Intro.
MA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation Nondeterminism NFSMs.
MA/CSSE 474 Theory of Computation
CSE 105 theory of computation
More About Nondeterminism
CSE 105 theory of computation
Presentation transcript:

MA/CSSE 474 Theory of Computation Decision Problems DFSMs

Your Questions? Friday's class Reading Assignments HW1 solutions HW2 or HW3 Anything else

Some "Canonical" Languages from our textbook A n B n = {a n b n : n >= 0} Bal = { strings of balanced parentheses} WW = {ww : w   *} PalEven {ww R : w   *} A n B n C n = {a n b n c n : n >= 0} HP ALL = { : 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}

Decision Problems

A decision problem is simply a problem for which the answer is yes or no (True or False). A decision procedure answers a decision problem. Examples: Given an integer n, does n have a pair of consecutive integers as factors? The language recognition problem: Given a language L and a string w, is w in L? Our focus in this course Recap - Decision Problems

Recap - The Power of Encoding Anything can be encoded as a string. For example, on a computer everything is encoded as a string of bits. Assume that we have a scheme for encoding objects (integers, for example). is the string encoding of X. is the string encoding of the pair X, Y. Problems that don’t look like decision problems about strings and languages can be recast into new problems that do look like that.

Web Pattern Matching Pattern matching on the web: Problem: Given a search string w and a web document d, do they “match”? In other words, should a search engine, on input w, consider returning d? An instance of the problem: (w, d) The language to be decided: { : d is a candidate match for the string w}

The Halting Problem Does a program always halt? Problem: Given a program p, written in some some standard programming language L, is p guaranteed to halt, no matter what input it is given? An instance of the problem: Does Python program "print(input())" always halt? The language to be decided: HP ALL = {p  L : p halts on all inputs}

Primality Testing Problem: Given a nonnegative integer n, is it prime? An instance of the problem: Is 9 prime? To encode the problem we need a way to encode each instance: We encode each nonnegative integer as a binary string. The language to be decided (2 ways to express it): PRIMES = {w : w is the binary encoding of a prime integer}. Equivalent: PRIMES = { : n is a prime integer}.

Problem: Given an undirected graph G, is it connected? An instance of the problem: Encoding of the problem: Let V be a set of binary numbers, one for each vertex in G. Then we construct  G  as follows: Write |V| as a binary number, Write a list of edges; each pair of binary numbers represents one edge. Separate all such binary numbers by “/”. 101/1/10/1/100/10/101/10/11 The language to be decided: CONNECTED = {w  {0, 1, /}* : w = n 1 /n 2 /…n i, where each n i is a binary string and w encodes a connected graph, as described above}. Graph Connectivity The string below encodes a connected graph, but 110/1/10/1/100/10/101/10/11 Encodes a graph that is not connected. Can you see why?

Problem: Given a protein fragment f and a complete protein molecule p, could f be a fragment from p? Encoding of the problem: Represent each protein molecule or fragment as a sequence of amino acid residues. Assign a letter to each of the 20 possible amino acids. So a protein fragment might be represented as AGHTYWDNR. The language to be decided: { : f could be a fragment from p}. Protein Sequence Alignment

Cast multiplication as language recognition: Problem: Given two nonnegative integers, compute their product. Encoding of the problem: Transform computing into verification. The language to be decided: L = {w of the form: x =, where: is any well-formed integer, and integer 3 = integer 1  integer 2 } 12x9=108  L 12=12  L 12x8=108  L Turning Problems into Language Recognition Problems

Cast sorting as language recognition decision problem: Problem: Given a list of integers, sort it. Encoding of the problem: Transform the sorting problem into one of examining a pair of lists. The language to be decided: L ={w 1 # w 2 :  n  1 (w 1 is of the form, w 2 is of the form, and w 2 contains the same objects as w 1 and w 2 is sorted)} Examples: #  L #  L Turning Problems Into Language Recognition Problems

Casting database querying as decision: Problem: Given a database and a query, execute the query. Encoding of the problem: Transform the query execution problem into evaluating a reply for correctness. The language to be decided: L = {d # q # a: d is an encoding of a database, q is a string representing a query, and a is the correct result of applying q to d} Example: (name, age, phone), (John, 23, ) (Mary, 24, )#(select name age=23)# (John)  L Turning Problems Into Decision Problems

By equivalent we mean that either problem can be reduced to the other. If we have a machine to solve either problem, we can use it to build a machine to solve the other, using only the starting machine and other functions that can be built using machines of equal or lesser power. We will see that eduction does not always preserve efficiency! The Traditional Problems and their Language Formulations are Equivalent

Consider the multiplication example: INTEGERPROD = {w of the form x =, where: is any well-formed integer representation, and integer 3 = integer 1  integer 2 } Given a multiplication procedure, we can build a language recognition decision procedure : Given the language recognition procedure, we can build a multiplication procedure : An Example

Regular Languages Regular Language Regular Expression Finite State Machine Represents Accepts

A real-world FSM Example A D C B

Recap - Definition of a DFSM 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, s M ), to indicate that this component is part of machine M. The D is for Deterministic

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: (s M, w) Where s M is the start state of M.

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. Note that this accomplishes the same thing as the "extended delta function" that we considered on Day 1. Two notations for the same concept.

Computations Using FSMs A computation by M is a finite sequence of configurations C 0, C 1, …, C n for some n  0 such that: C 0 is an initial configuration, C n is of the form (q,  ), for some state q  K M,  i  {0, 1, …, n-1} (C i ⊦ M C i+1 )

An Example Computation A FSM M that accepts decimal representations of odd integers: even odd even q 0 q 1 odd On input 235, the configurations are: (q 0, 235) ⊦ M (q 0, 35) ⊦ M (q 1, 5) ⊦ M (q 1,  ) Thus (q 0, 235) ⊦ M * (q 1,  )

Accepting and Rejecting A DFSM M accepts a string w iff: (s M, w) ⊦ M * (q,  ), for some q  A M A DFSM M rejects a string w iff: (s M, w) ⊦ M * (q,  ), for some q  A M 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 after |w| steps. Thus a DFSM accepts or rejects every string.

Proof of Theorem Theorem: Every DFSM M, in configuration (q, w), halts after |w| steps. Proof: by induction on |w| Base case: If w is , it halts in 0 steps. Induction step: Assume true for strings of length n and show for strings of length n+1. Let w   *, w  . Then | w | = n+1 for some n  ℕ. So w must be ax for some a, x *, | x | = n. Let q' be  (q, a ). By definition of ⊦, (q, w ) ⊦ M (q', x ) By the induction hypothesis, starting from configuration (q', x ), M halts after n steps. Thus, starting from the original configuration, M halts after n+1 steps.

Regular Languages Definition: A language L is regular iff L = L(M) for some DFSM M.

Example L = {w  { a, b }* : every a is immediately followed by a b }. state  input  ab q 0 q1q1 q0q0 q1q1 q2q2 q0q0 q2q2 q2q2 q2q2  can also be represented as a transition table: q 2 is a dead state.

Exercises: Construct DFSMs for L = {w  { 0, 1 }* : w has odd parity}. iI.e. an odd number of 1's. L = {w  { a, b }* : no two consecutive characters are the same}. L = {w  {a, b}* : # a (w) >= # b (w) } L = {w  {a, b}* : ∀ x,y  {a, b}* (w=xy → | # a (x) - # b (x)| <= 2 ) }