5. BlooP, FlooP and GlooP - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

5. BlooP, FlooP and GlooP

Description:

BlooP - the only loop allowed is a bounded loop, where each loop repeats a ... What about for a ternary tree? 15. 9. P, NP, and NP-complete ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 21
Provided by: bruceb59
Category:
Tags: bloop | floop | gloop | ternary

less

Transcript and Presenter's Notes

Title: 5. BlooP, FlooP and GlooP


1
5. BlooP, FlooP and GlooP
  • The incompleteness of formal systems has
    important consequences some problems just cannot
    be solved!
  • We looked at two kinds of languages
  • BlooP - the only loop allowed is a bounded loop,
    where each loop repeats a predefined maximum
    number of times.
  • FlooP as above, but the loops can continue
    without limit, possibly forever!
  • BlooP is our language for defining predictably
    terminating calculations, while FlooP is used
    when you do not know how many loops are needed.

2
  • Different kinds of recursion
  • Primitive recursive is synonymous with BlooP
    computable
  • General recursive is synonymous with computable
    by terminating FlooP programs
  • Partial recursive is synonymous with computable
    by nonterminating FlooP programs
  • Primitive and general recursive notions are
    representable in TNT (e.g. primeness)
  • Representable means all true instances are
    theorems and all false ones are non-theorems,
    e.g., 5 is prime is a theorem of TNT
  • 6 is prime is a non-theorem.

3
Diagonalization arguments
  • By constructing an ordered list of BlooP programs
    we showed that some programs must exist which
    were not in BlooP, implying something more
    powerful exists like FlooP
  • A similar argument does not work for FlooP
    programs, because they are not guaranteed to stop
    running
  • However, if we could determine if an arbitrary
    program would halt, could could use the same
    arguments to show something more powerful than
    FlooP exists (GlooP?)

4
Is this possible?
  • Generally we believe that FlooP is as powerful a
    language as we will ever find
  • Church-Turing thesis
  • (1) What is human-computable is
    machine-computable
  • (2) What is machine-computable is
    FlooP-computable
  • What is human-computable is FlooP-computable (i.e
    general or partial recursive)
  • If we believe this, then we must infer that it is
    impossible to create a termination tester!

5
Kinds of potential questions
  • What is meant by BlooP and FlooP, and how do they
    relate to the various kinds of recursion ?
  • Can you program a given function, like finding
    the next prime, with a BlooP or FlooP program?
  • Reconstruct the diagonalization arguments to make
    the diagonal functions (e.g. BluediagN) and
    explain why they work for BlooP but not for
    FlooP.
  • Explain how a termination tester, if it existed,
    might be useful for solving outstanding
    questions.
  • What are three different statements of the
    Church-Turing thesis?

6
6. Computability
  • Something is computable if it can be solved with
    a FlooP program
  • Not all functions are computable the set of
    possible functions is uncountable, while the
    number of FlooP programs is countably infinite
  • Partially solvable an algorithm exists which can
    solve all instances which are solvable, but which
    may run forever for the unsolvable instances

7
Unsolvable problems
  • The Halting Problem
  • Is there an algorithm that can decide whether
    the execution of an arbitrary program halts for
    an arbitrary input?
  • The Total Problem
  • The Equivalence Problem
  • Posts Correspondence Problem
  • Hilberts Tenth Problem
  • Some of these are actually partially solvable
    (e.g. the halting problem, Posts problem)

8
Typical kinds of questions
  • What is meant by computable?
  • What is the difference between a countably
    infinite set and an uncountably infinite set?
  • Give some examples of unsolvable (or undecidable)
    problems and describe them.
  • Why is the halting problem considered partially
    solvable?
  • Can you apply what youve learned about the
    limits of computing to the question of artificial
    intelligence?

9
7. Analysing Algorithms
  • All algorithms are not created equal, some use
    computing resources more efficiently
  • This is quantified by the time complexity
    function, T(n), which describes how the time to
    execute it changes with the size of the input
  • Different kinds of complexity
  • every case,average, best case, worst case
  • Example 1 search routines
  • Sequential search vs Binary search
  • T(n) n T(n) log n
  • Example 2 sort routines
  • Exchange sort vs. Merge sort
  • T(n) n(n-1)/2 T(n) n log n

10
Typical kinds of problems
  • Given a simple algorithm, can you determine how
    its time complexity function scales as a function
    of its inputs?
  • Given a time complexity function, how does the
    time required change when the input size is
    changed?
  • What is the maximum input n that can be run in a
    given time for a particular T(n)?
  • Given two algorithms with different T(n)s, for
    what values of n does it make sense to use each
    method?

11
8. Asymptotic behaviour of functions
  • There is a hierarchy of possible complexity
    functions based on their behaviour as the input
    becomes very large
  • 1 lt log n lt n ltn log n lt n2 lt n3 lt 2n lt n! lt
    nn
  • What is of most relevance is the fastest growing
    part of T(n)

12
  • Comparing rates of growth
  • Big theta
  • f has the same growth rate (or the same order )
    as g if we can find a number N, two nonzero
    numbers c and d such that
  • c.g(n) ? f(n) ? d.g(n)
  • for all n ? N.
  • This is written, f(n) ? ?(g(n))
  • Big O - f(n) grows slower or as fast as g(n)
  • f(n) ? O(g(n))
  • Big Omega - f(n) grows as fast or faster than
    g(n)
  • f(n) ? ?(g(n))

13
Optimal algorithms
  • Assuming we have a well posed problem, there may
    be many ways of solving it. Usually, we try to
    find the optimal solution.
  • To check whether a solution is optimal, it is
    useful to find a lower bound for the minimum
    number of operations required.
  • A lower bound can often be found using decision
    trees. The number of lowest branches in the tree
    should exceed the number of outcomes of the
    problem.
  • Unfortunately, we can not always determine what
    the lower bound is and whether our solution is
    optimal.

14
Typical kinds of problems
  • Given two functions, f(n) and g(n), can you prove
    that f is big theta of g?
  • Can you determine where a particular function
    f(n) belongs in the hierarchy of functions?
  • What is the minimum number of decisions required
    to solve a problem with 45 possible solutions
    given a binary tree?
  • What about for a ternary tree?

15
9. P, NP, and NP-complete
  • We can classify problems based on how the best
    algorithms scale with the size of their input
  • Two basic categories arise
  • Tractable problems are those that are solvable in
    practice, and whose solutions are at worst
    polynomial in time,
  • For example 1, log n, n, n log n, n2 , n3
  • Intractable problems are very difficult to solve
    in practice and the time required usually grows
    exponentially with the size of input
  • For example 2n , n! , nn

16
Four types of problems
  • Proven unsolvable (undecidable) e.g. Halting
    problem.
  • Polynomial solutions found (tractable) e.g.
    searching, sorting.
  • Proven to need super-polyomial time (intractable)
    e.g. Tower of Hanoi.
  • Unknown if tractable or intractable. E.g.
    factorisation, travelling salesperson.

17
Complexity classes
  • Decision problems (or tests) are ones with a
    yes or no answer
  • P is the set of decision problems which are
    always solvable by polynomial time algorithms
  • NP is the set of decision problems which are
    always verifiable by polynomial time algorithms
  • Non-deterministic problems are those which can
    be solved with a guessing stage and a
    verification stage
  • P ? NP All problems in P are also in NP
  • Does NP P ? We just dont know!

18
NP-Complete problems
  • NP-Complete problems are the ones that are
    hardest to solve in NP, they could be used to
    solve any other NP problem.
  • Every NP-complete problem is polynomially
    reducible to every other.
  • IF an NP-complete problem was ever shown to have
    a polynomial solution then P NP.
  • Examples logical satisfiability, timetabling,
    travelling salesperson, map colouring, etc.

19
Typical questions
  • Give some examples of tractable and intractable
    problems, and some we are not sure about.
  • Give the formal definitions of the complexity
    classes, P, NP and NP-complete.
  • What is meant by a non-deterministic problem?
  • Discuss the consequences of P NP. How might
    you prove or disprove it?
  • How would you show that your specific problem was
    NP-complete?

20
  • Thats it!
  • Good luck on the exam !
  • Hopefully everyone will pass the first try, but
    if you do have to re-sit the exam, be sure to
    learn from your mistakes.
Write a Comment
User Comments (0)
About PowerShow.com