1 / 57

Advanced Theory of Computation

Advanced Theory of Computation. Course outlines. Automata theory, formal languages, Turing machines, computability theory and reducibility, computational complexity, determinism, non-determinism, time hierarchy, space hierarchy, NP completeness, selected advanced topics.

reese
Télécharger la présentation

Advanced Theory of Computation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Theory of Computation

  2. Course outlines • Automata theory, formal languages, Turing machines, computability theory and reducibility, computational complexity, determinism, non-determinism, time hierarchy, space hierarchy, NP completeness, selected advanced topics. • Text Books/Reference Books: • Michael Sipser, Introduction to the Theory of Computation, First Edition, 1997, PWS Publishing Company. • Christos Papadimitriou, Computational Complexity, 1994, Addison-Wesley. • John Hopcroft and Jeffrey Ullman, Introduction to Automata Theory, Languages, and Computation, 1979, Addison-Wesley. (or the second edition). • Tao Jiang, Ming Li, and Bala Ravikumar, Formal models and Computability, in Handbook of Computer Science, CRC Press, 1996. • T.H. Cormen, et al., Introduction to Algorithms, MIT Press and McGraw-Hill Book Co., 1990. • Peter Linz, An Introduction to Formal Languages and Automata, ISBN: 0-669-17342-8.

  3. course outline (cont'd) • PART I: Finite Automata and Regular Sets • DFA,NFA,regular expressions and their equivalence • limitation of FAs; • Closure properties of FAs, • Optimization of FAs

  4. course outline (cont'd) • PART II: Pushdown Automata and Context Free Languages • CFGs and CFLs; normal forms of CFG • Limitation of CFG; PDAs and their variations, • closure properties of CFLs • Equivalence of pda and CFGs; deterministic PDAs • parsing (Early or CYK's algorithms) • PART III: Turing Machines and Effective Computability • Turing machine [& its variations] and Equivalence models • Universal TMs • Decidable and undecidable problems (Recursive sets and recursively enumerable sets) • Problems reductions ; Some undecidable problems

  5. Chapter 1 Introduction

  6. Mathematical preliminaries (reviews) • Sets • Relations • Functions • Induction • Basics of Languages • A Language for specifying languages

  7. Sets • Basic structure upon which all other (discrete and continuous ) structures are built. • A set is a collection of objects. • An object is anything of interest, maybe itself a set. • Definition 1. • A set is a collection of objects. • The objects in a set are called the elements or members of the set. • If x is a member of a set S, we say S contains x. • Notation: x Î S vs x Ï S • Ex: In 1,2,3,4,5, the collection of 1,3 5 is a set.

  8. Set description • How to describe a set:? 1. List all its member: • The set of all positive odd integer >10 = ? • The set all decimal digits = ? • The set of all upper case English letters = ? • The set of all nonnegative integers = ? 2. Set builder notation: • P(x) : a property (or a statement or a proposition) about objects. • e.g., P(x) = “ x > 0 and x is odd” • Then {x | P(x) } is the set of objects satisfying property P. • P(3) is true => 3 Î {x | P(x)} • P(2) is false => 2 Ï {x | P(x)}

  9. Set predicates Definition 2. • Two sets S1, S2 are equal iff they have the same elements • S1 = S2 iff"x (x Î S1 <=> x Î S2) • Ex: {1,3,5} = {1,5,3} = {1,1,3,3, 5} • Null set ={} = Æ =def the collection of no objects. • Def 3’: [empty set] for-all x x Ï Æ. • Def 3. [subset] • A Í B iff all elements of A are elements of B. • A Í B <=> for-all x (x Î A => x Î B)). • Def 3’’: A Ì B =def A Í B /\ A ¹ B. • Exercise : Show that: 1. For all set A (Æ Í A) • 2. (A Í B /\ B Í A) <=> (A = B) 3. A Í Æ => A = Æ

  10. Size or cardinality of a set • Def. 4 • | A | = the size(cardinality) of A = # of distinct elements of A. • Ex: • |{1,3,3,5}| = ? • |{}| = ? • | the set of binary digits } | = ? • |N| = ? ; |Z| = ? ; | {2i | i in N} = ? • |R| = ? • Def. 5. • A set A is finite iff |A| is a natural number ; o/w it is infinite. • Two sets are of the same size (cardinality) iff there is a 1-1 & onto mapping between them.

  11. countability of sets • Exercise: Show that • 1. |N| = |Z| = | Q | = {4,5,6,...} • 2. |R| = | [0, 1) | • 3. |N| ¹ |R| • Def. • A set A is said to be denumerable iff |A| = |N|. • A set is countable (or enumerable) iff either |A| = n for some n in N or |A| = |N|. • By exercise 3, • R is not countable. • Q and Z is countable.

  12. The power set Def 6. • If A is a set, then the collection of all subsets of A is also a set, called the power set of A and is denoted as P(A) or 2A. • Ex: • P({0,1,2}) = ? • P({}) = ? • |P({1,2,..., n})| = ? • Order of elements in a set are indistinguishable. But sometimes we need to distinguish between (1,3,4) and (3,4,1) --> ordered n-tuples

  13. Cartesian Products Def. 7 [n-tuple] • If a1,a2,...,an (n > 0) are n objects, then “(a1,a2,...,an)” is a new object, called an (ordered) n-tuple [ with ai as the ith elements. • Any orderd 2-tuple is called a pair. • (a1,a2,...,am) = (b1,b2,...,bn) iff • m = n and for i = 1,..,n ai = bi. Def. 8: [Cartesian product] A x B =def {(a,b) | a in A /\ b in B } A1 x A2 x ...x An =def {(a1,...,an) | ai in Ai }. Ex: A = {1,2}, B = {a,b,c} , C = {0,1} 1. A x B = ? ; 2. B x A = ? 3. A x {} = ? ;4. A x B x C = ?

  14. Set operations • union, intersection, difference , complement, • Definition. 1. AÈ B = {x | x in A or x in B } 2. AÇ B = {x | x in A and x in B } 3. A - B = {x | x in A but x not in B } 4. ~ A = U - A 5. If A Ç B = {} => call A and B disjoint.

  15. Set identites • Identity laws: A ? ? = A • Domination law: U ? ? = U; {} ?? = {} • Idempotent law: A ? A = A ; • complementation: ~~A = A • commutative : A ? B = B ? A • Associative: A ? (B ? C) = (A ? B ) ? C • Distributive: A ? (B ? C) = ? • DeMoregan’s law: ~(A ? B) = ~A ? ~B Note: Any set of objects satisfying all the above laws is called a Boolean algebra.

  16. Prove set equality 1. Show that ~(A È B) = ~A Ç~B by show that • 1. ~(A È B) Í ~A Ç~B • 2. ~A Ç~B Í ~(A È B) • pf: (By definition) Let x be any element in ~(A È B) ... 2. show (1) by using set builder and logical equivalence. 3. Show distributive law by using membership table. 4. show ~(AÈ (BÇ C)) = (~C Ç~B) È ~A by set identities.

  17. Functions • Def. 1 [functions] A, B: two sets 1. A function f from A to B is a set of pairs (x, y) in AxBs.t., for each x in A there is at most one y in B s.t. (x,y) in f. 2. if (x,y) in f, we write f(x) = y. 3. f :A ->B means f is a function from A to B. • Def. 2. If f:A -> B ==> 1. A: the domain of f; B: the codomainof f if f(a)=b => 2. b is the image of a; 3. a is the preimageof b 4. range(f) = {y | $x s.t. f(x) = y} = f(A). 5. preimage(f) = {x | $ y s.t. f(x) = y } = f-1(B).

  18. Types of functions • Def 4. f: A x B; S: a subset of A, T: a subset of B 1. f(S) =def {y | $ x in S s.t. f(x) = y } 2. f-1(T) =def {x | $ y in T s.t. f(x) = y } • Def. [1-1, onto, injection, surjection, bijection] f: A -> B. • f is 1-1 (an injection) iff f(x)=(fy) => x = y. • f is onto (surjective, a surjection) iff f(A) = B • f is 1-1 & onto <=> f is bijective(a bijection, 1-1 correspondence)

  19. Relations • A, B: two sets • AxB (Cartesian Product of A and B) is the set of all ordered pairs {<a,b> | a Î A and b Î B }. • Examples: A= {1,2,3}, B= {4,5,6} => AxB = ? • A1,A2,...,An (n > 0): n sets • A1xA2x...xAn = {<a1,a2,...,an> | ai Î Ai }. • Example: 1. A1={1,2},A2={a,b},A3={x,y} ==> |A1xA2xA3| = ? 2. A1= {}, A2={a,b} => A1xA2 = ?

  20. Binary relations • Binary relation: • A,B: two sets • A binary relation R between A and B is any subset of AxB. • Example: • If A={1,2,3}, B ={4,5,6}, then which of the following is a binary relation between A and B ? R1 = {<1,4>, <1,5>, <2,6> } R2 = {} R3 = {1,2,3,4} R4 = {<1,2>, <3,4>, <5,6> }

  21. Terminology about binary relations • R: a binary relation between A and B (I.e., a subset of AxB), then • The domain of R: dom(R) = {x Î A | $ y Î B s.t. <x,y> Î R} • The range of R: range(R) ={y Î B, | $ x Î A, s.t., <x,y> Î R} • <x,y> Î R is usually written as x R y. • If A = B, then R is simply called a relation over(on) A. • An n-tuple relation R among A1,A2,...,An --- is any subset of A1xA2...xAn, n is called the arityof R • If A1=A2=...=An=A => R is called an n-tuple relation (on A),.

  22. Operations on relations (and functions) • R ÍAxB; S Í B x C: two relations • composition of R and S: • R · S = {<a,c> | there is b in B s.t., <a,b> in R and <b,c> in S }. • Identity relation: IA = {<a,a> | a in A } • Converse relation: R-1 = {<b,a> | <a,b> in R } • f:A -> B; g: B->C: two functions, then g·f:A->C defined by g·f(x) = g(f(x)). • Note: function and relation compositions are associative, I.e., for any function or relation f,g,h, f· (g·h) = (f·g) ·h

  23. Properties of binary relations • R: A binary relation on S, 1. R is reflexiveiff for all x in S, x R x. 2. R is irreflexiveiff for all x in S, not x R x. 3. R is symmetriciff for all x, y in S, xRy => yRx. 4. R is asymmetriciff for all x,y in S, xRy => not yRx. 5. R is antisymmetriciff for all x,y in S, xRy and yRx => x=y. 6. R is transitiveiff for all x,y,z in S, xRy and yRz => xRz. Graph realization of a binary relation and its properties. rule: if xRy then draw an arc from x on left S to y on right R. x x y y s R

  24. Examples • The relation £ on the set of natural numbers N. What properties does £ satisfy ? • ref. irref, or neither ? • symmetric, asymmetric or antisymmetric ? • transitive ? • The relation > on the set of natural numbers N. • The divide | relation on integers N ? • x | y iff x divides y. (eg. 2 | 10, but not 3 | 10) What properties do > and | satisfy ? • The BROTHER relation on males (or on all people) • (x,y) Î BROTHER iff x is y’s brother. • The ANCESTOR relation on a family. • (x,y) Î ANCESTOR if x is an ancestor of y. What properties does BROTHER(ANCESTOR) have?

  25. Mathematical Induction • An inductive proof has three parts: • Basis case • Inductive hypothesis • Inductive step • Related to recursive programming.

  26. Mathematical Induction Theorem: For all n>=1. Proof #1: (by induction on n) Basis: n = 1 1 = 1

  27. Inductive hypothesis: Suppose that for some k>=1. Inductive step: We will show that by the inductive hypothesis It follows that for all n>=1.

  28. Theorem: For all n>=1. Proof #2: (by induction on n) Basis: n = 1 1 = 1

  29. Inductive hypothesis: Suppose there exists a k>=1 such that that for all m, where 1 <= m <= k. Inductive step: We will show that by the inductive hypothesis It follows that for all n>=1

  30. Mathematical Induction • What is the difference between proof #1 and proof #2? • The inductive hypothesis for proof #2 assumes more than that for proof #1. • Proof #1 is sometimes called weak induction • Proof #2 is sometimes called strong induction • Many times weak induction is sufficient, but other times strong induction is more convenient.

  31. minds symbolize refers to language External world stand for Basics of formal languages What is a language ? The meaning triangle:

  32. Different levels of language analysis • phonetic and phonological analysis • determine how words are related to sounds that realize them; required for speech understanding. • morphological analysis: • determine how words are formed from more basic meaning units called "morphemes". • morpheme: primitive unit of meaning in a language. • eg: friendly = friend + ly; luckily = lucky + ly • syntax analysis: • determine how words can be put together to form correct sentences • determine what structure role each word plays in the sentence • determine what phrases are subparts of what other parts.

  33. levels of language analysis • Semantics analysis : • determine what words mean and how these meanings combine in sentence to form sentence meanings. • context independent. • Pragmatic analysis: • concern how sentences are used in different situation and how use affects the interpretation of sentences. • Discourse analysis,... • World knowledge,... • Languages (including natural and programming languages) contains many facet, each an active research domain of AI, linguistics, psychology, philosophy, cognitive science and mathematics.

  34. What are formal languages • In the study of formal languages we care only the well-formedness (or more abstractly the membership of), but not the meaning of sentences, in a language. Ex1: Our usual decimal language of positive numbers ? • Prob: Which of the following are well-formed [representation of] numbers: (1) 128 (2) 0023 (3) 44ac (4) 3327 • Let L be the set of all well-formed [representations of ] numbers. ==> 123, 3327 in L but 0023, 44ac not in L. • So according to the view of FL, The usual decimal language of positive numbers (i.e., L) is just the set { x | x is a finite sequence of digits w/t leading zeros }. • Note: FL don't care that string '134' corresponds to the (abstract) positive number whose binary rep. is 10000000

  35. Definition 2.1 • An alphabet S (or vocabulary) is a finite set. • Ex: decimal_alphabet = {0,1,2,3,4,5,6,7,8,9} • binary_digit = {0,1}; Hexidecimal-alphabet = {0,..,9,A,..,F} • alphabet-of-English-sentences = {a, word, good, luckily,...} • alphabet-of-English-words = {a,...,z,A,...,Z} • Elements of an alphabet are called letters or symbols • A string (or word or sentence) over S a finite sequence of elements of S. • Ex: if S = {a,b} then 'aabaa' is a string over S of length 5. • The length of a string x, denoted |x|, is the number of symbols in x. ex: |abbaa| = 5. • there is a unique string of length 0, called the null string or empty string, and is denoted by e (or l)

  36. Definition 2.1 (cont'd) • S* =def the set of all strings over S. • Ex: {a,b}* = {e,a,b,aa,ab,ba,bb,aaa,...} • {a}* = {e,a,aa,aaa,aaaa,...} = {an | n ³ 0}. • {}* = ? ( {} or {e} or e ?) • Note the difference b/t sets and strings: • {a,b} = {b,a} but ab ¹ ba. • {a,a,b} = {a,b} but aab ¹ ab • So what's a (formal) language ? • A language over S is a set of strings over S (i.e., a subset of S*). Ex: let S = {0,...,9} then all the followings are languages over S. • 1. {e} 2. {} 3. {0,...,9} = S 4. {x | x ÎS* and has no leading 0s} 5. S5 = {x | |x| = 5} 6. S* = {x | |x| is finite }

  37. Examples of practically used formal languages Ex: Let D be the set of all ASCII codes. • a C program is simply a finite string over D satisfying all syntax rules of C. • C-language =def { x | x is a well-formed C program over D }. • PASCAL-language = {x | x is a well-formed PASCAL program over D }. Similarly, let ENG-DIC = The set of all English lexicons = { John, Mary, is, are, a, an, good, bad, boys, girl,..} • an English sentence is simply a string over ENG-DIC • ==> English =def {x | x is a legal English sentence over END-DIC} ==> • 1.John is a good boy . Î English. • 2. |John is a good boy . | = ?

  38. issues about formal languages • Why need formal languages? • for specification (specifying programs, meanings etc.) • i.e., basic tools for communications b/t people and machines. • although FL does not provide all needed theoretical framework for subsequent (semantic processing...) processing, it indeed provides a necessary start, w/t which subsequent processing would be impossible -- first level of abstraction. • Many basic problems [about computation] can be investigated at this level. • How to specify(or represent) a language ? • Notes: All useful natural and programming languages contains infinite number of strings (or programs and sentences)

  39. Languages and Problems What is a problem ? Example problems: • 1. Prob1(The integer-addition problem): Given any pair of integers x and y, return their sum x+y. • 2. Prob2(The sorting problem): Given any list of integers, find their sorted list. • 3. Prob3(The even length bit string problem): Given an input bit string x, determine if it is of even length? • Problem space: the set of all possible inputs (problem instances) • Prob1 ==> {(x,y) | x,y in Z} = Z2; • Prob2 ==> Z* ={ x | x is a list of numbers}; • Prob3 ==> {0,1}* = the set of all possible bit strings.

  40. What is a problem ? • Solution space: the set of all possible outputs (problem solutions). • Prob1 ==> Z • Prob2 ==> {x | x is a sorted list of integers } = {1, 1 3 5,...} • Prob3 ==> { yes, no } (or {true, false} or {0,1} etc. ) • So abstractly a problem Pr is a triple (P, S, Q) where • P is a set called the problem space of Pr • S is a set called the solution space of Pr and • Q is a binary relation between P and S. For any pair (x,y) in PxS, if (x,y) in Q, we say y is a solution of Pr for input x. • If there are multiple y’s with (x,y) in Q, we say x has multiple solutions • If there is no y with (x,y) in Q, we say x has no solution. • note: Sometimes we simply identify Pr with Q

  41. What is a problem (cont’d) Example: • 1. Prob1 = (Z2, Z, Q1) where • Q1 = {((x,y), x+y) | x,y in Z} = {((1,1),2), ((2,3),5),...} • Since ((1,2),3) Î Q1, we say 3 is the solution of the integer addition problem for input x and y. • 2. Prob2 = (Z*, {x | x is a list of sorted integers}, Q2) where • Q2 = {(x,y) | y is a sorted list of x } • = {(1 23 4 4 35, 1 4 4 23 35), (1 3 10 4 7, 1 3 4 7 10), • (e,e),...} • 3. Prob3 = (S*, {yes, no}, Q3 ) where • Q3 = { (e, yes), (1, no) (0, no), (11, yes), (01, yes),...} • ==> Prob3( yes-or-no problems) is called a decision problem.

  42. What is a decision problem? A decision (yes/no;true/false) problemPris a problem (P, S, Q) where • S = {yes,no} and • Q is a total function (I.e., for each x in P there is exactly on y in S s.t. (x,y) in Q). The set • Pos = { x | (x, yes) in Q} is called the set of positive instances of Pr and • Neg = P - Pos is called the set of all negative instances of the problem • Note: Since (P,S,Q) and (P, Pos) can be uniquely determined by each other, we can simply use (P, Pos) (and sometimes even use the set Pos if P is clear in the context) to represent the problem.

  43. Some example decision problems Prob4: Given an input integer x, determine if it is a prime. => Prob4 = (Z, {x | x is a prime integer}) Prob5: Given two integers x,y, determine if x < y ? => Prob5 = ({(x,y) |x,y in Z}, {(x,y) | x < y} ) Prob6: Given a list of numbers x1,...,xn and a number y, determine if y is an upper bound of x1,..,xn ? => Prob6 = ({(L,y) | L is a list of numbers, y is a number}, {(L, y) | y ³ max(L) } Prob7: Given a list of number x1,..,xn, return the largest? => not a decision problem !

  44. encode Abstract problem Concrete Problem represent Abstract problems and Concrete Problems • The problems defined above are called abstract problems since all P, S and Q are abstract mathematical objects. • On the other hand, the problem Prob3 of determining if input bit string is of length even is called a concrete problem since both its input instances and output are (symbol; bit) strings, which real machines can manipulate. • In general we say a problem (P,S,Q) is a concrete problem if P and S are (formal) languages (I.e., sets of strings)) • For concrete problems we can say of their computability. • But how can we say that a non-concrete problem is computable or not ? • solution: Concrete representation of Abstract problems

  45. (Decision) problem representations • Prob = (P, Pos) : a problem; S: an alphabet. e: P -> S*. 1. If e is a 1-1 mapping, then we say (S*,e) is a (language) representation (or encoding) of the problem Prob. 2. For each instance I in Prob, the string e(I) is called the representation of I under the representation (S*,e). Ex: Prob8: Given two nonnegative integers x,y, determine if x < y ? => Prob8 = ({(x,y) |x,y in N}, {(x,y) | x < y} ) Let S = {0,..,9,[,],|}, and for each number x let e(x) = decimal rep. of x. and for each instance (x,y) of Prob1, let e((x,y)) = [ e(x) | e(y) ] => e(P) is a subset of S* = { [e(x)|e(y)] |x < y } = {[0|1], [2|4],...}. Conclusion: Since there are easy ways to transform abstract problems into concrete problems (by simple encoding), the study of computability and complexity of abstract problems can be reduced to the study of concrete language problems

  46. How to specify a language • principles: 1. must be precise and no ambiguity among users of the language: 2. efficient for machine processing • tools: • 1. traditional mathematical notations: • A = {x | |x| < 3 and x Î {a,b}} = {e,a,b,aa,ab,ba,bb} • problem: in general not machine understandable. • 2. via programs (or machines) : • P: a program; L(P) =def {x | P return 'ok' on input string x} • precise, no ambiguity, machine understandable. • hard to understand for human users !! • 3. via grammars: (easy for human to understand) • Ex: noun := book | boy | jirl | John | Mary • art := a | an | the ; prep := on | under | of | ... • adj := good | bad | smart | ... • NP := noun | art noun | NP PP | ... • PP := prep NP ==> 'the man on the bridge' Î PP.

  47. Non-enumerability of languages • Recall that a set is denumerable if it is countably infinite. (i.e., A set T is denumerable if there is a 1-1 and onto mapping b/t T and {0,1,...}) • Exercises: If S is finite and nonempty, then • 1. S* is denumerable (i.e., |S*| = |N| ) • 2. 2S* (ie., the set of all languages over S) is uncountable. • pf: Since |2S*| ¹ |S*| = |N|, hence |2S*| is not countable

  48. Operations on strings • string concatenations: • x,y: two strings ==> x·y is a new string with y appended to the tail of x. • Some properties of · : 1. ASSOC: (xy)z = x(yz) ; 2. Identity: ex = xe = x. 3. |xy| = |x| + |y|. • Note: any algebra (M, ·, e) satisfies 1 and 2 is called a monoid. • so (S*,·,e) is a monoid for any alphabet S. • conventions and abbreviations: • S: for alphabet ; a,b,c: for symbols; • x,y,z: for strings; A,B,C: for languages; • a^5 for aaaaa; a^1 = a ; a^0 = e. • #a(x) =def number of a's in x. ==> #a(aabbcca) = 3.

  49. Operations on languages (i.e, string sets) 1. usual set operations: • Union: A U B = {x | x Î A or x Î B } Ex: {a,ab} U { ab, aab} = {a,ab,aab} • intersection: A Ç B = {x | x Î A and x Î B } • complements in S*: ~A =def S* - A = { x | x not Î A} • ex: ~{x | |x| is even } = {x | |x| is odd }. 2. Set concatenations: A·B =def {xy | x Î A and y Î B }. • Ex: {b,ba} {a,ab} = {ba,bab,baa,baab}. • Note: like string concatenation, set concatenation is asso and has an identity {e}. Hence (2S*, · , {e}) is a monoid. 3. Powers of A: An ( n ³ 0) is defined inductively: 1. A0 = { e}; An+1 = A·An = A·A·...·A. ----- n A's

  50. Operations on languages (cont'd) Ex: Let A = {ab,abb}. Then • 1. A0 = ? 2. A1 = ? 3. A2 = ? 4. |A4|=? • 5. Hence {a,b,c}n = {x Î {a,b,c}* | |x| = n } and • An = { x1x2...xn | x1,...,xnÎ A } 5. Asterate (or star) A* of A is the union of all finite powers of A: A* =def Uk ³ 0 AK = A0 U A UA2 U A3 U ... = {x1x2...xn | n ³ 0 and xiÎ A for 1 ³ i ³ n } notes: 1. n can be 0 ==> eÎ A*. ==> eÎ {}*. 2. If A = S ==> A* = S* = the set of all finite strings over S.

More Related