---
# System prepended metadata

title: COMP3
tags: [Master]

---

---
tags: Master
---

# COMP3

# Computing
Given a function, or equivalently a set, we say that it is computable (or decidable, or recursive) if and only if a procedure can be described to compute the function’s outcome in a finite number of steps.

(Collatz) However, we have provided a procedure that terminates with the correct answer when the answer is “yes” (the function is not total, in the sense that it doesn’t always provide an answer). We call such set recursively enumerable (or RE, in short).

The diagonal method

# (deterministic) TMs
- multi-tape same as single (constant overhead)
- 2-size alphabet same as any bigger alphabet (constant overhead)

## Universal TMs
(Church-Turing thesis). Turing machines are at least as powerful as every physically realizable model of computation.
The set of decision functions f : N → {0, 1} (or, equivalently, f : Σ∗ → {0, 1}), is uncountable.
Given a finite alphabet Σ, the number of TMs on that alphabet is countable.
There are uncomputable decision functions.
HALT is uncomputable
HALTε is uncomputable
A decision function f : Σ∗ → {0, 1} is recursive if and only if it is both R.E. and co-R.E.
Busy beaver is uncomputable

Let languages L1 and L2 and function f be such that L1 <f L2; then
1. if L2 is decidable and f is computable, then L1 is decidable too;
2. if L1 is undecidable and f is computable, then L2 is undecidable too;
3. lf L1 is undecidable and L2 is decidable, then f is uncomputable.
(Rice’s Theorem). All non-trivial semantic properties of TMs are undecidable.

PCP (Post Correspondance Problem) (stringhe concatenate ripetute) is undecidable

Kolmogorov complexity (livello di compressione) is undecidable (“The smallest positive integer not definable with less than thirteen Englishwords.”)

![](https://i.imgur.com/KM9reyg.png)


# P vs NP and Non-det TMs
Non-det TM:
- branches each time it can choose multiple paths and executes them together
- "chooses" the perfect path for acceptance

DTIME(f) = n° step max determ TM è limitato da f
NTIME(f) = .. ........ non-det TM ..

P = DTIME polinomiale
NP = NTIME polinomiale = verifica con certificato in DTIME polinomiale

certificato = informazione utile a verificare che x app a L (che x non app a L nei coNP, co...)
NB: certificato polinomiale rispetto a input

NP hard: at least as hard as all NP (all NP have reduction to this Language)
NP complete: NP hard and NP (the hardest in NP)
reductions are POLINOMIAL (L=>L1 adds polinomial overhead to the equivalent L1 problem)
L complete and L=>L1 (LT ≤p L1) implies L1 complete

L (log space), NL
(Savitch’s theorem). Given a function f(n), NSPACE f(n) ⊆ DSPACE f(n)^2
PSPACE = NPSPACE

# NP complete
- SAT (TM => boolean circuits => SAT)
- 3-SAT
- INDSET: set of vertices of size K that are all disconnected
- CLIQUE: opposite of INDSET: set of vertices of size K that are all connected (complete)
- ILP: Integer Linear Programming (boh)
- VERTEX COVER: vertex subset of size <= k such that every edge is connected to at least one vertex
- 3-VERTEX COLORING (with 3 colors)
- SET COVER: pick exactly k of the given subsets of S, union must be S
- SUBSET SUM: pick elements so that sum=k
- KNAPSACK: max capacity is C and minimum value to achieve is V
- (directed) HAMILTONIAN PATH: find path that touches every vertex exactly once (in directed graph)
- DIRECTED HAMILTONIAN CYCLE: find cycle (closed path) that touches every vertex exactly once
- UNDIRECTED HAMILTONIAN CYCLE
- TRAVELING SALESMAN PROBLEM: given undirected COMPLETE graph, find hamiltonian path of total edge cost <= K
- K-VERTEX COLORING (k colors)
- 

# THEOREMS
### theorem 1: k-tape machine emulation in O(T(n)^2)
need c*T(n) steps for each step of the original machine, therefore
c*T(n)*T(n) = O(T(n)^2)

### theorem 2: alphabet to binary emulation in O(T(n))
![](https://i.imgur.com/Cq576ft.png)
need extra states to remember what I'm reading and what I'm writing
![](https://i.imgur.com/Fca2iM7.png)

### Church-Turing thesis
![](https://i.imgur.com/A7EYiRC.png)

### Decision functions are uncountable
![](https://i.imgur.com/DbrrKS0.png)

### TMs in sigma star are countable
![](https://i.imgur.com/ls5sE4l.png)

### There are uncomputable decision functions
![](https://i.imgur.com/ccmrZ4d.png)

### Theorem 3
![](https://i.imgur.com/sgcB5G3.png)
UC(uc) would give the opposite of UC(uc) (impossible)

### Theorem 4: HALT is uncomputable
![](https://i.imgur.com/JwIMvDX.png)
Reduce UC to HALT

### Theorem 5: HALTe is uncomputable
Machine that writes its own input, then starts computing
We reduced HALT(s,t) to HALTe(s) => impossibru

### Theorem 6
![](https://i.imgur.com/Knq4cGn.png)

### Theorem 7
![](https://i.imgur.com/Qxh0Iek.png)

### Busy beaver
![](https://i.imgur.com/d59AdRS.png)

### S(n) is uncomputable
![](https://i.imgur.com/WONUtUI.png)
Could run S(n) steps to check HALT

### Theorem 9: Busy beaver outgrows everything
![](https://i.imgur.com/4086pIZ.png)

### Theorem 10: Reductions
![](https://i.imgur.com/DMVFWeo.png)

### Using HALT to check mathematical problems
![](https://i.imgur.com/2pupdA6.png)


### RICE's theorem
![](https://i.imgur.com/OgjTSxo.png)
![](https://i.imgur.com/DlYeYhb.png)
![](https://i.imgur.com/nfj2z0M.png)
![](https://i.imgur.com/cHeCihl.png)


### PCP problem
![](https://i.imgur.com/Ht0Onzr.png)
![](https://i.imgur.com/FbBtybY.png)

### Kolmogorov complexity
![](https://i.imgur.com/dRM79nn.png)
![](https://i.imgur.com/u2G4t6k.png)
![](https://i.imgur.com/QHg3lLq.png)

## P vs NP
### Polinomial time
![](https://i.imgur.com/roNeTj8.png)
![](https://i.imgur.com/ZLf5h6w.png)

### CNF
![](https://i.imgur.com/pJVOht3.png)
![](https://i.imgur.com/2SM17mD.png)

### NP definition 1
![](https://i.imgur.com/JRItoQU.png)

### NP definition 2
![](https://i.imgur.com/wSK77MT.png)


### K-sat <= SAT
![](https://i.imgur.com/iPoImFX.png)
![](https://i.imgur.com/pezYLOy.png)

### SAT <= 3-SAT
![](https://i.imgur.com/NlNiAND.png)

### CLIQUE equivalent to INDSET
![](https://i.imgur.com/jswxWN9.png)

### 3-sat <= INDSET
![](https://i.imgur.com/rIuzbCC.png)
![](https://i.imgur.com/3u1Vvkk.png)

## NP hard and NP complete
![](https://i.imgur.com/rgy9i1J.png)
![](https://i.imgur.com/pbv3xDH.png)

### SAT is NP hard (therefore NP complete)
![](https://i.imgur.com/VemAh7M.png)
![](https://i.imgur.com/K8yHgJA.png)

### NP complete reductions
![](https://i.imgur.com/rBjb3GM.png)





