CSCI 301 L21 Notes

Lecture 21 - Notes

Goals

Announcements

New Teams - New Norms

Team Norms

Take five minutes with your team to:

Write your norms on the Team Norms sheet.

I’ll collect these after class and redistribute them with the Exercise/Problem sheets each day.

We’ll occasionally revisit norms and make any adjustments deemed necessary.

Theory of Computation - A High-Level Introduction

Computability theory: what can be computed?

Turns out not everything is computable. Example: the halting problem. Construct a program \(H\) that takes as input another program \(P\) and its input \(I\). The correct output of \(H\) is True if \(P\) ever terminates when given input \(I\), and False otherwise.

It’s impossible to write \(H\)! Here’s a proof, which Alan Turing first showed in 1936(!):

Proof by contradiction: Suppose \(H\) exists. Consider the program \(Z\):

program Z( String x ):
  if H(x,x):
    loop forever
  else:
    return

Now imagine running program \(Z\) with \(Z\) as input. This calls \(H(Z,Z)\); this will tell us whether \(Z\) terminates. Thus there are two cases:

Computational complexity: how can we classify computable problems by difficulty?

Not all problems are equivalently easy to solve.

Example: \(P\) vs \(NP\).

A problem is in \(P\) if it can be solved in “polynomial time”.

A problem is in \(NP\) if a solution to the problem can be verified in “polynomial time”.

We don’t know whether these are the same! That is, we don’t know if there are problems in \(NP\) that are not in \(P\).

Automata Theory: the study of abstract “machines”

To study these formally, we need to model concepts like computer and problem mathematically. Traditional methods for doing this come from automata theory, which is the study of simple, abstract models of computation.

In this approach, an automaton is a simple model of computation, and the problems they solve relate to to the acceptance of languages. Before defining these formally, let’s look at an example.

Suppose you’re programming a toll gate, and the toll required to open the gate is 15 cents. The machine can accept nickels (\(5\textcent\) coins) and dimes (\(10\textcent\) coins). You could imagine writing code for this:

total = 0
while total < 15:
    coin = accept_coin()
    total += coin.value
open_gate()

We could also more abstractly model this using a “state machine”:

(See the picture in the whiteboard notes)

(End of what we covered in L21)

Alphabets, Strings, and Languages

Let’s now get more formal about what these machines can do; we will abstract away the specifics of the problem by rephrasing it in terms of the language accepted by the machine. Some definitions: