Theory of Computation and Formal Languages Part of



























- Slides: 27

Theory of Computation and Formal Languages Part of the materials are from Courtesy of Prof. Peter J. Downey Department of Computer Science, University of Arizona Theory of Computation, NTUEE

Theory of Computation Lecture 01 Introduction Theory of Computation, NTUEE

Theory of Computation: areas • Formal Language Theory n n n language = set of sentences (strings) grammar = rules for generating strings production/deduction systems capabilities & limitations application: programming language specification • Automata Theory (Abstract Machines) n n models for the computing process with various resources characterize ``computable” capabilities & limitations application: parsing algorithms • Complexity Theory n n inherent difficulty of problems (upper and lower bounds) time/space resources intractable or unsolvable problems application: algorithm design Theory of Computation, NTUEE 3

Major Themes • Study models for n n n problems machines languages • Classify n n machines by their use of memory grammars and languages by type languages by class hierarchies problems by their use of resources (time, space, …) • Develop relationships between models n n n reduce solution of one problem to solution of another simulate one machine by another characterize grammar type by machine recognizer Theory of Computation, NTUEE 4

Describing Problems • Problems described by functions n n functions assign ouputs to inputs described by tables, formulae, circuits, math logic, algorithms Example: TRAVELLING SALESPERSON Problem Input: n(n-1)/2 distances between n cities Output: order to visit cities that gives shortest tour (or length of tour) • Problems described by languages n n n ``yes/no’’ problems or decision problems a language represents a problem or question input strings in the language: answer is ``yes’’; else ``no” Example: HALTING Problem Input: a string w and a Turing Machine M Output: ``yes” if ; ``no” otherwise u equivalent to asking if string where Theory of Computation, NTUEE 5

Types of Machines • Logic circuit memoryless; values combined using gates s c Circuit size = 5 n Circuit depth = 3 x Theory of Computation, NTUEE y z 6

Types of Machines (cont. ) • Finite-state automaton (FSA) n n bounded number of memory states step: input, current state determines next state & output a 0 Mod 3 counter state/ouput (Moore) machine 1 a 2 a • models programs with a finite number of bounded registers • reducible to 0 registers b Theory of Computation, NTUEE 7

Types of Machines (cont. ) • Pushdown Automaton (PDA) n finite control and a single unbounded stack a, A/AA b, A/ a, $/A$ b, A/ g #, $/ models finite program + one unbounded stack of bounded registers top $ b Theory of Computation, NTUEE 8

Types of Machines (cont. ) • Pushdown Automaton (PDA) finite control and a single unbounded stack n a, A/AA b, A/ a, $/A$ b, A/ g #, $/ models finite program + one unbounded stack of bounded registers aaabbb# A $ A A A A $ $ $ Theory of Computation, NTUEE $ accepting 9

Types of Machines (cont. ) • Pushdown Automaton (PDA) finite control and a single unbounded stack n a, A/AA b, A/ a, $/A$ b, A/ g #, $/ models finite program + one unbounded stack of bounded registers aaabbbb# A $ ? A A A A $ $ $ Theory of Computation, NTUEE rejecting $ 10

Types of Machines (cont. ) • Pushdown Automaton (PDA) finite control and a single unbounded stack n a, A/AA b, A/ a, $/A$ b, A/ g #, $/ models finite program + one unbounded stack of bounded registers aaabb# A $ A A A A $ $ $ Theory of Computation, NTUEE ? rejecting 11

Types of Machines (cont. ) • Random access machine (RAM) finite program and an unbounded, addressable random access memory of ``registers” n models general programs n u unbounded # of bounded registers Example: 4 3 2 1 0 b Theory of Computation, NTUEE 12

Types of Machines (cont. ) • Turing Machine (TM) n n n finite control & tape of bounded cells unbounded in # to R current state, cell scanned determine next state & overprint symbol control writes over symbol in cell and moves head 1 cell L or R models simple ``sequential’’ memory; no addressability fixed amount of information (b) per cell b Finitestate control Theory of Computation, NTUEE 13

How Machines are Used • To specify functions or sets n Transducer - maps string to string w n Acceptor - ``recognizes” or ``accepts’’ a set of strings w n n f(w) M M yes no M accepts strings which cause it to enter a final state Generator - ``generates” a set of strings M n Theory of Computation, NTUEE f(w) M generates all values generated during computation 14

How Machines are Used The equivalence between acceptor and generator • Using an acceptor to implement a generator for wi=w 0, w 1, w 2, w 3, …, do wi Acceptor yes print wi no #include “acceptor. h” generator() { for wi=w 0, w 1, w 2, w 3, …, do if accept(wi) print(wi); } Theory of Computation, NTUEE 15

How Machines are Used The equivalence between acceptor and generator • Using a generator to implement an acceptor w>wi Generator one wi at at time w=wi w<wi return “yes” return “no” #include “generator. h” acceptor(w) { while (wi=generator) null, do if w=wi, return “yes”; else if w<wi, return “no”; } Theory of Computation, NTUEE 16

Types of Language • A language is a set of strings over an alphabet • Grammars are rules for generating a set of strings • Machines can accept languages (sets) Theory of Computation, NTUEE 17

Types of Language (cont. ) • Languages can represent complex ``problems” Example: Traveling Salesperson Language (TSL) strings describe instances of TSP having tours of length k here is one string in TSL when n=4 : 4 2 2 3 3 1 3 Theory of Computation, NTUEE 2 4 3 Why? cities visited in order 1, 4, 2, 3, 1 tour distance = 10 18

Types of Language (cont. ) The equivalence of language recogintion and problem solving • An algorithm is known that will accept length n strings in TSL in time exponential in n -- BUT none known for polynomial time • TSL is an NP-complete language: n NP is an acronym for recognizable in nondeterministic polynomial time n NP-complete languages are ``maximally hard” among all in NP n the best known recognition algorithms need time exponential in n n all NP-complete languages either require exponenital time OR can be done efficiently in poly-time, but we do not (yet) know which! n we will use reduction to show that a language is NP-complete; major subject later on Theory of Computation, NTUEE 19

Languages: Characterize Grammar by Machine Language Grammar Automaton Computably Enumerable (c. e. ) or Recursively Enumerable (r. e. ) type 0 (unrestricted) � TM Context-Free (CFL) type 2 A CFG Regular (Reg) = strict inclusion = 2 -way conversion algorithm Theory of Computation, NTUEE (det. or non-det. ) non-det. PDA type 3 FSA A a. B A a right-linear (det. or non-det. ) “Chomsky Hierarchy” 20

Classifying Problems by Resources • What is the smallest size circuit (fewest gates) to add two binary numbers? • What is the smallest depth circuit for binary addition? (low depth fast) • can a FSA be used to recognize all binary strings with = numbers of 1 s & 0 s? Must a stronger model be used? • How quickly can we determine if strings of length n are in TSL? • How much space is needed to decide if boolean formulae of length n are satisfiable? Theory of Computation, NTUEE 21

Relationships between problems Reduction • the most powerful technique available to compare the complexity of two problems • reducing the solution of problem A to the solution of problem B A is no harder than B (written A B ) n The translation procedure should be no harder than the complexity of A. Example: squaring multiplication: suppose we have an algorithm mult(x, y) that will multiply two integers. Then square(x) = mult(x, x) [trivial reduction] Theory of Computation, NTUEE 22

Relationships between problems Reduction • the most powerful technique available to compare the complexity of two problems • reducing the solution of problem A to the solution of problem B A is no harder than B (written A B ) n The translation procedure should be no harder than the complexity of A. Example: 2 -PARTITION MAKESPAN SCHEDULING 2 -PARTITION: Given a set H of natural numbers, is there a subset H’ of H such that a (H-H’) a = a H’a’ ? MAKESPAN SCHEDULING: Given n processor and m tasks with execution time c 1, c 2, …, cm, find a shortest schedule of executing these m tasks on this n processors. Both problems are NP-complete! Theory of Computation, NTUEE 23

Relationships between problems Reduction • the most powerful technique available to compare the complexity of two problems • reducing the solution of problem A to the solution of problem B A is no harder than B (written A B ) n The translation procedure should be no harder than the complexity of A. Example: matrix-mult matrix-inversion = A, B embed Theory of Computation, NTUEE invert matrix pick A*B 24

Obtaining Results • Use definitions, theorems and lemmas, with proofs • Proofs use construction, induction, reduction, contradiction n Construction: design an algorithm for a problem, or to build a machine from a grammar, etc. n Induction: a base case and an induction step imply a conclusion about the general case. Main tool for showing algorithms or constructions are correct. n Reduction: solve a new problem by using the solution to an old problem + some additional operations or transformations n Contradiction: make an assumption, show that an absurd conclusion follows; conclude the negation of the assumption holds (“reductio ad absurdum”) Theory of Computation, NTUEE 25

Class of all languages Reg CF CS L le b a d i c e le D b era um n y. E l p m o C Theory of Computation, NTUEE b a t u le b era m nu E ly tab u p m No o n-C 26

Summary: Theory of Computation • Models of the computing process n n n circuits finite state automata pushdown automata Turing machines capabilities and limitations • Notion of ``effectively computable procedure’’ n n n universality of the notion Church’s Thesis what is algorithmically computable • Limitations of the algorithmic process n unsolvability (undecidability) & reducibility • Inherent complexity of computational problems n n upper and lower bounds: classification by resource use NP-completeness & reducibility Theory of Computation, NTUEE 27
Types of languages in theory of computation
Formal languages and automata theory tutorial
Automata theory tutorial
Csc3130
Automata theory tutorial
Formal language
An introduction to formal languages and automata
Union set operation
Theory of computation
Transition graph
Theory of computation
Theory of computation
Finite automata calculator
Is etm recognizable
Time hierarchy theorem proof
Anbncn pda
Theory of computation quiz
Theory of computation
Dfa to nfa
The theory of computation
Uva lookup computing id
Formal relational query languages
Formal relational query languages
Grouping in relational algebra
Similarities of formal and non formal education
Unit 1 formal informal and non formal education
Difference between als and formal education
Wtax compensation table