forked from awmorp/turing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TP4--Q3-3.txt
25 lines (20 loc) · 1.15 KB
/
TP4--Q3-3.txt
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
; ENSAI - Cours de Calculabilité et Complexité
; Machine de Turing - TP4 - Q3.3
; Utilisez ce code via le simulateur, à l'adresse https://naereen.github.io/jsTuring_fr/turing.html#Machine
; Incrémentation binaire : ajouter 1 à un nombre binaire
; Entrée : un nombre binaire, n
; Sortie : le nombre binaire n+1
; Exemple entrée : 110 (= 6)
; Exemple sortie : 111 (= 7), sans retenue à propager
; Exemple entrée : 111 (= 7)
; Exemple sortie : 1000 (= 8), avec retenue à propager
; État q0 : on lit sans modifier tous les 1 et 0 du mot, vers la droite
q0 1 1 d q0 ; pas encore la fin du mot
q0 0 0 d q0 ; pas encore la fin du mot
q0 _ _ g retenue ; on est à la fin du mot : on commence à faire le calcul
; État retenue : on doit faire le +1, en étant à la fin du mot
retenue 0 1 * stop-accepté ; on a finit, on écrit la retenue, et c'est bon
retenue 1 0 g retenue ; on change le 1 en 0, on propage la retenue
retenue _ 1 * stop-accepté ; on a finit, en étant allé tout à gauche : on écrit la retenue, et c'est bon
; Astuce pour charger le ruban avec un mot initial intéressant.
;$INITIAL_TAPE:1001110