-
Notifications
You must be signed in to change notification settings - Fork 1
/
SyntheseCalculabilite.tex
2928 lines (2452 loc) · 101 KB
/
SyntheseCalculabilite.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\input{lib.tex}
\usepackage{pdfpages}
\usepackage{palatino}
\usepackage{enumitem}
\usepackage[bottom]{footmisc}
\usepackage{desclist}
\usepackage{tocloft}
\setlength\cftparskip{4pt}
\setlist[itemize]{topsep=3pt,after=\vspace{.5\baselineskip}}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\setlength{\parskip}{2mm}
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\newcommand{\stcomp}[1]{\overline{#1}}
\newcommand{\N}{\mathbb{N}}
% Make the style indentedefinition use bold for the name of the theorem
\makeatletter
\def\th@indenteddefinition{%
\thm@notefont{}% same as heading font
\normalfont % body font
}
\makeatother
\lstset{language={Java}}
\def\blurb{\textsc{Université catholique de Louvain\\
École polytechnique de Louvain}}
\def\clap#1{\hbox to 0pt{\hss #1\hss}}%
\def\ligne#1{%
\hbox to \hsize{%
\vbox{\centering #1}}}%
\def\haut#1#2#3{%
\hbox to \hsize{%
\rlap{\vtop{\raggedright #1}}%
\hss
\clap{\vbox{\vfill\centering #2\vfill}}%
\hss
\llap{\vtop{\raggedleft #3}}}}%
\begin{document}
\begin{titlepage}
\thispagestyle{empty}\vbox to 1\vsize{%
\vss
\vbox to 1\vsize{%
\haut{\raisebox{-8mm}{\includegraphics[width=2cm]{logo_ucl.pdf}}}{\blurb}{\raisebox{-3mm}{\includegraphics[scale=0.35]{logo_epl.jpg}}}
\vfill
\ligne{\Huge \textbf{\textsc{Synthèse calculabilité}}}
\vspace{5mm}
\ligne{\large{-- juin 2014 --}}
\vfill
\vspace{5mm}
\ligne{%
\textsc{Hachez} Floran
}
\ligne{%
\vspace{5mm}
\textbf{Contributeurs :}
}
\ligne{%
\textsc{François} Robinet
}
\ligne{%
\textsc{Lena} Peschke
}
\ligne{%
\textsc{Lionel} Nobel
}
}%
\vss
}
\end{titlepage}
\tableofcontents
\newpage
La synthèse est assez longue et fortement inspirée du cours sur la calculabilité
de Yves Deville à l'UCL. Mais, elle reprend ce qui est selon moi intéressant à connaitre
pour l'examen et qui devrait suffire pour répondre et pour justifier les QCM.
Les sources sont sur github : https://github.com/FHachez/SyntheseQ6
\section{Introduction}
\label{sec:introduction}
\paragraph{}
La calculabilité c'est l'étude des limites de l'informatique. Il faut bien
faire attention à faire la différence entre les limites théoriques et les limites
pratiques. Pour la calculabilité, on s'occupe des limites théoriques.
Alors que pour la complexité on s'occupe des limites pratiques. La complexité
détermine la frontière entre ce qui est faisable en pratique et infaisable en pratique.
La question principale de la calculabilité est: "quels sont les problèmes qui peuvent
être résolus par un programme?". La caractéristique de calculabilité ne donne aucune autre information sur le programme que son existence.
\paragraph{} Le but est donc de tracer des frontières entre les programmes calculables,
non calculables et non calculables en pratique.
\paragraph{}
Ça nous permet de savoir quand ça ne sert à rien de résoudre un problème.
De plus, on est conscient de sa complexité intrinsèque d'un
problème.
% paragraph (end)
\subsection{Notion de problème}
\label{subsec:notion_de_probl_me}
\paragraph{}
Premièrement, on doit parler la notion de problème.
Attention, il ne faut pas confondre un problème avec un programme.
Les caractéristiques d'un problème sont:
\begin{itemize}
\item un problème est générique : il s'applique à un ensemble de données.
\item pour chaque donnée particulière, il existe une réponse.
\end{itemize}
On représente un problème dans le cours par une fonction. Donc dans le cours,
la description d'un problème est équivalente à la description d'une fonction.
% paragraph (end)
% subsection notion_de_probl_me (end)
\subsection{Notion de programme}
\label{ssub:notion_de_programme}
Un programme est une "procédure effective", c'est-à-dire exécutable par une machine.
Il existe plein de formalismes permettant la description de "procédure effective".
% subsection notion_de_programme (end)
\subsection{Résultats principaux}
\label{sub:r_sultat_principaux}
\begin{itemize}
\item Équivalence des langages de programmation (complets).
\item Problème non calculable : il existe des problèmes qui ne peuvent
être résolus par un programme. Ex: détection de virus, équivalence
de programme,...
\item Problème intrinsèquement complexe. (Voir complexité) Les problèmes
qui ont une complexité supérieure ou égale à l'exponentielle. Dans
ce cas, même l'amélioration des ordinateurs n'influence presque pas
la taille de l'entrée possible.
\end{itemize}
% subsection r_sultat_principaux (end)
\subsection{Détection de virus}
\label{sub:d_tection_de_virus}
On veut déterminer si un programme P avec une entrée D est nuisible.
Spécification du programme detecteur(P,D):\\
\textbf{Préconditions :} un programme P et une donnée D\\
\textbf{Postconditions :} "Mauvais" si P(D) est nuisible,
"Bon" sinon
\paragraph{}On va créer un programme drole(P) et essayer de détecter s’ il est nuisible.
\begin{lstlisting}
drole(P) \\
if detecteur(P,P) = "Mauvais"
then stop
else infecter un autre programme en y inserant P
\end{lstlisting}
Testons drole(drole).
\begin{lstlisting}
drole(drole)
if detecteur(drole, drole) = "Mauvais"
then stop
else infecter un autre programme en y inserant drole
\end{lstlisting}
\begin{itemize}
\item Si drole(drole) est nuisible alors le programme s'arrête or il
n'est pas nuisible puisqu'il n'a infecté aucun programme.
\item Si par contre il n'est pas nuisible alors il va infecter un
autre programme.
\end{itemize}
On a donc une contradiction ce qui implique que le programme drole ne peut
exister, ce qui implique que le programme detecteur non plus.
% paragraph (end)
% subsection d_tection_de_virus (end)
% section introduction (end)Introduction
\section{Concepts}
\label{sec:concepts}
% Dans cette partie il y a pas moyen de synthétiser beaucoup.
\subsection{Ensembles, langages, relations et fonctions}
\label{sub:ensembles_langages_relations_et_fonctions}
\subsubsection{Ensembles}
\label{ssub:ensembles}
Un ensemble est une collection d'objets, sans répétition, appelés les éléments
de l'ensemble.\\
Notation :
\begin{itemize}
\item Ensemble fini : \{ 0, 1, 2\}
\item Ensemble infini : \{ 0, 1, 2, ...\}
\item Produit cartésien : $A \times B$
\item Ensemble des ensembles : $2^A$ ou $\mathcal{P}(A)$
\item Complément : $\stcomp{A}$
\end{itemize}
% subsubsection ensembles (end)
\subsubsection{Langages}
\label{ssub:Langages}
Notation :
\begin{itemize}
\item une chaîne de caractère ou un mot : séquence FINIE de symboles.
abceced, 010101101
\item chaîne de caractères vide : $\epsilon$
\item un alphabet $\Sigma$ est un ensemble de symboles. $\Sigma = \{1, 2\}$
\item un langage est un ensemble de mots constitués de symboles d'un alphabet
donné.
\item ensemble de tous les mots possibles sur l'alphabet $\Sigma$ : $\Sigma ^*$
\end{itemize}
% subsubsection Langages (end)
\subsubsection{Relations}
\label{ssub:relations}
Soient $A$, $B$ des ensembles.
\begin{itemize}
\item Une relation $R$ sur $A$, $B$ est un sous-ensemble de $A \times B$. C'est-à-dire
un ensemble de paires $<a,b>$ avec $a\in A$, $b\in B$.
\item On peut définir une relation par sa table
\item On peut écrire $<a,b> \in R$ ou $aRb$ ou $R(a,b)$.
\end{itemize}
% subsubsection relations (end)
\subsubsection{Fonctions}
\label{ssub:fonctions}
Soient $A$, $B$ des ensembles.
\begin{itemize}
\item Une fonction $f: A \rightarrow B$ est une relation telle que pour $a \in
A$, il existe au plus un $b \in B$ tel que $<a,b> \in f$
\item écrire $f(a)=b$ est équivalent à $<a,b> \in f$
\item Si il n'existe pas de $b \in B$ tel que $f(a)=b$ alors $f(a)$ est indéfini,
$f(a) = \perp$
\end{itemize}
Dans le cours on utilise les propriétés classiques: dom($f$), image($f$), fonction totale,
fonction partielle, fonction surjective, injective et bijective. Celles-ci ne
seront pas redéfinies ici.\\
On utilise aussi l'\textbf{extension} :
$f: A \rightarrow B$ est une extension de $g: A \rightarrow B$ si $\forall x \in A : g(x)\neq \perp \Rightarrow f(x) = g(x)$.
Autrement dit, $f$ a la même valeur que $g$ partout où $g$ est définie.
\paragraph{Définition d'une fonction}
\label{par:d_finition_d_une_fonciton}
On définit une fonction par sa table qui peut-être infinie.\\
On peut définir la table de plusieurs façons :
\begin{itemize}
\item Par un texte fini déterminant sans contradiction ni ambigüité le contenu
de la table.
\item Par un algorithme ex : $f(x) = 2x^3+5$
\item Écrire toutes les paires de la relation.
\end{itemize}
Attention, il n'est pas nécessaire de décrire ou de connaître un moyen de la calculer
pour pouvoir la définir. Ex : $f(x) = 1$ s'il y a de la vie autre part que sur terre,
$0$ sinon.
% paragraph d_finition_d_une_fonction (end)
% subsubsection fonctions (end)
% subsection ensembles_langages_relations_et_fonctions (end)
\subsection{Ensemble énumérable}
\label{sub:ensemble_num_rables}
Avant de dire ce qu'est un ensemble énumérable, on doit savoir que deux ensembles
ont le même cardinal s’il existe une bijection entre eux.
\begin{mydef}[Ensemble énumérable]
Un ensemble est énumérable ou dénombrable s'il est fini ou s'il a le même cardinal que $\mathbb{\N}$. \\
Quelques propriétés :
\end{mydef}
\begin{myprop}
Tout sous-ensemble d'un ensemble énumérable est énumérable.
\end{myprop}
\begin{myprop}
L'union et l'intersection de deux ensembles énumérables sont énumérables.
\end{myprop}
\begin{myprop}
L'union d'une infinité d'ensembles énumérables est énumérable.\\ (Facile à
démontrer, voir TP)
\end{myprop}
Quelques ensembles non énumérables :
\begin{myexem}
L'ensemble $\R$
\end{myexem}
\begin{myexem}
L'ensemble des sous-ensembles de $\N$, $\mathcal{P}(\N)$
\end{myexem}
\begin{myexem}
L'ensemble des chaînes infinies de caractère sur un alphabet fini
\end{myexem}
\begin{myexem}
L'ensemble des fonctions de $\N$ dans $\N$ (Cas important)
\end{myexem}
% subsection ensemble_num_rables (end)
\subsection{Cantor}
\label{sub:cantor}
On va montrer qu'il existe des ensembles non énumérables par diagonalisation. Ex $\R$.
\begin{myexem}
Exemple de démonstration par diagonalisation:
\begin{enumerate}
\item Construire une table : Liste de tous les grands
mathématiciens \\
\begin{tabular}{l}
\textit{\textbf{D}}E MORGAN \\
A\textit{\textbf{B}}EL\\
BO\textit{\textbf{O}}LE\\
BRO\textit{\textbf{U}}WER\\
SIER\textit{\textbf{P}}INSKI\\
WEIER\textit{\textbf{S}}TRASS\\
\end{tabular}
\item Sélectionner la diagonale : $diag = $DBOUPS
\item Modifier l'élément égal à la diagonale : $diag' =$ CANTOR
\item Montrer que l'élément n'est pas dans la liste $\Rightarrow$ Contradiction
\item Conclusion :
\begin{itemize}
\item Soit on sait que la liste est complète\\
$ \Rightarrow$ CANTOR n'est pas un grand
mathématicien (cas utilisé pour démontrer
halt).
\item Soit on sait que CANTOR est un grand
mathématicien \\
$ \Rightarrow$ la liste est incomplète
(cas utilisé pour la diagonalisation de CANTOR)
\end{itemize}
\end{enumerate}
\end{myexem}
\begin{mytheo}[Diagonalisation de Cantor]
Soit $E = \{ x \text{ réel }| 0<x\leq1\}$, $E$ est non énumérable.
\end{mytheo}
\paragraph{Démonstration :}
On va montrer qu'un nombre $d'$ n'est pas dans l'énumération alors qu'on sait
que $d'$ est un nombre réel compris entre 0 et 1.
On suppose $E$ énumérable. Donc il existe une énumération des éléments de $E$,
$x_0, x_1,\dots,X_k,\dots$. On peut représenter un nombre $x_k$ comme étant une
suite de chiffre $x_{ki}$ : $x_k = 0.x_{k0}x_{k1}\dots x_{kk}\dots$.
\begin{enumerate}
\item On peut donc construire une table infinie : \\
\begin{tabular}{|c||c|c|c|c|c|c|}
\hline
& 1 digit & 2 digit & 3 digit & ... & k+1 digit & ... \\
\hline
$x_0$ & $x_{00}$ & $x_{01}$ & $x_{02}$ & ... & $x_{0k}$ & ... \\
$x_1$ & $x_{10}$ & $x_{11}$ & $x_{12}$ & ... & $x_{1k}$ & ... \\
$x_2$ & $x_{20}$ & $x_{21}$ & $x_{22}$ & ... & $x_{2k}$ & ... \\
: & : &:& : & : & : &:\\
$x_k$ & $x_{k0}$ & $x_{k1}$ & $x_{k2}$ & ... & $x_{kk}$ & ... \\
: & : &:& : & : & : &:\\
\hline
\end{tabular}
\item Sélection de la diagonale (celle-ci est un nombre réel compris
entre 0 et 1)
\[ d=0.x_{00}x_{11}...x_{kk}... \]
\item Modification de cet élément $d$ pour obtenir
\[ d'=0.x_{00}'x_{11}'...x_{kk}'... \]
Où $x_{ii}'=5$ si $x_{ii}'\neq 5$ \\
$x_{ii}'=6$ si $x_{ii}'= 5$ \\
On a toujours que cet élément $d'$ est compris entre 0 et 1
\item Contradiction, car $d'$ est dans l'énumération, car $E$ est
énumérable (par supposition). Il existe donc $x_p=d'$,
\[ d'=x_p=0.x_{p0}x_{p1}...x_{pp}... \]
\[ d'=0.x_{00}'x_{11}'...x_{pp}'... \]
La contradiction vient du fait qu'on a choisi $x_{pp}' \neq
x_{pp}$. Donc $d' \neq x_p$ ce qui implique que $d'$ n'est pas
dans l'énumération.
\item Conclusion : $E$ n'est pas énumérable
\end{enumerate}
% subsection cantor (end)
\subsection{Conclusion}
Les ensembles énumérables sont importants pour la suite du cours et aussi, car en
informatique on ne considère que les ensembles énumérables.
Dans le cours, on va souvent devoir montrer qu'un ensemble est énumérable/non énumérable.
Généralement on va utiliser une des techniques suivantes:
\begin{itemize}
\item montrer qu'il y a une bijection avec $\N$ ou $\R$
\item montrer que l'ensemble est fini
\item utiliser la diagonalisation (cf. Cantor)
\item écrire un programme qui énumère l'ensemble
\end{itemize}
% subsection conclusion (end)
% section concepts (end)
\section{Résultats fondamentaux}
\label{sec:r_sultats_fondamentaux}
\subsection{Algorithmes et effectivité}
\label{sub:algorithmes_et_effectivit_}
Qu'est-ce qu'un algorithme?
\begin{mydef}[Algorithme]
C'est une procédure qui peut être appliquée à n'importe
quelle donnée et qui a pour effet de produire un résultat. C'est un ensemble fini
d'instructions qui peuvent être exécutées. Dans ce cours, on ne tracasse pas
de la taille des données, des instructions ni de la mémoire disponible, mais
les considère comme finies.
\end{mydef}
\begin{myrem}
Un algorithme n'est pas une fonction, mais un algorithme calcule une
fonction.
De plus dans le cours on se limite aux fonctions de $\N^n$ dans $\N$. Car on peut,
montrer que ça revient au même que de considérer de $\N^n$ dans $\N^n$ (
$\N^n$ est énumérable et donc au plus de même cardinal que $\N$). On va aussi
utiliser Java comme modèle étant donné que c'est plus facile et qu'on va montrer
que les modèles complets sont équivalents.
\end{myrem}
% subsection algorithmes_et_effectivit_ (end)
\subsection{Fonctions calculables, ensembles récursifs et récursivement énumérables}
\label{sub:fonctions_calculables_ensembles_r_crusids_et_r_cursivement_num_rables}
\subsubsection{Fonction calculable}
\label{ssub:fonction_calculable}
\begin{mydef}[Fonction calculable]
Une fonction $f$ est calculable s’il existe un algorithme qui, recevant comme donnée
n'importe quels nombres naturels $x_1$,...$x_n$ fournit \textbf{tôt ou tard} comme
résultat $f(x)$ s’il existe.
\end{mydef}
\paragraph{} S’il ne se termine pas c'est que $f(x)=\perp$. \\
\begin{myrem}
Il faut faire attention entre ne pas être capable d'écrire un algorithme
et ne pas savoir l'écrire. (Voir exemple TP et cours : y a-t-il une rose
verte sur Mars ou encore x occurrences de 5 dans $\pi$).
\end{myrem}
\begin{myrem}
Une fonction peut-être totale calculable ou partielle calculable.
\end{myrem}
% subsubsection fonction_calculable (end)
\subsubsection{Ensemble récursif et récursivement énumérable}
\label{ssub:ensemble_r_cursif_et_r_cursivement_num_rable}
Soit $A\subseteq \N$
\begin{mydef}[Ensemble récursif]
$A$ est récursif s’ il existe un algorithme qui recevant un $x\in \N$,
fournit \textbf{tôt ou tard} comme résultat
\begin{tabular}{l}
1 si $x\in A$\\
0 si $x\notin A$\\
\end{tabular}
. L'algorithme décide si $x$ est dans $A$ ou non.
\end{mydef}
\begin{mydef}[Ensemble récursivement énumérable]
$A$ est récursivement énumérable s’ il existe un algorithme qui recevant
un $x\in \N$, fourni \textbf{tôt ou tard} \\
comme résultat
\begin{tabular}{l}
1 si $x\in A$\\
ne se termine pas ou retourne un résultat $\neq1$ si
$x\notin A$\\
\end{tabular}
\end{mydef}
\begin{myrem}
Le souci lorsque c'est récursivement énumérable,
c'est que même si l'algorithme permet de dire si x est dans A, si x
n'est pas dans A on ne sait rien dire. En effet, on ne peut pas dire à un moment qu'on
arrête l'algorithme et que l'élément n'est pas dans A.
Car il est possible que x soit dans A et que l'algorithme ne
l'ait pas encore déterminé (l'algorithme retourne tôt ou tard un
résultat si x est dans A!).
\end{myrem}
\paragraph{Définition importante :}
\label{par:d_finition_importante}
\begin{mydef}[Fonction caractéristique]
Fonction caractéristique de A:
$X_A$ : $\N$ $\rightarrow$ $\N$, \\
tel que $X_A(x)$ =
\begin{tabular}{l}
1 si x $\in$ A \\
0 si x $\notin$ A
\end{tabular}
\end{mydef}
\begin{myprop}
A est un ensemble récursif ssi $X_A$ est une fonction totale
calculable. \\
Ça veut dire qu'il existe une fonction $X_A$ qui décide si n'importe
qu'elle x appartient ou non à A. Ce qui est évident.
\end{myprop}
\begin{myprop}
A est un ensemble récursivement énumérable ssi A = dom(f) et f est une
fonction (totale ou partielle) calculable.\\
En effet, si f(x) est défini alors
x appartient à A.
\end{myprop}
\begin{myprop}
A est un ensemble récursivement énumérable ssi A est vide ou A = image(f) et f
est une fonction totale calculable. \\
Car f est une fonction d'énumération (elle
peut répéter plusieurs fois un élément, mais ce n'est pas gênant).
\end{myprop}
% paragraph d_finition_importante (end)
\paragraph{Propriétés importantes}
\label{par:propri_t_s_importantes}
\begin{myprop}
A récursif $\Rightarrow$ A récursivement énumérable. (Propriété plus
faible)
\end{myprop}
\begin{myprop}
A récursif $\Rightarrow$ ($\N$\textbackslash A) récursif.\\ On peut facilement créer
un programme qui retourne 1 - le programme qui décide A.
\end{myprop}
\begin{myprop}
A récursivement énumérable et ($\N$\textbackslash A) récursivement énumérable
$\Rightarrow$ A récursif.\\ Il suffit de créer un programme
qui exécute un peu du programme qui décide A puis un peu de celui qui
décide ($\N$\textbackslash A). Et ainsi de suite, jusqu'au moment ou l'un
des programmes retourne une réponse.
\end{myprop}
\begin{myprop}
A fini $\Rightarrow$ A récursif. (Trivial)
\end{myprop}
\begin{myprop}
($\N$\textbackslash A) fini $\Rightarrow$ A récursif. (Trivial)
\end{myprop}
% paragraph propri_t_s_importantes (end)
% subsubsection ensemble_r_cursif_et_r_cursivement_num_rable (end)
% subsection fonctions_calculables_ensembles_r_crusids_et_r_cursivement_num_rables (end)
\subsection{Thèse de Church-Turing}
\label{sub:th_se_de_church_turing}
Grâce à la définition, on sait montrer qu'une fonction est calculable. Mais comment
montrer qu'une fonction n'est pas calculable? Pour ça on a besoin d'une définition
couvrant la totalité des fonctions calculables. \\
Une autre question est est-ce que prendre un modèle particulier est restrictif?\\
La thèse de Turing répond à ces questions.
\begin{enumerate}
\item Aucun modèle de la notion de fonction calculable n'est plus puissant
que les Machines de Turing \\
Version moderne : Une fonction est calculable s'il existe un
programme d'ordinateur qui calcul cette fonction
\item Toute fonction calculable est calculable par une machine de Turing.
\item Toutes les définitions formelles de la calculabilité connues à ce
jour sont équivalentes (Théorème, ça a été démontré) (justifie
l'utilisation de Java comme modèle)
\item Toutes les formalisations de la calculabilité établies par la
suite seront équivalentes aux définitions connues
\end{enumerate}
1, 2 et 4 sont des thèses universellement reconnues comme vraies et la 3 est un
théorème.
% subsection th_se_de_church_turing (end)
\subsection{Programmes et fonctions}
\label{sub:programmes_et_fonctions}
Dans le cours on utilise un langage de programmation, Java, comme modèle.
\begin{mydef}[P]
Soit P l'ensemble des programmes Java qui reçoit un ou plusieurs entiers comme
donnée et qui imprime/retourne un résultat.
\end{mydef}
\begin{myprop}
P est un ensemble infini dénombrable, car c'est chaîne de caractère d'un
alphabet fini. P est récursif, car il existe un programme, le compilateur, qui détermine
si un programme est un programme Java ou non.
\end{myprop}
\begin{mydef}[Énumération de P]
P = $P_0$, $P_1$,... ,$P_k$,... est l'énumération des programmes Java
sans répétition. Ce qui implique qu'on peut numéroter les programmes Java.\\
\end{mydef}
\begin{mydef}[$P_k$]
$P_k$ est le programme numéro k dans P
\end{mydef}
\begin{mydef}[$\phi^{(n)}_k$]
$\phi^{(n)}_k$ : $\N^n \rightarrow \N$ comme
étant la fonction calculée par $P_k$
\end{mydef}
\begin{myprop}
Il existe donc une fonction f : $\N\rightarrow P$ telle que :
\begin{itemize}
\item f(k) = $P_k$
\item f calculable
\item k (numéro d'un programme) et $P_k$ sont deux représentations
distinctes d'un même objet.
\end{itemize}
\end{myprop}
% subsection programmes_et_fonctions (end)
\subsection{Existence de fonctions non calculable}
\label{sub:existence_de_fonction_non_calculables}
Il existe beaucoup de fonctions non calculables, car le nombre de fonctions de $\N$
dans $\N$ est non dénombrable (Démo par Cantor lors d'un TP). Or le nombre de
programmes Java est dénombrable. Donc il y a beaucoup de fonctions qui ne sont
pas calculables.
\paragraph{} On va s'intéresser qu'aux fonctions qui sont définies par une table
finie ou une table infinie que l'on peut décrire de façon finie
(on n'est pas capable d'écrire une définition infinie). Il en existe une infinité
dénombrable.
\paragraph{} On va maintenant montrer que ce n'est pas parce qu’une fonction
est définie par une table finie qu'elle est nécessairement calculable (exemple la
fonction halt qui détermine si un programme se termine ou non).
% subsection existence_de_fonction_non_calculables (end)
\subsection{Problème de l'arrêt}
\label{sub:probl_me_de_l_arr_t}
\begin{mydef}[halt]
halt est la fonction : P x $\N$ $\rightarrow$ $\N$ telle que \\
\begin{tabular}{rl}
halt(n, x) = 1 & si $P_n(x)$ se termine \\
halt(n, x) = 0 & sinon \\
ou &\\
halt(n, x) = 1 & si $\phi_n(x)\neq \perp$ \\
halt(n, x) = 0 & sinon \\
\end{tabular}
\end{mydef}
\begin{myprop}
halt est une fonction bien définie, totale et sa table est infinie, mais décrite
de manière finie. Or on va montrer que halt n'est pas calculable par
diagonalisation (comme pour la démonstration de Cantor).\\
\end{myprop}
\begin{myrem}
Attention, juste dire qu'on ne sait pas écrire un programme qui calcule
halt ne prouve pas qu'on ne sait pas calculer halt. En effet, comme vu
dans le chapitre 1, le programme existe est différent de savoir écrire
le programme.
\end{myrem}
\begin{mytheo}[halt]
halt n'est pas calculable
\end{mytheo}
\paragraph{Démonstration :}
On suppose halt calculable.
\begin{enumerate}
\item On peut donc construire une table infinie définissant la fonction
halt : \\
\begin{tabular}{|c||c|c|c|c|c|c|}
\hline
& 0 & 1 & 2 & ... & k & ... \\
\hline
$p_0$ & $halt(0,0)$ & $halt(0,1)$ & $halt(0,2)$ & ... & $halt(0,k)$ & ... \\
$p_1$ & $halt(1,0)$ & $halt(1,1)$ & $halt(1,2)$ & ... & $halt(1,k)$ & ... \\
$p_2$ & $halt(2,0)$ & $halt(2,1)$ & $halt(2,2)$ & ... & $halt(2,k)$ & ... \\
: & : &:& : & : & : &:\\
$p_k$ & $halt(k,0)$ & $halt(k,1)$ & $halt(k,2)$ & ... & $halt(k,k)$ & ... \\
: & : &:& : & : & : &:\\
\hline
\end{tabular}
\item Sélection de la diagonale
\[ diag :halt(0,0),halt(1,1),...,halt(k,k),... \]
\[diag(n) = halt(n,n)\]
\item Modification de cet élément diag pour obtenir
$diag'(n) =$
\begin{tabular}{c}
1 si halt(n,n) = 0\\
$\perp$ si halt(n,n) = 1\\
\end{tabular}\\
$diag'$ est calculable, car halt est calculable (il y a moyen
d'écrire un programme qui calcul $diag'$ en utilisant $diag$)
\item Contradiction :\\
Donc il existe un programme $P_d$ qui calcule
$diag'$.
$diag'(d) =$
\begin{tabular}{c}
1 si halt(d,d) = 0\\
$\perp$ si halt(d,d) = 1\\
\end{tabular}
Mais,
\begin{itemize}
\item Si $diag'(d)= 1$ $\\
\Rightarrow \ halt(d,d) = 0 \\
\Rightarrow \ P_d(d)$ ne se termine donc pas $ \\
\Rightarrow diag'(d)$ ne se termine pas $ \\
\Rightarrow diag'(d) = \perp$ or on a supposé que $diag'(d) = 1$ $ \\
\Rightarrow $
Contradiction.
\item Si $diag'(d)= \perp$ $\\
\Rightarrow \ halt(d,d) = 1 \\
\Rightarrow \ P_d(d)$ se termine $ \\
\Rightarrow diag'(d)$ termine $ \\
\Rightarrow diag'(d) = 1$ or on a supposé que $diag'(d) = \perp$ $ \\
\Rightarrow $
Contradiction.
\end{itemize}
\item Conclusion : $diag'$ n'est pas calculable $ \Rightarrow $ $diag$
n'est pas calculable $ \Rightarrow $ halt n'est pas calculable.
\end{enumerate}
\paragraph{Conclusion} Il n'existe pas d'algorithme qui détermine si n'importe
quel programme $P_n$ se termine ou non. Mais dans certains formalismes qui ne
sont pas des modèles complets la fonction halt de ce formalisme est calculable.
Par exemple un langage qui ne permet de calculer
que des fonctions totales (exemple java sans aucune boucle)
, halt est calculable (halt retourne toujours 1). \\
De plus, il faut faire attention, car ce n'est pas parce que halt n'est pas
calculable que pour un programme donné k, $halt(k,x)$ est non calculable. Par
exemple $halt(32,123)$ est une fonction constant donc calculable (ce n'est pas
pour autant qu'on est capable d'écrire l'algorithme), $halt(32,x)$ peut-être
calculable, mais ça dépend du
programme 32, par exemple si celui-ci est constant.
\begin{myrem}
Cette partie du cours est très importante, car on a trouvé un
"trou dans le mur des fonctions calculables" et on va étendre le trou (métaphore
de Mr Deville). C'est-à-dire que maintenant on va utiliser halt pour montrer
que d'autres fonctions sont calculables/non calculable. Par exemple
par réduction par rapport à halt.
\end{myrem}
Il existe donc au moins un ensemble non récursif
K.
\begin{mydef}[K]
K =
\begin{tabular}{l}
\{n|(n,n)$\in$ HALT\}\\
\{n| halt(n,n)=1\}\\
\{n| $P_n(n)$ se termine\} \\
\end{tabular}
K est donc l'ensemble des programmes n, $P_n$, qui
se termine pour l'entrée n.
\end{mydef}
\begin{mydef}[HALT]
HALT est l'ensemble des programmes k qui se termine pour l'entrée x,
\[ HALT = \{(n,x)|P_n(x)\text{se termine}\}\]
\end{mydef}
\begin{myprop}
K et HALT ne sont pas récursifs
\end{myprop}
\begin{myprop}
K et HALT sont récursivement énumérables (car il suffit de lancer le
programme et s’il retourne quelque chose il se termine sinon on ne sait
pas)
\end{myprop}
\begin{myprop}
$\stcomp{HALT}$ n'est pas récursivement énumérable sinon HALT
serait récursif.
\end{myprop}
\begin{myprop}
$\stcomp{K}$ n'est pas récursivement énumérable
\end{myprop}
TODO insérer le schéma sur les fonctions et les ensembles
\begin{mydef}[Un ensemble co-récursivement énumérable] est un ensemble dont le
complément est récursivement énumérable. Par exemple $\stcomp{HALT}$. On peut
en déduire que si un ensemble est récursivement énumérable et co-récursivement
énumérable alors il est récursif.
\end{mydef}
% subsection probl_me_de_l_arr_t (end)
\subsection{Insuffisance des fonctions totales}
\label{sub:insuffisance_des_fonctions_totales}
Comme on a vu qu'il était possible de calculer halt dans un modèle qui
ne permet de calculer que des fonctions totales. On se pose la question de
pourquoi on n'utilise pas un tel modèle pour lequel la fonction halt est
calculable (pour un tel modèle halt retourne toujours 1.
De plus les fonctions "pratiques" sont
des fonctions totales. Mais on va montrer qu'un tel modèle nous restreint
beaucoup sur ce qu'on peut calculer.
\begin{myexem}
Un tel modèle est par exemple BLOOP (défini plus loin) ou encore
Java, mais sans boucle donc par intuition on se doute qu'il y a
beaucoup de choses qu'on ne peut pas calculer.
\end{myexem}
\begin{mydef}
Posons Q un langage (\textbf{non trivial}) dont tous les programmes se terminent et pour
lequel il existe un interpréteur calculable, interpret(n,x)=$\phi'_n$.
\end{mydef}
\begin{mydef}
$\phi'_k$ est la fonction calculée par le programme $Q_k$.
\end{mydef}
\begin{myprop}
L'interpréteur est une fonction totale.
\end{myprop}
\begin{mytheo}[Hoare-Allison]
\label{Hoare_Allison}
interpret(n,x) n'est pas calculable dans Q.\\
\end{mytheo}
\paragraph{Démonstration :}
On suppose interpret calculable.
\begin{enumerate}
\item On peut donc construire une table infinie définissant la fonction
interpret : \\
\begin{tabular}{|c||c|c|c|c|c|c|}
\hline
& 0 & 1 & 2 & ... & k & ... \\
\hline
$Q_0$ & $interpret(0,0)$ & $interpret(0,1)$ & $interpret(0,2)$ & ... & $interpret(0,k)$ & ... \\
$Q_1$ & $interpret(1,0)$ & $interpret(1,1)$ & $interpret(1,2)$ & ... & $interpret(1,k)$ & ... \\
$Q_2$ & $interpret(2,0)$ & $interpret(2,1)$ & $interpret(2,2)$ & ... & $interpret(2,k)$ & ... \\
: & : &:& : & : & : &:\\
$Q_k$ & $interpret(k,0)$ & $interpret(k,1)$ & $interpret(k,2)$ & ... & $interpret(k,k)$ & ... \\
: & : &:& : & : & : &:\\
\hline
\end{tabular}
\item Sélection de la diagonale
\[diag(n) = interpret(n,n)\]
\item Modification de cet élément diag pour obtenir
$diag'(n) = interpret(n,n)+1$
$diag'$ est calculable, car interpret est calculable dans Q (il y a moyen
d'écrire un programme qui calcule $diag'$ en utilisant $diag$)
\item Contradiction :\\
Donc il existe un programme $Q_d$ qui calcule
$diag'(d) = interpret(d,d)+1$ (par construction).
Mais, par définition $diag'(d) = \phi_d(d) = interpret(d,d)$.
En effet, calculer $\phi_d(d)$ revient à interpréter le programme
d avec la donnée d.
\item Conclusion : $diag'$ n'est pas calculable $ \Rightarrow $ $diag$
n'est pas calculable $ \Rightarrow $ interpret n'est pas calculable
dans Q.
\end{enumerate}
\begin{myrem}
Si on toutes les fonctions calculées par les programmes de Q n'étaient
pas totales, alors ça n'aurait pas posé de problème, car $interpret(d,d)$
ne se serait pas terminé or un programme qui ne se termine pas +
quelque chose, reste un programme qui ne se termine pas.
\end{myrem}
\subsubsection{Implication du théorème \ref{Hoare_Allison}, Hoare Allison }
\begin{myprop}
Si un langage (\textbf{non trivial}) ne permet que le calcul de fonction total alors :
\begin{itemize}
\item l'interpréteur de ce langage n'est pas calculable dans ce langage
\item il existe des fonctions totales non programmables dans ce langage
\item ce langage est \bf{restrictif}
\end{itemize}
\end{myprop}
\begin{myprop}
Si on peut programmer l'interpréteur d'un langage L dans L alors il est
impossible de programmer la fonction halt de L car celle-ci n'est pas calculable.
\end{myprop}
\begin{myprop}
Dans un langage de programmation, il est donc impossible que
l'interpréteur et la fonction halt (de ce langage) puissent être programmés dans ce langage.
\end{myprop}
\begin{myprop}
Si on veut pouvoir programmer toutes les fonctions
totales dans un langage, le langage doit permettre la programmation de
fonctions non totales.
\end{myprop}
\begin{myprop}
L'ensemble \{n| $\phi_n$ est totale\} n'est pas récursif. (sinon on
saurait créer un langage qui ne calcule que des fonctions totales??)
\end{myprop}
\begin{mytheo}[fonction universelle]
La fonction universelle (c'est-à-dire l'interpréteur) est $\theta(n,x)$ (programme $P_z$) tel que :
\[ \exists z \forall n,x : \theta(n,x) = \phi_n(x)\]
\end{mytheo}
% subsection insuffisance_des_fonctions_totales (end)
\subsection{Extension de fonctions partielles}
\label{sub:extension_de_fonctions_partielles}
\begin{mytheo}
Il existe une fonction partielle calculable g telle
qu'aucune fonction totale calculable n'est une extension de g.
\end{mytheo}
\begin{myrem}
Ca implique que si on a une fonction partielle g, il n'est pas
toujours possible de créer une fonction totale f qui étend g
tel que en dehors du domaine de g, f retourne un code d'erreur.
\end{myrem}
% subsection extension_de_fonctions_partielles (end)
\subsection{Théorème de Rice}
\label{sub:th_or_me_de_rice}
Soit A $\subseteq$ $\N$
\begin{mytheo}[Rice]
Si $A$ récursif et $A\neq \emptyset$ et $A \neq \N$ \\
Alors $\exists i \in A$ et $\exists j \in \N \setminus A$ tels que $\phi _i = \phi _j$
\end{mytheo}
On utilise le plus souvent le théorème de Rice en ayant recourt à sa contraposée:
\begin{mytheo}[Rice (contraposée)]
Si $\forall i \in A$ et $\forall j \in \stcomp{A}$ on a $\phi_i \neq \phi_j$ \\
Alors $A$ non-récursif ou $A = \emptyset$ ou $A = \N$
\end{mytheo}
Dans de nombreux cas, on peut garantir $A \neq \emptyset$ et $A \neq \N$, ce qui permet de se servir de la contraposée pour démontrer qu'un ensemble est non-récursif sans utiliser la preuve par diagonalisation.
\paragraph{Démonstration : }
On a $\forall i \in A$ et $\forall j \in \stcomp{A}$ tel que $\phi_i \neq
\phi_j$\\
Supposons $A$ récursif, $A=\emptyset$ et $A\neq \N$\\
On va montrer que HALT est récursif, car on peut construire un programme qui
décide HALT, alors qu'on sait que HALT n'est pas récursif.
\begin{enumerate}
\item Construisons le programme $P_k$
\begin{lstlisting}
while true do;
\end{lstlisting}
$\forall x \ \phi_k(x) = \perp$
\item $\stcomp{A}\neq \emptyset$ car $A \neq \N$,
supposons $k\in \stcomp{A}$ (hypothèse sans importance, car montrer que
$A$ ou $\stcomp{A}$ est non récursif revient au même, car $A$ non
récursif $ \Leftrightarrow $ $\stcomp{A}$ non récursif) \\
\item $A\neq \emptyset$ par hypothèse, supposons $m\in A$
\item $\phi_i \neq \phi_j$ et ce $\forall i \in A, \forall j \in \stcomp{A}$ par hypothèse donc
$\phi_m \neq \phi_k$
\item Construisons un programme $P(z)$ qui calcule la fonction $g(z)$,
$P(z) \equiv $
\begin{lstlisting}
P_n(x);
P_m(z);
\end{lstlisting}
\begin{myrem}
On sait que si un programme calcule une fonction $
f(x)=\perp \ \forall x$ alors ce programme doit être dans $\stcomp{A}$ car
$f(x) =\phi_k(x)$.
Or
\begin{itemize}
\item soit notre programme $P(z)$ ne se termine pas $\forall