Please enable JavaScript.
Coggle requires JavaScript to display documents.
Theory Of Computing - Coggle Diagram
Theory Of Computing
Computability
Effective Computability
-
A set is effectively enumerable iff it is the range of a total or partial effectively computable function on the natural numbers
A function ƒ is effectively computable there is a list of instructions giving a step-by-step procedure that will determine in a finite number of steps the value ƒ(n) for any argument n for which ƒ returns a value.
Formal Notions of EC
-
-
Church-Turing Thesis
Any real-world computation can be translated into an equivalent computation on a Turing Machine
Turing Machines
-
Example Turing Machines
TM that accepts {a^n b^n c^n | n ≥ 0}
- TM starts in s, scans right to check if input string has form abc*
- Machine does not change anything (i.e. replaces each symbol with same symbol)
- TM replaces first blank symbol |_| with right endmarker -|
- TM scans left, erases first
c, then first b, then first a until |-
- TM scans right, erases one
a, one b, one c
- TM continues same process
- If TM sees one occurrence of a letter and no occurrence of another, it rejects
- If TM erases all letters, and only blanks between |- and -| remain, it accepts
Decidability
-
Recursive Languages
A language is recursive if there exists a Turing Machine that accepts on all strings in the language and rejects on all strings (over the same alphabet) that are not in the language
Recursively Enumerable Languages
A language is recursively enumerable if there exists a Turing Machine that accepts on all strings in the language and does not accept all strings (over the same alphabet) that are not in the language - can reject or loop.
-
-
Proofs
Recursive sets are closed under complement
- Given a TM M that accepts A, construct a TM M' that accepts -A
- This can be done by swapping the accept and reject states
- Since A is recursive, all inputs either accept or reject so...
- M' accepts Σ* - A and rejects A
- Therefore, a Turing Machine exists that accepts exactly the complement of A and is still recursive as accept states and reject states = Σ*
Lemma: If L and -L are r.e. then L is recursive
- Let's say there are two TMs M1 (which accepts L) and M2 (which accepts -L)
- Assume there is a TM N that simulates M1 and M2 such that when M1 accepts, N accepts and when M2 accepts, N rejects.
- This means that N accepts the same language as M1.
- Since M1 accepts everything in L, it never hangs for L
- Since M2 accepts everything in -L, it never hangs for -L
- This means that N will not hang on any string, making it total.
- Since the language of N is total and L is its language then L is recursive.
This proof requires constructing the TM N. This can be done with a double-tape Turing Machine.
Lemma: If L r.e. but not recursive, -L is not r.e.
- Assume there is a TM M1 that accepts L and TM M2 that accepts -L.
- If L is r.e. but not recursive then M1 must loop on some strings that are not in L, a.k.a -L
- If -L were r.e. then M2 would have to accept for all strings not in L.
- Since we know that some of these loop, M2 cannot accept on every string in -L.
- Therefore there is not TM for -L that accepts for every string in -L.
- Therefore, L is not r.e.
Decidable Properties
Property
A property of a string is a predicate that tells you something about the string. It is either true or false. For example:
- The string has length 2 : {w | #w = 2}
- There is a letter ‘g’ in the string : {w | ‘g’ ∈ w}
Decidable Property
A property is decidable if all strings with that property form a language that is recursive.
- For example: the property that the given string is equal to “duwang” (because all finite languages are recursive)
Semi-decidable Property
A property is semi-decidable if all strings with that property form a language that is recursively enumerable
- For example: the property that the given string is an encoding for a Turing Machine that halts (you can simulate the TM and accept if it halts, but if it loops, then your simulation will loop, making this recursively enumerable but not recursive).
-
Halting Problem
Definition
Informal
Can you come up with a TM that takes M#x as input and accept if M halts on X and rejects if M loops on x
-
-
-
Decidability
-
Semi-Decidable
A decision problem for which there exists a TM that accepts yes/true instances but rejects or loops on no/false instances
-
Reductions
-
Problems
-
Blank Tape Halting Problem (BTHP)
Decide whether a TM M’ halts on the blank tape (no input).
Decide whether a TM M’ halts on input epsilon.
-
-
Properties
-
-
-
-
If A reduces to B and A is not recursive then neither is B
If A ≤ B and A not recursive then neither is B
-
Rice's Theorem
Every non-trivial property of r.e sets is undecidable
If you partition the set of all r.e sets into two using some condition, both partitions will be undecidable
-
Context Free Languages
-
Pushdown Automata (PDAs)
-
Each transition, an element is popped or pushed onto the stack.
Transitions displayed as a,b->c
Where:
- a = input symbol (symbol read from input)
- b = symbol at the top of the stack
- c = symbol to be pushed onto stack
- p = current state
- q = next state
-
When reading from the top of the stack, the element gets popped so to increase the size of the stack, you need to push two symbols
-
-
-
Complexity
Big Notation
Big-ϴ (theta)
Informally
If an algorithm f(n) is ϴ(g(n)) where g(n) is an equation, then the algorithm's complexity scales with g(n) and can do no better or worse
If an algorithm f(n) if ϴ(g(n)) then g(n) is the asymptotic upper and lower bound of f(n)
Formally
For c>0, d>0, integer M>0
dg(n) ≤ f(n) ≤ cg(n)
For all n >= M
f(n) and g(n) have the same rate of growth
Big-O
Informally
If an algorithm f(n) is O(g(n)) then g(n) is the asymptotic upper bound on the complexity of f(n)
f(n) cannot scale worse than g(n)
Formally
For c>0, integer M>0
f(n) ≤ cg(n)
For all n >= M
g(n) is the asymptotic upper bound for f(n)
The Class P
The set of all decision problems that can be solved by a deterministic Turing machine in polynomial time
-
Example Problems
In P
Searching an ordered list
Use binary search, which is O(logn)
Testing whether a list is sorted
Go through the list sequentially and compare every element with the element before, which is O(n)
Searching an unordered list
Use sequential search, which is O(n)
Not in P
Given a first-order statement about non-negative integer variables (with only symbols 0, 1, +, = and logical operators allowed), is it true?
-
-
-
PATH Problem
Problem Statement
Given a directed graph, does there exist a directed path connecting two given nodes?
Solution Algorithm
Mark the start node and mark all nodes it connects to and all the nodes they connect to.
If end node is marked at the end then a solution exists.
This runs in O(n*m) where n is number of nodes and m is number of edges
-
HAMPATH Problem
Problem Statement
Given a directed graph, does there exist a directed path connecting two given nodes that goes through each node exactly once?
Properties
-
The best solution is exponential, whether a better one exists is unknown
-
The Class NP
The set of all decision problems that can be solved by a deterministic Turing machine in polynomial time
-
-
-
Problems
SAT Problem
Problem Statement
Given a boolean expression, does there exist an assignment of true and false values such that the formula is satisfied
-
Proof
We can non-deterministically generate all possible assignments to the variables and then check if the formula is satisfied. Since an NTM always picks the correct assignment, it can solve the problem in linear time (the number of variables).
However, a deterministic variable would require 2^n time where n in the number of variable at it would have to exhaust all possible branches to prove it is unsatisfiable.
HAMPATH Problem
Problem Statement
Given a directed graph, does there exist a directed path connecting two given nodes that goes through each node exactly once
-
Proof
We can non-deterministically generate all sequences of nodes of equal length to the size of the graph and then check the following
- No repetitions are found in the sequence
- The start and end of the sequence coincide with the required nodes
- The sequences define a directed path through the graph
TSP(D) Problem
Problem Statement
Given a graph with weighted edges and an input D, is there a route that goes through every node and ends back at the start with at most distance D
-
Proof
Non-deterministically guess the order of cities to check in, then add up the distances to see if its at most D
3COL Problem
Problem Statement
Given a graph G, is it possible to colour all the nodes of G from one of three colours such that no two adjacent nodes share the same colour.
-
Proof
Non-deterministically guess the colour of each vertex; our computation at each step branches into each of the three colours
-
Presburger Arithmetic
-
-
It is a set of variables, each with either a for all or there exists.
This is combined with an equation that contains the variables from the set.
-
-
NP-Completeness
-
3COL to SAT
-
This can be done by creating a boolean formula with 3 variables for each node x is the graph: rx, gx, bx for is node x red etc.. These variables can be combined in three formulas:
- Union them all to say each node must have a colour
- Negate the ands of each length 2 subset of the variables to say each node must only have ONE colour
- Negate the AND of the same colour of x and y where x -> y to say that adjacent nodes cannot share the same colour.
NP-Hard
A problem is in NP-Hard if all problems in NP can reduce to it in polynomial time.
NP-Hard is the set of all such problems.
Cook-Levin Theorem
-
Corollary
If SAT in P, P=NP
NP-Complete
A problem that is in NP-Hard and in NP
i.e. All problems in NP can reduce to it in polynomial time and the problem itself is in NP
SAT is NP-Complete
-
Cook and Levin proved that SAT is NP-Complete. Therefore, to prove a problem X is NP-Complete all you have to do is prove that it is in NP and find a polynomial time reduction from SAT to X
If X is NP-Hard and X reduces to Y in polynomial time, then X is also NP-Hard
Space Complexity
Definition
The space complexity of a decider is f(n) where f(n) is the maximum number of tape cells the machine scans in any of its branches of computation, on any input of length n
-
-
Space vs Time Complexity
-
Proof
There are at most |Q| * f(n) * 2^(O(f(n))) possible configurations
- |Q| is the number of configurations
- f(n) is the number of possible head positions
- 2^(O(f(n))) is the number of possible tape configurations
A decider will not repeat configurations (on any branch)
So the longest the decider can run is |Q| * f(n) * 2^(O(f(n))) steps.
This is equivalent to 2^(O(f(n)))
PSPACE and NPSPACE
PSPACE
The set of all languages that can be decided by a deterministic Turing machine in polynomial space
NPSPACE
The set of all languages that can be determined by a non-deterministic Turing machine in polynomial space
-
Savitch's Theorem
Theorem
Every f(n) space non-deterministic TM, has an equivalent f(n)^2 space deterministic TM
-
PSPACE-Completeness
PSPACE-Hard
A language X is PSPACE-Hard if every language in PSPACE is polynomial-time reducible to X
-
Why do these definitions use polynomial-time reductions rather than polynomial-space reductions?
Completeness is only meaningful if you use reductions from a potentially smaller class. Every non-trivial problem in PSPACE is PSPACE-complete under PSPACE reductions. However, this is potentially not the case under PTIME reductions as it is a potentially smaller class.
TQBF Problem
-
-
Proof TQBF ∈ PSPACE
- Any tqbf can be rewritten to include quantifiers at the start in linear space
- Recursive algorithm for t.q.b.f on input <φ>:
- If φ of the form ∃x.ψ then call the algorithm on ψ[0/x] and ψ[1/x]. Accept if either accept
- If φ of the form ∀x.ψ then call the algorithm on ψ[0/x] and ψ[1/x]. Accept if both accept
- If φ contains no quantifiers, evaluate it. If true then accept
- This process uses O(n+m) space (where n is the number of variables and m is the size of φ)
-
-