1 include "turing/turing.ma".
4 axiom q0 : Q. axiom q1 : Q. axiom q2 : Q. axiom q3 : Q. axiom q4 : Q. axiom q5 : Q.
5 axiom q6 : Q. axiom q7 : Q. axiom q8 : Q. axiom q9 : Q. axiom q10 : Q. axiom q11 : Q.
6 axiom q12 : Q. axiom q13 : Q. axiom q14 : Q. axiom q15 : Q. axiom q16 : Q.
12 [lista di simboli] fa match su un simbolo qualunque nella lista
13 ad esempio [#|,] fa match con la gratella "#", la barra verticale "|" e la virgola ","
15 Convenzione variabili:
16 - x,y,z,D = bit (non marcati)
17 - *x,*y,*z,*D = bit marcati
18 - c,d,e = caratteri (bit marcati e non marcati e separatori)
21 c/D --> Q : leggo c, scrivo c, mi sposto a D e passo allo stato Q
22 c/d/D --> Q : leggo c, scrivo d, mi sposto a D e passo allo stato Q
24 MACCHINA per confronto tuple:
25 =============================
28 ls # current # ... | input , output , D | ... # rs
34 ls # current # ... | input , output , D | ... # rs (rimuove le marcature e si sposta sull'output)
39 ls # current # ... | input , output , D | ... # rs (sposta la marcatura alla tupla successiva)
47 \forall c != *z. c/L --> 1
48 \forall x. *x/x/R --> 2(x)
51 \forall y. y/*y/R --> 3(x)
55 \forall y.\forall c != *y. c/R --> 3(x)
60 \forall x. x/*x/L --> 1
64 \forall c != |. c/R --> 5
68 \forall x. x/*x/L --> 7
71 \forall c != #. c/L --> 7
75 \forall c != #. c/L --> 8
76 \forall x. *x/x/L --> 8
80 \forall x. x/*x/L --> FAILURE
89 [ mark x ⇒ 〈q2 x,〈bit x,R〉〉
92 [ bit y ⇒ 〈q3 x,〈mark y,R〉〉
93 | grid ⇒ 〈q3 x,〈grid,R〉〉
96 [ mark y ⇒ match bool_eqb x y with
97 [ true ⇒ 〈q4,〈bit y,R〉〉
98 | false ⇒ 〈q5,〈bit y,R〉〉 ]
101 [ comma ⇒ 〈qSuccess,〈comma,R〉〉
102 | bit x ⇒ 〈q1,〈mark x,L〉〉
103 | _ ⇒ 〈qsink,〈c,N〉〉 ]
108 [ bit x ⇒ 〈q7,〈mark x,L〉〉
109 | _ ⇒ 〈qsink,〈c,N〉〉 ]
111 [ grid ⇒ 〈q8,〈grid,L〉〉
114 [ grid ⇒ 〈q9,〈grid,R〉〉
115 | mark x ⇒ 〈q8,〈bit x,L〉〉
118 [ bit x ⇒ 〈qFailure,〈mark x,L〉〉
119 | _ ⇒ 〈qsink,〈c,N〉〉 ]
120 | qsink ⇒ 〈qsink,〈c,N〉〉 ]
124 ==============================
125 MACCHINA PER COPIA NUOVO STATO IN CURRENT
126 ==============================
130 ls # current # ... | in_state , out_state , D | ... # rs
135 ls # out_state # ... | in_state , out_state , D | ... # rs
140 \forall x. x/*x/L --> 1
151 \forall x. x/*x/R --> 4
156 \forall x. *x/x/R --> 5(x)
160 \forall y. y/*y/L --> 7(x)
163 \forall D. D/*D/L --> 7(x)
167 \forall y. *y/x/R --> 3
171 \forall D. *D/D/L --> 9
178 [ bit x ⇒ 〈q1,〈mark x,L〉〉
179 | _ ⇒ 〈qsink,〈c,N〉〉 ]
185 | _ ⇒ 〈qsink,〈c,N〉〉 ]
189 | _ ⇒ 〈qsink,〈c,N〉〉 ]
191 [ bit x ⇒ 〈q4,〈mark x,R〉〉
193 | _ ⇒ 〈qsink,〈c,N〉〉 ]
199 | mark x ⇒ 〈q5 x,〈bit x,R〉〉 ]
200 | q5 x ⇒ match c with
201 [ grid ⇒ 〈q6 x,〈c,R〉〉
202 | bit y ⇒ 〈q7 x,〈mark y,L〉〉
203 | _ ⇒ 〈qsink,〈c,N〉〉 ]
204 | q6 x ⇒ match c with
205 [ bit D ⇒ 〈q7 x,〈mark D,L〉〉
206 | _ ⇒ 〈qsink,〈c,N〉〉 ]
207 | q7 x ⇒ match c with
208 [ bit y ⇒ 〈q7 x,〈c,L〉〉
209 | comma ⇒ 〈q7 x,〈c,L〉〉
211 | grid ⇒ 〈q7 x,〈c,L〉〉
212 | mark y ⇒ 〈q3,〈bit x,R〉〉 ]
218 | mark D ⇒ 〈q9,〈bit D,L〉〉 ]
219 | q9 ⇒ ? (* successo *)
223 ==================================
224 MACCHINE PER SPOSTARE LA "TESTINA"
225 ================================
227 Lo spostamento a sx si ottiene mediante
229 ls x # current y # macchina # rs
231 ls x # current # y macchina # rs
233 ls x # current # macchina # y rs
235 ls # x current # macchina # y rs
237 ls # current x # macchina # y rs
240 Lo spostamento a dx si ottiene mediante
242 ls # current x # macchina # y rs
244 ls x # current # macchina # y rs
246 ls x # current # macchina y # rs
248 ls x # current y # macchina # rs
253 Sposta il carattere binario su cui si trova la testina oltre il primo # alla sua sinistra.
267 \forall x.x/L --> 1(x)
270 \forall c != #. c/x/R --> 2(c)
274 \forall d. d/c/L --> 0
277 \forall c. c/#/L --> 4
285 [ bit x ⇒ 〈q1 x,〈c,L〉〉
286 | _ ⇒ 〈qsink,〈c,N〉〉 ]
287 | q1 x ⇒ match c with
288 [ grid ⇒ 〈q3,〈bit x,R〉〉
289 | _ ⇒ 〈q2 c,〈bit x,R〉〉 ]
292 | q4 ⇒ (* finale *) ].
297 Sposta il carattere binario su cui si trova la testina oltre il primo # alla sua destra.
311 \forall x.x/R --> 1(x)
314 \forall c != #. c/x/L --> 2(c)
318 \forall d. d/c/R --> 0
321 \forall c. c/#/L --> 4
329 [ bit x ⇒ 〈q1 x,〈c,R〉〉
331 | q1 x ⇒ match c with
332 [ grid ⇒ 〈q3,〈bit x,L〉〉
333 | _ ⇒ 〈q2 c,〈bit x,L〉〉 ]
336 | q4 ⇒ (* finale *) ].
341 Sposta il carattere binario su cui si trova la testina appena prima del primo # alla sua destra.
354 \forall x. x/R --> 1(x)
357 \forall c != #. c/x/L --> 2(c)
361 \forall d. d/c/R --> 0
370 [ bit x ⇒ 〈q1 x,〈c,R〉〉
371 | _ ⇒ 〈qsink,〈c,N〉〉 ]
372 | q1 x ⇒ match c with
373 [ grid ⇒ 〈q3,〈grid,L〉〉
374 | _ ⇒ 〈q2 c,〈bit x,L〉〉
376 | q3 ⇒ (* finale *) ].