1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "turing/mono.ma".
19 - return its nth element
20 - return the index of a given element
22 axiom FS_crd : FinSet → nat.
23 axiom FS_nth : ∀F:FinSet.nat → option F.
24 axiom index_of_FS : ∀F:FinSet.F → nat.
26 (* unary bit representation (with a given length) of a certain number *)
27 axiom unary_of_nat : nat → nat → (list bool).
29 axiom FinVector : Type[0] → nat → FinSet.
31 definition binary_base_states ≝ initN 6.
33 definition bin0 : binary_base_states ≝ mk_Sig ?? 0 (leb_true_to_le 1 6 (refl …)).
34 definition bin1 : binary_base_states ≝ mk_Sig ?? 1 (leb_true_to_le 2 6 (refl …)).
35 definition bin2 : binary_base_states ≝ mk_Sig ?? 2 (leb_true_to_le 3 6 (refl …)).
36 definition bin3 : binary_base_states ≝ mk_Sig ?? 3 (leb_true_to_le 4 6 (refl …)).
37 definition bin4 : binary_base_states ≝ mk_Sig ?? 4 (leb_true_to_le 5 6 (refl …)).
38 definition bin5 : binary_base_states ≝ mk_Sig ?? 5 (leb_true_to_le 6 6 (refl …)).
40 definition states_binaryTM : FinSet → FinSet → FinSet ≝ λsig,states.
41 FinProd (FinProd states binary_base_states)
42 (FinProd (FinOption sig) (initN (S (2 * (FS_crd sig))))).
44 axiom daemon : ∀T:Type[0].T.
46 definition to_initN : ∀n,m.n < m → initN m ≝ λn,m,Hn.mk_Sig … n ….// qed.
48 definition initN_pred : ∀n.∀m:initN n.initN n ≝ λn,m.mk_Sig … (pred (pi1 … m)) ….
49 cases m #m0 /2 by le_to_lt_to_lt/ qed.
51 (* controllare i contatori, molti andranno incrementati di uno *)
52 definition trans_binaryTM : ∀sig,states:FinSet.
53 (states × (option sig) → states × (option sig) × move) →
54 ((states_binaryTM sig states) × (option bool) →
55 (states_binaryTM sig states) × (option bool) × move)
56 ≝ λsig,states,trans,p.
58 let 〈s0,phase,ch,count〉 ≝ s in
59 let (H1 : O < S (2*FS_crd sig)) ≝ ? in
60 let (H2 : FS_crd sig < S (2*FS_crd sig)) ≝ ? in
61 match pi1 … phase with
62 [ O ⇒ (*** PHASE 0: read ***)
63 match pi1 … count with
64 [ O ⇒ 〈〈s0,bin1,ch,to_initN (FS_crd sig) ? H2〉,None ?,N〉
66 [ Some a0 ⇒ if (a0 == true)
67 then 〈〈s0,bin0,FS_nth sig k,initN_pred … count〉, None ?,R〉
68 else 〈〈s0,bin0,ch,initN_pred … count〉,None ?,R〉
69 | None ⇒ (* Overflow position! *)
70 〈〈s0,bin4,None ?,to_initN 0 ? H1〉,None ?,R〉 ] ]
71 | S phase ⇒ match phase with
72 [ O ⇒ (*** PHASE 1: restart ***)
73 match pi1 … count with
74 [ O ⇒ 〈〈s0,bin2,ch,to_initN (FS_crd sig) ? H2〉,None ?,N〉
75 | S k ⇒ 〈〈s0,bin1,ch,initN_pred … count〉,None ?,L〉 ]
76 | S phase ⇒ match phase with
77 [ O ⇒ (*** PHASE 2: write ***)
78 let 〈s',a',mv〉 ≝ trans 〈s0,ch〉 in
79 match pi1 … count with
80 [ O ⇒ let mv' ≝ match mv with [ R ⇒ N | _ ⇒ L ] in
81 let count' ≝ match mv with [ R ⇒ 0 | N ⇒ FS_crd sig | L ⇒ 2*(FS_crd sig) ] in
82 〈〈s',bin3,ch,to_initN count' ??〉,None ?,mv'〉
84 [ None ⇒ 〈〈s0,bin2,ch,initN_pred … count〉,None ?,R〉
85 | Some a0' ⇒ let out ≝ (FS_nth ? k == a') in
86 〈〈s0,bin2,ch,initN_pred … count〉,Some ? out,R〉 ]
88 | S phase ⇒ match phase with
89 [ O ⇒ (*** PHASE 3: move head left ***)
90 match pi1 … count with
91 [ O ⇒ 〈〈s0,bin0,None ?,to_initN (FS_crd sig) ? H2〉, None ?,N〉 (* the end: restart *)
92 | S k ⇒ 〈〈s0,bin3,ch,initN_pred … count〉, None ?,L〉 ]
93 | S phase ⇒ match phase with
94 [ O ⇒ (*** PHASE 4: check position ***)
96 [ None ⇒ (* niltape/rightof: we can write *) 〈〈s0,bin2,ch,to_initN (FS_crd sig) ? H2〉,None ?,N〉
97 | Some _ ⇒ (* leftof *)
98 let 〈s',a',mv〉 ≝ trans 〈s0,ch〉 in
100 [ None ⇒ (* we don't write anything: go to end of 2 *) 〈〈s0,bin2,ch,to_initN 0 ? H1〉,None ?,N〉
101 | Some _ ⇒ (* extend tape *) 〈〈s0,bin5,ch,to_initN (FS_crd sig) ? H2〉,None ?,L〉 ]
103 | S _ ⇒ (*** PHASE 5: left extension ***)
104 match pi1 … count with
105 [ O ⇒ 〈〈s0,bin2,ch,to_initN (FS_crd sig) ? H2〉,None ?,N〉
106 | S k ⇒ 〈〈s0,bin5,ch,initN_pred … count〉,Some ? false,L〉 ]]]]]].
108 whd in match count'; cases mv whd in ⊢ (?%?); //
111 definition halt_binaryTM : ∀sig,M.states_binaryTM sig (states sig M) → bool ≝
112 λsig,M,s.let 〈s0,phase,ch,count〉 ≝ s in
113 pi1 … phase == O ∧ halt sig M s0.
116 * Una mk_binaryTM prende in input una macchina M e produce una macchina che:
117 * - ha per alfabeto FinBool
118 * - ha stati di tipo ((states … M) × (initN 7)) ×
119 ((option sig) × (initN (2*dimensione dell'alfabeto di M + 1))
120 * dove il primo elemento corrisponde allo stato della macchina input,
121 * il secondo identifica la fase (lettura, scrittura, spostamento)
122 * il terzo identifica il carattere oggetto letto
123 * il quarto è un contatore
124 * - la funzione di transizione viene prodotta da trans_binaryTM
125 * - la funzione di arresto viene prodotta da halt_binaryTM
127 definition mk_binaryTM ≝
129 mk_TM FinBool (states_binaryTM sig (states sig M))
130 (trans_binaryTM sig (states sig M) (trans sig M))
131 (〈start sig M,bin0,None ?,FS_crd sig〉) (halt_binaryTM sig M).// qed.
133 definition bin_char ≝ λsig,ch.unary_of_nat (FS_crd sig) (index_of_FS sig ch).
135 definition bin_current ≝ λsig,t.match current ? t with
136 [ None ⇒ [ ] | Some c ⇒ bin_char sig c ].
138 definition tape_bin_lift ≝ λsig,t.
139 let ls' ≝ flatten ? (map ?? (bin_char sig) (left ? t)) in
140 let c' ≝ option_hd ? (bin_current sig t) in
141 let rs' ≝ tail ? (bin_current sig t)@flatten ? (map ?? (bin_char sig) (right ? t)) in
142 mk_tape ? ls' c' rs'.
144 definition R_bin_lift ≝ λsig,R,t1,t2.
145 ∃u1.t1 = tape_bin_lift sig u1 →
146 ∃u2.t2 = tape_bin_lift sig u2 ∧ R u1 u2.
148 definition state_bin_lift :
149 ∀sig.∀M:TM sig.states sig M → states ? (mk_binaryTM ? M)
150 ≝ λsig,M,q.〈q,bin0,None ?,FS_crd sig〉.// qed.
152 lemma lift_halt_binaryTM :
153 ∀sig,M,q.halt sig M q = halt ? (mk_binaryTM sig M) (state_bin_lift ? M q).
156 lemma binaryTM_bin0_bin1 :
158 step ? (mk_binaryTM sig M) (mk_config ?? (〈q,bin0,ch,O〉) t)
159 = mk_config ?? (〈q,bin1,ch,to_initN (FS_crd sig) ??〉) t. //
162 lemma binaryTM_bin0_bin4 :
164 current ? t = None ? → S k <S (2*FS_crd sig) →
165 step ? (mk_binaryTM sig M) (mk_config ?? (〈q,bin0,ch,S k〉) t)
166 = mk_config ?? (〈q,bin4,None ?,to_initN 0 ??〉) (tape_move ? t R). [2,3://]
167 #sig #M #t #q #ch #k #Hcur #Hk
168 whd in match (step ???); whd in match (trans ???);
172 lemma binaryTM_bin0_true :
174 current ? t = Some ? true → S k <S (2*FS_crd sig) →
175 step ? (mk_binaryTM sig M) (mk_config ?? (〈q,bin0,ch,S k〉) t)
176 = mk_config ?? (〈q,bin0,FS_nth sig k,to_initN k ??〉) (tape_move ? t R).[2,3:/2 by lt_S_to_lt/]
177 #sig #M #t #q #ch #k #Hcur #Hk
178 whd in match (step ???); whd in match (trans ???);
182 lemma binaryTM_bin0_false :
184 current ? t = Some ? false → S k <S (2*FS_crd sig) →
185 step ? (mk_binaryTM sig M) (mk_config ?? (〈q,bin0,ch,S k〉) t)
186 = mk_config ?? (〈q,bin0,ch,to_initN k ??〉) (tape_move ? t R).[2,3:/2 by lt_S_to_lt/]
187 #sig #M #t #q #ch #k #Hcur #Hk
188 whd in match (step ???); whd in match (trans ???);
193 axiom binary_to_bin_char :∀sig,csl,csr,a.
194 csl@true::csr=bin_char sig a → FS_nth ? (length ? csr) = Some ? a.
196 lemma binaryTM_phase0_midtape_aux :
199 ∀csr,csl,t,ch.length ? csr < S (2*FS_crd sig) →
200 t = mk_tape ? (reverse ? csl@ls) (option_hd ? (csr@rs)) (tail ? (csr@rs)) →
201 csl@csr = bin_char sig a →
202 |csl@csr| = FS_crd sig →
203 (index_of_FS ? a < |csl| → ch = Some ? a) →
204 loopM ? (mk_binaryTM sig M) (S (length ? csr) + k)
205 (mk_config ?? (〈q,bin0,ch,length ? csr〉) t)
206 = loopM ? (mk_binaryTM sig M) k
207 (mk_config ?? (〈q,bin1,Some ? a,FS_crd sig〉)
208 (mk_tape ? (reverse ? (bin_char ? a)@ls) (option_hd ? rs) (tail ? rs))). [2,3:/2 by O/]
209 #sig #M #q #ls #a #rs #k #Hhalt #csr elim csr
210 [ #csl #t #ch #Hlen #Ht >append_nil #Hcsl #Hlencsl #Hch >loopM_unfold >loop_S_false [|normalize //]
211 >Hch [| >Hlencsl (* lemmatize *) @daemon]
212 <loopM_unfold @eq_f >binaryTM_bin0_bin1 @eq_f >Ht
213 whd in match (step ???); whd in match (trans ???); <Hcsl %
215 [ #csr0 #IH #csl #t #ch #Hlen #Ht #Heq #Hcrd #Hch >loopM_unfold >loop_S_false [|normalize //]
216 <loopM_unfold lapply (binary_to_bin_char … Heq) #Ha >binaryTM_bin0_true
218 lapply (IH (csl@[true]) (tape_move FinBool t R) ??????)
220 | >associative_append @Hcrd
221 | >associative_append @Heq
222 | >Ht whd in match (option_hd ??) in ⊢ (??%?); whd in match (tail ??) in ⊢ (??%?);
225 [ normalize >rev_append_def >rev_append_def >reverse_append %
226 | #r1 #rs1 normalize >rev_append_def >rev_append_def >reverse_append % ]
227 | #c1 #csr1 normalize >rev_append_def >rev_append_def >reverse_append % ]
230 #H whd in match (plus ??); >H @eq_f @eq_f2 %
231 | #csr0 #IH #csl #t #ch #Hlen #Ht #Heq #Hcrd #Hch >loopM_unfold >loop_S_false [|normalize //]
232 <loopM_unfold >binaryTM_bin0_false [| >Ht % ]
233 lapply (IH (csl@[false]) (tape_move FinBool t R) ??????)
235 | (* by cases: if index < |csl|, then Hch, else False *)
237 | >associative_append @Hcrd
238 | >associative_append @Heq
239 | >Ht whd in match (option_hd ??) in ⊢ (??%?); whd in match (tail ??) in ⊢ (??%?);
242 [ normalize >rev_append_def >rev_append_def >reverse_append %
243 | #r1 #rs1 normalize >rev_append_def >rev_append_def >reverse_append % ]
244 | #c1 #csr1 normalize >rev_append_def >rev_append_def >reverse_append % ]
247 #H whd in match (plus ??); >H @eq_f @eq_f2 %
252 lemma binaryTM_phase0_midtape :
253 ∀sig,M,t,q,ls,a,rs,ch,k.
255 t = mk_tape ? ls (option_hd ? (bin_char ? a)) (tail ? (bin_char sig a@rs)) →
256 loopM ? (mk_binaryTM sig M) (S (length ? (bin_char ? a)) + k)
257 (mk_config ?? (〈q,bin0,ch,length ? (bin_char ? a)〉) t)
258 = loopM ? (mk_binaryTM sig M) k
259 (mk_config ?? (〈q,bin1,Some ? a,FS_crd sig〉)
260 (mk_tape ? (reverse ? (bin_char ? a)@ls) (option_hd ? rs) (tail ? rs))). [|@daemon|//]
261 #sig #M #t #q #ls #a #rs #ch #k #Hhalt #Ht
262 cut (∃c,cl.bin_char sig a = c::cl) [@daemon] * #c * #cl #Ha >Ha
263 >(binaryTM_phase0_midtape_aux ? M q ls a rs ? ? (c::cl) [ ] t ch) //
264 [| normalize #Hfalse @False_ind cases (not_le_Sn_O ?) /2/
265 | <Ha (* |bin_char sig ?| = FS_crd sig *) @daemon
271 lemma binaryTM_phase0_None :
275 current ? t = None ? →
276 loopM ? (mk_binaryTM sig M) (S k) (mk_config ?? (〈q,bin0,ch,S n〉) t)
277 = loopM ? (mk_binaryTM sig M) k
278 (mk_config ?? (〈q,bin4,None ?,to_initN O ??〉) (tape_move ? t R)). [2,3: /2 by le_to_lt_to_lt/ ]
279 #sig #M #t #q #ch #k #n #Hn #Hhalt cases t
280 [ >loopM_unfold >loop_S_false [|@Hhalt] //
281 | #r0 #rs0 >loopM_unfold >loop_S_false [|@Hhalt] //
282 | #l0 #ls0 >loopM_unfold >loop_S_false [|@Hhalt] //
283 | #ls #cur #rs normalize in ⊢ (%→?); #H destruct (H) ]
286 lemma binaryTM_bin1_O :
288 step ? (mk_binaryTM sig M) (mk_config ?? (〈q,bin1,ch,O〉) t)
289 = mk_config ?? (〈q,bin2,ch,to_initN (FS_crd sig) ??〉) t. [2,3://]
293 lemma binaryTM_bin1_S :
294 ∀sig,M,t,q,ch,k. S k <S (2*FS_crd sig) →
295 step ? (mk_binaryTM sig M) (mk_config ?? (〈q,bin1,ch,S k〉) t)
296 = mk_config ?? (〈q,bin1,ch,to_initN k ??〉) (tape_move ? t L). [2,3:/2 by lt_S_to_lt/]
297 #sig #M #t #q #ch #k #HSk %
300 lemma binaryTM_phase1 :
301 ∀sig,M,q,ls1,ls2,cur,rs,ch,k.
302 |ls1| = FS_crd sig → (cur = None ? → rs = [ ]) →
303 loopM ? (mk_binaryTM sig M) (S (FS_crd sig) + k)
304 (mk_config ?? (〈q,bin1,ch,FS_crd sig〉) (mk_tape ? (ls1@ls2) cur rs))
305 = loopM ? (mk_binaryTM sig M) k
306 (mk_config ?? (〈q,bin2,ch,FS_crd sig〉)
307 (mk_tape ? ls2 (option_hd ? (reverse ? ls1@option_cons ? cur rs))
308 (tail ? (reverse ? ls1@option_cons ? cur rs)))). [2,3:/2 by O/]
309 cut (∀sig,M,q,ls1,ls2,ch,k,n,cur,rs.
310 |ls1| = n → n<S (2*FS_crd sig) → (cur = None ? → rs = [ ]) →
311 loopM ? (mk_binaryTM sig M) (S n + k)
312 (mk_config ?? (〈q,bin1,ch,n〉) (mk_tape ? (ls1@ls2) cur rs))
313 = loopM ? (mk_binaryTM sig M) k
314 (mk_config ?? (〈q,bin2,ch,FS_crd sig〉)
315 (mk_tape ? ls2 (option_hd ? (reverse ? ls1@option_cons ? cur rs))
316 (tail ? (reverse ? ls1@option_cons ? cur rs))))) [1,2://]
317 [ #sig #M #q #ls1 #ls2 #ch #k elim ls1
318 [ #n normalize in ⊢ (%→?); #cur #rs #Hn <Hn #Hcrd #Hcur >loopM_unfold >loop_S_false [| % ]
319 >binaryTM_bin1_O cases cur in Hcur;
320 [ #H >(H (refl ??)) -H %
322 | #l0 #ls0 #IH * [ #cur #rs normalize in ⊢ (%→?); #H destruct (H) ]
323 #n #cur #rs normalize in ⊢ (%→?); #H destruct (H) #Hlt #Hcur
324 >loopM_unfold >loop_S_false [|%] >binaryTM_bin1_S
325 <(?:mk_tape ? (ls0@ls2) (Some ? l0) (option_cons ? cur rs) =
326 tape_move FinBool (mk_tape FinBool ((l0::ls0)@ls2) cur rs) L)
327 [| cases cur in Hcur; [ #H >(H ?) // | #cur' #_ % ] ]
328 >(?:loop (config FinBool (states FinBool (mk_binaryTM sig M))) (S (|ls0|)+k)
329 (step FinBool (mk_binaryTM sig M))
330 (λc:config FinBool (states FinBool (mk_binaryTM sig M))
331 .halt FinBool (mk_binaryTM sig M)
332 (cstate FinBool (states FinBool (mk_binaryTM sig M)) c))
333 (mk_config FinBool (states FinBool (mk_binaryTM sig M))
334 〈q,bin1,ch,to_initN (|ls0|) (S (2*FS_crd sig))
335 (lt_S_to_lt (|ls0|) (S (2*FS_crd sig)) Hlt)〉
336 (mk_tape FinBool (ls0@ls2) (Some FinBool l0) (option_cons FinBool cur rs)))
337 = loopM FinBool (mk_binaryTM sig M) k
338 (mk_config FinBool (states FinBool (mk_binaryTM sig M))
339 〈q,bin2,〈ch,FS_crd sig〉〉
341 (option_hd FinBool (reverse FinBool ls0@l0::option_cons FinBool cur rs))
342 (tail FinBool (reverse FinBool ls0@l0::option_cons FinBool cur rs)))))
344 | >(?: l0::option_cons ? cur rs = option_cons ? (Some ? l0) (option_cons ? cur rs)) [| % ]
345 @trans_eq [|| @(IH ??? (refl ??)) [ /2 by lt_S_to_lt/ | #H destruct (H) ] ]
348 >reverse_cons >associative_append %
350 | #Hcut #sig #M #q #ls1 #ls2 #cur #rs #ch #k #Hlen @Hcut // ]
353 lemma binaryTM_bin3_O :
355 step ? (mk_binaryTM sig M) (mk_config ?? (〈q,bin3,ch,O〉) t)
356 = mk_config ?? (〈q,bin0,None ?,to_initN (FS_crd sig) ??〉) t. [2,3://]
360 lemma binaryTM_bin3_S :
361 ∀sig,M,t,q,ch,k. S k <S (2*FS_crd sig) →
362 step ? (mk_binaryTM sig M) (mk_config ?? (〈q,bin3,ch,S k〉) t)
363 = mk_config ?? (〈q,bin3,ch,to_initN k ??〉) (tape_move ? t L). [2,3:/2 by lt_S_to_lt/]
364 #sig #M #t #q #ch #k #HSk %
367 lemma binaryTM_phase3 :∀sig,M,q,ls1,ls2,ch,k,n,cur,rs.
368 |ls1| = n → n<S (2*FS_crd sig) → (cur = None ? → rs = [ ]) →
369 loopM ? (mk_binaryTM sig M) (S n + k)
370 (mk_config ?? (〈q,bin3,ch,n〉) (mk_tape ? (ls1@ls2) cur rs))
371 = loopM ? (mk_binaryTM sig M) k
372 (mk_config ?? (〈q,bin0,None ?,FS_crd sig〉)
373 (mk_tape ? ls2 (option_hd ? (reverse ? ls1@option_cons ? cur rs))
374 (tail ? (reverse ? ls1@option_cons ? cur rs)))). [2,3://]
375 #sig #M #q #ls1 #ls2 #ch #k elim ls1
376 [ #n normalize in ⊢ (%→?); #cur #rs #Hn <Hn #Hcrd #Hcur >loopM_unfold >loop_S_false [| % ]
377 >binaryTM_bin3_O cases cur in Hcur;
378 [ #H >(H (refl ??)) -H %
380 | #l0 #ls0 #IH * [ #cur #rs normalize in ⊢ (%→?); #H destruct (H) ]
381 #n #cur #rs normalize in ⊢ (%→?); #H destruct (H) #Hlt #Hcur
382 >loopM_unfold >loop_S_false [|%] >binaryTM_bin3_S
383 <(?:mk_tape ? (ls0@ls2) (Some ? l0) (option_cons ? cur rs) =
384 tape_move FinBool (mk_tape FinBool ((l0::ls0)@ls2) cur rs) L)
385 [| cases cur in Hcur; [ #H >(H ?) // | #cur' #_ % ] ]
386 >(?:loop (config FinBool (states FinBool (mk_binaryTM sig M))) (S (|ls0|)+k)
387 (step FinBool (mk_binaryTM sig M))
388 (λc:config FinBool (states FinBool (mk_binaryTM sig M))
389 .halt FinBool (mk_binaryTM sig M)
390 (cstate FinBool (states FinBool (mk_binaryTM sig M)) c))
391 (mk_config FinBool (states FinBool (mk_binaryTM sig M))
392 〈q,bin3,ch,to_initN (|ls0|) (S (2*FS_crd sig))
393 (lt_S_to_lt (|ls0|) (S (2*FS_crd sig)) Hlt)〉
394 (mk_tape FinBool (ls0@ls2) (Some FinBool l0) (option_cons FinBool cur rs)))
395 = loopM FinBool (mk_binaryTM sig M) k
396 (mk_config FinBool (states FinBool (mk_binaryTM sig M))
397 〈q,bin0,〈None ?,FS_crd sig〉〉
399 (option_hd FinBool (reverse FinBool ls0@l0::option_cons FinBool cur rs))
400 (tail FinBool (reverse FinBool ls0@l0::option_cons FinBool cur rs)))))
402 | >(?: l0::option_cons ? cur rs = option_cons ? (Some ? l0) (option_cons ? cur rs)) [| % ]
403 @trans_eq [|| @(IH ??? (refl ??)) [ /2 by lt_S_to_lt/ | #H destruct (H) ] ]
406 >reverse_cons >associative_append %
412 lemma binaryTM_loop :
414 loopM sig M i (mk_config ?? q t) = Some ? (mk_config ?? qf tf) →
415 ∃k.loopM ? (mk_binaryTM sig M) k
416 (mk_config ?? (state_bin_lift ? M q) (tape_bin_lift ? t)) =
417 Some ? (mk_config ?? (state_bin_lift ? M qf) (tape_bin_lift ? tf)).
419 [ #t #q #qf #tf change with (None ?) in ⊢ (??%?→?); #H destruct (H)
420 | -i #i #IH #t #q #tf #qf
422 lapply (refl ? (halt sig M (cstate ?? (mk_config ?? q t))))
423 cases (halt ?? q) in ⊢ (???%→?); #Hhalt
424 [ >(loop_S_true ??? (λc.halt ?? (cstate ?? c)) (mk_config ?? q t) Hhalt)
425 #H destruct (H) %{1} >loopM_unfold >loop_S_true // ]
426 (* interesting case: more than one step *)
427 >(loop_S_false ??? (λc.halt ?? (cstate ?? c)) (mk_config ?? q t) Hhalt)
428 <loopM_unfold >(config_expand ?? (step ???)) #Hloop
429 lapply (IH … Hloop) -IH * #k0 #IH <config_expand in Hloop; #Hloop
435 theorem sem_binaryTM : ∀sig,M.
436 mk_binaryTM sig M ⊫ R_bin_lift ? (R_TM ? M (start ? M)).
437 #sig #M #t #i generalize in match t; -t
438 @(nat_elim1 … i) #m #IH #intape #outc #Hloop