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/copy.ma".
18 include "turing/universal/move_tape.ma".
19 include "turing/universal/match_machines.ma".
25 if is_true(current) (* current state is final *)
37 if is_marked(current) = false (* match ok *)
50 case bit false: move_tape_l
51 case bit true: move_tape_r
52 case null: adv_to_grid_l; move_l; adv_to_grid_l;
59 definition init_match ≝
60 mark ? · adv_to_mark_r ? (λc:STape.is_grid (\fst c)) · move_r ? ·
61 move_r ? · mark ? · move_l ? · adv_to_mark_l ? (is_marked ?).
63 definition R_init_match ≝ λt1,t2.
64 ∀ls,l,rs,c,d. no_grids (〈c,false〉::l) → no_marks l →
65 t1 = midtape STape ls 〈c,false〉 (l@〈grid,false〉::〈bar,false〉::〈d,false〉::rs) →
66 t2 = midtape STape ls 〈c,true〉 (l@〈grid,false〉::〈bar,false〉::〈d,true〉::rs).
68 lemma sem_init_match : Realize ? init_match R_init_match.
70 cases (sem_seq ????? (sem_mark ?)
71 (sem_seq ????? (sem_adv_to_mark_r ? (λc:STape.is_grid (\fst c)))
72 (sem_seq ????? (sem_move_r ?)
73 (sem_seq ????? (sem_move_r ?)
74 (sem_seq ????? (sem_mark ?)
75 (sem_seq ????? (sem_move_l ?)
76 (sem_adv_to_mark_l ? (is_marked ?))))))) intape)
77 #k * #outc * #Hloop #HR
78 @(ex_intro ?? k) @(ex_intro ?? outc) % [@Hloop] -Hloop
79 #ls #l #rs #c #d #Hnogrids #Hnomarks #Hintape
81 #ta * whd in ⊢ (%→?); * #Hta #_ lapply (Hta … Hintape) -Hta -Hintape #Hta
82 * #tb * whd in ⊢ (%→?); * #_ #Htb cases (Htb … Hta) -Htb -Hta
83 [* #Hgridc @False_ind @(absurd … Hgridc) @eqnot_to_noteq
84 @(Hnogrids 〈c,false〉) @memb_hd ]
85 * * #Hgrdic #Htb #_ lapply (Htb l 〈grid,false〉 (〈bar,false〉::〈d,false〉::rs) (refl …) (refl …) ?)
86 [#x #membl @Hnogrids @memb_cons @membl] -Htb #Htb
87 * #tc * whd in ⊢ (%→?); * #_ #Htc lapply (Htc … Htb) -Htc -Htb #Htc
88 * #td * whd in ⊢ (%→?); * #_ #Htd lapply (Htd … Htc) -Htd -Htc #Htd
89 * #te * whd in ⊢ (%→?); * #Hte #_ lapply (Hte … Htd) -Hte -Htd #Hte
90 * #tf * whd in ⊢ (%→?); * #_ #Htf lapply (Htf … Hte) -Htf -Hte #Htf
91 whd in ⊢ (%→?); * #_ #Htg cases (Htg … Htf) -Htg -Htf
92 #_ #Htg cases (Htg (refl …)) -Htg #Htg #_
93 lapply (Htg (〈grid,false〉::reverse ? l) 〈c,true〉 ls (refl …) (refl …) ?)
94 [#x #membl @Hnomarks @daemon] -Htg #Htg >Htg >reverse_cons >reverse_reverse
100 init_current_on_match; (* no marks in current *)
107 definition init_copy ≝
108 init_current_on_match · move_r ? ·
109 adv_to_mark_r ? (is_marked ?) · adv_mark_r ?.
111 definition R_init_copy ≝ λt1,t2.
113 no_marks l1 → no_grids l1 →
114 no_marks l2 → is_grid c = false →
115 t1 = midtape STape (l1@〈c,false〉::〈grid,false〉::ls) 〈grid,false〉 (l2@〈comma,true〉::〈d,false〉::rs) →
116 t2 = midtape STape (〈comma,false〉::(reverse ? l2)@〈grid,false〉::l1@〈c,true〉::〈grid,false〉::ls) 〈d,true〉 rs.
118 lemma list_last: ∀A.∀l:list A.
119 l = [ ] ∨ ∃a,l1. l = l1@[a].
120 #A #l <(reverse_reverse ? l) cases (reverse A l)
122 |#a #l1 %2 @(ex_intro ?? a) @(ex_intro ?? (reverse ? l1)) //
126 lemma sem_init_copy : Realize ? init_copy R_init_copy.
128 cases (sem_seq ????? sem_init_current_on_match
129 (sem_seq ????? (sem_move_r ?)
130 (sem_seq ????? (sem_adv_to_mark_r ? (is_marked ?))
131 (sem_adv_mark_r ?))) intape)
132 #k * #outc * #Hloop #HR
133 @(ex_intro ?? k) @(ex_intro ?? outc) % [@Hloop] -Hloop
134 #l1 #l2 #c #ls #d #rs #Hl1marks #Hl1grids #Hl2marks #Hc #Hintape
136 #ta * whd in ⊢ (%→?); #Hta lapply (Hta … Hl1grids Hc Hintape) -Hta -Hintape #Hta
137 * #tb * whd in ⊢ (%→?); * #_ #Htb lapply (Htb … Hta) -Htb -Hta
138 generalize in match Hl1marks; -Hl1marks cases (list_last ? l1)
139 [#eql1 >eql1 #Hl1marks whd in ⊢ ((???%)→?); whd in ⊢ ((???(????%))→?); #Htb
140 * #tc * whd in ⊢ (%→?); * #_ #Htc lapply (Htc … Htb) -Htc -Htb *
141 [* whd in ⊢ ((??%?)→?); #Htemp destruct (Htemp)]
142 * * #_ #Htc #_ lapply (Htc … (refl …) (refl …) ?)
143 [#x #membx @Hl2marks @membx]
144 #Htc whd in ⊢ (%→?); * #Houtc #_ cases (Houtc (reverse ? l2@〈grid,false〉::〈c,true〉::〈grid,false〉::ls) comma)
145 -Houtc #Houtc lapply (Houtc … Htc) -Houtc -Htc #Houtc #_
147 |* #c1 * #tl #eql1 >eql1 #Hl1marks >reverse_append >reverse_single
148 whd in ⊢ ((???%)→?); whd in ⊢ ((???(????%))→?);
149 >associative_append whd in ⊢ ((???(????%))→?); #Htb
150 * #tc * whd in ⊢ (%→?); * #_ #Htc lapply (Htc … Htb) -Htc -Htb *
151 [* >Hl1marks [#Htemp destruct (Htemp)] @memb_append_l2 @memb_hd]
152 * * #_ >append_cons <associative_append #Htc lapply (Htc … (refl …) (refl …) ?)
153 [#x #membx cases (memb_append … membx) -membx #membx
154 [cases (memb_append … membx) -membx #membx
155 [@Hl1marks @memb_append_l1 @daemon
156 |>(memb_single … membx) %
160 -Htc #Htc #_ whd in ⊢ (%→?); * #Houtc #_ cases (Houtc (reverse (FinProd FSUnialpha FinBool) ((reverse STape tl@[〈grid,false〉])@l2)
161 @c1::〈c,true〉::〈grid,false〉::ls) comma)
162 -Houtc #Houtc lapply (Houtc … Htc) -Houtc -Htc #Houtc #_
163 >Houtc >reverse_append >reverse_append >reverse_single
164 >reverse_reverse >associative_append >associative_append
165 >associative_append %
169 definition init_copy ≝
171 (seq ? init_current_on_match
173 (adv_to_mark_r ? (is_marked ?)))).
175 definition R_init_copy ≝ λt1,t2.
177 no_marks l1 → no_grids l1 →
178 no_marks l2 → no_grids l2 → is_grid c = false → is_grid d =false →
179 t1 = midtape STape (l1@〈grid,false〉::l2@〈c,false〉::〈grid,false〉::l3) 〈comma,true〉 (〈d,false〉::rs) →
180 t2 = midtape STape (〈comma,false〉::l1@〈grid,false〉::l2@〈c,true〉::〈grid,false〉::l3) 〈d,true〉 rs.
182 lemma list_last: ∀A.∀l:list A.
183 l = [ ] ∨ ∃a,l1. l = l1@[a].
184 #A #l <(reverse_reverse ? l) cases (reverse A l)
186 |#a #l1 %2 @(ex_intro ?? a) @(ex_intro ?? (reverse ? l1)) //
190 lemma sem_init_copy : Realize ? init_copy R_init_copy.
192 cases (sem_seq ????? (sem_adv_mark_r ?)
193 (sem_seq ????? sem_init_current_on_match
194 (sem_seq ????? (sem_move_r ?)
195 (sem_adv_to_mark_r ? (is_marked ?)))) intape)
196 #k * #outc * #Hloop #HR
197 @(ex_intro ?? k) @(ex_intro ?? outc) % [@Hloop] -Hloop
198 #l1 #l2 #c #l3 #d #rs #Hl1marks #Hl1grids #Hl2marks #Hl2grids #Hc #Hd #Hintape
200 #ta * whd in ⊢ (%→?); #Hta lapply (Hta … Hintape) -Hta -Hintape #Hta
201 * #tb * whd in ⊢ (%→?);
202 >append_cons #Htb lapply (Htb (〈comma,false〉::l1) l2 c … Hta)
204 |#x #membx cases (orb_true_l … membx) -membx #membx
205 [>(\P membx) // | @Hl1grids @membx]
207 * #tc * whd in ⊢ (%→?); #Htc lapply (Htc … Htb) -Htc -Htb
208 >reverse_append >reverse_cons cases (list_last ? l2)
209 [#Hl2 >Hl2 >associative_append whd in ⊢ ((???(??%%%))→?); #Htc
210 whd in ⊢ (%→?); #Htd cases (Htd … Htc) -Htd -Htc
211 [* whd in ⊢ ((??%?)→?); #Habs destruct (Habs)]
212 * #_ #Htf lapply (Htf … (refl …) (refl …) ?)
213 [#x >reverse_cons #membx cases (memb_append … membx) -membx #membx
214 [@Hl1marks @daemon |>(memb_single … membx) //]
216 |#Htf >Htf >reverse_reverse >associative_append %
218 |* #a * #l21 #Heq >Heq >reverse_append >reverse_single
219 >associative_append >associative_append >associative_append whd in ⊢ ((???(??%%%))→?); #Htc
220 whd in ⊢ (%→?); #Htd cases (Htd … Htc) -Htd -Htc
221 [* >Hl2marks [#Habs destruct (Habs) |>Heq @memb_append_l2 @memb_hd]]
222 * #_ <associative_append <associative_append #Htf lapply (Htf … (refl …) (refl …) ?)
223 [#x >reverse_cons #membx cases (memb_append … membx) -membx #membx
224 [cases (memb_append … membx) -membx #membx
225 [@Hl2marks >Heq @memb_append_l1 @daemon
226 |>(memb_single … membx) //]
227 |cases (memb_append … membx) -membx #membx
228 [@Hl1marks @daemon |>(memb_single … membx) //]
230 | #Htf >Htf >reverse_append >reverse_reverse
231 >reverse_append >reverse_reverse >associative_append
232 >reverse_single >associative_append >associative_append
233 >associative_append %
238 definition exec_action ≝
239 init_copy · copy · move_r … · move_tape.
241 definition map_move ≝
242 λc,mv.match c with [ null ⇒ None ? | _ ⇒ Some ? 〈c,false,move_of_unialpha mv〉 ].
244 (* - aggiungere a legal_tape le condizioni
245 only_bits ls, rs; bit_or_null c
246 - ci vuole un lemma che dimostri
247 bit_or_null c1 = true bit_or_null mv = true
248 mv ≠ null → c1 ≠ null
249 dal fatto che c1 e mv sono contenuti nella table
252 definition Pre_exec_action ≝ λt1.
253 ∃n,curconfig,ls,rs,c0,c1,s0,s1,table1,newconfig,mv,table2.
254 table_TM n (table1@〈comma,false〉::〈s1,false〉::newconfig@〈c1,false〉::〈comma,false〉::〈mv,false〉::table2) ∧
255 no_marks curconfig ∧ only_bits (curconfig@[〈s0,false〉]) ∧
256 only_bits (〈s1,false〉::newconfig) ∧ bit_or_null c1 = true ∧
257 |curconfig| = |newconfig| ∧
258 legal_tape ls 〈c0,false〉 rs ∧
259 t1 = midtape STape (〈c0,false〉::curconfig@〈s0,false〉::〈grid,false〉::ls) 〈grid,false〉
260 (table1@〈comma,true〉::〈s1,false〉::newconfig@〈c1,false〉::〈comma,false〉::〈mv,false〉::table2@〈grid,false〉::rs).
262 definition R_exec_action ≝ λt1,t2.
263 ∀n,curconfig,ls,rs,c0,c1,s0,s1,table1,newconfig,mv,table2.
264 table_TM n (table1@〈comma,false〉::〈s1,false〉::newconfig@〈c1,false〉::〈comma,false〉::〈mv,false〉::table2) →
265 no_marks curconfig → only_bits (curconfig@[〈s0,false〉]) →
266 only_bits (〈s1,false〉::newconfig) → bit_or_null c1 = true →
267 |curconfig| = |newconfig| →
268 legal_tape ls 〈c0,false〉 rs →
269 t1 = midtape STape (〈c0,false〉::curconfig@〈s0,false〉::〈grid,false〉::ls) 〈grid,false〉
270 (table1@〈comma,true〉::〈s1,false〉::newconfig@〈c1,false〉::〈comma,false〉::〈mv,false〉::table2@〈grid,false〉::rs) →
271 ∀t1'.t1' = lift_tape ls 〈c0,false〉 rs →
273 t2 = midtape STape ls1 〈grid,false〉
274 (〈s1,false〉::newconfig@〈c2,false〉::〈grid,false〉::
275 table1@〈comma,false〉::〈s1,false〉::newconfig@〈c1,false〉::〈comma,false〉::〈mv,false〉::table2@〈grid,false〉::rs1) ∧
276 lift_tape ls1 〈c2,false〉 rs1 =
277 tape_move STape t1' (map_move c1 mv) ∧ legal_tape ls1 〈c2,false〉 rs1.
279 (* move the following 2 lemmata to mono.ma *)
280 lemma tape_move_left_eq :
282 tape_move ? t (Some ? 〈c,L〉) =
283 tape_move_left ? (left ? t) c (right ? t).
287 lemma tape_move_right_eq :
289 tape_move ? t (Some ? 〈c,R〉) =
290 tape_move_right ? (left ? t) c (right ? t).
294 lemma lift_tape_not_null :
295 ∀ls,c,bc,rs.c ≠ null → lift_tape ls 〈c,bc〉 rs = midtape ? ls 〈c,bc〉 rs.
296 #ls #c #bc #rs cases c //
297 #Hfalse @False_ind /2/
300 lemma merge_char_not_null :
301 ∀c1,c2.c1 ≠ null → merge_char c1 c2 ≠ null.
302 #c1 #c2 @not_to_not cases c2
303 [ #c1' normalize #Hfalse destruct (Hfalse)
305 | *: normalize #Hfalse destruct (Hfalse)
309 lemma merge_char_null : ∀c.merge_char null c = c.
313 lemma merge_char_cases : ∀c1,c2.merge_char c1 c2 = c1 ∨ merge_char c1 c2 = c2.
320 (* lemma merge_char_c_bit :
321 ∀c1,c2.is_bit c2 = true → merge_char c1 c2 = c2.
324 |*: normalize #Hfalse destruct (Hfalse) ]
327 lemma merge_char_c_bit :
328 ∀c1,c2.is_null c2 = true → merge_char c1 c2 = c1.
331 |*: normalize #Hfalse destruct (Hfalse) ]
336 (*lemma GRealize_to_Realize :
337 ∀sig,M,R.GRealize sig M (λx.True) R → Realize sig M R.
338 #sig #M #R #HR #t @HR //
341 lemma sem_exec_action : GRealize ? exec_action Pre_exec_action R_exec_action.
342 @(sem_seq_app_guarded … (Realize_to_GRealize … sem_init_copy) ???)
343 [3:@(sem_seq_app_guarded … sem_copy)
344 [3:@(sem_seq_app_guarded … (Realize_to_GRealize … (sem_move_r STape)))
345 [3:@(Realize_to_GRealize … (sem_move_tape …))
353 * #n * #curconfig * #ls * #rs * #c0 * #c1 * #s0 * #s1 * #table1 * #newconfig
354 * #mv * #table2 * * * * * * *
355 #Htable #Hcurconfig1 #Hcurconfig2 #Hnewconfig #Hc1 #Hlen #Htape #Ht1
356 whd in ⊢ (%→?); >Ht1 #HR
357 lapply (HR (〈c0,false〉::curconfig) table1 s0 ls s1
358 (newconfig@〈c1,false〉::〈comma,false〉::〈mv,false〉::table2@〈grid,false〉::rs) ???? (refl ??))
359 [(*Hcurconfig2*) @daemon
360 |(*by Htable *) @daemon
361 |(*Hcurconfig2*) @daemon
362 |(*Hcurconfig1*) @daemon ]
364 %{(〈grid,false〉::ls)} %{s0} %{s1} %{c0} %{c1} %{(〈mv,false〉::table2@〈grid,false〉::rs)}
365 %{newconfig} %{(〈comma,false〉::reverse ? table1)} %{curconfig} >Ht2
366 % [ % [ % [ % [ % [ % [ % [ %
368 |(*by Htabel*) @daemon ]
369 |(*by Htable*) @daemon ]
374 |cases Htape * * // ]
377 #ta #outtape #HR #n #curconfig #ls #rs #c0 #c1 #s0 #s1 #table1 #newconfig #mv
378 #table2 #Htable #Hcurconfig1 #Hcurconfig2 #Hnewconfig #Hbitnullc1 #Hlen #Htape
380 cases HR -HR #tb * whd in ⊢ (%→?); #Htb
381 lapply (Htb (〈c0,false〉::curconfig) table1 s0 ls s1
382 (newconfig@〈c1,false〉::〈comma,false〉::〈mv,false〉::table2@〈grid,false〉::rs)
384 [ (*Hcurconfig2*) @daemon
386 | (* by Htape bit_or_null c0 = true, moreover Hcurconfig2 *) @daemon
387 | (*Hcurconfig1*) @daemon ]
388 #Htb * #tc * whd in ⊢ (%→?); #Htc
389 lapply (Htc (〈grid,false〉::ls) s0 s1 c0 c1 (〈mv,false〉::table2@〈grid,false〉::rs) newconfig (〈comma,false〉::reverse ? table1) curconfig Htb ????????) -Htc
390 [9:|*:(* bit_or_null c0,c1; |curconfig| = |newconfig|*) @daemon ]
391 #Htc * #td * whd in ⊢ (%→?); * #_ #Htd lapply (Htd … Htc) -Htd whd in ⊢(???(??%%%)→?);#Htd
392 whd in ⊢ (%→?); #Houtc whd in Htd:(???%); whd in Htd:(???(??%%%));
394 (〈comma,false〉::〈c1,false〉::reverse ? newconfig@〈s1,false〉::〈comma,false〉::reverse ? table1)
395 mv table2 (merge_char c0 c1) (reverse ? newconfig@[〈s1,false〉]) ls ????????)
396 [3: cases Htape -Htape * * #Hnomarks #Hbits #Hc0 #Hlsrs % [ % [ %
397 [ #x #Hx cases (orb_true_l … Hx) #Hx'
399 | @Hnomarks @memb_cons // ]
401 | cases (merge_char_cases c0 c1) #Hmerge >Hmerge // ]
402 | cases (true_or_false (c0 == null)) #Hc0'
405 [ >(\P Hc0') * #Hfalse @False_ind /2/
408 | % % @merge_char_not_null @(\Pf Hc0') ] ]
409 |4:>Htd @(eq_f3 … (midtape ?))
410 [ @eq_f @eq_f >associative_append >associative_append %
414 || >reverse_cons >reverse_cons >reverse_append >reverse_reverse
415 >reverse_cons >reverse_cons >reverse_reverse
416 >associative_append >associative_append >associative_append
417 >associative_append >associative_append
419 | (* well formedness of table *) @daemon
420 | (* Hnewconfig *) @daemon
421 | (* bit_or_null mv = true (well formedness of table) *) @daemon
422 | -Houtc * #ls1 * #rs1 * #newc * #Hnewtapelegal * #Houtc *
425 @(ex_intro ?? ls1) @(ex_intro ?? rs1) @(ex_intro ?? newc)
428 [ >Houtc -Houtc >reverse_append
429 >reverse_reverse >reverse_single @eq_f
430 >reverse_cons >reverse_cons >reverse_append >reverse_cons
431 >reverse_cons >reverse_reverse >reverse_reverse
432 >associative_append >associative_append
433 >associative_append >associative_append
434 >associative_append >associative_append %
435 | >Hmv >Hta' >Htapemove
436 (* mv = bit false -→ c1 = bit ? *)
437 cut (∃c1'.c1 = bit c1') [ @daemon ] * #c1' #Hc1
438 >Hc1 >tape_move_left_eq >(legal_tape_left … Htape)
439 >(legal_tape_right … Htape) %
444 @(ex_intro ?? ls1) @(ex_intro ?? rs1) @(ex_intro ?? newc) %
446 [ >Houtc -Houtc >reverse_append
447 >reverse_reverse >reverse_single @eq_f
448 >reverse_cons >reverse_cons >reverse_append >reverse_cons
449 >reverse_cons >reverse_reverse >reverse_reverse
450 >associative_append >associative_append
451 >associative_append >associative_append
452 >associative_append >associative_append %
453 |>Hmv >Hta' >Htapemove
454 cut (∃c1'.c1 = bit c1') [ @daemon ] * #c1' #Hc1
455 >Hc1 >tape_move_right_eq >(legal_tape_left … Htape)
456 >(legal_tape_right … Htape) %
461 | * * * #Hmv #Hlseq #Hrseq #Hnewc
462 @(ex_intro ?? ls1) @(ex_intro ?? rs1) @(ex_intro ?? newc) %
464 [ >Houtc -Houtc >reverse_append
465 >reverse_reverse >reverse_single @eq_f
466 >reverse_cons >reverse_cons >reverse_append >reverse_cons
467 >reverse_cons >reverse_reverse >reverse_reverse
468 >associative_append >associative_append
469 >associative_append >associative_append
470 >associative_append >associative_append %
471 |>Hmv >Hta' cases c1 in Hnewc;
472 [ #c1' whd in ⊢ (??%?→?);#Hnewc <Hnewc
473 >Hlseq >Hrseq whd in ⊢ (??%%);
474 >(legal_tape_left … Htape) >(legal_tape_right … Htape) %
475 | whd in ⊢ (??%?→?); #Hnewc >Hnewc >Hlseq >Hrseq %
476 |*: whd in ⊢ (??%?→?);#Hnewc <Hnewc
477 >Hlseq >Hrseq whd in ⊢ (??%%);
478 >(legal_tape_left … Htape) >(legal_tape_right … Htape) %
488 if is_false(current) (* current state is not final *)
491 if is_marked(current) = false (* match ok *)
499 definition uni_step ≝
500 ifTM ? (test_char STape (λc.\fst c == bit false))
502 (init_match · match_tuple ·
503 (ifTM ? (test_char ? (λc.¬is_marked ? c))
504 (exec_action · move_r …)
508 definition R_uni_step_true ≝ λt1,t2.
509 ∀n,table,s0,s1,c0,c1,ls,rs,curconfig,newconfig,mv.
510 0 < |table| → table_TM (S n) table →
511 match_in_table (S n) (〈s0,false〉::curconfig) 〈c0,false〉
512 (〈s1,false〉::newconfig) 〈c1,false〉 〈mv,false〉 table →
513 legal_tape ls 〈c0,false〉 rs →
514 t1 = midtape STape (〈grid,false〉::ls) 〈s0,false〉
515 (curconfig@〈c0,false〉::〈grid,false〉::table@〈grid,false〉::rs) →
516 ∀t1'.t1' = lift_tape ls 〈c0,false〉 rs →
519 (t2 = midtape STape (〈grid,false〉::ls1) 〈s1,false〉
520 (newconfig@〈c2,false〉::〈grid,false〉::table@〈grid,false〉::rs1) ∧
521 lift_tape ls1 〈c2,false〉 rs1 =
522 tape_move STape t1' (map_move c1 mv) ∧ legal_tape ls1 〈c2,false〉 rs1).
524 definition R_uni_step_false ≝ λt1,t2.
525 ∀b. current STape t1 = Some ? 〈bit b,false〉 → b = true ∧ t2 = t1.
527 (*axiom sem_match_tuple : Realize ? match_tuple R_match_tuple.*)
529 definition us_acc : states ? uni_step ≝ (inr … (inl … (inr … start_nop))).
531 definition Pre_uni_step ≝ λt1.
532 ∃n,table,s0,s1,c0,c1,ls,rs,curconfig,newconfig,mv.
533 0 < |table| ∧ table_TM (S n) table ∧
534 match_in_table (S n) (〈s0,false〉::curconfig) 〈c0,false〉
535 (〈s1,false〉::newconfig) 〈c1,false〉 〈mv,false〉 table ∧
536 legal_tape ls 〈c0,false〉 rs ∧
537 t1 = midtape STape (〈grid,false〉::ls) 〈s0,false〉
538 (curconfig@〈c0,false〉::〈grid,false〉::table@〈grid,false〉::rs).
541 accGRealize ? uni_step us_acc Pre_uni_step
542 R_uni_step_true R_uni_step_false.
543 @(acc_sem_if_app_guarded STape … (sem_test_char ? (λc:STape.\fst c == bit false))
544 ? (test_char_inv …) (sem_nop …) …)
545 [| @(sem_seq_app_guarded … (Realize_to_GRealize … sem_init_match) ???)
547 | 3: @(sem_seq_app_guarded … sem_match_tuple
548 (Realize_to_GRealize … (sem_if ????????? (sem_test_char … (λc.¬is_marked FSUnialpha c))
549 (sem_seq … sem_exec_action (sem_move_r …))
554 ||| #t1 #t2 * #n * #table * #s0 * #s1 * #c0 * #c1 * #ls * #rs * #curconfig
555 * #newconfig * #mv * * * *
556 #Hlen1 #Htable #Hmatch #Hlegal #Ht1
558 cut (∃tup,table0.table = tup@table0 ∧ tuple_TM (S n) tup)
560 * #tup * #table0 * #Htableeq * #qin * #cin * #qout * #cout * #mv0
562 #Hqinnomarks #_ #Hqinbits #_ #_ #_ #_ #_ #Hqinlen #_ #Htupeq
563 cut (∃d,qin0.qin = 〈d,false〉::qin0)
564 [ lapply Hqinlen lapply Hqinnomarks -Hqinlen -Hqinnomarks cases qin
565 [ #_ normalize in ⊢ (%→?); #Hfalse destruct (Hfalse)
566 | * #d #bd #qin0 #Hqinnomarks #_ %{d} %{qin0}
568 @(Hqinnomarks 〈d,bd〉) @memb_hd ] ]
571 lapply (Ht2 (〈grid,false〉::ls) (curconfig@[〈c0,false〉])
572 (qin0@〈cin,false〉::〈comma,false〉::qout@〈cout,false〉::〈comma,false〉::〈mv0,false〉::table0@〈grid,false〉::rs) s0 d ???)
573 [ >Ht1 @eq_f >associative_append @eq_f @eq_f @eq_f
574 >Htableeq >Htupeq >associative_append whd in ⊢ (??%?);
575 @eq_f >Hqineq >associative_append @eq_f whd in ⊢ (??%?);
576 @eq_f whd in ⊢ (??%?); @eq_f
577 >associative_append %
581 #Ht2 % [| % [| % [| % [ @Ht2 ]
585 l1 = curconfig@[〈c0,false〉]
588 l3 = qin0@[〈cin,false〉]
589 l4 = qout@〈cout,false〉::〈comma,false〉::〈mv0,false〉::table0
593 %{ls} %{s0} %{(curconfig@[〈c0,false〉])}
594 %{([〈bar,false〉])} %{d} %{(qin0@[〈cin,false〉])}
595 %{(qout@〈cout,false〉::〈comma,false〉::〈mv0,false〉::table0)}
596 %{rs} %{n} @daemon (* TODO *)
602 #ta whd in ⊢ (%→?); #Hta #HR
603 #n #fulltable #s0 #s1 #c0 #c1 #ls #rs #curconfig #newconfig #mv
604 #Htable_len cut (∃t0,table. fulltable =〈bar,false〉::〈t0,false〉::table) [(* 0 < |table| *) @daemon]
605 * #t0 * #table #Hfulltable >Hfulltable -fulltable
606 #Htable #Hmatch #Htape #Hintape #t1' #Ht1'
607 >Hintape in Hta; * * * #c #bc *
608 whd in ⊢ (??%?→?); #HSome destruct (HSome) #Hc #Hta % [@(\P Hc)]
610 #tb * whd in ⊢ (%→?); #Htb
611 lapply (Htb (〈grid,false〉::ls) (curconfig@[〈c0,false〉]) (table@〈grid,false〉::rs) c t0 ???)
612 [ >Hta >associative_append %
616 #tc * whd in ⊢ (%→?); #Htc cases (Htc … Htable … Htb) -Htb -Htc
617 [| * #Hcurrent #Hfalse @False_ind
618 (* absurd by Hmatch *) @daemon
620 | (* Htable (con lemma) *) @daemon
621 | (* Hmatch *) @daemon
622 | (* Htable *) @daemon
623 | (* Htable, Hmatch → |config| = n
624 necessaria modifica in R_match_tuple, le dimensioni non corrispondono
627 * #table1 * #newc * #mv1 * #table2 * #Htableeq #Htc *
628 [ * #td * whd in ⊢ (%→?); >Htc -Htc * * #c2 * whd in ⊢ (??%?→?); #Hc2 destruct (Hc2)
630 cut (newc = 〈s1,false〉::newconfig@[〈c1,false〉]) [@daemon] #Hnewc
631 >Hnewc cut (mv1 = 〈mv,false〉)
633 * #te * whd in ⊢ (%→?); #Hte
634 cut (td = midtape STape (〈c0,false〉::reverse STape curconfig@〈c,false〉::〈grid,false〉::ls)
636 ((table1@〈bar,false〉::〈c,false〉::curconfig@[〈c0,false〉])@〈comma,true〉::〈s1,false〉::
637 newconfig@〈c1,false〉::〈comma,false〉::〈mv,false〉::table2@〈grid,false〉::rs))
639 [ >reverse_append >reverse_single %
640 | >associative_append >associative_append normalize
641 >associative_append >Hmv1 >Hnewc @eq_f @eq_f @eq_f @eq_f @eq_f @eq_f
642 whd in ⊢ (??%?); >associative_append %
645 -Htd #Htd lapply (Hte … (S n) … Htd … Ht1') -Htd -Hte
647 | (*|curconfig| = |newconfig|*) @daemon
648 | (* Htable → bit_or_null c1 = true *) @daemon
649 | (* only_bits (〈s1,false〉::newconfig) *) @daemon
650 | (* only_bits (curconfig@[〈s0,false〉]) *) @daemon
651 | (* no_marks (reverse ? curconfig) *) @daemon
652 | >Hmv1 in Htableeq; >Hnewc
653 >associative_append >associative_append normalize
654 >associative_append >associative_append
655 #Htableeq <Htableeq // ]
656 * #ls1 * #rs1 * #c2 * * #Hte #Hliftte #Hlegalte
657 whd in ⊢ (%→?); * #_ #Houttape lapply (Houttape … Hte) -Houttape #Houttape
658 whd in Houttape:(???%); whd in Houttape:(???(??%%%));
659 @ex_intro [| @(ex_intro ?? rs1) @ex_intro [| % [ %
660 [ >Houttape @eq_f @eq_f @eq_f @eq_f
661 change with ((〈bar,false〉::〈t0,false〉::table)@?) in ⊢ (???%);
662 >Htableeq >associative_append >associative_append
663 >associative_append normalize >associative_append
664 >associative_append normalize >Hnewc <Hmv1
665 >associative_append normalize >associative_append
673 | * #td * whd in ⊢ (%→%→?); >Htc * #Htd
674 lapply (Htd ? (refl ??)) normalize in ⊢ (%→?);
675 #Hfalse destruct (Hfalse)
678 | #t1 #t2 #t3 whd in ⊢ (%→%→?); #Ht1 #Ht2
679 #b #Hb >Hb in Ht1; * #Hc #Ht1 lapply (Hc ? (refl ??)) -Hc #Hb' %
680 // cases b in Hb'; normalize #H1 //
685 @(acc_sem_if_app STape … (sem_test_char ? (λc:STape.\fst c == bit false))
686 (sem_seq … sem_init_match
687 (sem_seq … sem_match_tuple
688 (sem_if … (* ????????? (sem_test_char … (λc.¬is_marked FSUnialpha c)) *)
689 (sem_seq … sem_exec_action (sem_move_r …))
695 #ta whd in ⊢ (%→?); #Hta #HR
696 #n #fulltable #s0 #s1 #c0 #c1 #ls #rs #curconfig #newconfig #mv
697 #Htable_len cut (∃t0,table. fulltable =〈bar,false〉::〈t0,false〉::table) [(* 0 < |table| *) @daemon]
698 * #t0 * #table #Hfulltable >Hfulltable -fulltable
699 #Htable #Hmatch #Htape #Hintape #t1' #Ht1'
700 >Hintape in Hta; * * * #c #bc *
701 whd in ⊢ (??%?→?); #HSome destruct (HSome) #Hc #Hta % [@(\P Hc)]
703 #tb * whd in ⊢ (%→?); #Htb
704 lapply (Htb (〈grid,false〉::ls) (curconfig@[〈c0,false〉]) (table@〈grid,false〉::rs) c t0 ???)
705 [ >Hta >associative_append %
709 #tc * whd in ⊢ (%→?); #Htc cases (Htc … Htable … Htb) -Htb -Htc
710 [| * #Hcurrent #Hfalse @False_ind
711 (* absurd by Hmatch *) @daemon
713 | (* Htable (con lemma) *) @daemon
714 | (* Hmatch *) @daemon
715 | (* Htable *) @daemon
716 | (* Htable, Hmatch → |config| = n
717 necessaria modifica in R_match_tuple, le dimensioni non corrispondono
720 * #table1 * #newc * #mv1 * #table2 * #Htableeq #Htc *
721 [ * #td * whd in ⊢ (%→?); >Htc -Htc * * #c2 * whd in ⊢ (??%?→?); #Hc2 destruct (Hc2)
723 cut (newc = 〈s1,false〉::newconfig@[〈c1,false〉]) [@daemon] #Hnewc
724 >Hnewc cut (mv1 = 〈mv,false〉)
726 * #te * whd in ⊢ (%→?); #Hte
727 cut (td = midtape STape (〈c0,false〉::reverse STape curconfig@〈c,false〉::〈grid,false〉::ls)
729 ((table1@〈bar,false〉::〈c,false〉::curconfig@[〈c0,false〉])@〈comma,true〉::〈s1,false〉::
730 newconfig@〈c1,false〉::〈comma,false〉::〈mv,false〉::table2@〈grid,false〉::rs))
732 [ >reverse_append >reverse_single %
733 | >associative_append >associative_append normalize
734 >associative_append >Hmv1 >Hnewc @eq_f @eq_f @eq_f @eq_f @eq_f @eq_f
735 whd in ⊢ (??%?); >associative_append %
738 -Htd #Htd lapply (Hte … (S n) … Htd … Ht1') -Htd -Hte
740 | (*|curconfig| = |newconfig|*) @daemon
741 | (* Htable → bit_or_null c1 = true *) @daemon
742 | (* only_bits (〈s1,false〉::newconfig) *) @daemon
743 | (* only_bits (curconfig@[〈s0,false〉]) *) @daemon
744 | (* no_marks (reverse ? curconfig) *) @daemon
745 | >Hmv1 in Htableeq; >Hnewc
746 >associative_append >associative_append normalize
747 >associative_append >associative_append
748 #Htableeq <Htableeq // ]
749 * #ls1 * #rs1 * #c2 * * #Hte #Hliftte #Hlegalte
750 whd in ⊢ (%→?); * #_ #Houttape lapply (Houttape … Hte) -Houttape #Houttape
751 whd in Houttape:(???%); whd in Houttape:(???(??%%%));
752 @ex_intro [| @(ex_intro ?? rs1) @ex_intro [| % [ %
753 [ >Houttape @eq_f @eq_f @eq_f @eq_f
754 change with ((〈bar,false〉::〈t0,false〉::table)@?) in ⊢ (???%);
755 >Htableeq >associative_append >associative_append
756 >associative_append normalize >associative_append
757 >associative_append normalize >Hnewc <Hmv1
758 >associative_append normalize >associative_append
766 | * #td * whd in ⊢ (%→%→?); >Htc * #Htd
767 lapply (Htd ? (refl ??)) normalize in ⊢ (%→?);
768 #Hfalse destruct (Hfalse)
771 | #t1 #t2 #t3 whd in ⊢ (%→%→?); #Ht1 #Ht2
772 #b #Hb >Hb in Ht1; * #Hc #Ht1 lapply (Hc ? (refl ??)) -Hc #Hb' %
773 // cases b in Hb'; normalize #H1 //