600.325/425 Declarative Methods - J. Eisner1 Encodings and reducibility.

Slides:



Advertisements
Similar presentations
Models of Computation Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms Week 1, Lecture 2.
Advertisements

Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
NP-Hard Nattee Niparnan.
Time Complexity P vs NP.
Lecture 19. Reduction: More Undecidable problems
Lecture 24 MAS 714 Hartmut Klauck
Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
Complexity class NP Is the class of languages that can be verified by a polynomial-time algorithm. L = { x in {0,1}* | there exists a certificate y with.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Tyler Robison Summer
1 Introduction to Computability Theory Lecture13: Mapping Reductions Prof. Amos Israeli.
1 Lecture 4 Topics –Problem solving Subroutine Theme –REC language class The class of solvable problems Closure properties.
1 Polynomial Church-Turing thesis A decision problem can be solved in polynomial time by using a reasonable sequential model of computation if and only.
The Analytical Engine Module 6 Program Translation.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Analysis of Algorithms CS 477/677
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
CS21 Decidability and Tractability
Hardness Results for Problems P: Class of “easy to solve” problems Absolute hardness results Relative hardness results –Reduction technique.
Theory of Computation. Computation Computation is a general term for any type of information processing that can be represented as an algorithm precisely.
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
CENG 311 Machine Representation/Numbers
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Lesson 1b: Computer Systems and Program Development CPS118.
Foundations of Computer Science Computing …it is all about Data Representation, Storage, Processing, and Communication of Data 10/4/20151CS 112 – Foundations.
Randomized Turing Machines
Theory of Computing Lecture 15 MAS 714 Hartmut Klauck.
Approximation Algorithms Pages ADVANCED TOPICS IN COMPLEXITY THEORY.
Computer Systems Organization CS 1428 Foundations of Computer Science.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
1 The Halting Problem and Decidability How powerful is a TM? Any program in a high level language can be simulated by a TM. Any algorithmic procedure carried.
CSC 413/513: Intro to Algorithms NP Completeness.
David Luebke 1 10/25/2015 CS 332: Algorithms Skip Lists Hash Tables.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 3813 Introduction to Formal Languages and Automata Chapter 14 An Introduction to Computational Complexity These class notes are based on material from.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
MA/CSSE 474 Theory of Computation Decision Problems DFSMs.
Introduction to Digital Media. What is it? Digital media is what computers use to; Store, transmit, receive and manipulate data Raw data are numbers,
Umans Complexity Theory Lectures Lecture 1a: Problems and Languages.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
NP-complete Problems Prof. Sin-Min Lee Department of Computer Science.
Limits to Computation How do you analyze a new algorithm? –Put it in the form of existing algorithms that you know the analysis. –For example, given 2.
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.
NP-Completness Turing Machine. Hard problems There are many many important problems for which no polynomial algorithms is known. We show that a polynomial-time.
NP-Completeness  For convenience, the theory of NP - Completeness is designed for decision problems (i.e. whose solution is either yes or no).  Abstractly,
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
CS 461 – Oct. 28 TM applications –Recognize a language √ –Arithmetic √ –Enumerate a set –Encode a data structure or problem to solve Two kinds of TMs –Decider:
Number Systems Decimal Can you write 12,045 in expanded form? Base? Allowable digits for each place?
CMPT 438 Algorithms.
P & NP.
CS 461 – Nov. 2 Sets Prepare for ATM finite vs. infinite Infinite sets
Growth of Functions & Algorithms
Probabilistic Algorithms
Part VI NP-Hardness.
CSE 311 Foundations of Computing I
Lecture 22 Complexity and Reductions
Introduction to the Analysis of Complexity
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Encodings and reducibility
CPS 173 Computational problems, algorithms, runtime, hardness
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs
Algorithms.
Week 11 - Wednesday CS221.
Lecture 22 Complexity and Reductions
Presentation transcript:

/425 Declarative Methods - J. Eisner1 Encodings and reducibility

/425 Declarative Methods - J. Eisner 2 Designing your little language You have to encode your problem as a string  How would you encode a tree? That is, what’s a nice little language for trees?  More than one option? What solvers could you write? Does every string encode some tree?  How would you encode an arbitrary graph? Is it okay if there are two encodings of the same graph? What solvers could you write?

/425 Declarative Methods - J. Eisner 3 Remind me why we’re using strings? Why not design a Java graph object & write solver to work on that?  Then your solver can only take input from another Java program  Can only send its output (if a graph) to another Java program  Where do those programs get their input and send their output?  All programs must be running at once, to see same object How do you save or transmit a structure with pointers? Solution is serialization – turn object into a string! Strings are a “least common denominator”  Simple storage  Simple communication between programs can even peek at what’s being communicated … and even run programs to analyze or modify it Can all finite data structures really be “serialized” as strings?  Sure … computer’s memory can be regarded as a string of bytes.  Theoretical CS even regards all problems as string problems! A Turing machine’s input and output tapes can be regarded as strings P = “polynomial time” = class of decision problems that are O(n k ) for some constant k, where n = length of the input string

/425 Declarative Methods - J. Eisner 4 Encoding mismatches How do you run graph algorithms on a string that represents a tree? How do you run tree algorithms on a string that represents a graph?  Assuming you know the graph is a tree  Should reject graphs that aren’t trees (syntax error) (What’s the corresponding problem & solution for Java classes?) How do you run a graph algorithm to sort a sequence of numbers?

You want to write a solver that determines if an integer is prime  How hard is this? How hard is it to factor an integer? How do you encode the number 2010 as a string?  “2010”  “MMX” Slightly harder for solver But easier for some users (ancient Romans)  “ ” Slightly easier for solver (if a PC) But harder for most users  Does it matter which of the above we use?  “2*3*5*67” (encode 2010 as its unique factorization) Qualitatively different! Why?  “ ….” (2010 times) Qualitatively different! Why? /425 Declarative Methods - J. Eisner 5 Encoding integers No harder: First convert from d digits to b bits in O(d) time If b = # bits, can factor in But test primality in about O(b 6 ). Can test primality in O(length of input) Then test primality in time O(b 6 ) = O((4d) 6 ) = O(4 6 d 6 ) = O(d 6 ) So decimal encoding isn’t harder; is it easier?

/425 Declarative Methods - J. Eisner 6 Reducibility One way to build a solver is to “wrap” another solver Solver for X Solver for Y encode input decode output X(input) = decode(Y(encode(input))) Can set this up without knowing how to solve Y!  As we find (faster) solvers for Y, automatically get (faster) solvers for X

/425 Declarative Methods - J. Eisner 7 Reducibility Sort Longest acyclic path in graph

/425 Declarative Methods - J. Eisner 8 Reducibility Factorize Roman numeral Factorize binary number

/425 Declarative Methods - J. Eisner 9 Reducibility Factorize binary number Factorize Roman numeral

/425 Declarative Methods - J. Eisner 10 Reducibility then so is this one. If this problem is easy (as long as encoding/decoding is easy and compact) factorize something like “2007” factorize something like “3*3*223” not as easy!

/425 Declarative Methods - J. Eisner 11 Reducibility then so is this one. If this problem is easy (as long as encoding/decoding is easy and compact) factorize something like “2007” factorize something like “111111…..” not as easy!

/425 Declarative Methods - J. Eisner 12 Reducibility then so is this one. If this problem is easy What do we mean by a hard vs. an easy problem?  A hard problem has no fast solvers  An easy problem has at least one fast solver (as long as encoding/decoding is easy and compact)

/425 Declarative Methods - J. Eisner 13 Reducibility then is this one necessarily hard? If this problem is hard What do we mean by a hard vs. an easy problem?  A hard problem has no fast solvers  An easy problem has at least one fast solver (Nope. There might be a different, faster way to sort.)

/425 Declarative Methods - J. Eisner 14 Reducibility gives us a fast solver here. Fast solver here What do we mean by a hard vs. an easy problem?  A hard problem has no fast solvers  An easy problem has at least one fast solver (Even faster ones might exist.)

/425 Declarative Methods - J. Eisner 15 Reducibility EASIER PROBLEM (or a tie) HARDER PROBLEM What do we mean by a hard vs. an easy problem?  A hard problem has no fast solvers  An easy problem has at least one fast solver (Even faster solvers might or might not exist.)

/425 Declarative Methods - J. Eisner 16 Interreducibility EASIER PROBLEM (or a tie) HARDER PROBLEM What do we mean by a hard vs. an easy problem?  A hard problem has no fast solvers  An easy problem has at least one fast solver (Even faster solvers might exist.)

/425 Declarative Methods - J. Eisner 17 Interreducibility Interreducible problems They must tie! Equally easy (or equally hard) if we’re willing to ignore encoding/decoding cost. EASIER PROBLEM (or a tie) HARDER PROBLEM Factorize Roman numeral Factorize binary number Factorize Roman numeral

/425 Declarative Methods - J. Eisner 18 Reducibility & “typical” behavior then is this solver fast on most inputs? If this solver is fast on most inputs Not necessarily – the encoding might tend to produce hard inputs for the inner solver

/425 Declarative Methods - J. Eisner 19 Reducibility & approximation then is this solver equally accurate? If this solver is accurate within a 10% error (Does almost-longest path lead to an almost-sort?) (Not the way I measure “almost”!) Some reductions (encode/decode funcs) may preserve your idea of “almost.” In such cases, any accurate solver for the inner problem will yield one for the outer problem. Just be careful to check: don’t assume reduction will work!

/425 Declarative Methods - J. Eisner 20 Proving hardness then so is this one. If this problem is easy What do we mean by a hard vs. an easy problem?  A hard problem has no fast solvers  An easy problem has at least one fast solver So what can we conclude if outer problem is believed to be hard?

/425 Declarative Methods - J. Eisner 21 Proving hardness Factoring integers Cracking Blum- Blum-Shub cryptography What do we mean by a hard vs. an easy problem?  A hard problem has no fast solvers  An easy problem has at least one fast solver So what can we conclude if outer problem is believed to be hard?