]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/turing/multi_universal/moves_2.ma
converting certain basic machines to composed machines
[helm.git] / matita / matita / lib / turing / multi_universal / moves_2.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 "turing/turing.ma".
13 include "turing/inject.ma".
14 include "turing/while_multi.ma".
15 include "turing/while_machine.ma".
16 include "turing/simple_machines.ma".
17 include "turing/if_machine.ma".
18
19 definition parmove_states ≝ initN 3.
20
21 definition parmove0 : parmove_states ≝ mk_Sig ?? 0 (leb_true_to_le 1 3 (refl …)).
22 definition parmove1 : parmove_states ≝ mk_Sig ?? 1 (leb_true_to_le 2 3 (refl …)).
23 definition parmove2 : parmove_states ≝ mk_Sig ?? 2 (leb_true_to_le 3 3 (refl …)).
24
25 (*
26
27 src: a b c ... z ---→ a b c ... z 
28      ^                            ^
29
30 dst: _ _ _ ... _ ---→ a b c ... z 
31      ^                            ^
32
33 0) (x,_) → (x,_)(R,R) → 1
34    (None,_) → None 2
35 1) (_,_) → None 1
36 2) (_,_) → None 2
37
38 *)
39
40 definition trans_parmove_step ≝ 
41  λsrc,dst,sig,n,D.
42  λp:parmove_states × (Vector (option sig) (S n)).
43  let 〈q,a〉 ≝ p in
44  match pi1 … q with
45  [ O ⇒ match nth src ? a (None ?) with
46    [ None ⇒ 〈parmove2,null_action sig n〉
47    | Some a0 ⇒ match nth dst ? a (None ?) with
48      [ None ⇒ 〈parmove2,null_action ? n〉
49      | Some a1 ⇒ 〈parmove1,change_vec ? (S n)
50                           (change_vec ?(S n)
51                            (null_action ? n) (〈None ?,D〉) src)
52                           (〈None ?,D〉) dst〉 ] ]
53  | S q ⇒ match q with 
54    [ O ⇒ (* 1 *) 〈parmove1,null_action ? n〉
55    | S _ ⇒ (* 2 *) 〈parmove2,null_action ? n〉 ] ].
56
57 definition parmove_step ≝ 
58   λsrc,dst,sig,n,D.
59   mk_mTM sig n parmove_states (trans_parmove_step src dst sig n D) 
60     parmove0 (λq.q == parmove1 ∨ q == parmove2).
61
62 definition R_parmove_step_true ≝ 
63   λsrc,dst,sig,n,D.λint,outt: Vector (tape sig) (S n).
64   ∃x1,x2.
65    current ? (nth src ? int (niltape ?)) = Some ? x1 ∧
66    current ? (nth dst ? int (niltape ?)) = Some ? x2 ∧
67    outt = change_vec ?? 
68             (change_vec ?? int
69               (tape_move ? (nth src ? int (niltape ?)) D) src)
70             (tape_move ? (nth dst ? int (niltape ?)) D) dst.
71
72 definition R_parmove_step_false ≝ 
73   λsrc,dst:nat.λsig,n.λint,outt: Vector (tape sig) (S n).
74   (current ? (nth src ? int (niltape ?)) = None ?  ∨
75    current ? (nth dst ? int (niltape ?)) = None ?) ∧
76    outt = int.
77
78 lemma parmove_q0_q2_null_src :
79   ∀src,dst,sig,n,D,v.src < S n → dst < S n → 
80   nth src ? (current_chars ?? v) (None ?) = None ? → 
81   step sig n (parmove_step src dst sig n D)
82     (mk_mconfig ??? parmove0 v) =
83     mk_mconfig ??? parmove2 v.
84 #src #dst #sig #n #D #v #Hsrc #Hdst #Hcurrent
85 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?);
86 @eq_f2
87 [ whd in ⊢ (??(???%)?); >Hcurrent %
88 | whd in ⊢ (??(????(???%))?); >Hcurrent @tape_move_null_action ]
89 qed.
90
91 lemma parmove_q0_q2_null_dst :
92   ∀src,dst,sig,n,D,v,s.src < S n → dst < S n → 
93   nth src ? (current_chars ?? v) (None ?) = Some ? s → 
94   nth dst ? (current_chars ?? v) (None ?) = None ? → 
95   step sig n (parmove_step src dst sig n D)
96     (mk_mconfig ??? parmove0 v) =
97     mk_mconfig ??? parmove2 v.
98 #src #dst #sig #n #D #v #s #Hsrc #Hdst #Hcursrc #Hcurdst
99 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?);
100 @eq_f2
101 [ whd in ⊢ (??(???%)?); >Hcursrc whd in ⊢ (??(???%)?); >Hcurdst %
102 | whd in ⊢ (??(????(???%))?); >Hcursrc
103   whd in ⊢ (??(????(???%))?); >Hcurdst @tape_move_null_action ]
104 qed.
105
106 lemma parmove_q0_q1 :
107   ∀src,dst,sig,n,D,v.src ≠ dst → src < S n → dst < S n → 
108   ∀a1,a2.
109   nth src ? (current_chars ?? v) (None ?) = Some ? a1 →
110   nth dst ? (current_chars ?? v) (None ?) = Some ? a2 → 
111   step sig n (parmove_step src dst sig n D)
112     (mk_mconfig ??? parmove0 v) =
113     mk_mconfig ??? parmove1 
114      (change_vec ? (S n) 
115        (change_vec ?? v
116          (tape_move ? (nth src ? v (niltape ?)) D) src)
117        (tape_move ? (nth dst ? v (niltape ?)) D) dst).
118 #src #dst #sig #n #D #v #Hneq #Hsrc #Hdst
119 #a1 #a2 #Hcursrc #Hcurdst
120 whd in ⊢ (??%?); >(eq_pair_fst_snd … (trans ????)) whd in ⊢ (??%?); @eq_f2
121 [ whd in match (trans ????);
122   >Hcursrc >Hcurdst %
123 | whd in match (trans ????);
124   >Hcursrc >Hcurdst whd in ⊢ (??(????(???%))?); 
125   >tape_move_multi_def <(change_vec_same ?? v dst (niltape ?)) in ⊢ (??%?);
126   >pmap_change <(change_vec_same ?? v src (niltape ?)) in ⊢(??%?);
127   >pmap_change <tape_move_multi_def >tape_move_null_action
128   @eq_f2 // >nth_change_vec_neq //
129 ]
130 qed.
131
132 lemma sem_parmove_step :
133   ∀src,dst,sig,n,D.src ≠ dst → src < S n → dst < S n → 
134   parmove_step src dst sig n D ⊨ 
135     [ parmove1: R_parmove_step_true src dst sig n D, 
136              R_parmove_step_false src dst sig n ].
137 #src #dst #sig #n #D #Hneq #Hsrc #Hdst #int
138 lapply (refl ? (current ? (nth src ? int (niltape ?))))
139 cases (current ? (nth src ? int (niltape ?))) in ⊢ (???%→?);
140 [ #Hcursrc %{2} %
141   [| % [ %
142     [ whd in ⊢ (??%?); >parmove_q0_q2_null_src /2/
143     | normalize in ⊢ (%→?); #H destruct (H) ]
144     | #_ % // % // ] ]
145 | #a #Ha lapply (refl ? (current ? (nth dst ? int (niltape ?))))
146   cases (current ? (nth dst ? int (niltape ?))) in ⊢ (???%→?);
147   [ #Hcurdst %{2} %
148     [| % [ %
149       [ whd in ⊢ (??%?); >(parmove_q0_q2_null_dst …) /2/ 
150       | normalize in ⊢ (%→?); #H destruct (H) ]
151       | #_ % // %2 // ] ]
152   | #b #Hb %{2} %
153     [| % [ % 
154       [whd in ⊢  (??%?); >(parmove_q0_q1 … Hneq Hsrc Hdst ? b ??)
155         [2: <(nth_vec_map ?? (current …) dst ? int (niltape ?)) //
156         |3: <(nth_vec_map ?? (current …) src ? int (niltape ?)) //
157         | // ]
158       | #_ %{a} %{b} % // % // ]
159       | * #H @False_ind @H % ]
160 ]]]
161 qed.
162
163 definition parmove ≝ λsrc,dst,sig,n,D.
164   whileTM … (parmove_step src dst sig n D) parmove1.
165
166 definition R_parmoveL ≝ 
167   λsrc,dst,sig,n.λint,outt: Vector (tape sig) (S n).
168   (∀x,xs,rs.
169     nth src ? int (niltape ?) = midtape sig xs x rs → 
170     ∀ls0,x0,target,rs0.|xs| = |target| → 
171     nth dst ? int (niltape ?) = midtape sig (target@ls0) x0 rs0 → 
172     outt = change_vec ?? 
173            (change_vec ?? int (mk_tape sig [] (None ?) (reverse ? xs@x::rs)) src)
174            (mk_tape sig (tail ? ls0) (option_hd ? ls0) (reverse ? target@x0::rs0)) dst) ∧
175   (∀x,xs,rs.
176     nth dst ? int (niltape ?) = midtape sig xs x rs → 
177     ∀ls0,x0,target,rs0.|xs| = |target| → 
178     nth src ? int (niltape ?) = midtape sig (target@ls0) x0 rs0 → 
179     outt = change_vec ?? 
180            (change_vec ?? int (mk_tape sig [] (None ?) (reverse ? xs@x::rs)) dst)
181            (mk_tape sig (tail ? ls0) (option_hd ? ls0) (reverse ? target@x0::rs0)) src) ∧
182   ((current ? (nth src ? int (niltape ?)) = None ? ∨
183     current ? (nth dst ? int (niltape ?)) = None ?) →
184     outt = int).
185   
186 lemma wsem_parmoveL : ∀src,dst,sig,n.src ≠ dst → src < S n → dst < S n → 
187   parmove src dst sig n L ⊫ R_parmoveL src dst sig n.
188 #src #dst #sig #n #Hneq #Hsrc #Hdst #ta #k #outc #Hloop
189 lapply (sem_while … (sem_parmove_step src dst sig n L Hneq Hsrc Hdst) … Hloop) //
190 -Hloop * #tb * #Hstar @(star_ind_l ??????? Hstar) -Hstar
191 [ whd in ⊢ (%→?); * #H #Houtc % [2: #_ @Houtc ] cases H #Hcurtb
192   [ % 
193     [ #x #xs #rs #Hsrctb >Hsrctb in Hcurtb; normalize in ⊢ (%→?);
194       #Hfalse destruct (Hfalse)
195     | #x #xs #rs #Hdsttb #ls0 #x0 #target #rs0 #Hlen #Hsrctb >Hsrctb in Hcurtb;
196       normalize in ⊢ (%→?); #H destruct (H)
197     ]
198   | %
199     [ #x #xs #rs #Hsrctb #ls0 #x0 #target 
200       #rs0 #Hlen #Hdsttb >Hdsttb in Hcurtb; normalize in ⊢ (%→?); #H destruct (H)
201     | #x #xs #rs #Hdsttb >Hdsttb in Hcurtb; normalize in ⊢ (%→?);
202       #Hfalse destruct (Hfalse)
203     ]
204   ]  
205 | #td #te * #c0 * #c1 * * #Hc0 #Hc1 #Hd #Hstar #IH #He 
206   lapply (IH He) -IH * * #IH1a #IH1b #IH2 % [ %
207   [ #x #xs #rs #Hsrc_td #ls0 #x0 #target
208     #rs0 #Hlen #Hdst_td
209     >Hsrc_td in Hc0; normalize in ⊢ (%→?); #Hc0 destruct (Hc0)
210     >Hdst_td in Hd; >Hsrc_td @(list_cases2 … Hlen)
211     [ #Hxsnil #Htargetnil >Hxsnil >Htargetnil #Hd >IH2 
212       [2: %1 >Hd >nth_change_vec_neq [|@(sym_not_eq … Hneq)]
213       >nth_change_vec //]  
214       >Hd -Hd @(eq_vec … (niltape ?))
215       #i #Hi cases (decidable_eq_nat i src) #Hisrc
216       [ >Hisrc >(nth_change_vec_neq … src dst) [|@(sym_not_eq … Hneq)]
217         >nth_change_vec //
218         >(nth_change_vec_neq … src dst) [|@(sym_not_eq … Hneq)]
219         >nth_change_vec //
220       | cases (decidable_eq_nat i dst) #Hidst
221         [ >Hidst >nth_change_vec // >nth_change_vec //
222           >Hdst_td in Hc1; >Htargetnil
223           normalize in ⊢ (%→?); #Hc1 destruct (Hc1) cases ls0 //
224         | >nth_change_vec_neq [|@(sym_not_eq … Hidst)]
225           >nth_change_vec_neq [|@(sym_not_eq … Hisrc)]
226           >nth_change_vec_neq [|@(sym_not_eq … Hidst)]
227           >nth_change_vec_neq [|@(sym_not_eq … Hisrc)] % 
228         ]
229       ]
230     | #hd1 #hd2 #tl1 #tl2 #Hxs #Htarget >Hxs >Htarget #Hd
231       >(IH1a hd1 tl1 (c0::rs) ? ls0 hd2 tl2 (x0::rs0))
232       [ >Hd >(change_vec_commute … ?? td ?? src dst) //
233         >change_vec_change_vec
234         >(change_vec_commute … ?? td ?? dst src) [|@sym_not_eq //]
235         >change_vec_change_vec
236         >reverse_cons >associative_append
237         >reverse_cons >associative_append % 
238       | >Hd >nth_change_vec //
239       | >Hxs in Hlen; >Htarget normalize #Hlen destruct (Hlen) //
240       | >Hd >nth_change_vec_neq [|@sym_not_eq //]
241         >nth_change_vec // ]
242     ]
243   | #x #xs #rs #Hdst_td #ls0 #x0 #target
244     #rs0 #Hlen #Hsrc_td
245     >Hdst_td in Hc0; normalize in ⊢ (%→?); #Hc0 destruct (Hc0)
246     >Hsrc_td in Hd; >Hdst_td @(list_cases2 … Hlen)
247     [ #Hxsnil #Htargetnil >Hxsnil >Htargetnil #Hd >IH2 
248       [2: %2 >Hd >nth_change_vec //]
249       >Hd -Hd @(eq_vec … (niltape ?))
250       #i #Hi cases (decidable_eq_nat i dst) #Hidst
251       [ >Hidst >(nth_change_vec_neq … dst src) //
252         >nth_change_vec // >nth_change_vec //
253       | cases (decidable_eq_nat i src) #Hisrc
254         [ >Hisrc >nth_change_vec // >(nth_change_vec_neq …) [|@sym_not_eq //]
255           >Hsrc_td in Hc1; >Htargetnil
256           normalize in ⊢ (%→?); #Hc1 destruct (Hc1) >nth_change_vec //
257           cases ls0 //
258         | >nth_change_vec_neq [|@(sym_not_eq … Hidst)]
259           >nth_change_vec_neq [|@(sym_not_eq … Hisrc)]
260           >nth_change_vec_neq [|@(sym_not_eq … Hisrc)]
261           >nth_change_vec_neq [|@(sym_not_eq … Hidst)] % 
262         ]
263       ]
264     | #hd1 #hd2 #tl1 #tl2 #Hxs #Htarget >Hxs >Htarget #Hd
265       >(IH1b hd1 tl1 (x::rs) ? ls0 hd2 tl2 (x0::rs0))
266       [ >Hd >(change_vec_commute … ?? td ?? dst src) [|@sym_not_eq //]
267         >change_vec_change_vec
268         >(change_vec_commute … ?? td ?? src dst) //
269         >change_vec_change_vec
270         >reverse_cons >associative_append
271         >reverse_cons >associative_append
272         >change_vec_commute [|@sym_not_eq //] %
273       | >Hd >nth_change_vec_neq [|@sym_not_eq //] >nth_change_vec //
274       | >Hxs in Hlen; >Htarget normalize #Hlen destruct (Hlen) //
275       | >Hd >nth_change_vec // ]
276     ]
277   ]
278 | >Hc0 >Hc1 * [ #Hc0 destruct (Hc0) | #Hc1 destruct (Hc1) ]
279 ] ]
280 qed.
281  
282 lemma terminate_parmoveL :  ∀src,dst,sig,n,t.
283   src ≠ dst → src < S n → dst < S n → 
284   parmove src dst sig n L ↓ t.
285 #src #dst #sig #n #t #Hneq #Hsrc #Hdst
286 @(terminate_while … (sem_parmove_step …)) //
287 <(change_vec_same … t src (niltape ?))
288 cases (nth src (tape sig) t (niltape ?))
289 [ % #t1 * #x1 * #x2 * * >nth_change_vec // normalize in ⊢ (%→?); #Hx destruct 
290 |2,3: #a0 #al0 % #t1 * #x1 * #x2 * * >nth_change_vec // normalize in ⊢ (%→?); #Hx destruct
291 | #ls lapply t -t elim ls
292   [#t #c #rs % #t1 * #x1 * #x2 * * >nth_change_vec // normalize in ⊢ (%→?);
293    #H1 destruct (H1) #Hcurdst >change_vec_change_vec #Ht1 % 
294    #t2 * #y1 * #y2 * * >Ht1 >nth_change_vec_neq [|@sym_not_eq //]
295    >nth_change_vec // normalize in ⊢ (%→?); #H destruct (H)
296   |#l0 #ls0 #IH #t #c #rs % #t1 * #x1 * #x2 * * >nth_change_vec //
297    normalize in ⊢ (%→?); #H destruct (H) #Hcurdst
298    >change_vec_change_vec >change_vec_commute // #Ht1 >Ht1 @IH
299   ]
300 ]
301 qed.
302
303 lemma sem_parmoveL : ∀src,dst,sig,n.
304   src ≠ dst → src < S n → dst < S n → 
305   parmove src dst sig n L ⊨ R_parmoveL src dst sig n.
306 #src #dst #sig #n #Hneq #Hsrc #Hdst @WRealize_to_Realize 
307 [/2/ | @wsem_parmoveL //]
308 qed.
309
310 (* while {
311      if current != null 
312         then move_r
313         else nop
314      }
315  *)
316
317 definition mte_step ≝ λalpha,D.
318 ifTM ? (test_null alpha) (single_finalTM ? (move alpha D)) (nop ?) tc_true.
319  
320 definition R_mte_step_true ≝ λalpha,D,t1,t2.
321   ∃ls,c,rs.
322     t1 = midtape alpha ls c rs ∧ t2 = tape_move ? t1 D.
323
324 definition R_mte_step_false ≝ λalpha.λt1,t2:tape alpha.
325   current ? t1 = None ? ∧ t1 = t2.
326
327 definition mte2 : ∀alpha,D.states ? (mte_step alpha D) ≝ 
328 λalpha,D.(inr … (inl … (inr … start_nop))).
329   
330 lemma sem_mte_step :
331   ∀alpha,D.mte_step alpha D ⊨ 
332    [ mte2 … : R_mte_step_true alpha D, R_mte_step_false alpha ] .
333 #alpha #D #ta
334 @(acc_sem_if_app ??????????? (sem_test_null …) 
335   (sem_move_single …) (sem_nop alpha) ??)
336 [ #tb #tc #td * #Hcurtb
337   lapply (refl ? (current ? tb)) cases (current ? tb) in ⊢ (???%→?);
338   [ #H @False_ind >H in Hcurtb; * /2/ ]
339   -Hcurtb #c #Hcurtb #Htb whd in ⊢ (%→?); #Htc whd
340   cases (current_to_midtape … Hcurtb) #ls * #rs #Hmidtb 
341   %{ls} %{c} %{rs} % //
342 | #tb #tc #td * #Hcurtb #Htb whd in ⊢ (%→?); #Htc whd % // ]
343 qed.
344
345 definition move_to_end ≝ λsig,D.whileTM sig (mte_step sig D) (mte2 …).
346
347 definition R_move_to_end_r ≝ 
348   λsig,int,outt.
349   (current ? int = None ? → outt = int) ∧
350   ∀ls,c,rs.int = midtape sig ls c rs → outt = mk_tape ? (reverse ? rs@c::ls) (None ?) [ ].
351   
352 lemma wsem_move_to_end_r : ∀sig. move_to_end sig R ⊫ R_move_to_end_r sig.
353 #sig #ta #k #outc #Hloop
354 lapply (sem_while … (sem_mte_step sig R) … Hloop) //
355 -Hloop * #tb * #Hstar @(star_ind_l ??????? Hstar) -Hstar
356 [ * #Hcurtb #Houtc % /2/ #ls #c #rs #Htb >Htb in Hcurtb; normalize in ⊢ (%→?); #H destruct (H)
357 | #tc #td * #ls * #c * #rs * #Htc >Htc cases rs
358   [ normalize in ⊢ (%→?); #Htd >Htd #Hstar #IH whd in ⊢ (%→?); #Hfalse
359     lapply (IH Hfalse) -IH * #Htd1 #_ %
360     [ normalize in ⊢ (%→?); #H destruct (H)
361     | #ls0 #c0 #rs0 #H destruct (H) >Htd1 // ]
362   | #r0 #rs0 whd in ⊢ (???%→?); #Htd >Htd #Hstar #IH whd in ⊢ (%→?); #Hfalse
363     lapply (IH Hfalse) -IH * #_ #IH %
364     [ normalize in ⊢ (%→?); #H destruct (H)
365     | #ls1 #c1 #rs1 #H destruct (H) >reverse_cons >associative_append @IH % ] ] ]
366 qed.
367
368 lemma terminate_move_to_end_r :  ∀sig,t.move_to_end sig R ↓ t.
369 #sig #t @(terminate_while … (sem_mte_step sig R …)) //
370 cases t
371 [ % #t1 * #ls * #c * #rs * #H destruct
372 |2,3: #a0 #al0 % #t1 * #ls * #c * #rs * #H destruct
373 | #ls #c #rs lapply c -c lapply ls -ls elim rs
374   [ #ls #c % #t1 * #ls0 * #c0 * #rs0 * #Hmid #Ht1 destruct %
375     #t2 * #ls1 * #c1 * #rs1 * normalize in ⊢ (%→?); #H destruct
376   | #r0 #rs0 #IH #ls #c % #t1 * #ls1 * #c1 * #rs1 * #Hmid #Ht1 destruct @IH
377   ]
378 ]
379 qed.
380
381 lemma sem_move_to_end_r : ∀sig. move_to_end sig R ⊨ R_move_to_end_r sig.
382 #sig @WRealize_to_Realize //
383 qed.
384
385 definition R_move_to_end_l ≝ 
386   λsig,int,outt.
387   (current ? int = None ? → outt = int) ∧
388   ∀ls,c,rs.int = midtape sig ls c rs → outt = mk_tape ? [ ] (None ?) (reverse ? ls@c::rs).
389   
390 lemma wsem_move_to_end_l : ∀sig. move_to_end sig L ⊫ R_move_to_end_l sig.
391 #sig #ta #k #outc #Hloop
392 lapply (sem_while … (sem_mte_step sig L) … Hloop) //
393 -Hloop * #tb * #Hstar @(star_ind_l ??????? Hstar) -Hstar
394 [ * #Hcurtb #Houtc % /2/ #ls #c #rs #Htb >Htb in Hcurtb; normalize in ⊢ (%→?); #H destruct (H)
395 | #tc #td * #ls * #c * #rs * #Htc >Htc cases ls
396   [ normalize in ⊢ (%→?); #Htd >Htd #Hstar #IH whd in ⊢ (%→?); #Hfalse
397     lapply (IH Hfalse) -IH * #Htd1 #_ %
398     [ normalize in ⊢ (%→?); #H destruct (H)
399     | #ls0 #c0 #rs0 #H destruct (H) >Htd1 // ]
400   | #l0 #ls0 whd in ⊢ (???%→?); #Htd >Htd #Hstar #IH whd in ⊢ (%→?); #Hfalse
401     lapply (IH Hfalse) -IH * #_ #IH %
402     [ normalize in ⊢ (%→?); #H destruct (H)
403     | #ls1 #c1 #rs1 #H destruct (H) >reverse_cons >associative_append @IH % ] ] ]
404 qed.
405
406 lemma terminate_move_to_end_l :  ∀sig,t.move_to_end sig L ↓ t.
407 #sig #t @(terminate_while … (sem_mte_step sig L …)) //
408 cases t
409 [ % #t1 * #ls * #c * #rs * #H destruct
410 |2,3: #a0 #al0 % #t1 * #ls * #c * #rs * #H destruct
411 | #ls elim ls
412   [ #c #rs % #t1 * #ls0 * #c0 * #rs0 * #Hmid #Ht1 destruct %
413     #t2 * #ls1 * #c1 * #rs1 * normalize in ⊢ (%→?); #H destruct
414   | #l0 #ls0 #IH #c #rs % #t1 * #ls1 * #c1 * #rs1 * #Hmid #Ht1 destruct @IH
415   ]
416 ]
417 qed.
418
419 lemma sem_move_to_end_l : ∀sig. move_to_end sig L ⊨ R_move_to_end_l sig.
420 #sig @WRealize_to_Realize //
421 qed.