# Lecture 022

## Computability

Decision Problem: a set of elements of some type

• $S = \{(r, s): regexp * string | s \in L(r) \}$ (where (r, s) : t)

• Decision procedure of S: function $\code{f: t -> bool}$ (f decides S)

• f(x) => true iff $x \in S$
• f is total

Decidable (recursive): if there exists a decision procedure for S

Example:

fun acc(r, s) = accept r s


(acc decides S)

### Showing function can't tell whether a function is in halting problem. (undecidable)

The halting problem: $HALT = \{(g, x) : (int -> int) * int | g(x) is valuable (ie. no loop) \}$ Theorem: HALT is undecidable Proof:

Suppose H is a decision procedure for HALT (H decides whether the input is in HALT)
fun loop x = loop x
fun diag (x: int): int = if H (diag, x) then loop 0 else 0
(Contradiction, because if H says diag do not loop, then it loop)


### Showing function can't tell whether a function with 0 as argument is in halting problem. (undecidable)

$HALT0 = \{g : int -> int | g(0) is valuable \}$ Theorem: HALT0 is undecidable Proof:

Suppose Z: (int -> int) -> bool decides HALT0
(* Now we are creating an H from already working Z *)
fun H (g: int -> int, x : int) : bool = Z (fn _ => g x_)
(* Therefore, Z should not exist because H does not exist *)


Reduction: HALT <= HALT0 (if I can do HALT0, then at least I can do HALT), HALT is easier than HALT0 (If HALT0 is decidable, then HALT is decidable)

### Showing exists function that loop or tell whether a function is in halting problem (R.E.)

Semi-Decision procedure (recursively enumerable, r.e.): may not be total (can loop)

HALT0 is r.e. (as well as HALT)

fun Z (g: int -> int) : bool = (g 0; true)


### Sets

Co-r.e.: if $ is in r.e., then $ is in co-r.e.

S : decision_problem is in the Universal set $. $

Lemma 1: If set $ is decidable, then set $ is decidable. Where the symbol $ was used to represent set complement (co-). (if there exists a total function to tell whether $s \in S$ and return true, then there exists a total function to tell whether $s \in S$ and return false)

Lemma 2: If $, then S is decidable Proof: to decide whether x is in S.

• $S$: original set, that is in R.E.

• $\lnot S$: complement of the set

• $f$: a function semi-decides S

• $f'$: a function semi-decides $\lnot S$

• then we can run two functions in parallel and give a definite answer

### Questions

Are r.e. and co-r.e. really complement of each other? If so, there exists no element in r.e. \cap co-r.e. by definition. Lemma 2's assumption is false

Table of Content