2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department of the University of Bologna, Italy.
8 \ / This file is distributed under the terms of the
9 \ / GNU General Public License Version 2
10 V_____________________________________________________________*)
17 include "turing/universal/marks.ma".
19 definition STape ≝ FinProd … FSUnialpha FinBool.
21 definition only_bits ≝ λl.
22 ∀c.memb STape c l = true → is_bit (\fst c) = true.
24 definition no_grids ≝ λl.
25 ∀c.memb STape c l = true → is_grid (\fst c) = false.
27 definition no_bars ≝ λl.
28 ∀c.memb STape c l = true → is_bar (\fst c) = false.
30 definition no_marks ≝ λl.
31 ∀c.memb STape c l = true → is_marked ? c = false.
33 lemma bit_not_grid: ∀d. is_bit d = true → is_grid d = false.
34 * // normalize #H destruct
37 lemma bit_not_bar: ∀d. is_bit d = true → is_bar d = false.
38 * // normalize #H destruct
41 (* by definition, a tuple is not marked *)
42 definition tuple_TM : nat → list STape → Prop ≝
45 only_bits qin ∧ only_bits qout ∧ only_bits mv ∧
46 |qin| = n ∧ |qout| = n (* ∧ |mv| = ? *) ∧
47 t = qin@〈comma,false〉::qout@〈comma,false〉::mv.
49 inductive table_TM : nat → list STape → Prop ≝
50 | ttm_nil : ∀n.table_TM n []
51 | ttm_cons : ∀n,t1,T.tuple_TM n t1 → table_TM n T → table_TM n (t1@〈bar,false〉::T).
53 lemma no_grids_in_table: ∀n.∀l.table_TM n l → no_grids l.
55 [normalize #n #x #H destruct
56 |#m #t1 #t2 * #qin * #qout * #mv * * * * * *
57 #Hmarks #Hqin #Hqout #Hmv #_ #_ #Heq #Ht2 #Hind
59 cases (memb_append … membx) -membx #membx
60 [cases (memb_append … membx) -membx #membx
61 [@bit_not_grid @Hqin //
62 |cases (orb_true_l … membx) -membx #membx
64 |cases (memb_append … membx) -membx #membx
65 [@bit_not_grid @Hqout //
66 |cases (orb_true_l … membx) -membx #membx
68 |@bit_not_grid @Hmv //
73 |cases (orb_true_l … membx) -membx #membx
81 lemma no_marks_in_table: ∀n.∀l.table_TM n l → no_marks l.
83 [normalize #n #x #H destruct
84 |#m #t1 #t2 * #qin * #qout * #mv * * * * * *
85 #Hmarks #_ #_ #_ #_ #_ #_ #Ht2 #Hind
86 #x #Hx cases (memb_append … Hx) -Hx #Hx
88 |cases (orb_true_l … Hx) -Hx #Hx
96 axiom last_of_table: ∀n,l,b.¬ table_TM n (l@[〈bar,b〉]).
99 l0 x* a l1 x0* a0 l2 ------> l0 x a* l1 x0 a0* l2
102 if current (* x *) = #
105 then move_right; ----
107 if current (* x0 *) = 0
108 then advance_mark ----
112 else x = 1 (* analogo *)
118 MARK NEXT TUPLE machine
119 (partially axiomatized)
121 marks the first character after the first bar (rightwards)
124 definition bar_or_grid ≝ λc:STape.is_bar (\fst c) ∨ is_grid (\fst c).
126 definition mark_next_tuple ≝
127 seq ? (adv_to_mark_r ? bar_or_grid)
128 (ifTM ? (test_char ? (λc:STape.is_bar (\fst c)))
129 (move_right_and_mark ?) (nop ?) 1).
131 definition R_mark_next_tuple ≝
134 (* c non può essere un separatore ... speriamo *)
135 t1 = midtape STape ls c (rs1@〈grid,false〉::rs2) →
136 no_marks rs1 → no_grids rs1 → bar_or_grid c = false →
137 (∃rs3,rs4,d,b.rs1 = rs3 @ 〈bar,false〉 :: rs4 ∧
139 Some ? 〈d,b〉 = option_hd ? (rs4@〈grid,false〉::rs2) ∧
140 t2 = midtape STape (〈bar,false〉::reverse ? rs3@c::ls) 〈d,true〉 (tail ? (rs4@〈grid,false〉::rs2)))
142 (no_bars rs1 ∧ t2 = midtape ? (reverse ? rs1@c::ls) 〈grid,false〉 rs2).
146 (∀x.memb A x l = true → f x = false) ∨
147 (∃l1,c,l2.f c = true ∧ l = l1@c::l2 ∧ ∀x.memb ? x l1 = true → f x = false).
149 [ % #x normalize #Hfalse *)
151 theorem sem_mark_next_tuple :
152 Realize ? mark_next_tuple R_mark_next_tuple.
154 lapply (sem_seq ? (adv_to_mark_r ? bar_or_grid)
155 (ifTM ? (test_char ? (λc:STape.is_bar (\fst c))) (move_right_and_mark ?) (nop ?) 1) ????)
156 [@sem_if [5: // |6: @sem_move_right_and_mark |7: // |*:skip]
158 |||#Hif cases (Hif intape) -Hif
159 #j * #outc * #Hloop * #ta * #Hleft #Hright
160 @(ex_intro ?? j) @ex_intro [|% [@Hloop] ]
162 #ls #c #rs1 #rs2 #Hrs #Hrs1 #Hrs1' #Hc
164 [ * #Hfalse >Hfalse in Hc; #Htf destruct (Htf)
165 | * #_ #Hta cases (tech_split STape (λc.is_bar (\fst c)) rs1)
166 [ #H1 lapply (Hta rs1 〈grid,false〉 rs2 (refl ??) ? ?)
167 [ * #x #b #Hx whd in ⊢ (??%?); >(Hrs1' … Hx) >(H1 … Hx) %
169 | -Hta #Hta cases Hright
170 [ * #tb * whd in ⊢ (%→?); #Hcurrent
171 @False_ind cases (Hcurrent 〈grid,false〉 ?)
172 [ normalize #Hfalse destruct (Hfalse)
174 | * #tb * whd in ⊢ (%→?); #Hcurrent
175 cases (Hcurrent 〈grid,false〉 ?)
176 [ #_ #Htb whd in ⊢ (%→?); #Houtc
179 | >Houtc >Htb >Hta % ]
183 | * #rs3 * #c0 * #rs4 * * #Hc0 #Hsplit #Hrs3
184 % @(ex_intro ?? rs3) @(ex_intro ?? rs4)
185 lapply (Hta rs3 c0 (rs4@〈grid,false〉::rs2) ???)
186 [ #x #Hrs3' whd in ⊢ (??%?); >Hsplit in Hrs1;>Hsplit in Hrs3;
187 #Hrs3 #Hrs1 >(Hrs1 …) [| @memb_append_l1 @Hrs3'|]
188 >(Hrs3 … Hrs3') @Hrs1' >Hsplit @memb_append_l1 //
189 | whd in ⊢ (??%?); >Hc0 %
190 | >Hsplit >associative_append % ] -Hta #Hta
192 [ * #tb * whd in ⊢ (%→?); #Hta'
195 [ #_ #Htb' >Htb' in Htb; #Htb
196 generalize in match Hsplit; -Hsplit
198 [ #Hta #Hsplit >(Htb … Hta)
199 >(?:c0 = 〈bar,false〉)
200 [ @(ex_intro ?? grid) @(ex_intro ?? false)
202 [(* Hsplit *) @daemon |(*Hrs3*) @daemon ] | % ] | % ]
203 | (* Hc0 *) @daemon ]
204 | #r5 #rs5 >(eq_pair_fst_snd … r5)
205 #Hta #Hsplit >(Htb … Hta)
206 >(?:c0 = 〈bar,false〉)
207 [ @(ex_intro ?? (\fst r5)) @(ex_intro ?? (\snd r5))
208 % [ % [ % [ (* Hc0, Hsplit *) @daemon | (*Hrs3*) @daemon ] | % ]
209 | % ] | (* Hc0 *) @daemon ] ] | >Hta % ]
210 | * #tb * whd in ⊢ (%→?); #Hta'
213 [ #Hfalse @False_ind >Hfalse in Hc0;
219 definition init_current ≝
220 seq ? (adv_to_mark_l ? (is_marked ?))
221 (seq ? (clear_mark ?)
222 (seq ? (adv_to_mark_l ? (λc:STape.is_grid (\fst c)))
223 (seq ? (move_r ?) (mark ?)))).
225 definition R_init_current ≝ λt1,t2.
226 ∀l1,c,l2,b,l3,c1,rs,c0,b0. no_marks l1 → no_grids l2 → is_grid c = false →
227 Some ? 〈c0,b0〉 = option_hd ? (reverse ? (〈c,true〉::l2)) →
228 t1 = midtape STape (l1@〈c,true〉::l2@〈grid,b〉::l3) 〈c1,false〉 rs →
229 t2 = midtape STape (〈grid,b〉::l3) 〈c0,true〉
230 ((tail ? (reverse ? (l1@〈c,false〉::l2))@〈c1,false〉::rs)).
232 lemma sem_init_current : Realize ? init_current R_init_current.
234 cases (sem_seq ????? (sem_adv_to_mark_l ? (is_marked ?))
235 (sem_seq ????? (sem_clear_mark ?)
236 (sem_seq ????? (sem_adv_to_mark_l ? (λc:STape.is_grid (\fst c)))
237 (sem_seq ????? (sem_move_r ?) (sem_mark ?)))) intape)
238 #k * #outc * #Hloop #HR
239 @(ex_intro ?? k) @(ex_intro ?? outc) % [@Hloop]
240 cases HR -HR #ta * whd in ⊢ (%→?); #Hta
241 * #tb * whd in ⊢ (%→?); #Htb
242 * #tc * whd in ⊢ (%→?); #Htc
243 * #td * whd in ⊢ (%→%→?); #Htd #Houtc
244 #l1 #c #l2 #b #l3 #c1 #rs #c0 #b0 #Hl1 #Hl2 #Hc #Hc0 #Hintape
245 cases (Hta … Hintape) [ * #Hfalse normalize in Hfalse; destruct (Hfalse) ]
246 -Hta * #_ #Hta lapply (Hta l1 〈c,true〉 ? (refl ??) ??) [@Hl1|%]
247 -Hta #Hta lapply (Htb … Hta) -Htb #Htb cases (Htc … Htb) [ >Hc -Hc * #Hc destruct (Hc) ]
248 -Htc * #_ #Htc lapply (Htc … (refl ??) (refl ??) ?) [@Hl2]
249 -Htc #Htc lapply (Htd … Htc) -Htd
250 >reverse_append >reverse_cons
251 >reverse_cons in Hc0; cases (reverse … l2)
252 [ normalize in ⊢ (%→?); #Hc0 destruct (Hc0)
253 #Htd >(Houtc … Htd) %
254 | * #c2 #b2 #tl2 normalize in ⊢ (%→?);
255 #Hc0 #Htd >(Houtc … Htd)
256 whd in ⊢ (???%); destruct (Hc0)
257 >associative_append >associative_append %
261 definition match_tuple_step ≝
262 ifTM ? (test_char ? (λc:STape.¬ is_grid (\fst c)))
265 (ifTM ? (test_char ? (λc:STape.is_grid (\fst c)))
267 (seq ? mark_next_tuple
268 (ifTM ? (test_char ? (λc:STape.is_grid (\fst c)))
269 (mark ?) (seq ? (move_l ?) init_current) tc_true)) tc_true)))
272 definition R_match_tuple_step_true ≝ λt1,t2.
273 ∀ls,c,l1,l2,c1,l3,l4,rs,n.
274 is_bit c = true → only_bits l1 → no_marks l1 (* → no_grids l2 *) → is_bit c1 = true →
275 only_bits l3 → n = |l1| → |l1| = |l3| →
276 table_TM (S n) (l2@〈bar,false〉::〈c1,false〉::l3@〈comma,false〉::l4) →
277 t1 = midtape STape (〈grid,false〉::ls) 〈c,true〉
278 (l1@〈grid,false〉::l2@〈bar,false〉::〈c1,true〉::l3@〈comma,false〉::l4@〈grid,false〉::rs) →
280 (〈c,false〉::l1 = 〈c1,false〉::l3 ∧
281 t2 = midtape ? (reverse ? l1@〈c,false〉::〈grid,false〉::ls) 〈grid,false〉
282 (l2@〈bar,false〉::〈c1,false〉::l3@〈comma,true〉::l4@〈grid,false〉::rs))
284 (* non facciamo match e marchiamo la prossima tupla *)
285 ((〈c,false〉::l1 ≠ 〈c1,false〉::l3 ∧
286 ∃c2,l5,l6.l4 = l5@〈bar,false〉::〈c2,false〉::l6 ∧
287 (* condizioni su l5 l6 l7 *)
288 t2 = midtape STape (〈grid,false〉::ls) 〈c,true〉
289 (l1@〈grid,false〉::l2@〈bar,false〉::〈c1,false〉::l3@〈comma,false〉::
290 l5@〈bar,false〉::〈c2,true〉::l6@〈grid,false〉::rs))
292 (* non facciamo match e non c'è una prossima tupla:
293 non specifichiamo condizioni sul nastro di output, perché
294 non eseguiremo altre operazioni, quindi il suo formato non ci interessa *)
295 (〈c,false〉::l1 ≠ 〈c1,false〉::l3 ∧ no_bars l4 ∧ current ? t2 = Some ? 〈grid,true〉)).
297 definition R_match_tuple_step_false ≝ λt1,t2.
298 ∀ls,c,rs.t1 = midtape STape ls c rs → is_grid (\fst c) = true ∧ t2 = t1.
300 include alias "basics/logic.ma".
303 lemma eq_f4: ∀A1,A2,A3,A4,B.∀f:A1 → A2 →A3 →A4 →B.
304 ∀x1,x2,x3,x4,y1,y2,y3,y4. x1 = y1 → x2 = y2 →x3=y3 →x4 = y4 →
305 f x1 x2 x3 x4 = f y1 y2 y3 y4.
309 lemma some_option_hd: ∀A.∀l:list A.∀a.∃b.
310 Some ? b = option_hd ? (l@[a]) .
311 #A #l #a cases l normalize /2/
314 axiom tech_split2 : ∀A,l1,l2,l3,l4,x.
315 memb A x l1 = false → memb ? x l3 = false →
316 l1@x::l2 = l3@x::l4 → l1 = l3 ∧ l2 = l4.
318 axiom injective_append : ∀A,l.injective … (λx.append A x l).
320 lemma sem_match_tuple_step:
321 accRealize ? match_tuple_step (inr … (inl … (inr … 0)))
322 R_match_tuple_step_true R_match_tuple_step_false.
323 @(acc_sem_if_app … (sem_test_char ? (λc:STape.¬ is_grid (\fst c))) …
324 (sem_seq … sem_compare
325 (sem_if … (sem_test_char ? (λc:STape.is_grid (\fst c)))
327 (sem_seq … sem_mark_next_tuple
328 (sem_if … (sem_test_char ? (λc:STape.is_grid (\fst c)))
329 (sem_mark ?) (sem_seq … (sem_move_l …) (sem_init_current …))))))
331 [(* is_grid: termination case *)
332 2:#t1 #t2 #t3 whd in ⊢ (%→?); #H #H1 whd #ls #c #rs #Ht1
333 cases (H c ?) [2: >Ht1 %] #Hgrid #Heq %
334 [@injective_notb @Hgrid | <Heq @H1]
335 |#tapea #tapeout #tapeb whd in ⊢ (%→?); #Htapea
336 * #tapec * #Hcompare #Hor
337 #ls #c #l1 #l2 #c1 #l3 #l4 #rs #n #Hc #Hl1bars #Hl1marks #Hc1 #Hl3 #eqn
338 #eqlen #Htable #Htapea1 cases (Htapea 〈c,true〉 ?) >Htapea1 [2:%]
339 #notgridc -Htapea -Htapea1 -tapea #Htapeb
340 cases (Hcompare … Htapeb) -Hcompare -Htapeb * #_ #_ #Hcompare
341 cases (Hcompare c c1 l1 l3 (l2@[〈bar,false〉]) (l4@〈grid,false〉::rs) eqlen Hl1bars Hl3 Hl1marks … (refl …) Hc ?)
343 [* #Htemp destruct (Htemp) #Htapec %1 % [%]
344 >Htapec in Hor; -Htapec *
345 [2: * #t3 * whd in ⊢ (%→?); #H @False_ind
346 cases (H … (refl …)) whd in ⊢ ((??%?)→?); #H destruct (H)
347 |* #taped * whd in ⊢ (%→?); #Htaped cases (Htaped ? (refl …)) -Htaped *
348 #Htaped whd in ⊢ (%→?); #Htapeout >Htapeout >Htaped >associative_append
351 |* #la * #c' * #d' * #lb * #lc * * * #H1 #H2 #H3 #Htapec
352 cut (〈c,false〉::l1 ≠ 〈c1,false〉::l3)
354 [@(not_to_not …H1) normalize #H destruct %
355 |#x #tl @not_to_not normalize #H destruct //
358 cut (is_bit d' = true)
360 [normalize in ⊢ (%→?); #H destruct //
361 |#x #tl #H @(Hl3 〈d',false〉)
362 normalize in H; destruct @memb_append_l2 @memb_hd
365 >Htapec in Hor; -Htapec *
366 [* #taped * whd in ⊢ (%→?); #H @False_ind
367 cases (H … (refl …)) >(bit_not_grid ? Hd') #Htemp destruct (Htemp)
368 |* #taped * whd in ⊢ (%→?); #H cases (H … (refl …)) -H #_
369 #Htaped * #tapee * whd in ⊢ (%→?); #Htapee
370 <(associative_append ? lc (〈comma,false〉::l4)) in Htaped; #Htaped
371 cases (Htapee … Htaped ???) -Htaped -Htapee
372 [* #rs3 * * (* we proceed by cases on rs4 *)
373 [(* rs4 is empty : the case is absurd since the tape
374 cannot end with a bar *)
375 * #d * #b * * * #Heq1 @False_ind
376 cut (∀A,l1,l2.∀a:A. a::l1@l2=(a::l1)@l2) [//] #Hcut
377 >Hcut in Htable; >H3 >associative_append
378 normalize >Heq1 >Hcut <associative_append >Hcut
379 <associative_append #Htable @(absurd … Htable)
382 * #d2 #b2 #rs3' * #d * #b * * * #Heq1 #Hnobars
383 cut (memb STape 〈d2,b2〉 (l2@〈bar,false〉::〈c1,false〉::l3@〈comma,false〉::l4) = true)
384 [@memb_append_l2 @memb_cons
385 cut (∀A,l1,l2.∀a:A. a::l1@l2=(a::l1)@l2) [//] #Hcut
386 >Hcut >H3 >associative_append @memb_append_l2
387 @memb_cons >Heq1 @memb_append_l2 @memb_cons @memb_hd] #d2intable
388 cut (is_grid d2 = false)
389 [@(no_grids_in_table … Htable … 〈d2,b2〉 d2intable)] #Hd2
391 [@(no_marks_in_table … Htable … 〈d2,b2〉 d2intable)] #Hb2
392 >Hb2 in Heq1; #Heq1 -Hb2 -b2
393 whd in ⊢ ((???%)→?); #Htemp destruct (Htemp) #Htapee >Htapee -Htapee *
394 [(* we know current is not grid *)
395 * #tapef * whd in ⊢ (%→?); #Htapef
396 cases (Htapef … (refl …)) >Hd2 #Htemp destruct (Htemp)
397 |* #tapef * whd in ⊢ (%→?); #Htapef
398 cases (Htapef … (refl …)) #_ -Htapef #Htapef
399 * #tapeg >Htapef -Htapef *
402 #H lapply (H … (refl …)) whd in ⊢ (???%→?); -H #Htapeg
405 whd in ⊢ (%→?); #Htapeout
406 %1 cases (some_option_hd ? (reverse ? (reverse ? la)) 〈c',true〉)
409 (Htapeout (reverse ? rs3 @〈d',false〉::reverse ? la@reverse ? (l2@[〈bar,false〉])@(〈grid,false〉::reverse ? lb))
410 c' (reverse ? la) false ls bar (〈d2,true〉::rs3'@〈grid,false〉::rs) c00 b00 ?????) -Htapeout
411 [whd in ⊢ (??(??%??)?); @eq_f3 [2:%|3: %]
413 generalize in match (〈c',true〉::reverse ? la@〈grid,false〉::ls); #l
414 whd in ⊢ (???(???%)); >associative_append >associative_append %
415 |>reverse_cons @Hoption
417 [normalize in ⊢ (%→?); #Htemp destruct (Htemp)
418 @injective_notb @notgridc
419 |#x #tl normalize in ⊢ (%→?); #Htemp destruct (Htemp)
420 @bit_not_grid @(Hl1bars 〈c',false〉) @memb_append_l2 @memb_hd
422 |cut (only_bits (la@(〈c',false〉::lb)))
423 [<H2 whd #c0 #Hmemb cases (orb_true_l … Hmemb)
424 [#eqc0 >(\P eqc0) @Hc |@Hl1bars]
425 |#Hl1' #x #Hx @bit_not_grid @Hl1'
426 @memb_append_l1 @daemon
429 |>reverse_append >reverse_cons >reverse_reverse
430 >reverse_append >reverse_reverse
431 >reverse_cons >reverse_append >reverse_reverse
432 >reverse_append >reverse_cons >reverse_reverse
434 #Htapeout % [@Hnoteq]
436 cut (∃rs32.rs3 = lc@〈comma,false〉::rs32)
437 [ (*cases (tech_split STape (λc.c == 〈bar,false〉) l4)
439 | * #l41 * * #cbar #bfalse * #l42 * * #Hbar #Hl4 #Hl41
440 @(ex_intro ?? l41) >Hl4 in Heq1; #Heq1
442 cut (sublist … lc l3)
443 [ #x #Hx cases la in H3;
444 [ normalize #H3 destruct (H3) @Hx
445 | #p #la' normalize #Hla' destruct (Hla')
446 @memb_append_l2 @memb_cons @Hx ] ] #Hsublist*)
450 (〈c1,false〉::l3@〈comma,false〉::l4= la@〈d',false〉::rs3@〈bar,false〉::〈d2,b2〉::rs3')
452 cut (l4=rs32@〈bar,false〉::〈d2,false〉::rs3')
453 [ >Hrs3 in Heq1; @daemon ] #Hl4
454 @(ex_intro … rs32) @(ex_intro … rs3') %
458 |(*>Hrs3 *)>append_cons
459 > (?:l1@〈grid,false〉::l2@〈bar,false〉::〈c1,false〉::l3@〈comma,false〉::rs32@〈bar,false〉::〈d2,true〉::rs3'@〈grid,false〉::rs
460 = (l1@〈grid,false〉::l2@〈bar,false〉::〈c1,false〉::l3@〈comma,false〉::rs32@[〈bar,false〉])@〈d2,true〉::rs3'@〈grid,false〉::rs)
461 [|>associative_append normalize
462 >associative_append normalize
463 >associative_append normalize
464 >associative_append normalize
467 @(injective_append … (〈d2,false〉::rs3'))
468 >(?:(la@[〈c',false〉])@((((lb@[〈grid,false〉])@l2@[〈bar,false〉])@la)@[〈d',false〉])@rs3
469 =((la@〈c',false〉::lb)@([〈grid,false〉]@l2@[〈bar,false〉]@la@[〈d',false〉]@rs3)))
470 [|>associative_append >associative_append
471 >associative_append >associative_append >associative_append
472 >associative_append >associative_append % ]
473 <H2 normalize (* <Hrs3 *)
474 >associative_append >associative_append >associative_append
475 @eq_f normalize @eq_f >associative_append
476 >associative_append @eq_f normalize @eq_f
477 >(append_cons ? 〈d',false〉) >associative_append
478 <Heq1 >Hl4 <associative_append <append_cons
480 >associative_append normalize
481 >associative_append normalize %
487 |* #Hnobars #Htapee >Htapee -Htapee *
488 [whd in ⊢ (%→?); * #tapef * whd in ⊢ (%→?); #Htapef
489 cases (Htapef … (refl …)) -Htapef #_ #Htapef >Htapef -Htapef
490 whd in ⊢ (%→?); #Htapeout %2
491 >(Htapeout … (refl …)) %
494 | whd #x #Hx @Hnobars @memb_append_l2 @memb_cons //
498 |whd in ⊢ (%→?); * #tapef * whd in ⊢ (%→?); #Htapef
499 cases (Htapef … (refl …)) -Htapef
500 whd in ⊢ ((??%?)→?); #Htemp destruct (Htemp)
502 |(* no marks in table *)
503 #x #membx @(no_marks_in_table … Htable)
504 @memb_append_l2 @memb_cons
505 cut (∀A,l1,l2.∀a:A. a::l1@l2=(a::l1)@l2) [//] #Hcut >Hcut
506 >H3 >associative_append @memb_append_l2 @memb_cons @membx
507 |(* no grids in table *)
508 #x #membx @(no_grids_in_table … Htable)
509 @memb_append_l2 @memb_cons
510 cut (∀A,l1,l2.∀a:A. a::l1@l2=(a::l1)@l2) [//] #Hcut >Hcut
511 >H3 >associative_append @memb_append_l2 @memb_cons @membx
512 |whd in ⊢ (??%?); >(bit_not_grid … Hd') >(bit_not_bar … Hd') %
515 |#x #membx @(no_marks_in_table … Htable)
516 @memb_append_l2 @memb_cons @memb_cons @memb_append_l1 @membx
517 |#x #membx @(no_marks_in_table … Htable)
518 cases (memb_append … membx) -membx #membx
519 [@memb_append_l1 @membx | @memb_append_l2 >(memb_single … membx) @memb_hd]
520 |>associative_append %
529 scrolls through the tuples in the transition table until one matching the
530 current configuration is found
533 definition match_tuple ≝ whileTM ? match_tuple_step (inr … (inl … (inr … 0))).
535 definition R_match_tuple ≝ λt1,t2.
537 is_bit c = true → only_bits l1 → is_bit c1 = true → n = |l1| →
538 table_TM (S n) (〈c1,true〉::l2) →
539 t1 = midtape STape (〈grid,false〉::ls) 〈c,true〉
540 (l1@〈grid,false〉::〈c1,true〉::l2@〈grid,false〉::rs) →
543 〈c1,false〉::l2 = l3@〈c,false〉::l1@〈comma,false〉::newc@〈comma,false〉::mv@l4 ∧
544 t2 = midtape ? (reverse ? l1@〈c,false〉::〈grid,false〉::ls) 〈grid,false〉
545 (l3@〈c,false〉::l1@〈comma,true〉::newc@〈comma,false〉::mv@l4@〈grid,false〉::rs))
547 (* non facciamo match su nessuna tupla;
548 non specifichiamo condizioni sul nastro di output, perché
549 non eseguiremo altre operazioni, quindi il suo formato non ci interessa *)
550 (current ? t2 = Some ? 〈grid,true〉 ∧
552 〈c1,false〉::l2 ≠ l3@〈c,false〉::l1@〈comma,false〉::newc@〈comma,false〉::mv@l4).