This is an old revision of the document!


Reduceri Turing

Reducerile Turing sunt o unealtă folositoare pentru a demonstra (ne)decidabilitatea/acceptabilitatea unor probleme. Vom folosi în mod predominant reducerile pentru a demonstra prin absurd că o problemă nouă $ f$ nu este decidabilă, atfel:

  • presupunem că $ f$ e decidabilă, deci există o mașină $ M_f$ care o decide
  • alegem o problemă cunoscută $ g$ despre care știm deja (dintr-o demonstrație anterioară de la curs/laborator) că este nedecidabilă. Un exemplu bun este problema terminării.
  • găsim o transformare computabilă $ T: \Sigma^* \rightarrow \Sigma^*$ pentru care propoziția $ \forall w \in \Sigma^*, g(w) = TRUE \iff f(T(w)) = TRUE$ este adevărată
  • putem deci să construim mașina $ M_g$ care pentru orice input $ w$ simulează $ M_T$, apoi $ M_f$; rezultatul fiind că $ g$ e decidabilă
  • în urma contradicției, concluzionăm că presupunerea e greșită, deci $ f$ nu e decidabilă.
În continuare, aveti un cheatsheet.pdf pentru a va ajuta la rezolvări.

1. Demonstrați, folosind reduceri, că următoarele probleme sunt nedecidabile:

  • $ f_{111}(M) = TRUE \iff M[111] \rightarrow TRUE$

Click to display ⇲

Click to hide ⇱

O să încercăm să arătăm că $ f_{h} \le_m f_{111}$.

Trebuie să găsim o transformare t care primeşte inputul lui Halting Problem şi întoarce un input pentru $ f_{111}$: $ M, w \to t \to M^*$

După ce am găsit asta, mai ramane de demonstrat doar: $ f_{h}(M, w) = TRUE \iff f_{111}(M^*) = TRUE$

$ M^*(x):$

   run M[w]
   return x == 111

Demonstraţii:

  1. $ f_{h}(M, w) = TRUE \Rightarrow M[w] \text{se termină} \Rightarrow \text{vom returna x == 111} \Rightarrow \text{când x este 111}, M^* \text{va tranziţiona în Y} \Rightarrow M^*[111] \rightarrow TRUE \Rightarrow f_{111}(M^*) = TRUE$
  2. $ f_{111}(M^*) = TRUE \Rightarrow M^*[111] \rightarrow TRUE \Rightarrow \text{am ajuns la return} \Rightarrow \text{run M[w] din }M^* \text{nu a ciclat} \Rightarrow \text{M[w] s-a oprit} \Rightarrow f_{h}(M, w) = TRUE$

Din cele 2 direcţii ale demonstraţiei $\Rightarrow f_{h} \le_m f_{111}$.

  • $ f_{p}(M) = TRUE \iff \forall w, M \text{ decide dacă w e palindrom} $

Click to display ⇲

Click to hide ⇱

O să încercăm să arătăm că $ f_{h} \le_m f_{p}$.

Trebuie să găsim o transformare t care primeşte inputul lui Halting Problem şi întoarce un input pentru $ f_{p}$: $ M, w \to t \to M^*$

$ M^*(x):$

   run M[w]
   check if x is palindrome

Demonstraţii:

  1. $ f_{h}(M, w) = TRUE \Rightarrow M[w] \text{se termină} \Rightarrow \text{o sa verificăm dacă x este palindrom} \Rightarrow \text{când x este palindrom}, M^* \text{va tranziţiona în Y} \Rightarrow f_{p}(M^*) = TRUE$
  2. $ f_{p}(M^*) = TRUE \Rightarrow M^*[x] \text{decide daca x este palindrom } \forall x \Rightarrow \text{am ajuns la return} \Rightarrow \text{run M[w] din }M^* \text{nu a ciclat} \Rightarrow \text{M[w] s-a oprit} \Rightarrow f_{h}(M, w) = TRUE$

Din cele 2 direcţii ale demonstraţiei $\Rightarrow f_{h} \le_m f_{p}$.

  • $ f_{rev}(M) = TRUE \iff \forall w, M \text{ computează inversul lui w}$

Click to display ⇲

Click to hide ⇱

O să încercăm să arătăm că $ f_{h} \le_m f_{rev}$.

Trebuie să găsim o transformare t care primeşte inputul lui Halting Problem şi întoarce un input pentru $ f_{rev}$: $ M, w \to t \to M^*$

$ M^*(x):$

   run M[w]
   return rev(x)

Demonstraţii:

  1. $ f_{h}(M, w) = TRUE \Rightarrow M[w] \text{se termină} \Rightarrow \text{o sa calculeze rev(x) deoarece ajunge la return} \Rightarrow f_{rev}(M^*) = TRUE$
  2. $ f_{rev}(M^*) = TRUE \Rightarrow M^*[x] \text{calculeaza rev(x) } \forall x \forall x \Rightarrow \text{am ajuns la return} \Rightarrow \text{run M[w] din }M^* \text{nu a ciclat} \Rightarrow \text{M[w] s-a oprit} \Rightarrow f_{h}(M, w) = TRUE$

Din cele 2 direcţii ale demonstraţiei $\Rightarrow f_{h} \le_m f_{rev}$.

  • $ f_{own}(M) = TRUE \iff M[enc(M)] \rightarrow TRUE$

Click to display ⇲

Click to hide ⇱

O să încercăm să arătăm că $ f_{h} \le_m f_{own}$.

Trebuie să găsim o transformare t care primeşte inputul lui Halting Problem şi întoarce un input pentru $ f_{own}$: $ M, w \to t \to M^*$

$ M^*(x):$

   if x == enc(M*):
     run M[w]
   else:
     nu se termină

Demonstraţii:

  1. $ f_{h}(M, w) = TRUE \Rightarrow M[w] \text{se termină} \Rightarrow M^*[enc(M^*)] \text{se termina} \Rightarrow f_{own}(M^*) = TRUE$
  2. $ f_{own}(M^*) = TRUE \Rightarrow M^*[enc(M^*)] \text{se termina} \Rightarrow \text{run M[w] din }M^* \text{nu a ciclat} \Rightarrow \text{M[w] s-a oprit} \Rightarrow f_{h}(M, w) = TRUE$

Din cele 2 direcţii ale demonstraţiei $\Rightarrow f_{h} \le_m f_{own}$.

  • $ f_{finite}(M) = TRUE \iff M \text{ se oprește pentru un număr finit de cuvinte}$

Click to display ⇲

Click to hide ⇱

O să încercăm să arătăm că $ f_{h} \le_m f_{finite}$.

Trebuie să găsim o transformare t care primeşte inputul lui Halting Problem şi întoarce un input pentru $ f_{finite}$: $ M, w \to t \to M^*$

$ M^*(x):$

   run M[w] pentru maxim |x| paşi
    dacă M[w] s-a oprit:
     nu se termina
    else:
     se termina

Demonstraţii:

  1. $ f_{h}(M, w) = TRUE \Rightarrow M[w] \text{ se termină in n paşi} \Rightarrow M^*[w] \text{se opreşte } \forall x \text{, |x| < n}, \text{ciclează } \forall x \text{, |x| >= n} \Rightarrow f_{finite}(M^*) = TRUE$
  2. $ f_{finite}(M^*) = TRUE \Rightarrow M^*[x] \text{ se opreşte după un număr finit de cuvinte }\Rightarrow \text{M[w] s-a oprit după un număr finit de paşi} \Rightarrow f_{h}(M, w) = TRUE$

Din cele 2 direcţii ale demonstraţiei $\Rightarrow f_{h} \le_m f_{finite}$.

  • $ f_{set}(A, M) = TRUE \iff \forall w \in A, M[w] \text{ halts}$

Click to display ⇲

Click to hide ⇱

O să încercăm să arătăm că $ f_{h} \le_m f_{set}$.

Trebuie să găsim o transformare t care primeşte inputul lui Halting Problem şi întoarce un input pentru $ f_{set}$: $ M, w \to t \to A, M^*$

A = {101} $ M^*(x):$

   if x is in A:
    run M[w]
   else:
    nu se termină

Demonstraţii:

  1. $ f_{h}(M, w) = TRUE \Rightarrow M[w] \text{se termină} \Rightarrow \text{cum } M^* \text{se poate opri doar pentru x = 101} \Rightarrow f_{set}(A, M^*) = TRUE$
  2. $ f_{set}(M^*) = TRUE \Rightarrow M^*[x] \text{o să se oprească pentru orice x din A} \Rightarrow \text{M[w] s-a oprit} \Rightarrow f_{h}(M, w) = TRUE$

Din cele 2 direcţii ale demonstraţiei $\Rightarrow f_{h} \le_m f_{set}$.

  • $ f_{x}(M) = TRUE \iff \exists w, M[w] \text{ scrie un x pe bandă la un moment dat}$

Click to display ⇲

Click to hide ⇱

O să încercăm să arătăm că $ f_{h} \le_m f_{x}$.

Trebuie să găsim o transformare t care primeşte inputul lui Halting Problem şi întoarce un input pentru $ f_{x}$: $ M, w \to t \to M^*$

$ M^*(x):$

   run M[w]
   print x

Demonstraţii:

  1. $ f_{h}(M, w) = TRUE \Rightarrow M[w] \text{se termină} \Rightarrow \text{cum } M^* \text{printează x la final} \Rightarrow f_{x}(M^*) = TRUE$
  2. $ f_{x}(M^*) = TRUE \Rightarrow M^*[x] \text{ajunge să printeze x pe bandă} \Rightarrow \text{M[w] s-a oprit} \Rightarrow f_{h}(M, w) = TRUE$

Din cele 2 direcţii ale demonstraţiei $\Rightarrow f_{h} \le_m f_{x}$.

  • $ f_{eq}(M_1, M_2) = TRUE \iff \forall w, M_1[w] \equiv M_2[w]$; i.e. mașinile au același comportament (fie acceptă, fie resping, fie computează aceeași valoare, fie nu se termină) pentru orice cuvânt.

Click to display ⇲

Click to hide ⇱

O să încercăm să arătăm că $ f_{h} \le_m f_{eq}$.

Trebuie să găsim o transformare t care primeşte inputul lui Halting Problem şi întoarce un input pentru $ f_{eq}$: $ M, w \to t \to M_{1}, M_{2}$

$ M_{1}[x]: $

 acceptă

$ M_{2}[x]: $

   run M[w]
   acceptă

Demonstraţii:

  1. $ f_{h}(M, w) = TRUE \Rightarrow M[w] \text{se termină} \Rightarrow M_{2} \text{acceptă orice x, iar } M_{1}[x] \text{deja acceptă orice x din construcţie} \Rightarrow M_1[w] \equiv M_2[w] \Rightarrow f_{eq}(M_{1}, M_{2}) = TRUE$
  2. $ f_{eq}(M_{1}, M_{2}) = TRUE \Rightarrow M_1[w] \equiv M_2[w] \Rightarrow \text{stim din construcţie că} M_{1} \text{acceptă orice x} \Rightarrow M_{2} \text{acceptă orice x} \Rightarrow M[w] \text{se opreşte} \Rightarrow f_{h}(M, w) = TRUE$

Din cele 2 direcţii ale demonstraţiei $\Rightarrow f_{h} \le_m f_{eq}$.

În continuare, problemele $ f_{all}$ și $ f_{any}$ sunt cunoscute ca nedecidabile:
  • $ f_{all}(M) = 1 \iff \forall w, M[w] \rightarrow TRUE$
  • $ f_{any}(M) = 1 \iff \exists w, M[w] \rightarrow TRUE$

2. Construiți următoarele reduceri:

  • $ f_{all} \le_m f_{eq}$

Click to display ⇲

Click to hide ⇱

$ M \to t \to M_{1}, M_{2}$ Trebuie să construim o transformare t, astfel încât să obţinem 2 maşini cu acelaşi comportament doar dacă M[w] se opreşte pentru orice w

$ M_{1}[x]: $

 acceptă

$ M_{2}[x]: $

   run M[x]
   acceptă

Atenţie acest exercitiu are transformarea diferită faţă de exerciţiul 1, subpunctul 8.

Demonstraţii:

  1. $ f_{all}(M) = M \Rightarrow \forall x, M[x] \text{se termină} \Rightarrow M_{2} \text{ acceptă orice x, iar} M_{1} \text{deja acceptă orice x din construcţie} \Rightarrow M_1[w] \equiv M_2[w] \Rightarrow f_{eq}(M_{1}, M_{2}) = TRUE$
  2. $ f_{eq}(M_{1}, M_{2}) = TRUE \Rightarrow M_1[w] \equiv M_2[w] \text{, ştim din construcţie că } M_{1} \text{ acceptă orice x} \Rightarrow M_{2} \text{ acceptă orice x} \Rightarrow M[x] \text{se opreşte pentru orice x} \Rightarrow f_{all}(M, w) = TRUE$
  • $ f_{any} \le_m f_{eq}$

Click to display ⇲

Click to hide ⇱

$ M \to t \to M_{1}, M_{2}$

$ M_{1}[x]: $

 acceptă

$ M_{2}[x]: $

   k = 1
   inputs = [0]
   while true {
    for w in inputs:
     step(M[w]) // rulam o singura tranzitie
     if(M[w] s-a oprit)
      accepta
    k++
    inputs.append(k) 
   }

Demonstraţii:

  1. $ f_{any}(M) = M \Rightarrow \exists w, M[w] \text{se termină} \Rightarrow M_{2} \text{ acceptă orice x, iar} M_{1} \text{deja acceptă orice x din construcţie} \Rightarrow M_1[w] \equiv M_2[w] \Rightarrow f_{eq}(M_{1}, M_{2}) = TRUE$
  2. $ f_{eq}(M_{1}, M_{2}) = TRUE \Rightarrow M_1[w] \equiv M_2[w] \text{, ştim din construcţie că } M_{1} \text{ acceptă orice x} \Rightarrow M_{2} \text{ acceptă orice x} \Rightarrow \exists w \text{ astfel încât } M[w] \text{ se opreşte} \Rightarrow f_{any}(M, w) = TRUE$
  • $ f_{p} \le_m f_{eq}$

Click to display ⇲

Click to hide ⇱

$ M \to t \to M_{1}, M_{2}$

$ M_{1}[x]: $

 acceptă

$ M_{2}[x]: $

   run M[x]
   if M decide corect daca x este palindrom:
    accepta
   else:
    nu accepta

Demonstraţii:

  1. $ f_{p} = TRUE \Rightarrow \forall x M \text{decide daca e palindrom} \Rightarrow M_{2} \text{ acceptă orice x, iar} M_{1} \text{deja acceptă orice x din construcţie} \Rightarrow M_1[w] \equiv M_2[w] \Rightarrow f_{eq}(M_{1}, M_{2}) = TRUE$
  2. $ f_{eq}(M_{1}, M_{2}) = TRUE \Rightarrow M_1[w] \equiv M_2[w] \text{, ştim din construcţie că } M_{1} \text{ acceptă orice x} \Rightarrow M_{2} \text{ acceptă orice x} \Rightarrow M \text{ decide corect dacă x este palindrom} \Rightarrow f_{p} = TRUE$
  • $ f_{own} \le_m f_{eq}$

Click to display ⇲

Click to hide ⇱

$ M \to t \to M_{1}, M_{2}$

$ M_{1}[x]: $

 acceptă

$ M_{2}[x]: $

   if x == enc(M):
    run M[x]
   accepta

Demonstraţii:

  1. $ f_{own} = TRUE \Rightarrow M[enc(M)] \text{ se termină} \Rightarrow M_{2} \text{ acceptă orice x, iar} M_{1} \text{deja acceptă orice x din construcţie} \Rightarrow M_1[w] \equiv M_2[w] \Rightarrow f_{eq}(M_{1}, M_{2}) = TRUE$
  2. $ f_{eq}(M_{1}, M_{2}) = TRUE \Rightarrow M_1[w] \equiv M_2[w] \text{, ştim din construcţie că } M_{1} \text{ acceptă orice x} \Rightarrow M_{2} \text{ acceptă orice x} \Rightarrow M[enc(M)] \text{ se termină} \Rightarrow f_{own} = TRUE$
Dacă $ t_{1}$ şi $ t_{2}$ sunt două funcţii computabile $ \Rightarrow t = t_{1} \circ t_{2} $ este computabilă.

3. Demonstrați că relația $ \le_m$ e reflexivă și tranzitivă.

Click to display ⇲

Click to hide ⇱

Demonstrăm că $ \le_m$ e reflexivă

Fie o problemă $ f$ şi o transformare $ t: \Sigma^* \rightarrow \Sigma^*, t(w) = w$

$ f(w) = True \iff f(t(w)) = TRUE$ deci $ f \le_m f$

Demonstrăm că $ \le_m$ e tranzitivă

Fie probleme de decizie f, g, h astfel încât:

$ f \le_m g$ (deci există o transformare $ t_{1}$ a.î. $ f(w) = TRUE \iff g(t_{1}(w)) = TRUE$)

$ g \le_m h$ (deci există o transformare $ t_{2}$ a.î. $ g(w) = TRUE \iff h(t_{2}(w)) = TRUE$)

Luăm transformarea $ t = t_{1} \circ t_{2}$:

$ f(w) = TRUE \iff h(t_{2}(t_{1}(w))) = TRUE$

$ f(w) = TRUE \iff h(t(w))) = TRUE \Rightarrow f \le_m h$