1 include "turing/turing.ma".
7 [lista di simboli] fa match su un simbolo qualunque nella lista
8 ad esempio [#|,] fa match con la gratella "#", la barra verticale "|" e la virgola ","
10 Convenzione variabili:
11 - x,y,z,D = bit (non marcati)
12 - *x,*y,*z,*D = bit marcati
13 - c,d,e = caratteri (bit marcati e non marcati e separatori)
16 c/D --> Q : leggo c, scrivo c, mi sposto a D e passo allo stato Q
17 c/d/D --> Q : leggo c, scrivo d, mi sposto a D e passo allo stato Q
21 inductive alpha_uni : Type[0] ≝
22 | bit : bool → alpha_uni
23 | mark : bool → alpha_uni
24 | grid : alpha_uni | bar : alpha_uni | comma : alpha_uni.
26 inductive Qmatch : Type[0] ≝
27 | qm0 : Qmatch | qm1 : Qmatch | qm2 : bool → Qmatch | qm3 : bool → Qmatch
28 | qm4 : Qmatch | qm5 : Qmatch | qm6 : Qmatch | qm7 : Qmatch
29 | qm8 : Qmatch | qm9 : Qmatch
30 | qmsuccess : Qmatch | qmfailure : Qmatch | qmsink : Qmatch.
32 definition bool_eqb ≝ λb1,b2:bool.¬ (xorb b1 b2).
35 ==================================
36 MACCHINE PER SPOSTARE LA "TESTINA"
37 ================================
39 Lo spostamento a sx si ottiene mediante
41 ls x # current y # macchina # rs
43 ls x # current # y macchina # rs
45 ls x # current # macchina # y rs
47 ls # x current # macchina # y rs
49 ls # current x # macchina # y rs
52 Lo spostamento a dx si ottiene mediante
54 ls # current x # macchina # y rs
56 ls x # current # macchina # y rs
58 ls x # current # macchina y # rs
60 ls x # current y # macchina # rs
65 Sposta il carattere binario su cui si trova la testina oltre il primo # alla sua sinistra.
79 \forall x.x/L --> 1(x)
82 \forall c != #. c/x/R --> 2(c)
86 \forall d. d/c/L --> 0
89 \forall c. c/#/L --> 4
95 (* struttura generica della semantica *)
96 lemma move_char_sem: ∀inc. prec inc → ∃i. ∃outc. loop i step inc = Some outc
99 lemma sequential : ∀M1,M2.
106 definition post c1 c2 ≝
109 let leftt ≝ left tp1 in
110 let rightt ≝ right tp1 in
111 c2 = mk_config finals
117 [ bit x ⇒ 〈q1 x,〈c,L〉〉
118 | _ ⇒ 〈qsink,〈c,N〉〉 ]
119 | q1 x ⇒ match c with
120 [ grid ⇒ 〈q3,〈bit x,R〉〉
121 | _ ⇒ 〈q2 c,〈bit x,R〉〉 ]
124 | q4 ⇒ (* finale *) ].
129 Sposta il carattere binario su cui si trova la testina oltre il primo # alla sua destra.
143 \forall x.x/R --> 1(x)
146 \forall c != #. c/x/L --> 2(c)
150 \forall d. d/c/R --> 0
153 \forall c. c/#/L --> 4
161 [ bit x ⇒ 〈q1 x,〈c,R〉〉
163 | q1 x ⇒ match c with
164 [ grid ⇒ 〈q3,〈bit x,L〉〉
165 | _ ⇒ 〈q2 c,〈bit x,L〉〉 ]
168 | q4 ⇒ (* finale *) ].
173 Sposta il carattere binario su cui si trova la testina appena prima del primo # alla sua destra.
186 \forall x. x/R --> 1(x)
189 \forall c != #. c/x/L --> 2(c)
193 \forall d. d/c/R --> 0
202 [ bit x ⇒ 〈q1 x,〈c,R〉〉
203 | _ ⇒ 〈qsink,〈c,N〉〉 ]
204 | q1 x ⇒ match c with
205 [ grid ⇒ 〈q3,〈grid,L〉〉
206 | _ ⇒ 〈q2 c,〈bit x,L〉〉
208 | q3 ⇒ (* finale *) ].