1 include "basics/core_notation/fintersects_2.ma".
2 include "turing/mono.ma".
3 include "basics/vectors.ma".
5 (* We do not distinuish an input tape *)
7 (* tapes_no = number of ADDITIONAL working tapes *)
9 record mTM (sig:FinSet) (tapes_no:nat) : Type[1] ≝
11 trans : states × (Vector (option sig) (S tapes_no)) →
12 states × (Vector ((option sig) × move) (S tapes_no));
17 record mconfig (sig,states:FinSet) (n:nat): Type[0] ≝
19 ctapes : Vector (tape sig) (S n)
22 lemma mconfig_expand: ∀sig,n,Q,c.
23 c = mk_mconfig sig Q n (cstate ??? c) (ctapes ??? c).
27 lemma mconfig_eq : ∀sig,n,M,c1,c2.
28 cstate sig n M c1 = cstate sig n M c2 →
29 ctapes sig n M c1 = ctapes sig n M c2 → c1 = c2.
30 #sig #n #M1 * #s1 #t1 * #s2 #t2 //
33 definition current_chars ≝ λsig.λn.λtapes.
34 vec_map ?? (current sig) (S n) tapes.
36 lemma nth_current_chars : ∀sig,n,tapes,i.
37 nth i ? (current_chars sig n tapes) (None ?)
38 = current sig (nth i ? tapes (niltape sig)).
39 #sig #n #tapes #i >(nth_vec_map … (current sig) i (S n)) %
42 definition tape_move_multi ≝
44 pmap_vec ??? (tape_move_mono sig) n ts mvs.
46 lemma tape_move_multi_def : ∀sig,n,ts,mvs.
47 tape_move_multi sig n ts mvs = pmap_vec ??? (tape_move_mono sig) n ts mvs.
50 definition step ≝ λsig.λn.λM:mTM sig n.λc:mconfig sig (states ?? M) n.
51 let 〈news,mvs〉 ≝ trans sig n M 〈cstate ??? c,current_chars ?? (ctapes ??? c)〉 in
52 mk_mconfig ??? news (tape_move_multi sig ? (ctapes ??? c) mvs).
54 definition empty_tapes ≝ λsig.λn.
55 mk_Vector ? n (make_list (tape sig) (niltape sig) n) ?.
56 elim n // normalize //
59 (************************** Realizability *************************************)
60 definition loopM ≝ λsig,n.λM:mTM sig n.λi,cin.
61 loop ? i (step sig n M) (λc.halt sig n M (cstate ??? c)) cin.
63 lemma loopM_unfold : ∀sig,n,M,i,cin.
64 loopM sig n M i cin = loop ? i (step sig n M) (λc.halt sig n M (cstate ??? c)) cin.
67 definition initc ≝ λsig,n.λM:mTM sig n.λtapes.
68 mk_mconfig sig (states sig n M) n (start sig n M) tapes.
70 definition Realize ≝ λsig,n.λM:mTM sig n.λR:relation (Vector (tape sig) ?).
72 loopM sig n M i (initc sig n M t) = Some ? outc ∧ R t (ctapes ??? outc).
74 definition WRealize ≝ λsig,n.λM:mTM sig n.λR:relation (Vector (tape sig) ?).
76 loopM sig n M i (initc sig n M t) = Some ? outc → R t (ctapes ??? outc).
78 definition Terminate ≝ λsig,n.λM:mTM sig n.λt. ∃i,outc.
79 loopM sig n M i (initc sig n M t) = Some ? outc.
81 (* notation "M \vDash R" non associative with precedence 45 for @{ 'models $M $R}. *)
82 interpretation "multi realizability" 'models M R = (Realize ?? M R).
84 (* notation "M \VDash R" non associative with precedence 45 for @{ 'wmodels $M $R}. *)
85 interpretation "weak multi realizability" 'wmodels M R = (WRealize ?? M R).
87 interpretation "multi termination" 'fintersects M t = (Terminate ?? M t).
89 lemma WRealize_to_Realize : ∀sig,n .∀M: mTM sig n.∀R.
90 (∀t.M ↓ t) → M ⊫ R → M ⊨ R.
91 #sig #n #M #R #HT #HW #t cases (HT … t) #i * #outc #Hloop
92 @(ex_intro … i) @(ex_intro … outc) % // @(HW … i) //
95 theorem Realize_to_WRealize : ∀sig,n.∀M:mTM sig n.∀R.
97 #sig #n #M #R #H1 #inc #i #outc #Hloop
98 cases (H1 inc) #k * #outc1 * #Hloop1 #HR >(loop_eq … Hloop Hloop1) //
101 definition accRealize ≝ λsig,n.λM:mTM sig n.λacc:states sig n M.λRtrue,Rfalse.
103 loopM sig n M i (initc sig n M t) = Some ? outc ∧
104 (cstate ??? outc = acc → Rtrue t (ctapes ??? outc)) ∧
105 (cstate ??? outc ≠ acc → Rfalse t (ctapes ??? outc)).
107 (* notation "M ⊨ [q: R1,R2]" non associative with precedence 45 for @{ 'cmodels $M $q $R1 $R2}. *)
108 interpretation "conditional multi realizability" 'cmodels M q R1 R2 = (accRealize ?? M q R1 R2).
110 (*************************** guarded realizablity *****************************)
111 definition GRealize ≝ λsig,n.λM:mTM sig n.
112 λPre:Vector (tape sig) ? →Prop.λR:relation (Vector (tape sig) ?).
114 loopM sig n M i (initc sig n M t) = Some ? outc ∧ R t (ctapes ??? outc).
116 definition accGRealize ≝ λsig,n.λM:mTM sig n.λacc:states sig n M.
117 λPre: Vector (tape sig) ? → Prop.λRtrue,Rfalse.
119 loopM sig n M i (initc sig n M t) = Some ? outc ∧
120 (cstate ??? outc = acc → Rtrue t (ctapes ??? outc)) ∧
121 (cstate ??? outc ≠ acc → Rfalse t (ctapes ??? outc)).
123 lemma WRealize_to_GRealize : ∀sig,n.∀M: mTM sig n.∀Pre,R.
124 (∀t.Pre t → M ↓ t) → M ⊫ R → GRealize sig n M Pre R.
125 #sig #n #M #Pre #R #HT #HW #t #HPre cases (HT … t HPre) #i * #outc #Hloop
126 @(ex_intro … i) @(ex_intro … outc) % // @(HW … i) //
129 lemma Realize_to_GRealize : ∀sig,n.∀M: mTM sig n.∀P,R.
130 M ⊨ R → GRealize sig n M P R.
131 #alpha #n #M #Pre #R #HR #t #HPre
132 cases (HR t) -HR #k * #outc * #Hloop #HR
133 @(ex_intro ?? k) @(ex_intro ?? outc) %
137 lemma acc_Realize_to_acc_GRealize: ∀sig,n.∀M:mTM sig n.∀q:states sig n M.∀P,R1,R2.
138 M ⊨ [q:R1,R2] → accGRealize sig n M q P R1 R2.
139 #alpha #n #M #q #Pre #R1 #R2 #HR #t #HPre
140 cases (HR t) -HR #k * #outc * * #Hloop #HRtrue #HRfalse
141 @(ex_intro ?? k) @(ex_intro ?? outc) %
142 [ % [@Hloop] @HRtrue | @HRfalse]
145 (******************************** monotonicity ********************************)
146 lemma Realize_to_Realize : ∀sig,n.∀M:mTM sig n.∀R1,R2.
147 R1 ⊆ R2 → M ⊨ R1 → M ⊨ R2.
148 #alpha #n #M #R1 #R2 #Himpl #HR1 #intape
149 cases (HR1 intape) -HR1 #k * #outc * #Hloop #HR1
150 @(ex_intro ?? k) @(ex_intro ?? outc) % /2/
153 lemma WRealize_to_WRealize: ∀sig,n.∀M:mTM sig n.∀R1,R2.
154 R1 ⊆ R2 → WRealize sig n M R1 → WRealize sig n M R2.
155 #alpha #n #M #R1 #R2 #Hsub #HR1 #intape #i #outc #Hloop
156 @Hsub @(HR1 … i) @Hloop
159 lemma GRealize_to_GRealize : ∀sig,n.∀M:mTM sig n.∀P,R1,R2.
160 R1 ⊆ R2 → GRealize sig n M P R1 → GRealize sig n M P R2.
161 #alpha #n #M #P #R1 #R2 #Himpl #HR1 #intape #HP
162 cases (HR1 intape HP) -HR1 #k * #outc * #Hloop #HR1
163 @(ex_intro ?? k) @(ex_intro ?? outc) % /2/
166 lemma GRealize_to_GRealize_2 : ∀sig,n.∀M:mTM sig n.∀P1,P2,R1,R2.
167 P2 ⊆ P1 → R1 ⊆ R2 → GRealize sig n M P1 R1 → GRealize sig n M P2 R2.
168 #alpha #n #M #P1 #P2 #R1 #R2 #Himpl1 #Himpl2 #H1 #intape #HP
169 cases (H1 intape (Himpl1 … HP)) -H1 #k * #outc * #Hloop #H1
170 @(ex_intro ?? k) @(ex_intro ?? outc) % /2/
173 lemma acc_Realize_to_acc_Realize: ∀sig,n.∀M:mTM sig n.∀q:states sig n M.
175 R1 ⊆ R3 → R2 ⊆ R4 → M ⊨ [q:R1,R2] → M ⊨ [q:R3,R4].
176 #alpha #n #M #q #R1 #R2 #R3 #R4 #Hsub13 #Hsub24 #HRa #intape
177 cases (HRa intape) -HRa #k * #outc * * #Hloop #HRtrue #HRfalse
178 @(ex_intro ?? k) @(ex_intro ?? outc) %
179 [ % [@Hloop] #Hq @Hsub13 @HRtrue // | #Hq @Hsub24 @HRfalse //]
182 (**************************** A canonical relation ****************************)
184 definition R_mTM ≝ λsig,n.λM:mTM sig n.λq.λt1,t2.
186 loopM ? n M i (mk_mconfig ??? q t1) = Some ? outc ∧
187 t2 = (ctapes ??? outc).
189 lemma R_mTM_to_R: ∀sig,n.∀M:mTM sig n.∀R. ∀t1,t2.
190 M ⊫ R → R_mTM ?? M (start sig n M) t1 t2 → R t1 t2.
191 #sig #n #M #R #t1 #t2 whd in ⊢ (%→?); #HMR * #i * #outc *
192 #Hloop #Ht2 >Ht2 @(HMR … Hloop)
195 (******************************** NOP Machine *********************************)
200 definition nop_states ≝ initN 1.
201 definition start_nop : initN 1 ≝ mk_Sig ?? 0 (le_n … 1). *)
204 λalpha:FinSet.λn.mk_mTM alpha n nop_states
205 (λp.let 〈q,a〉 ≝ p in 〈q,mk_Vector ? (S n) (make_list ? (〈None ?,N〉) (S n)) ?〉)
210 definition R_nop ≝ λalpha,n.λt1,t2:Vector (tape alpha) (S n).t2 = t1.
213 ∀alpha,n.nop alpha n⊨ R_nop alpha n.
214 #alpha #n #intapes @(ex_intro ?? 1)
215 @(ex_intro … (mk_mconfig ??? start_nop intapes)) % %
218 lemma nop_single_state: ∀sig,n.∀q1,q2:states ? n (nop sig n). q1 = q2.
219 normalize #sig #n0 * #n #ltn1 * #m #ltm1
220 generalize in match ltn1; generalize in match ltm1;
221 <(le_n_O_to_eq … (le_S_S_to_le … ltn1)) <(le_n_O_to_eq … (le_S_S_to_le … ltm1))
224 (************************** Sequential Composition ****************************)
225 definition null_action ≝ λsig.λn.
226 mk_Vector ? (S n) (make_list (option sig × move) (〈None ?,N〉) (S n)) ?.
227 elim (S n) // normalize //
230 lemma tape_move_null_action: ∀sig,n,tapes.
231 tape_move_multi sig (S n) tapes (null_action sig n) = tapes.
232 #sig #n #tapes cases tapes -tapes #tapes whd in match (null_action ??);
233 #Heq @Vector_eq <Heq -Heq elim tapes //
234 #a #tl #Hind whd in ⊢ (??%?); @eq_f2 // @Hind
237 definition seq_trans ≝ λsig,n. λM1,M2 : mTM sig n.
241 if halt sig n M1 s1 then 〈inr … (start sig n M2), null_action sig n〉
242 else let 〈news1,m〉 ≝ trans sig n M1 〈s1,a〉 in 〈inl … news1,m〉
243 | inr s2 ⇒ let 〈news2,m〉 ≝ trans sig n M2 〈s2,a〉 in 〈inr … news2,m〉
246 definition seq ≝ λsig,n. λM1,M2 : mTM sig n.
248 (FinSum (states sig n M1) (states sig n M2))
249 (seq_trans sig n M1 M2)
250 (inl … (start sig n M1))
252 [ inl _ ⇒ false | inr s2 ⇒ halt sig n M2 s2]).
254 (* notation "a · b" right associative with precedence 65 for @{ 'middot $a $b}. *)
255 interpretation "sequential composition" 'middot a b = (seq ?? a b).
257 definition lift_confL ≝
258 λsig,n,S1,S2,c.match c with
259 [ mk_mconfig s t ⇒ mk_mconfig sig (FinSum S1 S2) n (inl … s) t ].
261 definition lift_confR ≝
262 λsig,n,S1,S2,c.match c with
263 [ mk_mconfig s t ⇒ mk_mconfig sig (FinSum S1 S2) n (inr … s) t ].
266 definition halt_liftL ≝
267 λS1,S2,halt.λs:FinSum S1 S2.
270 | inr _ ⇒ true ]. (* should be vacuous in all cases we use halt_liftL *)
272 definition halt_liftR ≝
273 λS1,S2,halt.λs:FinSum S1 S2.
276 | inr s2 ⇒ halt s2 ]. *)
278 lemma p_halt_liftL : ∀sig,n,S1,S2,halt,c.
279 halt (cstate sig S1 n c) =
280 halt_liftL S1 S2 halt (cstate … (lift_confL … c)).
281 #sig #n #S1 #S2 #halt #c cases c #s #t %
284 lemma trans_seq_liftL : ∀sig,n,M1,M2,s,a,news,move.
285 halt ?? M1 s = false →
286 trans sig n M1 〈s,a〉 = 〈news,move〉 →
287 trans sig n (seq sig n M1 M2) 〈inl … s,a〉 = 〈inl … news,move〉.
288 #sig #n (*#M1*) * #Q1 #T1 #init1 #halt1 #M2 #s #a #news #move
289 #Hhalt #Htrans whd in ⊢ (??%?); >Hhalt >Htrans %
292 lemma trans_seq_liftR : ∀sig,n,M1,M2,s,a,news,move.
293 halt ?? M2 s = false →
294 trans sig n M2 〈s,a〉 = 〈news,move〉 →
295 trans sig n (seq sig n M1 M2) 〈inr … s,a〉 = 〈inr … news,move〉.
296 #sig #n #M1 * #Q2 #T2 #init2 #halt2 #s #a #news #move
297 #Hhalt #Htrans whd in ⊢ (??%?); >Hhalt >Htrans %
300 lemma step_seq_liftR : ∀sig,n,M1,M2,c0.
301 halt ?? M2 (cstate ??? c0) = false →
302 step sig n (seq sig n M1 M2) (lift_confR sig n (states ?? M1) (states ?? M2) c0) =
303 lift_confR sig n (states ?? M1) (states ?? M2) (step sig n M2 c0).
304 #sig #n #M1 (* * #Q1 #T1 #init1 #halt1 *) #M2 * #s #t
305 lapply (refl ? (trans ??? 〈s,current_chars sig n t〉))
306 cases (trans ??? 〈s,current_chars sig n t〉) in ⊢ (???% → %);
307 #s0 #m0 #Heq #Hhalt whd in ⊢ (???(?????%)); >Heq whd in ⊢ (???%);
308 whd in ⊢ (??(????%)?); whd in ⊢ (??%?); >(trans_seq_liftR … Heq) //
311 lemma step_seq_liftL : ∀sig,n,M1,M2,c0.
312 halt ?? M1 (cstate ??? c0) = false →
313 step sig n (seq sig n M1 M2) (lift_confL sig n (states ?? M1) (states ?? M2) c0) =
314 lift_confL sig n ?? (step sig n M1 c0).
315 #sig #n #M1 (* * #Q1 #T1 #init1 #halt1 *) #M2 * #s #t
316 lapply (refl ? (trans ??? 〈s,current_chars sig n t〉))
317 cases (trans ??? 〈s,current_chars sig n t〉) in ⊢ (???% → %);
319 whd in ⊢ (???(?????%)); >Heq whd in ⊢ (???%);
320 whd in ⊢ (??(????%)?); whd in ⊢ (??%?); >(trans_seq_liftL … Heq) //
323 lemma trans_liftL_true : ∀sig,n,M1,M2,s,a.
324 halt ?? M1 s = true →
325 trans sig n (seq sig n M1 M2) 〈inl … s,a〉 = 〈inr … (start ?? M2),null_action sig n〉.
326 #sig #n #M1 #M2 #s #a #Hhalt whd in ⊢ (??%?); >Hhalt %
329 lemma eq_ctape_lift_conf_L : ∀sig,n,S1,S2,outc.
330 ctapes sig (FinSum S1 S2) n (lift_confL … outc) = ctapes … outc.
331 #sig #n #S1 #S2 #outc cases outc #s #t %
334 lemma eq_ctape_lift_conf_R : ∀sig,n,S1,S2,outc.
335 ctapes sig (FinSum S1 S2) n (lift_confR … outc) = ctapes … outc.
336 #sig #n #S1 #S2 #outc cases outc #s #t %
339 theorem sem_seq: ∀sig,n.∀M1,M2:mTM sig n.∀R1,R2.
340 M1 ⊨ R1 → M2 ⊨ R2 → M1 · M2 ⊨ R1 ∘ R2.
341 #sig #n #M1 #M2 #R1 #R2 #HR1 #HR2 #t
342 cases (HR1 t) #k1 * #outc1 * #Hloop1 #HM1
343 cases (HR2 (ctapes sig (states ?? M1) n outc1)) #k2 * #outc2 * #Hloop2 #HM2
344 @(ex_intro … (k1+k2)) @(ex_intro … (lift_confR … outc2))
346 [@(loop_merge ???????????
347 (loop_lift ??? (lift_confL sig n (states sig n M1) (states sig n M2))
348 (step sig n M1) (step sig n (seq sig n M1 M2))
349 (λc.halt sig n M1 (cstate … c))
350 (λc.halt_liftL ?? (halt sig n M1) (cstate … c)) … Hloop1))
352 [ #sl #tl whd in ⊢ (??%? → ?); #Hl %
353 | #sr #tr whd in ⊢ (??%? → ?); #Hr destruct (Hr) ]
354 || #c0 #Hhalt <step_seq_liftL //
356 |6:cases outc1 #s1 #t1 %
357 |7:@(loop_lift … (initc ??? (ctapes … outc1)) … Hloop2)
359 | #c0 #Hhalt <step_seq_liftR // ]
360 |whd in ⊢ (??(????%)?);whd in ⊢ (??%?);
361 generalize in match Hloop1; cases outc1 #sc1 #tc1 #Hloop10
362 >(trans_liftL_true sig n M1 M2 ??)
363 [ whd in ⊢ (??%?); whd in ⊢ (???%);
364 @mconfig_eq whd in ⊢ (???%); //
365 | @(loop_Some ?????? Hloop10) ]
367 | @(ex_intro … (ctapes ? (FinSum (states ?? M1) (states ?? M2)) ? (lift_confL … outc1)))
368 % // >eq_ctape_lift_conf_L >eq_ctape_lift_conf_R //
372 theorem sem_seq_app: ∀sig,n.∀M1,M2:mTM sig n.∀R1,R2,R3.
373 M1 ⊨ R1 → M2 ⊨ R2 → R1 ∘ R2 ⊆ R3 → M1 · M2 ⊨ R3.
374 #sig #n #M1 #M2 #R1 #R2 #R3 #HR1 #HR2 #Hsub
375 #t cases (sem_seq … HR1 HR2 t)
376 #k * #outc * #Hloop #Houtc @(ex_intro … k) @(ex_intro … outc)
377 % [@Hloop |@Hsub @Houtc]
380 (* composition with guards *)
381 theorem sem_seq_guarded: ∀sig,n.∀M1,M2:mTM sig n.∀Pre1,Pre2,R1,R2.
382 GRealize sig n M1 Pre1 R1 → GRealize sig n M2 Pre2 R2 →
383 (∀t1,t2.Pre1 t1 → R1 t1 t2 → Pre2 t2) →
384 GRealize sig n (M1 · M2) Pre1 (R1 ∘ R2).
385 #sig #n #M1 #M2 #Pre1 #Pre2 #R1 #R2 #HGR1 #HGR2 #Hinv #t1 #HPre1
386 cases (HGR1 t1 HPre1) #k1 * #outc1 * #Hloop1 #HM1
387 cases (HGR2 (ctapes sig (states ?? M1) n outc1) ?)
388 [2: @(Hinv … HPre1 HM1)]
389 #k2 * #outc2 * #Hloop2 #HM2
390 @(ex_intro … (k1+k2)) @(ex_intro … (lift_confR … outc2))
392 [@(loop_merge ???????????
393 (loop_lift ??? (lift_confL sig n (states sig n M1) (states sig n M2))
394 (step sig n M1) (step sig n (seq sig n M1 M2))
395 (λc.halt sig n M1 (cstate … c))
396 (λc.halt_liftL ?? (halt sig n M1) (cstate … c)) … Hloop1))
398 [ #sl #tl whd in ⊢ (??%? → ?); #Hl %
399 | #sr #tr whd in ⊢ (??%? → ?); #Hr destruct (Hr) ]
400 || #c0 #Hhalt <step_seq_liftL //
402 |6:cases outc1 #s1 #t1 %
403 |7:@(loop_lift … (initc ??? (ctapes … outc1)) … Hloop2)
405 | #c0 #Hhalt <step_seq_liftR // ]
406 |whd in ⊢ (??(????%)?);whd in ⊢ (??%?);
407 generalize in match Hloop1; cases outc1 #sc1 #tc1 #Hloop10
408 >(trans_liftL_true sig n M1 M2 ??)
409 [ whd in ⊢ (??%?); whd in ⊢ (???%);
410 @mconfig_eq whd in ⊢ (???%); //
411 | @(loop_Some ?????? Hloop10) ]
413 | @(ex_intro … (ctapes ? (FinSum (states ?? M1) (states ?? M2)) n (lift_confL … outc1)))
414 % // >eq_ctape_lift_conf_L >eq_ctape_lift_conf_R //
418 theorem sem_seq_app_guarded: ∀sig,n.∀M1,M2:mTM sig n.∀Pre1,Pre2,R1,R2,R3.
419 GRealize sig n M1 Pre1 R1 → GRealize sig n M2 Pre2 R2 →
420 (∀t1,t2.Pre1 t1 → R1 t1 t2 → Pre2 t2) → R1 ∘ R2 ⊆ R3 →
421 GRealize sig n (M1 · M2) Pre1 R3.
422 #sig #n #M1 #M2 #Pre1 #Pre2 #R1 #R2 #R3 #HR1 #HR2 #Hinv #Hsub
423 #t #HPre1 cases (sem_seq_guarded … HR1 HR2 Hinv t HPre1)
424 #k * #outc * #Hloop #Houtc @(ex_intro … k) @(ex_intro … outc)
425 % [@Hloop |@Hsub @Houtc]
428 theorem acc_sem_seq : ∀sig,n.∀M1,M2:mTM sig n.∀R1,Rtrue,Rfalse,acc.
429 M1 ⊨ R1 → M2 ⊨ [ acc: Rtrue, Rfalse ] →
430 M1 · M2 ⊨ [ inr … acc: R1 ∘ Rtrue, R1 ∘ Rfalse ].
431 #sig #n #M1 #M2 #R1 #Rtrue #Rfalse #acc #HR1 #HR2 #t
432 cases (HR1 t) #k1 * #outc1 * #Hloop1 #HM1
433 cases (HR2 (ctapes sig (states ?? M1) n outc1)) #k2 * #outc2 * * #Hloop2
435 @(ex_intro … (k1+k2)) @(ex_intro … (lift_confR … outc2))
437 [@(loop_merge ???????????
438 (loop_lift ??? (lift_confL sig n (states sig n M1) (states sig n M2))
439 (step sig n M1) (step sig n (seq sig n M1 M2))
440 (λc.halt sig n M1 (cstate … c))
441 (λc.halt_liftL ?? (halt sig n M1) (cstate … c)) … Hloop1))
443 [ #sl #tl whd in ⊢ (??%? → ?); #Hl %
444 | #sr #tr whd in ⊢ (??%? → ?); #Hr destruct (Hr) ]
445 || #c0 #Hhalt <step_seq_liftL //
447 |6:cases outc1 #s1 #t1 %
448 |7:@(loop_lift … (initc ??? (ctapes … outc1)) … Hloop2)
450 | #c0 #Hhalt <step_seq_liftR // ]
451 |whd in ⊢ (??(????%)?);whd in ⊢ (??%?);
452 generalize in match Hloop1; cases outc1 #sc1 #tc1 #Hloop10
453 >(trans_liftL_true sig n M1 M2 ??)
454 [ whd in ⊢ (??%?); whd in ⊢ (???%);
455 @mconfig_eq whd in ⊢ (???%); //
456 | @(loop_Some ?????? Hloop10) ]
458 | >(mconfig_expand … outc2) in ⊢ (%→?); whd in ⊢ (??%?→?);
459 #Hqtrue destruct (Hqtrue)
460 @(ex_intro … (ctapes ? (FinSum (states ?? M1) (states ?? M2)) ? (lift_confL … outc1)))
461 % // >eq_ctape_lift_conf_L >eq_ctape_lift_conf_R /2/ ]
462 | >(mconfig_expand … outc2) in ⊢ (%→?); whd in ⊢ (?(??%?)→?); #Hqfalse
463 @(ex_intro … (ctapes ? (FinSum (states ?? M1) (states ?? M2)) ? (lift_confL … outc1)))
464 % // >eq_ctape_lift_conf_L >eq_ctape_lift_conf_R @HMfalse
465 @(not_to_not … Hqfalse) //
469 lemma acc_sem_seq_app : ∀sig,n.∀M1,M2:mTM sig n.∀R1,Rtrue,Rfalse,R2,R3,acc.
470 M1 ⊨ R1 → M2 ⊨ [acc: Rtrue, Rfalse] →
471 (∀t1,t2,t3. R1 t1 t3 → Rtrue t3 t2 → R2 t1 t2) →
472 (∀t1,t2,t3. R1 t1 t3 → Rfalse t3 t2 → R3 t1 t2) →
473 M1 · M2 ⊨ [inr … acc : R2, R3].
474 #sig #n #M1 #M2 #R1 #Rtrue #Rfalse #R2 #R3 #acc
475 #HR1 #HRacc #Hsub1 #Hsub2
476 #t cases (acc_sem_seq … HR1 HRacc t)
477 #k * #outc * * #Hloop #Houtc1 #Houtc2 @(ex_intro … k) @(ex_intro … outc)
479 |#H cases (Houtc1 H) #t3 * #Hleft #Hright @Hsub1 // ]
480 |#H cases (Houtc2 H) #t3 * #Hleft #Hright @Hsub2 // ]