1 / 29

Lecture 2

Lecture 2. Topics Importance of this material Fundamental Limitations Connecting Problems and Languages Problems Search, function and decision problems Languages Encodings of Problems Encode input instances of problem as strings Language Recognition Problem

abrial
Télécharger la présentation

Lecture 2

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. Lecture 2 • Topics • Importance of this material • Fundamental Limitations • Connecting Problems and Languages • Problems • Search, function and decision problems • Languages • Encodings of Problems • Encode input instances of problem as strings • Language Recognition Problem • Is an input string in the language?

  2. Phil. of life What is the purpose of life? What is achievable in life? What is NOT achievable in life? Phil. of computing What is the purpose of programming? What is solvable through programming? What is NOT solvable through programming? Importance: Philosophy

  3. Physics Study of fundamental physical laws and phenomenon like gravity and electricity Engineering Governed by physical laws Our material Study of fundamental computational laws and phenomenon like undecidability and universal computers Programming Governed by computational laws Importance: Science

  4. Problem Types • We classify problems based on • range (output set) size • infinite • binary • mapping type • function • unique output per input • relation • more than one output per input

  5. Inputs Outputs I) Search Problems • (countably) infinite range • the mapping may be a relation

  6. 1 3 9 Inputs Outputs Examples • Divisor • Input: Integer n • Output: An integral divisor of n 9

  7. Inputs Outputs II) Function Problems • (countably) infinite range • mapping is a function • unique solution per input

  8. 10 Inputs Outputs Examples • Sorting • Multiplication Problem • Input: 2 integers x and y • Output: xy 2,5

  9. 1 3 9 Inputs Outputs Examples • Maximum divisor problem • Input: Integer n • Output: size of maximum divisor of n smaller than n 9

  10. Yes No Inputs Outputs III) Decision Problems • Output is yes or no • range = {Yes, No} • unique solution • only one of Yes/No is correct

  11. (1,3,2,4) Yes (1,2,3,4) No Inputs Outputs Examples • Decision sorting • Input: list of numbers • Yes/No question: Is list in nondecreasing order?

  12. (3,5,14) Yes (3,5,15) No Inputs Outputs Examples • Decision multiplication • Input: Three numbers x,y, z • Yes/No question: Is xy = z?

  13. (14,5) Yes (14,7) No Inputs Outputs Examples • Decision Divisor Problem • Input: Two numbers x and y • Yes/No question: Is y a divisor of x?

  14. What about finite domain problems? • Note all problems described above have infinite domains (input set) • size of range varies from 2 to countably infinite • What happens if we had a problem with only a finite domain? • “Table lookup”

  15. Table Lookup Program string x; cin >> x; switch x { case “Kona”: cout << 3; break; case “Eric”: cout << 31; break; case “Cliff”: cout << 36; break; default: cout << “Illegal input\n”; }

  16. Generality of Decision Problems • We now show that we can focus only on decision problems • Having yes/no outputs is not limiting. • If we can solve a decision version of a problem, we can typically solve the function and search versions of the same problem as well

  17. Example • Decision divisor problem • Input: Integers x and y • Yes/No Question: Is y a divisor of x? • Assumption: Alg. A solves this problem • Function divisor problem • Input: Integer x • Output: Largest divisor of x that is not x • Goal: Construct alg. A’ to solve this problem

  18. Program A’ integer x, max, j; cin >> x; max = 1; for (j=2; j<x; j++) if (A(x,j)) // using A as a procedure max = j; return max;

  19. Connecting Problems and Languages • Start with any problem P • Convert P to equivalent decision problem P’ • Convert P’ to equiv set membership problem SP • Reinterpret P’ • Convert SP to language recognition problem L • Encoding scheme

  20. Set Membership Problem • Setting • Universe U • set S subset of U • Input • Element x in U • Yes/No Question • Is x in S?

  21. Decision Problems to Set Membership Problems • Reformulate/interpret a decision problem as a set membership problem • Universe U: set of all input instances • Set S: either set of all YES or all NO input instances

  22. Example • Decision divisor problem • Input: Integers x and y • Yes/No Question: Is y a divisor of x? • Set membership problem • Universe U = {(x,y) | x and y are integers} • Set S = {(x,y) | y divides x}

  23. Sets to Languages • How do we represent an input instance of a set membership problem? • We use an encoding scheme • Each input instance is mapped to a unique string over some finite alphabet . • Think ASCII • Corresponding language L: the set of strings corresponding to yes instances

  24. Decision multiplication problem • Alphabet S1= {0,1,2,3,4,5,6,7,8,9,;} • 7;10;25 NO instance • 3;4;12 YES instance • Binary Alphabet S2 = {0,1} • Encode alphabet S1 • 11 characters in S1 • 4 bits per character of S1 • Encoding of 3;4;12 • 001110110100101100010010

  25. Decision divisor problem • Fill in

  26. Language recognition problem (LRP) • Input Instance Description • Finite length string x in * (why finite?) • Yes/No Question • Is input string x in language L? • How does the language recognition problem for L relate to corresponding set membership problem?

  27. Illegal Decision Addition Problem • Illegal strings easily recognized • Thus two problems essentially identical S* 1;1;3 ;;1111;3 1;1;2 7;5;1 3;4;7 111;1111 Yes No

  28. Every decision problem can be formulated as an LRP • First convert to set membership problem • Then convert to language recognition problem using an encoding scheme • Illegal strings easily recognized

  29. Key Concepts • Different types of problems • always countably infinite domain • Decision problems • binary range = {YES, NO} • still general despite limited range • Set membership problem • Language recognition problem • encoding scheme

More Related