]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/turing/mono.ma
cd9598765f0ba881bf5b1afd3b6d6c6a73d276ad
[helm.git] / matita / matita / lib / turing / mono.ma
1 (*
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.           
5     ||I||                                                            
6     ||T||  
7     ||A||  
8     \   /  This file is distributed under the terms of the       
9      \ /   GNU General Public License Version 2   
10       V_____________________________________________________________*)
11
12 include "basics/vectors.ma".
13 (* include "basics/relations.ma". *)
14
15 (*
16 record tape (sig:FinSet): Type[0] ≝ 
17 { left : list (option sig);
18   right: list (option sig)
19 }.
20 *)
21
22 inductive tape (sig:FinSet) : Type[0] ≝ 
23 | niltape : tape sig
24 | leftof  : sig → list sig → tape sig
25 | rightof : sig → list sig → tape sig
26 | midtape : list sig → sig → list sig → tape sig.
27
28 definition left ≝ 
29  λsig.λt:tape sig.match t with
30  [ niltape ⇒ [] 
31  | leftof _ _ ⇒ [] 
32  | rightof s l ⇒ s::l
33  | midtape l _ _ ⇒ l ].
34
35 definition right ≝ 
36  λsig.λt:tape sig.match t with
37  [ niltape ⇒ [] 
38  | leftof s r ⇒ s::r 
39  | rightof _ _ ⇒ []
40  | midtape _ _ r ⇒ r ].
41  
42  
43 definition current ≝ 
44  λsig.λt:tape sig.match t with
45  [ midtape _ c _ ⇒ Some ? c
46  | _ ⇒ None ? ].
47
48 inductive move : Type[0] ≝
49 | L : move 
50 | R : move
51 | N : move
52 .
53
54 (* We do not distinuish an input tape *)
55
56 record TM (sig:FinSet): Type[1] ≝ 
57 { states : FinSet;
58   trans : states × (option sig) → states × (option (sig × move));
59   start: states;
60   halt : states → bool
61 }.
62
63 record config (sig,states:FinSet): Type[0] ≝ 
64 { cstate : states;
65   ctape: tape sig
66 }.
67
68 (* definition option_hd ≝ λA.λl:list (option A).
69   match l with
70   [nil ⇒ None ?
71   |cons a _ ⇒ a
72   ].
73   *)
74
75 (*definition tape_write ≝ λsig.λt:tape sig.λs:sig.
76   <left ? t) s (right ? t).
77   [ None ⇒ t
78   | Some s' ⇒ midtape ? (left ? t) s' (right ? t) ].*)
79   
80 definition tape_move_left ≝ λsig:FinSet.λlt:list sig.λc:sig.λrt:list sig.
81   match lt with
82   [ nil ⇒ leftof sig c rt
83   | cons c0 lt0 ⇒ midtape sig lt0 c0 (c::rt) ].
84   
85 definition tape_move_right ≝ λsig:FinSet.λlt:list sig.λc:sig.λrt:list sig.
86   match rt with
87   [ nil ⇒ rightof sig c lt
88   | cons c0 rt0 ⇒ midtape sig (c::lt) c0 rt0 ].
89
90 definition tape_move ≝ λsig.λt: tape sig.λm:option (sig × move).
91   match m with
92   [ None ⇒ t
93   | Some m' ⇒ 
94     let 〈s,m1〉 ≝ m' in 
95     match m1 with
96       [ R ⇒ tape_move_right ? (left ? t) s (right ? t)
97       | L ⇒ tape_move_left ? (left ? t) s (right ? t)
98       | N ⇒ midtape ? (left ? t) s (right ? t)
99       ] ].
100 (*
101   (None,[]) → □
102   (None,a::[]) → □
103   (None,a::b::rs) → None::b::rs
104   (Some a,[]) → [Some a]
105   (Some a,b::rs) → Some a::rs
106   *)
107 (*
108 definition option_cons ≝ λA.λa:option A.λl.
109   match a with
110   [ None ⇒ match l with
111     [ nil ⇒ []
112     | cons _ _ ⇒ a::l ]
113   | Some _ ⇒ a::l ].
114   
115 (* definition tape_update := λsig.λt: tape sig.λs:option sig.
116   let newright ≝ 
117     match right ? t with
118     [ nil ⇒ match s with
119       [ None ⇒ [] 
120       | Some a ⇒ [Some ? a] ]
121     | cons b rs ⇒ match s with
122       [ None ⇒ match rs with
123         [ nil ⇒ [] 
124         | cons _ _ ⇒ None ?::rs ]
125       | Some a ⇒ Some ? a::rs ] ]
126   in mk_tape ? (left ? t) newright. *)
127   
128 definition tape_move ≝ λsig.λt:tape sig.λm:option sig × move.
129   let 〈s,m1〉 ≝ m in match m1 with
130     [ R ⇒ mk_tape sig (option_cons ? s (left ? t)) (tail ? (right ? t))
131     | L ⇒ mk_tape sig (tail ? (left ? t)) 
132            (option_cons ? (option_hd ? (left ? t))
133              (option_cons ? s (tail ? (right ? t))))
134     | N ⇒ mk_tape sig (left ? t) (option_cons ? s (tail ? (right ? t)))
135     ].
136 *)
137   
138 definition step ≝ λsig.λM:TM sig.λc:config sig (states sig M).
139   let current_char ≝ current ? (ctape ?? c) in
140   let 〈news,mv〉 ≝ trans sig M 〈cstate ?? c,current_char〉 in
141   mk_config ?? news (tape_move sig (ctape ?? c) mv).
142   
143 let rec loop (A:Type[0]) n (f:A→A) p a on n ≝
144   match n with 
145   [ O ⇒ None ?
146   | S m ⇒ if p a then (Some ? a) else loop A m f p (f a)
147   ].
148   
149 lemma loop_incr : ∀A,f,p,k1,k2,a1,a2. 
150   loop A k1 f p a1 = Some ? a2 → 
151     loop A (k2+k1) f p a1 = Some ? a2.
152 #A #f #p #k1 #k2 #a1 #a2 generalize in match a1; elim k1
153 [normalize #a0 #Hfalse destruct
154 |#k1' #IH #a0 <plus_n_Sm whd in ⊢ (??%? → ??%?);
155  cases (true_or_false (p a0)) #Hpa0 >Hpa0 whd in ⊢ (??%? → ??%?); // @IH
156 ]
157 qed.
158
159 lemma loop_merge : ∀A,f,p,q.(∀b. p b = false → q b = false) →
160  ∀k1,k2,a1,a2,a3,a4.
161    loop A k1 f p a1 = Some ? a2 → 
162      f a2 = a3 → q a2 = false → 
163        loop A k2 f q a3 = Some ? a4 →
164          loop A (k1+k2) f q a1 = Some ? a4.
165 #Sig #f #p #q #Hpq #k1 elim k1 
166   [normalize #k2 #a1 #a2 #a3 #a4 #H destruct
167   |#k1' #Hind #k2 #a1 #a2 #a3 #a4 normalize in ⊢ (%→?);
168    cases (true_or_false (p a1)) #pa1 >pa1 normalize in ⊢ (%→?);
169    [#eqa1a2 destruct #eqa2a3 #Hqa2 #H
170     whd in ⊢ (??(??%???)?); >plus_n_Sm @loop_incr
171     whd in ⊢ (??%?); >Hqa2 >eqa2a3 @H
172    |normalize >(Hpq … pa1) normalize 
173     #H1 #H2 #H3 @(Hind … H2) //
174    ]
175  ]
176 qed.
177
178 lemma loop_split : ∀A,f,p,q.(∀b. q b = true → p b = true) →
179  ∀k,a1,a2.
180    loop A k f q a1 = Some ? a2 → 
181    ∃k1,a3.
182     loop A k1 f p a1 = Some ? a3 ∧ 
183       loop A (S(k-k1)) f q a3 = Some ? a2.
184 #A #f #p #q #Hpq #k elim k
185   [#a1 #a2 normalize #Heq destruct
186   |#i #Hind #a1 #a2 normalize 
187    cases (true_or_false (q a1)) #Hqa1 >Hqa1 normalize
188     [ #Ha1a2 destruct
189      @(ex_intro … 1) @(ex_intro … a2) % 
190        [normalize >(Hpq …Hqa1) // |>Hqa1 //]
191     |#Hloop cases (true_or_false (p a1)) #Hpa1 
192        [@(ex_intro … 1) @(ex_intro … a1) % 
193          [normalize >Hpa1 // |>Hqa1 <Hloop normalize //]
194        |cases (Hind …Hloop) #k2 * #a3 * #Hloop1 #Hloop2
195         @(ex_intro … (S k2)) @(ex_intro … a3) %
196          [normalize >Hpa1 normalize // | @Hloop2 ]
197        ]
198     ]
199   ]
200 qed.
201
202 (*
203 lemma loop_split : ∀A,f,p,q.(∀b. p b = false → q b = false) →
204  ∀k1,k2,a1,a2,a3.
205    loop A k1 f p a1 = Some ? a2 → 
206      loop A k2 f q a2 = Some ? a3 →
207        loop A (k1+k2) f q a1 = Some ? a3.
208 #Sig #f #p #q #Hpq #k1 elim k1 
209   [normalize #k2 #a1 #a2 #a3 #H destruct
210   |#k1' #Hind #k2 #a1 #a2 #a3 normalize in ⊢ (%→?→?);
211    cases (true_or_false (p a1)) #pa1 >pa1 normalize in ⊢ (%→?);
212    [#eqa1a2 destruct #H @loop_incr //
213    |normalize >(Hpq … pa1) normalize 
214     #H1 #H2 @(Hind … H2) //
215    ]
216  ]
217 qed.
218 *)
219
220 definition initc ≝ λsig.λM:TM sig.λt.
221   mk_config sig (states sig M) (start sig M) t.
222
223 definition Realize ≝ λsig.λM:TM sig.λR:relation (tape sig).
224 ∀t.∃i.∃outc.
225   loop ? i (step sig M) (λc.halt sig M (cstate ?? c)) (initc sig M t) = Some ? outc ∧
226   R t (ctape ?? outc).
227
228 definition WRealize ≝ λsig.λM:TM sig.λR:relation (tape sig).
229 ∀t,i,outc.
230   loop ? i (step sig M) (λc.halt sig M (cstate ?? c)) (initc sig M t) = Some ? outc → 
231   R t (ctape ?? outc).
232   
233 lemma loop_eq : ∀sig,f,q,i,j,a,x,y. 
234   loop sig i f q a = Some ? x → loop sig j f q a = Some ? y → x = y.
235 #sig #f #q #i #j @(nat_elim2 … i j)
236 [ #n #a #x #y normalize #Hfalse destruct (Hfalse)
237 | #n #a #x #y #H1 normalize #Hfalse destruct (Hfalse)
238 | #n1 #n2 #IH #a #x #y normalize cases (q a) normalize
239   [ #H1 #H2 destruct %
240   | /2/ ]
241 ]
242 qed.
243
244 theorem Realize_to_WRealize : ∀sig,M,R.Realize sig M R → WRealize sig M R.
245 #sig #M #R #H1 #inc #i #outc #Hloop
246 cases (H1 inc) #k * #outc1 * #Hloop1 #HR
247 >(loop_eq … Hloop Hloop1) //
248 qed.
249
250 definition accRealize ≝ λsig.λM:TM sig.λacc:states sig M.λRtrue,Rfalse:relation (tape sig).
251 ∀t.∃i.∃outc.
252   loop ? i (step sig M) (λc.halt sig M (cstate ?? c)) (initc sig M t) = Some ? outc ∧
253   (cstate ?? outc = acc → Rtrue t (ctape ?? outc)) ∧ 
254   (cstate ?? outc ≠ acc → Rfalse t (ctape ?? outc)).
255
256 (* Compositions *)
257
258 definition seq_trans ≝ λsig. λM1,M2 : TM sig. 
259 λp. let 〈s,a〉 ≝ p in
260   match s with 
261   [ inl s1 ⇒ 
262       if halt sig M1 s1 then 〈inr … (start sig M2), None ?〉
263       else 
264       let 〈news1,m〉 ≝ trans sig M1 〈s1,a〉 in
265       〈inl … news1,m〉
266   | inr s2 ⇒ 
267       let 〈news2,m〉 ≝ trans sig M2 〈s2,a〉 in
268       〈inr … news2,m〉
269   ].
270  
271 definition seq ≝ λsig. λM1,M2 : TM sig. 
272   mk_TM sig 
273     (FinSum (states sig M1) (states sig M2))
274     (seq_trans sig M1 M2) 
275     (inl … (start sig M1))
276     (λs.match s with
277       [ inl _ ⇒ false | inr s2 ⇒ halt sig M2 s2]). 
278
279 definition Rcomp ≝ λA.λR1,R2:relation A.λa1,a2.
280   ∃am.R1 a1 am ∧ R2 am a2.
281
282 (*
283 definition injectRl ≝ λsig.λM1.λM2.λR.
284    λc1,c2. ∃c11,c12. 
285      inl … (cstate sig M1 c11) = cstate sig (seq sig M1 M2) c1 ∧ 
286      inl … (cstate sig M1 c12) = cstate sig (seq sig M1 M2) c2 ∧
287      ctape sig M1 c11 = ctape sig (seq sig M1 M2) c1 ∧ 
288      ctape sig M1 c12 = ctape sig (seq sig M1 M2) c2 ∧ 
289      R c11 c12.
290
291 definition injectRr ≝ λsig.λM1.λM2.λR.
292    λc1,c2. ∃c21,c22. 
293      inr … (cstate sig M2 c21) = cstate sig (seq sig M1 M2) c1 ∧ 
294      inr … (cstate sig M2 c22) = cstate sig (seq sig M1 M2) c2 ∧
295      ctape sig M2 c21 = ctape sig (seq sig M1 M2) c1 ∧ 
296      ctape sig M2 c22 = ctape sig (seq sig M1 M2) c2 ∧ 
297      R c21 c22.
298      
299 definition Rlink ≝ λsig.λM1,M2.λc1,c2.
300   ctape sig (seq sig M1 M2) c1 = ctape sig (seq sig M1 M2) c2 ∧
301   cstate sig (seq sig M1 M2) c1 = inl … (halt sig M1) ∧
302   cstate sig (seq sig M1 M2) c2 = inr … (start sig M2). *)
303   
304 interpretation "relation composition" 'compose R1 R2 = (Rcomp ? R1 R2).
305
306 definition lift_confL ≝ 
307   λsig,S1,S2,c.match c with 
308   [ mk_config s t ⇒ mk_config sig (FinSum S1 S2) (inl … s) t ].
309   
310 definition lift_confR ≝ 
311   λsig,S1,S2,c.match c with
312   [ mk_config s t ⇒ mk_config sig (FinSum S1 S2) (inr … s) t ].
313   
314 definition halt_liftL ≝ 
315   λS1,S2,halt.λs:FinSum S1 S2.
316   match s with
317   [ inl s1 ⇒ halt s1
318   | inr _ ⇒ true ]. (* should be vacuous in all cases we use halt_liftL *)
319
320 definition halt_liftR ≝ 
321   λS1,S2,halt.λs:FinSum S1 S2.
322   match s with
323   [ inl _ ⇒ false 
324   | inr s2 ⇒ halt s2 ].
325       
326 lemma p_halt_liftL : ∀sig,S1,S2,halt,c.
327   halt (cstate sig S1 c) =
328      halt_liftL S1 S2 halt (cstate … (lift_confL … c)).
329 #sig #S1 #S2 #halt #c cases c #s #t %
330 qed.
331
332 lemma trans_liftL : ∀sig,M1,M2,s,a,news,move.
333   halt ? M1 s = false → 
334   trans sig M1 〈s,a〉 = 〈news,move〉 → 
335   trans sig (seq sig M1 M2) 〈inl … s,a〉 = 〈inl … news,move〉.
336 #sig (*#M1*) * #Q1 #T1 #init1 #halt1 #M2 #s #a #news #move
337 #Hhalt #Htrans whd in ⊢ (??%?); >Hhalt >Htrans %
338 qed.
339
340 lemma trans_liftR : ∀sig,M1,M2,s,a,news,move.
341   halt ? M2 s = false → 
342   trans sig M2 〈s,a〉 = 〈news,move〉 → 
343   trans sig (seq sig M1 M2) 〈inr … s,a〉 = 〈inr … news,move〉.
344 #sig #M1 * #Q2 #T2 #init2 #halt2 #s #a #news #move
345 #Hhalt #Htrans whd in ⊢ (??%?); >Hhalt >Htrans %
346 qed.
347
348 lemma config_eq : 
349   ∀sig,M,c1,c2.
350   cstate sig M c1 = cstate sig M c2 → 
351   ctape sig M c1 = ctape sig M c2 →  c1 = c2.
352 #sig #M1 * #s1 #t1 * #s2 #t2 //
353 qed.
354
355 lemma step_lift_confR : ∀sig,M1,M2,c0.
356  halt ? M2 (cstate ?? c0) = false → 
357  step sig (seq sig M1 M2) (lift_confR sig (states ? M1) (states ? M2) c0) =
358  lift_confR sig (states ? M1) (states ? M2) (step sig M2 c0).
359 #sig #M1 (* * #Q1 #T1 #init1 #halt1 *) #M2 * #s #t
360   lapply (refl ? (trans ?? 〈s,current sig t〉))
361   cases (trans ?? 〈s,current sig t〉) in ⊢ (???% → %);
362   #s0 #m0 cases t
363   [ #Heq #Hhalt
364   | 2,3: #s1 #l1 #Heq #Hhalt 
365   |#ls #s1 #rs #Heq #Hhalt ]
366   whd in ⊢ (???(????%)); >Heq
367   whd in ⊢ (???%);
368   whd in ⊢ (??(???%)?); whd in ⊢ (??%?);
369   >(trans_liftR … Heq) //
370 qed.
371
372 lemma step_lift_confL : ∀sig,M1,M2,c0.
373  halt ? M1 (cstate ?? c0) = false → 
374  step sig (seq sig M1 M2) (lift_confL sig (states ? M1) (states ? M2) c0) =
375  lift_confL sig ?? (step sig M1 c0).
376 #sig #M1 (* * #Q1 #T1 #init1 #halt1 *) #M2 * #s #t
377   lapply (refl ? (trans ?? 〈s,current sig t〉))
378   cases (trans ?? 〈s,current sig t〉) in ⊢ (???% → %);
379   #s0 #m0 cases t
380   [ #Heq #Hhalt
381   | 2,3: #s1 #l1 #Heq #Hhalt 
382   |#ls #s1 #rs #Heq #Hhalt ]
383   whd in ⊢ (???(????%)); >Heq
384   whd in ⊢ (???%);
385   whd in ⊢ (??(???%)?); whd in ⊢ (??%?);
386   >(trans_liftL … Heq) //
387 qed.
388
389 lemma loop_lift : ∀A,B,k,lift,f,g,h,hlift,c1,c2.
390   (∀x.hlift (lift x) = h x) → 
391   (∀x.h x = false → lift (f x) = g (lift x)) → 
392   loop A k f h c1 = Some ? c2 → 
393   loop B k g hlift (lift c1) = Some ? (lift … c2).
394 #A #B #k #lift #f #g #h #hlift #c1 #c2 #Hfg #Hhlift
395 generalize in match c1; elim k
396 [#c0 normalize in ⊢ (??%? → ?); #Hfalse destruct (Hfalse)
397 |#k0 #IH #c0 whd in ⊢ (??%? → ??%?);
398  cases (true_or_false (h c0)) #Hc0 >Hfg >Hc0
399  [ normalize #Heq destruct (Heq) %
400  | normalize <Hhlift // @IH ]
401 qed.
402
403 (* 
404 lemma loop_liftL : ∀sig,k,M1,M2,c1,c2.
405   loop ? k (step sig M1) (λc.halt sig M1 (cstate ?? c)) c1 = Some ? c2 →
406     loop ? k (step sig (seq sig M1 M2)) 
407       (λc.halt_liftL ?? (halt sig M1) (cstate ?? c)) (lift_confL … c1) = 
408     Some ? (lift_confL … c2).
409 #sig #k #M1 #M2 #c1 #c2 generalize in match c1;
410 elim k
411 [#c0 normalize in ⊢ (??%? → ?); #Hfalse destruct (Hfalse)
412 |#k0 #IH #c0 whd in ⊢ (??%? → ??%?);
413  cases (true_or_false (halt ?? (cstate sig (states ? M1) c0))) #Hc0 >Hc0
414  [ >(?: halt_liftL ?? (halt sig M1) (cstate sig ? (lift_confL … c0)) = true)
415    [ whd in ⊢ (??%? → ??%?); #Hc2 destruct (Hc2) %
416    | <Hc0 cases c0 // ]
417  | >(?: halt_liftL ?? (halt sig M1) (cstate ?? (lift_confL … c0)) = false)
418    [whd in ⊢ (??%? → ??%?); #Hc2 <(IH ? Hc2) @eq_f
419     @step_lift_confL //
420    | <Hc0 cases c0 // ]
421 qed.
422
423 lemma loop_liftR : ∀sig,k,M1,M2,c1,c2.
424   loop ? k (step sig M2) (λc.halt sig M2 (cstate ?? c)) c1 = Some ? c2 →
425     loop ? k (step sig (seq sig M1 M2)) 
426       (λc.halt sig (seq sig M1 M2) (cstate ?? c)) (lift_confR … c1) = 
427     Some ? (lift_confR … c2).
428 #sig #k #M1 #M2 #c1 #c2 generalize in match c1;
429 elim k
430 [#c0 normalize in ⊢ (??%? → ?); #Hfalse destruct (Hfalse)
431 |#k0 #IH #c0 whd in ⊢ (??%? → ??%?);
432  cases (true_or_false (halt ?? (cstate sig ? c0))) #Hc0 >Hc0
433  [ >(?: halt ? (seq sig M1 M2) (cstate sig ? (lift_confR … c0)) = true)
434    [ whd in ⊢ (??%? → ??%?); #Hc2 destruct (Hc2) %
435    | <Hc0 cases c0 // ]
436  | >(?: halt ? (seq sig M1 M2) (cstate sig ? (lift_confR … c0)) = false)
437    [whd in ⊢ (??%? → ??%?); #Hc2 <(IH ? Hc2) @eq_f
438     @step_lift_confR //
439    | <Hc0 cases c0 // ]
440  ]
441 qed.  
442
443 *)
444     
445 lemma loop_Some : 
446   ∀A,k,f,p,a,b.loop A k f p a = Some ? b → p b = true.
447 #A #k #f #p elim k 
448 [#a #b normalize #Hfalse destruct
449 |#k0 #IH #a #b whd in ⊢ (??%? → ?); cases (true_or_false (p a)) #Hpa
450  [ >Hpa normalize #H1 destruct //
451  | >Hpa normalize @IH
452  ]
453 ]
454 qed. 
455
456 lemma trans_liftL_true : ∀sig,M1,M2,s,a.
457   halt ? M1 s = true → 
458   trans sig (seq sig M1 M2) 〈inl … s,a〉 = 〈inr … (start ? M2),None ?〉.
459 #sig #M1 #M2 #s #a
460 #Hhalt whd in ⊢ (??%?); >Hhalt %
461 qed.
462
463 lemma eq_ctape_lift_conf_L : ∀sig,S1,S2,outc.
464   ctape sig (FinSum S1 S2) (lift_confL … outc) = ctape … outc.
465 #sig #S1 #S2 #outc cases outc #s #t %
466 qed.
467   
468 lemma eq_ctape_lift_conf_R : ∀sig,S1,S2,outc.
469   ctape sig (FinSum S1 S2) (lift_confR … outc) = ctape … outc.
470 #sig #S1 #S2 #outc cases outc #s #t %
471 qed.
472
473 theorem sem_seq: ∀sig,M1,M2,R1,R2.
474   Realize sig M1 R1 → Realize sig M2 R2 → 
475     Realize sig (seq sig M1 M2) (R1 ∘ R2).
476 #sig #M1 #M2 #R1 #R2 #HR1 #HR2 #t 
477 cases (HR1 t) #k1 * #outc1 * #Hloop1 #HM1
478 cases (HR2 (ctape sig (states ? M1) outc1)) #k2 * #outc2 * #Hloop2 #HM2
479 @(ex_intro … (k1+k2)) @(ex_intro … (lift_confR … outc2))
480 %
481 [@(loop_merge ??????????? 
482    (loop_lift ??? (lift_confL sig (states sig M1) (states sig M2))
483    (step sig M1) (step sig (seq sig M1 M2)) 
484    (λc.halt sig M1 (cstate … c)) 
485    (λc.halt_liftL ?? (halt sig M1) (cstate … c)) … Hloop1))
486   [ * *
487    [ #sl #tl whd in ⊢ (??%? → ?); #Hl %
488    | #sr #tr whd in ⊢ (??%? → ?); #Hr destruct (Hr) ]
489   || #c0 #Hhalt <step_lift_confL //
490   | #x <p_halt_liftL %
491   |6:cases outc1 #s1 #t1 %
492   |7:@(loop_lift … (initc ?? (ctape … outc1)) … Hloop2) 
493     [ * #s2 #t2 %
494     | #c0 #Hhalt <step_lift_confR // ]
495   |whd in ⊢ (??(???%)?);whd in ⊢ (??%?);
496    generalize in match Hloop1; cases outc1 #sc1 #tc1 #Hloop10 
497    >(trans_liftL_true sig M1 M2 ??) 
498     [ whd in ⊢ (??%?); whd in ⊢ (???%);
499       @config_eq whd in ⊢ (???%); //
500     | @(loop_Some ?????? Hloop10) ]
501  ]
502 | @(ex_intro … (ctape ? (FinSum (states ? M1) (states ? M2)) (lift_confL … outc1)))
503   % // >eq_ctape_lift_conf_L >eq_ctape_lift_conf_R //
504 ]
505 qed.
506