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_____________________________________________________________*)
12 include "turing/turing.ma".
14 definition compare_states ≝ initN 3.
16 definition comp0 : compare_states ≝ mk_Sig ?? 0 (leb_true_to_le 1 3 (refl …)).
17 definition comp1 : compare_states ≝ mk_Sig ?? 1 (leb_true_to_le 2 3 (refl …)).
18 definition comp2 : compare_states ≝ mk_Sig ?? 2 (leb_true_to_le 3 3 (refl …)).
20 definition trans_compare_step ≝
22 λp:compare_states × (Vector (option sig) (S n)).
25 [ O ⇒ match nth i ? a (None ?) with
26 [ None ⇒ 〈comp2,null_action sig n〉
27 | Some ai ⇒ match nth j ? a (None ?) with
28 [ None ⇒ 〈comp2,null_action ? n〉
29 | Some aj ⇒ if ai == aj
30 then 〈comp1,change_vec ? (S n)
31 (change_vec ? (S n) (null_action ? n) (〈None ?,R〉) i)
33 else 〈comp2,null_action ? n〉 ]
36 [ O ⇒ (* 1 *) 〈comp1,null_action ? n〉
37 | S _ ⇒ (* 2 *) 〈comp2,null_action ? n〉 ] ].
39 definition compare_step ≝
41 mk_mTM sig n compare_states (trans_compare_step i j sig n)
42 comp0 (λq.q == comp1 ∨ q == comp2).
44 definition R_comp_step_true ≝
45 λi,j,sig,n.λint,outt: Vector (tape sig) (S n).
47 current ? (nth i ? int (niltape ?)) = Some ? x ∧
48 current ? (nth j ? int (niltape ?)) = Some ? x ∧
51 (tape_move_right ? (nth i ? int (niltape ?))) i)
52 (tape_move_right ? (nth j ? int (niltape ?))) j.
54 definition R_comp_step_false ≝
55 λi,j:nat.λsig,n.λint,outt: Vector (tape sig) (S n).
56 (current ? (nth i ? int (niltape ?)) ≠ current ? (nth j ? int (niltape ?)) ∨
57 current ? (nth i ? int (niltape ?)) = None ? ∨
58 current ? (nth j ? int (niltape ?)) = None ?) ∧ outt = int.
60 lemma comp_q0_q2_null :
61 ∀i,j,sig,n,v.i < S n → j < S n →
62 (nth i ? (current_chars ?? v) (None ?) = None ? ∨
63 nth j ? (current_chars ?? v) (None ?) = None ?) →
64 step sig n (compare_step i j sig n) (mk_mconfig ??? comp0 v)
65 = mk_mconfig ??? comp2 v.
66 #i #j #sig #n #v #Hi #Hj
67 whd in ⊢ (? → ??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (?→??%?);
70 [ whd in ⊢ (??(???%)?); >Hcurrent %
71 | whd in ⊢ (??(????(???%))?); >Hcurrent @tape_move_null_action ]
73 [ whd in ⊢ (??(???%)?); >Hcurrent cases (nth i ?? (None sig)) //
74 | whd in ⊢ (??(????(???%))?); >Hcurrent
75 cases (nth i ?? (None sig)) [|#x] @tape_move_null_action ] ]
78 lemma comp_q0_q2_neq :
79 ∀i,j,sig,n,v.i < S n → j < S n →
80 (nth i ? (current_chars ?? v) (None ?) ≠ nth j ? (current_chars ?? v) (None ?)) →
81 step sig n (compare_step i j sig n) (mk_mconfig ??? comp0 v)
82 = mk_mconfig ??? comp2 v.
83 #i #j #sig #n #v #Hi #Hj lapply (refl ? (nth i ?(current_chars ?? v)(None ?)))
84 cases (nth i ?? (None ?)) in ⊢ (???%→?);
85 [ #Hnth #_ @comp_q0_q2_null // % //
86 | #ai #Hai lapply (refl ? (nth j ?(current_chars ?? v)(None ?)))
87 cases (nth j ?? (None ?)) in ⊢ (???%→?);
88 [ #Hnth #_ @comp_q0_q2_null // %2 //
90 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2
91 [ whd in match (trans ????); >Hai >Haj
92 whd in ⊢ (??(???%)?); cut ((ai==aj)=false)
93 [>(\bf ?) /2 by not_to_not/ % #Haiaj @Hneq
96 | whd in match (trans ????); >Hai >Haj
97 whd in ⊢ (??(????(???%))?); cut ((ai==aj)=false)
98 [>(\bf ?) /2 by not_to_not/ % #Haiaj @Hneq
100 |#Hcut >Hcut @tape_move_null_action
108 ∀i,j,sig,n,v,a.i ≠ j → i < S n → j < S n →
109 nth i ? (current_chars ?? v) (None ?) = Some ? a →
110 nth j ? (current_chars ?? v) (None ?) = Some ? a →
111 step sig n (compare_step i j sig n) (mk_mconfig ??? comp0 v) =
115 (tape_move_right ? (nth i ? v (niltape ?))) i)
116 (tape_move_right ? (nth j ? v (niltape ?))) j).
117 #i #j #sig #n #v #a #Heq #Hi #Hj #Ha1 #Ha2
118 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2
119 [ whd in match (trans ????);
120 >Ha1 >Ha2 whd in ⊢ (??(???%)?); >(\b ?) //
121 | whd in match (trans ????);
122 >Ha1 >Ha2 whd in ⊢ (??(????(???%))?); >(\b ?) //
123 change with (change_vec ?????) in ⊢ (??(????%)?);
124 <(change_vec_same … v j (niltape ?)) in ⊢ (??%?);
125 <(change_vec_same … v i (niltape ?)) in ⊢ (??%?);
127 >pmap_change >pmap_change <tape_move_multi_def
128 >tape_move_null_action
129 @eq_f2 // >nth_change_vec_neq //
133 lemma sem_comp_step :
134 ∀i,j,sig,n.i ≠ j → i < S n → j < S n →
135 compare_step i j sig n ⊨
136 [ comp1: R_comp_step_true i j sig n,
137 R_comp_step_false i j sig n ].
138 #i #j #sig #n #Hneq #Hi #Hj #int
139 lapply (refl ? (current ? (nth i ? int (niltape ?))))
140 cases (current ? (nth i ? int (niltape ?))) in ⊢ (???%→?);
143 [ whd in ⊢ (??%?); >comp_q0_q2_null /2/
144 | normalize in ⊢ (%→?); #H destruct (H) ]
145 | #_ % // % %2 // ] ]
146 | #a #Ha lapply (refl ? (current ? (nth j ? int (niltape ?))))
147 cases (current ? (nth j ? int (niltape ?))) in ⊢ (???%→?);
150 [ whd in ⊢ (??%?); >comp_q0_q2_null /2/ %2
151 | normalize in ⊢ (%→?); #H destruct (H) ]
152 | #_ % // >Ha >Hcurj % % % #H destruct (H) ] ]
153 | #b #Hb %{2} cases (true_or_false (a == b)) #Hab
156 [whd in ⊢ (??%?); >(comp_q0_q1 … a Hneq Hi Hj) //
157 >(\P Hab) <Hb @sym_eq @nth_vec_map
158 | #_ whd >(\P Hab) %{b} % // % // <(\P Hab) // ]
159 | * #H @False_ind @H %
163 [whd in ⊢ (??%?); >comp_q0_q2_neq //
164 <(nth_vec_map ?? (current …) i ? int (niltape ?))
165 <(nth_vec_map ?? (current …) j ? int (niltape ?)) >Ha >Hb
166 @(not_to_not ??? (\Pf Hab)) #H destruct (H) %
167 | normalize in ⊢ (%→?); #H destruct (H) ]
168 | #_ % // % % >Ha >Hb @(not_to_not ??? (\Pf Hab)) #H destruct (H) % ] ]
173 (* copy a character from src tape to dst tape without moving them *)
175 definition copy_states ≝ initN 3.
177 definition cc0 : copy_states ≝ mk_Sig ?? 0 (leb_true_to_le 1 3 (refl …)).
178 definition cc1 : copy_states ≝ mk_Sig ?? 1 (leb_true_to_le 2 3 (refl …)).
180 definition trans_copy_char_N ≝
181 λsrc,dst.λsig:FinSet.λn.
182 λp:copy_states × (Vector (option sig) (S n)).
185 [ O ⇒ 〈cc1,change_vec ? (S n)
186 (change_vec ? (S n) (null_action ? n) (〈None ?,N〉) src)
187 (〈nth src ? a (None ?),N〉) dst〉
188 | S _ ⇒ 〈cc1,null_action ? n〉 ].
190 definition copy_char_N ≝
192 mk_mTM sig n copy_states (trans_copy_char_N src dst sig n)
195 definition R_copy_char_N ≝
196 λsrc,dst,sig,n.λint,outt: Vector (tape sig) (S n).
197 outt = change_vec ?? int
198 (tape_write ? (nth dst ? int (niltape ?))
199 (current ? (nth src ? int (niltape ?)))) dst.
201 lemma copy_char_N_q0_q1 :
202 ∀src,dst,sig,n,v.src ≠ dst → src < S n → dst < S n →
203 step sig n (copy_char_N src dst sig n) (mk_mconfig ??? cc0 v) =
206 (tape_write ? (nth dst ? v (niltape ?))
207 (current ? (nth src ? v (niltape ?)))) dst).
208 #src #dst #sig #n #v #Heq #Hsrc #Hdst
209 whd in ⊢ (??%?); @eq_f
210 <(change_vec_same … v dst (niltape ?)) in ⊢ (??%?);
211 <(change_vec_same … v src (niltape ?)) in ⊢ (??%?);
213 >pmap_change >pmap_change <tape_move_multi_def
214 >tape_move_null_action @eq_f3 //
216 | >change_vec_same >change_vec_same >nth_current_chars // ]
219 lemma sem_copy_char_N:
220 ∀src,dst,sig,n.src ≠ dst → src < S n → dst < S n →
221 copy_char_N src dst sig n ⊨ R_copy_char_N src dst sig n.
222 #src #dst #sig #n #Hneq #Hsrc #Hdst #int
223 %{2} % [| % [ % | whd >copy_char_N_q0_q1 // ]]
226 (* copy a character from src tape to dst tape and advance both tape to
227 the right - useful for copying stings
229 definition copy_char_states ≝ initN 3.
231 definition trans_copy_char ≝
232 λsrc,dst.λsig:FinSet.λn.
233 λp:copy_char_states × (Vector (option sig) (S n)).
236 [ O ⇒ 〈cc1,change_vec ? (S n)
237 (change_vec ? (S n) (null_action ? n) (〈None ?,R〉) src)
238 (〈nth src ? a (None ?),R〉) dst〉
239 | S _ ⇒ 〈cc1,null_action ? n〉 ].
241 definition copy_char ≝
243 mk_mTM sig n copy_char_states (trans_copy_char src dst sig n)
246 definition R_copy_char ≝
247 λsrc,dst,sig,n.λint,outt: Vector (tape sig) (S n).
250 (tape_move_mono ? (nth src ? int (niltape ?)) 〈None ?, R〉) src)
251 (tape_move_mono ? (nth dst ? int (niltape ?))
252 〈current ? (nth src ? int (niltape ?)), R〉) dst.
254 lemma copy_char_q0_q1 :
255 ∀src,dst,sig,n,v.src ≠ dst → src < S n → dst < S n →
256 step sig n (copy_char src dst sig n) (mk_mconfig ??? cc0 v) =
260 (tape_move_mono ? (nth src ? v (niltape ?)) 〈None ?, R〉) src)
261 (tape_move_mono ? (nth dst ? v (niltape ?)) 〈current ? (nth src ? v (niltape ?)), R〉) dst).
262 #src #dst #sig #n #v #Heq #Hsrc #Hdst
264 <(change_vec_same … v dst (niltape ?)) in ⊢ (??%?);
265 <(change_vec_same … v src (niltape ?)) in ⊢ (??%?);
266 >tape_move_multi_def @eq_f2 //
267 >pmap_change >pmap_change <tape_move_multi_def
268 >tape_move_null_action @eq_f2 // @eq_f2
270 | >change_vec_same >change_vec_same // ]
274 ∀src,dst,sig,n.src ≠ dst → src < S n → dst < S n →
275 copy_char src dst sig n ⊨ R_copy_char src dst sig n.
276 #src #dst #sig #n #Hneq #Hsrc #Hdst #int
277 %{2} % [| % [ % | whd >copy_char_q0_q1 // ]]
280 definition copy0 : copy_states ≝ mk_Sig ?? 0 (leb_true_to_le 1 3 (refl …)).
281 definition copy1 : copy_states ≝ mk_Sig ?? 1 (leb_true_to_le 2 3 (refl …)).
282 definition copy2 : copy_states ≝ mk_Sig ?? 2 (leb_true_to_le 3 3 (refl …)).
284 definition trans_copy_step ≝
285 λsrc,dst.λsig:FinSet.λn.
286 λp:copy_states × (Vector (option sig) (S n)).
289 [ O ⇒ match nth src ? a (None ?) with
290 [ None ⇒ 〈copy2,null_action sig n〉
291 | Some ai ⇒ match nth dst ? a (None ?) with
292 [ None ⇒ 〈copy2,null_action ? n〉
294 〈copy1,change_vec ? (S n)
295 (change_vec ? (S n) (null_action ? n) (〈None ?,R〉) src)
300 [ O ⇒ (* 1 *) 〈copy1,null_action ? n〉
301 | S _ ⇒ (* 2 *) 〈copy2,null_action ? n〉 ] ].
303 definition copy_step ≝
305 mk_mTM sig n copy_states (trans_copy_step src dst sig n)
306 copy0 (λq.q == copy1 ∨ q == copy2).
308 definition R_copy_step_true ≝
309 λsrc,dst,sig,n.λint,outt: Vector (tape sig) (S n).
311 current ? (nth src ? int (niltape ?)) = Some ? x ∧
312 current ? (nth dst ? int (niltape ?)) = Some ? y ∧
315 (tape_move_mono ? (nth src ? int (niltape ?)) 〈None ?, R〉) src)
316 (tape_move_mono ? (nth dst ? int (niltape ?)) 〈Some ? x, R〉) dst.
318 definition R_copy_step_false ≝
319 λsrc,dst:nat.λsig,n.λint,outt: Vector (tape sig) (S n).
320 (current ? (nth src ? int (niltape ?)) = None ? ∨
321 current ? (nth dst ? int (niltape ?)) = None ?) ∧ outt = int.
323 lemma copy_q0_q2_null :
324 ∀src,dst,sig,n,v.src < S n → dst < S n →
325 (nth src ? (current_chars ?? v) (None ?) = None ? ∨
326 nth dst ? (current_chars ?? v) (None ?) = None ?) →
327 step sig n (copy_step src dst sig n) (mk_mconfig ??? copy0 v)
328 = mk_mconfig ??? copy2 v.
329 #src #dst #sig #n #v #Hi #Hj
330 whd in ⊢ (? → ??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (?→??%?);
333 [ whd in ⊢ (??(???%)?); >Hcurrent %
334 | whd in ⊢ (??(????(???%))?); >Hcurrent @tape_move_null_action ]
336 [ whd in ⊢ (??(???%)?); >Hcurrent cases (nth src ?? (None sig)) //
337 | whd in ⊢ (??(????(???%))?); >Hcurrent
338 cases (nth src ?? (None sig)) [|#x] @tape_move_null_action ] ]
342 ∀src,dst,sig,n,v,a,b.src ≠ dst → src < S n → dst < S n →
343 nth src ? (current_chars ?? v) (None ?) = Some ? a →
344 nth dst ? (current_chars ?? v) (None ?) = Some ? b →
345 step sig n (copy_step src dst sig n) (mk_mconfig ??? copy0 v) =
349 (tape_move_mono ? (nth src ? v (niltape ?)) 〈None ?, R〉) src)
350 (tape_move_mono ? (nth dst ? v (niltape ?)) 〈Some ? a, R〉) dst).
351 #src #dst #sig #n #v #a #b #Heq #Hsrc #Hdst #Ha1 #Ha2
352 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2
353 [ whd in match (trans ????);
354 >Ha1 >Ha2 whd in ⊢ (??(???%)?); >(\b ?) //
355 | whd in match (trans ????);
356 >Ha1 >Ha2 whd in ⊢ (??(????(???%))?); >(\b ?) //
357 change with (change_vec ?????) in ⊢ (??(????%)?);
358 <(change_vec_same … v dst (niltape ?)) in ⊢ (??%?);
359 <(change_vec_same … v src (niltape ?)) in ⊢ (??%?);
361 >pmap_change >pmap_change <tape_move_multi_def
362 >tape_move_null_action
363 @eq_f2 // >nth_change_vec_neq //
367 lemma sem_copy_step :
368 ∀src,dst,sig,n.src ≠ dst → src < S n → dst < S n →
369 copy_step src dst sig n ⊨
370 [ copy1: R_copy_step_true src dst sig n,
371 R_copy_step_false src dst sig n ].
372 #src #dst #sig #n #Hneq #Hsrc #Hdst #int
373 lapply (refl ? (current ? (nth src ? int (niltape ?))))
374 cases (current ? (nth src ? int (niltape ?))) in ⊢ (???%→?);
377 [ whd in ⊢ (??%?); >copy_q0_q2_null /2/
378 | normalize in ⊢ (%→?); #H destruct (H) ]
380 | #a #Ha lapply (refl ? (current ? (nth dst ? int (niltape ?))))
381 cases (current ? (nth dst ? int (niltape ?))) in ⊢ (???%→?);
384 [ whd in ⊢ (??%?); >copy_q0_q2_null /2/
385 | normalize in ⊢ (%→?); #H destruct (H) ]
386 | #_ % // %2 >Hcur_dst % ] ]
389 [whd in ⊢ (??%?); >(copy_q0_q1 … a b Hneq Hsrc Hdst) //
390 | #_ %{a} %{b} % // % //]
391 | * #H @False_ind @H %
399 (* advance in parallel on tapes src and dst; stops if one of the
400 two tapes is in oveflow *)
402 definition parmove_states ≝ initN 3.
404 definition parmove0 : parmove_states ≝ mk_Sig ?? 0 (leb_true_to_le 1 3 (refl …)).
405 definition parmove1 : parmove_states ≝ mk_Sig ?? 1 (leb_true_to_le 2 3 (refl …)).
406 definition parmove2 : parmove_states ≝ mk_Sig ?? 2 (leb_true_to_le 3 3 (refl …)).
409 src: a b c ... z ---→ a b c ... z
411 dst: _ _ _ ... _ ---→ a b c ... z
414 0) (x,_) → (x,_)(R,R) → 1
420 definition trans_parmove_step ≝
422 λp:parmove_states × (Vector (option sig) (S n)).
425 [ O ⇒ match nth src ? a (None ?) with
426 [ None ⇒ 〈parmove2,null_action sig n〉
427 | Some a0 ⇒ match nth dst ? a (None ?) with
428 [ None ⇒ 〈parmove2,null_action ? n〉
429 | Some a1 ⇒ 〈parmove1,change_vec ? (S n)
431 (null_action ? n) (〈None ?,D〉) src)
432 (〈None ?,D〉) dst〉 ] ]
434 [ O ⇒ (* 1 *) 〈parmove1,null_action ? n〉
435 | S _ ⇒ (* 2 *) 〈parmove2,null_action ? n〉 ] ].
437 definition parmove_step ≝
439 mk_mTM sig n parmove_states (trans_parmove_step src dst sig n D)
440 parmove0 (λq.q == parmove1 ∨ q == parmove2).
442 definition R_parmove_step_true ≝
443 λsrc,dst,sig,n,D.λint,outt: Vector (tape sig) (S n).
445 current ? (nth src ? int (niltape ?)) = Some ? x1 ∧
446 current ? (nth dst ? int (niltape ?)) = Some ? x2 ∧
449 (tape_move ? (nth src ? int (niltape ?)) D) src)
450 (tape_move ? (nth dst ? int (niltape ?)) D) dst.
452 definition R_parmove_step_false ≝
453 λsrc,dst:nat.λsig,n.λint,outt: Vector (tape sig) (S n).
454 (current ? (nth src ? int (niltape ?)) = None ? ∨
455 current ? (nth dst ? int (niltape ?)) = None ?) ∧
458 lemma parmove_q0_q2_null_src :
459 ∀src,dst,sig,n,D,v.src < S n → dst < S n →
460 nth src ? (current_chars ?? v) (None ?) = None ? →
461 step sig n (parmove_step src dst sig n D)
462 (mk_mconfig ??? parmove0 v) =
463 mk_mconfig ??? parmove2 v.
464 #src #dst #sig #n #D #v #Hsrc #Hdst #Hcurrent
465 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?);
467 [ whd in ⊢ (??(???%)?); >Hcurrent %
468 | whd in ⊢ (??(????(???%))?); >Hcurrent @tape_move_null_action ]
471 lemma parmove_q0_q2_null_dst :
472 ∀src,dst,sig,n,D,v,s.src < S n → dst < S n →
473 nth src ? (current_chars ?? v) (None ?) = Some ? s →
474 nth dst ? (current_chars ?? v) (None ?) = None ? →
475 step sig n (parmove_step src dst sig n D)
476 (mk_mconfig ??? parmove0 v) =
477 mk_mconfig ??? parmove2 v.
478 #src #dst #sig #n #D #v #s #Hsrc #Hdst #Hcursrc #Hcurdst
479 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?);
481 [ whd in ⊢ (??(???%)?); >Hcursrc whd in ⊢ (??(???%)?); >Hcurdst %
482 | whd in ⊢ (??(????(???%))?); >Hcursrc
483 whd in ⊢ (??(????(???%))?); >Hcurdst @tape_move_null_action ]
486 lemma parmove_q0_q1 :
487 ∀src,dst,sig,n,D,v.src ≠ dst → src < S n → dst < S n →
489 nth src ? (current_chars ?? v) (None ?) = Some ? a1 →
490 nth dst ? (current_chars ?? v) (None ?) = Some ? a2 →
491 step sig n (parmove_step src dst sig n D)
492 (mk_mconfig ??? parmove0 v) =
493 mk_mconfig ??? parmove1
496 (tape_move ? (nth src ? v (niltape ?)) D) src)
497 (tape_move ? (nth dst ? v (niltape ?)) D) dst).
498 #src #dst #sig #n #D #v #Hneq #Hsrc #Hdst
499 #a1 #a2 #Hcursrc #Hcurdst
500 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2
501 [ whd in match (trans ????);
503 | whd in match (trans ????);
504 >Hcursrc >Hcurdst whd in ⊢ (??(????(???%))?);
505 >tape_move_multi_def <(change_vec_same ?? v dst (niltape ?)) in ⊢ (??%?);
506 >pmap_change <(change_vec_same ?? v src (niltape ?)) in ⊢(??%?);
507 >pmap_change <tape_move_multi_def >tape_move_null_action
508 @eq_f2 // >nth_change_vec_neq //
512 lemma sem_parmove_step :
513 ∀src,dst,sig,n,D.src ≠ dst → src < S n → dst < S n →
514 parmove_step src dst sig n D ⊨
515 [ parmove1: R_parmove_step_true src dst sig n D,
516 R_parmove_step_false src dst sig n ].
517 #src #dst #sig #n #D #Hneq #Hsrc #Hdst #int
518 lapply (refl ? (current ? (nth src ? int (niltape ?))))
519 cases (current ? (nth src ? int (niltape ?))) in ⊢ (???%→?);
522 [ whd in ⊢ (??%?); >parmove_q0_q2_null_src /2/
523 | normalize in ⊢ (%→?); #H destruct (H) ]
525 | #a #Ha lapply (refl ? (current ? (nth dst ? int (niltape ?))))
526 cases (current ? (nth dst ? int (niltape ?))) in ⊢ (???%→?);
529 [ whd in ⊢ (??%?); >(parmove_q0_q2_null_dst …) /2/
530 | normalize in ⊢ (%→?); #H destruct (H) ]
534 [whd in ⊢ (??%?); >(parmove_q0_q1 … Hneq Hsrc Hdst ? b ??)
535 [2: <(nth_vec_map ?? (current …) dst ? int (niltape ?)) //
536 |3: <(nth_vec_map ?? (current …) src ? int (niltape ?)) //
538 | #_ %{a} %{b} % // % // ]
539 | * #H @False_ind @H % ]
543 (* perform a symultaneous test on all tapes; ends up in state partest1 if
544 the test is succesfull and partest2 otherwise *)
546 definition partest_states ≝ initN 3.
548 definition partest0 : partest_states ≝ mk_Sig ?? 0 (leb_true_to_le 1 3 (refl …)).
549 definition partest1 : partest_states ≝ mk_Sig ?? 1 (leb_true_to_le 2 3 (refl …)).
550 definition partest2 : partest_states ≝ mk_Sig ?? 2 (leb_true_to_le 3 3 (refl …)).
552 definition trans_partest ≝
554 λp:partest_states × (Vector (option sig) (S n)).
556 if test a then 〈partest1,null_action sig n〉
557 else 〈partest2,null_action ? n〉.
561 mk_mTM sig n partest_states (trans_partest sig n test)
562 partest0 (λq.q == partest1 ∨ q == partest2).
564 definition R_partest_true ≝
565 λsig,n,test.λint,outt: Vector (tape sig) (S n).
566 test (current_chars ?? int) = true ∧ outt = int.
568 definition R_partest_false ≝
569 λsig,n,test.λint,outt: Vector (tape sig) (S n).
570 test (current_chars ?? int) = false ∧ outt = int.
574 test (current_chars ?? v) = true →
575 step sig n (partest sig n test)(mk_mconfig ??? partest0 v)
576 = mk_mconfig ??? partest1 v.
577 #sig #n #test #v #Htest
578 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?);
580 [ whd in ⊢ (??(???%)?); >Htest %
581 | whd in ⊢ (??(????(???%))?); >Htest @tape_move_null_action ]
586 test (current_chars ?? v) = false →
587 step sig n (partest sig n test)(mk_mconfig ??? partest0 v)
588 = mk_mconfig ??? partest2 v.
589 #sig #n #test #v #Htest
590 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?);
592 [ whd in ⊢ (??(???%)?); >Htest %
593 | whd in ⊢ (??(????(???%))?); >Htest @tape_move_null_action ]
599 [ partest1: R_partest_true sig n test, R_partest_false sig n test ].
601 cases (true_or_false (test (current_chars ?? int))) #Htest
602 [ %{2} %{(mk_mconfig ? partest_states n partest1 int)} %
603 [ % [ whd in ⊢ (??%?); >partest_q0_q1 /2/ | #_ % // ]
604 | * #H @False_ind @H %
606 | %{2} %{(mk_mconfig ? partest_states n partest2 int)} %
607 [ % [ whd in ⊢ (??%?); >partest_q0_q2 /2/
608 | whd in ⊢ (??%%→?); #H destruct (H)]