Decision Problems - SFU Computing Science

Computability and Complexity
2-1
Problems and Languages
Computability and Complexity
Andrei Bulatov
Computability and Complexity
2-2
Math Prerequisites —— Alphabets and Languages
An alphabet is a (finite) set of symbols, e.g.
={0,1},
={0,1,…,9}, ={A,F,G,T},
={a,b,c,…,z},
A string (or a word) over an alphabet  is a (finite) sequence of
symbols from , e.g.
=0010110111, =314159, =FAGFTTAGT, =turingmachine
Length of a string  is the number of symbols in , denoted ().
Empty string  is a string containing no symbols.
The set of all non-empty strings over  is denoted by  
The set of all strings over  (including the empty string) is denoted by  *
A language over alphabet  is any subset of  *, e.g.
L  {, ab, abab , ababab ,}  {( ab) n | n  N  {0}}
Computability and Complexity
2-3
Models of Computation
To make statements about what can and cannot be computed we
need to define a scientific model of computation
We start with a very simple model which identifies 3 aspects of
any computation:
input
process
output
Computability and Complexity
Input and Output
We shall also make some other simplifying assumptions:
Input is a sequence of symbols in some fixed alphabet.
This means we need to define some way of encoding the description of
our problem as a sequence of symbols
Output
is either:
• A single bit indicating yes or no;
(In this model we consider only decision problems — that is,
problems which require a yes/no answer)
• A sequence of symbols from the same alphabet as the input.
(In this model we also allow search and optimisation problems —
that is, problems which require the computation of some answer or
of a best answer from some set of possibilities.)
2-4
Computability and Complexity
Decision Problems
In the first part of this course we will focus on decision problems
The standard way to define a decision problem is to describe a generic
instance, and a yes/no question about each instance.
Reachability
Instance: A finite directed graph G and vertices s and t
Question: Is there a path from s to t?
2-5
Computability and Complexity
Examples — Graph Problems
Euler Circuit
Instance: A finite graph G.
Question: Does G have an Euler Curcuit?
- i.e., a cycle that goes through each edge exactly once
Euler, 1736
Hamilton Circuit
Instance: A finite graph G.
Question: Does G have a Hamilton Curcuit?
- i.e., a cycle that goes through each vertex exactly once
Hamilton, 1850
2-6
Computability and Complexity
Examples — Graph Problems
Clique
Instance: A finite graph G and an integer K.
Question: Does G have a clique of size K?
- i.e., a set of K vertices that are fully connected
Colouring
Instance: A finite graph G and an integer K.
Question: Does G have a colouring with K colours?
- i.e., an assignment of colours to vertices such that adjacent
vertices have different colours
2-7
Computability and Complexity
2-8
A Graph Problem Instance
1
2
10
3
4
5
6
7
8
9
• Does this graph have an Euler Circuit?
• Does this graph have a Hamilton Circuit?
• Does it have a clique of size 4?
• Does it have a 3-colouring?
Computability and Complexity
Example
Linear Programming
Instance: An integer mn matrix M, vectors D  (d1 ,, d n ) ,
C  (c1 ,, cm ), and an integer B.
Question: Is there a rational vector X  ( x1 ,, xm ) such that
X  M  D, and X  C   B?
2-9
Computability and Complexity
Example
Travelling Salesperson(D)
Instance: A finite set of cities {c1 , c2 ,, cn }, a positive integer
distance d (i, j ) between each pair {ci , c j } , and an
integer B.
Question: Is there a permutation  of {1,, n} such that
 n1

  d ( (i ),  (i  1))   d ( ( n ),  (1))  B
 i 1

2-10
Computability and Complexity
Encodings
To input problems to a computer, each instance must be encoded in a
string of symbols over some alphabet.
To do this we need an encoding scheme.
To ensure that encoding the problem does not change its essential nature,
an encoding scheme must be concise:
• Not add unnecessary information, or padding (e.g. the solution!)
• Represent numerical information efficiently (not in base 1!)
2-11
Computability and Complexity
Question
What is a suitable encoding scheme for graphs?
2-12
Computability and Complexity
Languages
For a decision problem , and an encoding scheme e with alphabet ,
the set of strings corresponding to instances with answer yes is denoted
L(,e)
and called the language associated with  and e.
Note that
L(,e) *
For decision problems we just want to decide if a given string
belongs to L(,e)
2-13
Computability and Complexity
What is a computation?
Alan Turing considered this question in 1936
He argued that any computation can be done using the following steps:
• Concentrate on one part of the problem
(for example, one piece of paper, one arithmetic operation, etc.)
• Depending on this, and present state of the computer:
- Modify this part of problem;
- Move to another part of problem;
- Change into a new state.
• Repeat this until finished.
2-14
Computability and Complexity
Implications
• If the computation can be described in a finite space, then there can
can be only a finite number of different situations to deal with
• Therefore, there can be only a finite number of “states” and a
finite number of “symbols”.
• But note that the computation might continue forever and never
finish, and it might use (potentially) infinite storage space
2-15