37 lemma code_tp_length [simp]: |
34 lemma code_tp_length [simp]: |
38 "length (code_tp tp) = length tp" |
35 "length (code_tp tp) = length tp" |
39 by (induct tp) (simp_all) |
36 by (induct tp) (simp_all) |
40 |
37 |
41 lemma code_tp_nth [simp]: |
38 lemma code_tp_nth [simp]: |
42 "n < length tp \<Longrightarrow> (code_tp tp) ! n = cell_num (tp ! n)" |
39 "n < length tp \<Longrightarrow> (code_tp tp) ! n = cellnum (tp ! n)" |
43 apply(induct n arbitrary: tp) |
40 apply(induct n arbitrary: tp) |
44 apply(simp_all) |
41 apply(simp_all) |
45 apply(case_tac [!] tp) |
42 apply(case_tac [!] tp) |
46 apply(simp_all) |
43 apply(simp_all) |
47 done |
44 done |
48 |
45 |
49 lemma code_tp_replicate [simp]: |
46 lemma code_tp_replicate [simp]: |
50 "code_tp (c \<up> n) = (cell_num c) \<up> n" |
47 "code_tp (c \<up> n) = (cellnum c) \<up> n" |
51 by(induct n) (simp_all) |
48 by(induct n) (simp_all) |
52 |
49 |
|
50 text {* Coding Configurations and TMs *} |
53 |
51 |
54 fun Code_conf where |
52 fun Code_conf where |
55 "Code_conf (s, l, r) = (s, Code_tp l, Code_tp r)" |
53 "Code_conf (s, l, r) = (s, Code_tp l, Code_tp r)" |
56 |
54 |
57 fun code_instr :: "instr \<Rightarrow> nat" where |
55 fun code_instr :: "instr \<Rightarrow> nat" where |
58 "code_instr i = penc (action_num (fst i)) (snd i)" |
56 "code_instr i = penc (actnum (fst i)) (snd i)" |
59 |
57 |
60 fun Code_instr :: "instr \<times> instr \<Rightarrow> nat" where |
58 fun Code_instr :: "instr \<times> instr \<Rightarrow> nat" where |
61 "Code_instr i = penc (code_instr (fst i)) (code_instr (snd i))" |
59 "Code_instr i = penc (code_instr (fst i)) (code_instr (snd i))" |
62 |
60 |
63 fun code_tprog :: "tprog \<Rightarrow> nat list" |
61 fun code_tprog :: "tprog \<Rightarrow> nat list" |
144 "Left cf = ldec cf 1" |
142 "Left cf = ldec cf 1" |
145 |
143 |
146 fun Right where |
144 fun Right where |
147 "Right cf = ldec cf 2" |
145 "Right cf = ldec cf 2" |
148 |
146 |
|
147 text {* |
|
148 @{text "Steps cf m k"} computes the TM configuration after @{text "k"} steps of |
|
149 execution of TM coded as @{text "m"}. @{text Step} is a single step of the TM. |
|
150 *} |
|
151 |
149 fun Step :: "nat \<Rightarrow> nat \<Rightarrow> nat" |
152 fun Step :: "nat \<Rightarrow> nat \<Rightarrow> nat" |
150 where |
153 where |
151 "Step cf m = Conf (Newstate m (State cf) (Read (Right cf)), |
154 "Step cf m = Conf (Newstate m (State cf) (Read (Right cf)), |
152 Newleft (Left cf) (Right cf) (Action m (State cf) (Read (Right cf))), |
155 Newleft (Left cf) (Right cf) (Action m (State cf) (Read (Right cf))), |
153 Newright (Left cf) (Right cf) (Action m (State cf) (Read (Right cf))))" |
156 Newright (Left cf) (Right cf) (Action m (State cf) (Read (Right cf))))" |
154 |
157 |
155 text {* |
|
156 @{text "Steps cf m k"} computes the TM configuration after @{text "k"} steps of execution |
|
157 of TM coded as @{text "m"}. |
|
158 *} |
|
159 |
|
160 fun Steps :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
158 fun Steps :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
161 where |
159 where |
162 "Steps cf p 0 = cf" |
160 "Steps cf p 0 = cf" |
163 | "Steps cf p (Suc n) = Steps (Step cf p) p n" |
161 | "Steps cf p (Suc n) = Steps (Step cf p) p n" |
164 |
162 |
165 lemma Step_Steps_comm: |
163 lemma Step_Steps_comm: |
166 "Step (Steps cf p n) p = Steps (Step cf p) p n" |
164 "Step (Steps cf p n) p = Steps (Step cf p) p n" |
167 by (induct n arbitrary: cf) (simp_all only: Steps.simps) |
165 by (induct n arbitrary: cf) (simp_all only: Steps.simps) |
168 |
166 |
169 |
167 |
170 text {* |
168 text {* Decoding tapes back into numbers. *} |
171 Decoding tapes into binary or stroke numbers. |
|
172 *} |
|
173 |
169 |
174 definition Stknum :: "nat \<Rightarrow> nat" |
170 definition Stknum :: "nat \<Rightarrow> nat" |
175 where |
171 where |
176 "Stknum z \<equiv> (\<Sum>i < enclen z. ldec z i)" |
172 "Stknum z \<equiv> (\<Sum>i < enclen z. ldec z i)" |
177 |
|
178 |
|
179 definition |
|
180 "right_std z \<equiv> (\<exists>i \<le> enclen z. 1 \<le> i \<and> (\<forall>j < i. ldec z j = 1) \<and> (\<forall>j < enclen z - i. ldec z (i + j) = 0))" |
|
181 |
|
182 definition |
|
183 "left_std z \<equiv> (\<forall>j < enclen z. ldec z j = 0)" |
|
184 |
|
185 lemma ww: |
|
186 "(\<exists>k l. 1 \<le> k \<and> tp = Oc \<up> k @ Bk \<up> l) \<longleftrightarrow> |
|
187 (\<exists>i\<le>length tp. 1 \<le> i \<and> (\<forall>j < i. tp ! j = Oc) \<and> (\<forall>j < length tp - i. tp ! (i + j) = Bk))" |
|
188 apply(rule iffI) |
|
189 apply(erule exE)+ |
|
190 apply(simp) |
|
191 apply(rule_tac x="k" in exI) |
|
192 apply(auto)[1] |
|
193 apply(simp add: nth_append) |
|
194 apply(simp add: nth_append) |
|
195 apply(erule exE) |
|
196 apply(rule_tac x="i" in exI) |
|
197 apply(rule_tac x="length tp - i" in exI) |
|
198 apply(auto) |
|
199 apply(rule sym) |
|
200 apply(subst append_eq_conv_conj) |
|
201 apply(simp) |
|
202 apply(rule conjI) |
|
203 apply (smt length_replicate length_take nth_equalityI nth_replicate nth_take) |
|
204 by (smt length_drop length_replicate nth_drop nth_equalityI nth_replicate) |
|
205 |
|
206 lemma right_std: |
|
207 "(\<exists>k l. 1 \<le> k \<and> tp = Oc \<up> k @ Bk \<up> l) \<longleftrightarrow> right_std (Code_tp tp)" |
|
208 apply(simp only: ww) |
|
209 apply(simp add: right_std_def) |
|
210 apply(simp only: list_encode_inverse) |
|
211 apply(simp) |
|
212 apply(auto) |
|
213 apply(rule_tac x="i" in exI) |
|
214 apply(simp) |
|
215 apply(rule conjI) |
|
216 apply (metis Suc_eq_plus1 Suc_neq_Zero cell_num.cases cell_num.simps(1) leD less_trans linorder_neqE_nat) |
|
217 apply(auto) |
|
218 by (metis One_nat_def cell_num.cases cell_num.simps(2) less_diff_conv n_not_Suc_n nat_add_commute) |
|
219 |
|
220 lemma left_std: |
|
221 "(\<exists>k. tp = Bk \<up> k) \<longleftrightarrow> left_std (Code_tp tp)" |
|
222 apply(simp add: left_std_def) |
|
223 apply(simp only: list_encode_inverse) |
|
224 apply(simp) |
|
225 apply(auto) |
|
226 apply(rule_tac x="length tp" in exI) |
|
227 apply(induct tp) |
|
228 apply(simp) |
|
229 apply(simp) |
|
230 apply(auto) |
|
231 apply(case_tac a) |
|
232 apply(auto) |
|
233 apply(case_tac a) |
|
234 apply(auto) |
|
235 by (metis Suc_less_eq nth_Cons_Suc) |
|
236 |
|
237 |
173 |
238 lemma Stknum_append: |
174 lemma Stknum_append: |
239 "Stknum (Code_tp (tp1 @ tp2)) = Stknum (Code_tp tp1) + Stknum (Code_tp tp2)" |
175 "Stknum (Code_tp (tp1 @ tp2)) = Stknum (Code_tp tp1) + Stknum (Code_tp tp2)" |
240 apply(simp only: Code_tp.simps) |
176 apply(simp only: Code_tp.simps) |
241 apply(simp only: code_tp_append) |
177 apply(simp only: code_tp_append) |
274 "Stknum (Code_tp (<n> @ Bk \<up> l)) - 1 = n" |
210 "Stknum (Code_tp (<n> @ Bk \<up> l)) - 1 = n" |
275 apply(simp only: Stknum_append) |
211 apply(simp only: Stknum_append) |
276 apply(simp only: tape_of_nat.simps) |
212 apply(simp only: tape_of_nat.simps) |
277 apply(simp only: Code_tp.simps) |
213 apply(simp only: Code_tp.simps) |
278 apply(simp only: code_tp_replicate) |
214 apply(simp only: code_tp_replicate) |
279 apply(simp only: cell_num.simps) |
215 apply(simp only: cellnum.simps) |
280 apply(simp only: Stknum_up) |
216 apply(simp only: Stknum_up) |
281 apply(simp) |
217 apply(simp) |
282 done |
218 done |
|
219 |
|
220 |
|
221 section {* Standard Tapes *} |
|
222 |
|
223 definition |
|
224 "right_std z \<equiv> (\<exists>i \<le> enclen z. 1 \<le> i \<and> (\<forall>j < i. ldec z j = 1) \<and> (\<forall>j < enclen z - i. ldec z (i + j) = 0))" |
|
225 |
|
226 definition |
|
227 "left_std z \<equiv> (\<forall>j < enclen z. ldec z j = 0)" |
|
228 |
|
229 lemma ww: |
|
230 "(\<exists>k l. 1 \<le> k \<and> tp = Oc \<up> k @ Bk \<up> l) \<longleftrightarrow> |
|
231 (\<exists>i\<le>length tp. 1 \<le> i \<and> (\<forall>j < i. tp ! j = Oc) \<and> (\<forall>j < length tp - i. tp ! (i + j) = Bk))" |
|
232 apply(rule iffI) |
|
233 apply(erule exE)+ |
|
234 apply(simp) |
|
235 apply(rule_tac x="k" in exI) |
|
236 apply(auto)[1] |
|
237 apply(simp add: nth_append) |
|
238 apply(simp add: nth_append) |
|
239 apply(erule exE) |
|
240 apply(rule_tac x="i" in exI) |
|
241 apply(rule_tac x="length tp - i" in exI) |
|
242 apply(auto) |
|
243 apply(rule sym) |
|
244 apply(subst append_eq_conv_conj) |
|
245 apply(simp) |
|
246 apply(rule conjI) |
|
247 apply (smt length_replicate length_take nth_equalityI nth_replicate nth_take) |
|
248 by (smt length_drop length_replicate nth_drop nth_equalityI nth_replicate) |
|
249 |
|
250 lemma right_std: |
|
251 "(\<exists>k l. 1 \<le> k \<and> tp = Oc \<up> k @ Bk \<up> l) \<longleftrightarrow> right_std (Code_tp tp)" |
|
252 apply(simp only: ww) |
|
253 apply(simp add: right_std_def) |
|
254 apply(simp only: list_encode_inverse) |
|
255 apply(simp) |
|
256 apply(auto) |
|
257 apply(rule_tac x="i" in exI) |
|
258 apply(simp) |
|
259 apply(rule conjI) |
|
260 apply (metis Suc_eq_plus1 Suc_neq_Zero cellnum.cases cellnum.simps(1) leD less_trans linorder_neqE_nat) |
|
261 apply(auto) |
|
262 by (metis One_nat_def cellnum.cases cellnum.simps(2) less_diff_conv n_not_Suc_n nat_add_commute) |
|
263 |
|
264 lemma left_std: |
|
265 "(\<exists>k. tp = Bk \<up> k) \<longleftrightarrow> left_std (Code_tp tp)" |
|
266 apply(simp add: left_std_def) |
|
267 apply(simp only: list_encode_inverse) |
|
268 apply(simp) |
|
269 apply(auto) |
|
270 apply(rule_tac x="length tp" in exI) |
|
271 apply(induct tp) |
|
272 apply(simp) |
|
273 apply(simp) |
|
274 apply(auto) |
|
275 apply(case_tac a) |
|
276 apply(auto) |
|
277 apply(case_tac a) |
|
278 apply(auto) |
|
279 by (metis Suc_less_eq nth_Cons_Suc) |
|
280 |
|
281 |
|
282 section {* Standard- and Final Configurations, the Universal Function *} |
283 |
283 |
284 text {* |
284 text {* |
285 @{text "Std cf"} returns true, if the configuration @{text "cf"} |
285 @{text "Std cf"} returns true, if the configuration @{text "cf"} |
286 is a stardard tape. |
286 is a stardard tape. |
287 *} |
287 *} |
494 CN rec_if [cond0, CN rec_write [constn 0, Id 3 1], |
485 CN rec_if [cond0, CN rec_write [constn 0, Id 3 1], |
495 CN rec_if [cond1, CN rec_write [constn 1, Id 3 1], |
486 CN rec_if [cond1, CN rec_write [constn 1, Id 3 1], |
496 CN rec_if [cond2, case2, |
487 CN rec_if [cond2, case2, |
497 CN rec_if [cond3, CN rec_pdec2 [Id 3 1], Id 3 1]]]])" |
488 CN rec_if [cond3, CN rec_pdec2 [Id 3 1], Id 3 1]]]])" |
498 |
489 |
499 lemma newleft_lemma [simp]: |
|
500 "rec_eval rec_newleft [p, r, a] = Newleft p r a" |
|
501 by (simp add: rec_newleft_def Let_def) |
|
502 |
|
503 lemma newright_lemma [simp]: |
|
504 "rec_eval rec_newright [p, r, a] = Newright p r a" |
|
505 by (simp add: rec_newright_def Let_def) |
|
506 |
|
507 |
|
508 definition |
490 definition |
509 "rec_actn = rec_swap (PR (CN rec_pdec1 [CN rec_pdec1 [Id 1 0]]) |
491 "rec_actn = rec_swap (PR (CN rec_pdec1 [CN rec_pdec1 [Id 1 0]]) |
510 (CN rec_pdec1 [CN rec_pdec2 [Id 3 2]]))" |
492 (CN rec_pdec1 [CN rec_pdec2 [Id 3 2]]))" |
511 |
|
512 lemma act_lemma [simp]: |
|
513 "rec_eval rec_actn [n, c] = Actn n c" |
|
514 apply(simp add: rec_actn_def) |
|
515 apply(case_tac c) |
|
516 apply(simp_all) |
|
517 done |
|
518 |
493 |
519 definition |
494 definition |
520 "rec_action = (let cond1 = CN rec_noteq [Id 3 1, Z] in |
495 "rec_action = (let cond1 = CN rec_noteq [Id 3 1, Z] in |
521 let cond2 = CN rec_within [Id 3 0, CN rec_pred [Id 3 1]] in |
496 let cond2 = CN rec_within [Id 3 0, CN rec_pred [Id 3 1]] in |
522 let if_branch = CN rec_actn [CN rec_ldec [Id 3 0, CN rec_pred [Id 3 1]], Id 3 2] |
497 let if_branch = CN rec_actn [CN rec_ldec [Id 3 0, CN rec_pred [Id 3 1]], Id 3 2] |
523 in CN rec_if [CN rec_conj [cond1, cond2], if_branch, constn 4])" |
498 in CN rec_if [CN rec_conj [cond1, cond2], if_branch, constn 4])" |
524 |
499 |
525 lemma action_lemma [simp]: |
|
526 "rec_eval rec_action [m, q, c] = Action m q c" |
|
527 by (simp add: rec_action_def) |
|
528 |
|
529 definition |
500 definition |
530 "rec_newstat = rec_swap (PR (CN rec_pdec2 [CN rec_pdec1 [Id 1 0]]) |
501 "rec_newstat = rec_swap (PR (CN rec_pdec2 [CN rec_pdec1 [Id 1 0]]) |
531 (CN rec_pdec2 [CN rec_pdec2 [Id 3 2]]))" |
502 (CN rec_pdec2 [CN rec_pdec2 [Id 3 2]]))" |
532 |
|
533 lemma newstat_lemma [simp]: |
|
534 "rec_eval rec_newstat [n, c] = Newstat n c" |
|
535 apply(simp add: rec_newstat_def) |
|
536 apply(case_tac c) |
|
537 apply(simp_all) |
|
538 done |
|
539 |
503 |
540 definition |
504 definition |
541 "rec_newstate = (let cond = CN rec_noteq [Id 3 1, Z] in |
505 "rec_newstate = (let cond = CN rec_noteq [Id 3 1, Z] in |
542 let if_branch = CN rec_newstat [CN rec_ldec [Id 3 0, CN rec_pred [Id 3 1]], Id 3 2] |
506 let if_branch = CN rec_newstat [CN rec_ldec [Id 3 0, CN rec_pred [Id 3 1]], Id 3 2] |
543 in CN rec_if [cond, if_branch, Z])" |
507 in CN rec_if [cond, if_branch, Z])" |
544 |
508 |
545 lemma newstate_lemma [simp]: |
|
546 "rec_eval rec_newstate [m, q, r] = Newstate m q r" |
|
547 by (simp add: rec_newstate_def) |
|
548 |
|
549 definition |
509 definition |
550 "rec_conf = rec_lenc [Id 3 0, Id 3 1, Id 3 2]" |
510 "rec_conf = rec_lenc [Id 3 0, Id 3 1, Id 3 2]" |
551 |
511 |
552 lemma conf_lemma [simp]: |
|
553 "rec_eval rec_conf [q, l, r] = Conf (q, l, r)" |
|
554 by(simp add: rec_conf_def) |
|
555 |
|
556 definition |
512 definition |
557 "rec_state = CN rec_ldec [Id 1 0, Z]" |
513 "rec_state = CN rec_ldec [Id 1 0, Z]" |
558 |
514 |
559 definition |
515 definition |
560 "rec_left = CN rec_ldec [Id 1 0, constn 1]" |
516 "rec_left = CN rec_ldec [Id 1 0, constn 1]" |
561 |
517 |
562 definition |
518 definition |
563 "rec_right = CN rec_ldec [Id 1 0, constn 2]" |
519 "rec_right = CN rec_ldec [Id 1 0, constn 2]" |
564 |
|
565 lemma state_lemma [simp]: |
|
566 "rec_eval rec_state [cf] = State cf" |
|
567 by (simp add: rec_state_def) |
|
568 |
|
569 lemma left_lemma [simp]: |
|
570 "rec_eval rec_left [cf] = Left cf" |
|
571 by (simp add: rec_left_def) |
|
572 |
|
573 lemma right_lemma [simp]: |
|
574 "rec_eval rec_right [cf] = Right cf" |
|
575 by (simp add: rec_right_def) |
|
576 |
520 |
577 definition |
521 definition |
578 "rec_step = (let left = CN rec_left [Id 2 0] in |
522 "rec_step = (let left = CN rec_left [Id 2 0] in |
579 let right = CN rec_right [Id 2 0] in |
523 let right = CN rec_right [Id 2 0] in |
580 let state = CN rec_state [Id 2 0] in |
524 let state = CN rec_state [Id 2 0] in |
583 let newstate = CN rec_newstate [Id 2 1, state, read] in |
527 let newstate = CN rec_newstate [Id 2 1, state, read] in |
584 let newleft = CN rec_newleft [left, right, action] in |
528 let newleft = CN rec_newleft [left, right, action] in |
585 let newright = CN rec_newright [left, right, action] |
529 let newright = CN rec_newright [left, right, action] |
586 in CN rec_conf [newstate, newleft, newright])" |
530 in CN rec_conf [newstate, newleft, newright])" |
587 |
531 |
588 lemma step_lemma [simp]: |
532 definition |
589 "rec_eval rec_step [cf, m] = Step cf m" |
533 "rec_steps = PR (Id 3 0) (CN rec_step [Id 4 1, Id 4 3])" |
590 by (simp add: Let_def rec_step_def) |
|
591 |
|
592 definition |
|
593 "rec_steps = PR (Id 3 0) |
|
594 (CN rec_step [Id 4 1, Id 4 3])" |
|
595 |
|
596 lemma steps_lemma [simp]: |
|
597 "rec_eval rec_steps [n, cf, p] = Steps cf p n" |
|
598 by (induct n) (simp_all add: rec_steps_def Step_Steps_comm del: Step.simps) |
|
599 |
|
600 |
534 |
601 definition |
535 definition |
602 "rec_stknum = CN rec_minus |
536 "rec_stknum = CN rec_minus |
603 [CN (rec_sigma1 (CN rec_ldec [Id 2 1, Id 2 0])) [CN rec_enclen [Id 1 0], Id 1 0], |
537 [CN (rec_sigma1 (CN rec_ldec [Id 2 1, Id 2 0])) [CN rec_enclen [Id 1 0], Id 1 0], |
604 CN rec_ldec [Id 1 0, CN rec_enclen [Id 1 0]]]" |
538 CN rec_ldec [Id 1 0, CN rec_enclen [Id 1 0]]]" |
605 |
|
606 lemma stknum_lemma [simp]: |
|
607 "rec_eval rec_stknum [z] = Stknum z" |
|
608 by (simp add: rec_stknum_def Stknum_def lessThan_Suc_atMost[symmetric]) |
|
609 |
539 |
610 definition |
540 definition |
611 "rec_right_std = (let bound = CN rec_enclen [Id 1 0] in |
541 "rec_right_std = (let bound = CN rec_enclen [Id 1 0] in |
612 let cond1 = CN rec_le [constn 1, Id 2 0] in |
542 let cond1 = CN rec_le [constn 1, Id 2 0] in |
613 let cond2 = rec_all1_less (CN rec_eq [CN rec_ldec [Id 2 1, Id 2 0], constn 1]) in |
543 let cond2 = rec_all1_less (CN rec_eq [CN rec_ldec [Id 2 1, Id 2 0], constn 1]) in |
638 |
560 |
639 definition |
561 definition |
640 "rec_stop = (let steps = CN rec_steps [Id 3 2, Id 3 1, Id 3 0] in |
562 "rec_stop = (let steps = CN rec_steps [Id 3 2, Id 3 1, Id 3 0] in |
641 CN rec_conj [CN rec_final [steps], CN rec_std [steps]])" |
563 CN rec_conj [CN rec_final [steps], CN rec_std [steps]])" |
642 |
564 |
643 lemma std_lemma [simp]: |
|
644 "rec_eval rec_std [cf] = (if Std cf then 1 else 0)" |
|
645 by (simp add: rec_std_def) |
|
646 |
|
647 lemma final_lemma [simp]: |
|
648 "rec_eval rec_final [cf] = (if Final cf then 1 else 0)" |
|
649 by (simp add: rec_final_def) |
|
650 |
|
651 lemma stop_lemma [simp]: |
|
652 "rec_eval rec_stop [m, cf, k] = (if Stop m cf k then 1 else 0)" |
|
653 by (simp add: Let_def rec_stop_def) |
|
654 |
|
655 definition |
565 definition |
656 "rec_halt = MN (CN rec_not [CN rec_stop [Id 3 1, Id 3 2, Id 3 0]])" |
566 "rec_halt = MN (CN rec_not [CN rec_stop [Id 3 1, Id 3 2, Id 3 0]])" |
657 |
|
658 lemma halt_lemma [simp]: |
|
659 "rec_eval rec_halt [m, cf] = Halt m cf" |
|
660 by (simp add: rec_halt_def del: Stop.simps) |
|
661 |
567 |
662 definition |
568 definition |
663 "rec_uf = CN rec_pred |
569 "rec_uf = CN rec_pred |
664 [CN rec_stknum |
570 [CN rec_stknum |
665 [CN rec_right |
571 [CN rec_right |
666 [CN rec_steps [CN rec_halt [Id 2 0, Id 2 1], Id 2 1, Id 2 0]]]]" |
572 [CN rec_steps [CN rec_halt [Id 2 0, Id 2 1], Id 2 1, Id 2 0]]]]" |
667 |
573 |
|
574 lemma read_lemma [simp]: |
|
575 "rec_eval rec_read [x] = Read x" |
|
576 by (simp add: rec_read_def) |
|
577 |
|
578 lemma write_lemma [simp]: |
|
579 "rec_eval rec_write [x, y] = Write x y" |
|
580 by (simp add: rec_write_def) |
|
581 |
|
582 lemma newleft_lemma [simp]: |
|
583 "rec_eval rec_newleft [p, r, a] = Newleft p r a" |
|
584 by (simp add: rec_newleft_def Let_def) |
|
585 |
|
586 lemma newright_lemma [simp]: |
|
587 "rec_eval rec_newright [p, r, a] = Newright p r a" |
|
588 by (simp add: rec_newright_def Let_def) |
|
589 |
|
590 lemma act_lemma [simp]: |
|
591 "rec_eval rec_actn [n, c] = Actn n c" |
|
592 apply(simp add: rec_actn_def) |
|
593 apply(case_tac c) |
|
594 apply(simp_all) |
|
595 done |
|
596 |
|
597 lemma action_lemma [simp]: |
|
598 "rec_eval rec_action [m, q, c] = Action m q c" |
|
599 by (simp add: rec_action_def) |
|
600 |
|
601 lemma newstat_lemma [simp]: |
|
602 "rec_eval rec_newstat [n, c] = Newstat n c" |
|
603 apply(simp add: rec_newstat_def) |
|
604 apply(case_tac c) |
|
605 apply(simp_all) |
|
606 done |
|
607 |
|
608 lemma newstate_lemma [simp]: |
|
609 "rec_eval rec_newstate [m, q, r] = Newstate m q r" |
|
610 by (simp add: rec_newstate_def) |
|
611 |
|
612 lemma conf_lemma [simp]: |
|
613 "rec_eval rec_conf [q, l, r] = Conf (q, l, r)" |
|
614 by(simp add: rec_conf_def) |
|
615 |
|
616 lemma state_lemma [simp]: |
|
617 "rec_eval rec_state [cf] = State cf" |
|
618 by (simp add: rec_state_def) |
|
619 |
|
620 lemma left_lemma [simp]: |
|
621 "rec_eval rec_left [cf] = Left cf" |
|
622 by (simp add: rec_left_def) |
|
623 |
|
624 lemma right_lemma [simp]: |
|
625 "rec_eval rec_right [cf] = Right cf" |
|
626 by (simp add: rec_right_def) |
|
627 |
|
628 lemma step_lemma [simp]: |
|
629 "rec_eval rec_step [cf, m] = Step cf m" |
|
630 by (simp add: Let_def rec_step_def) |
|
631 |
|
632 lemma steps_lemma [simp]: |
|
633 "rec_eval rec_steps [n, cf, p] = Steps cf p n" |
|
634 by (induct n) (simp_all add: rec_steps_def Step_Steps_comm del: Step.simps) |
|
635 |
|
636 lemma stknum_lemma [simp]: |
|
637 "rec_eval rec_stknum [z] = Stknum z" |
|
638 by (simp add: rec_stknum_def Stknum_def lessThan_Suc_atMost[symmetric]) |
|
639 |
|
640 lemma left_std_lemma [simp]: |
|
641 "rec_eval rec_left_std [z] = (if left_std z then 1 else 0)" |
|
642 by (simp add: Let_def rec_left_std_def left_std_def) |
|
643 |
|
644 lemma right_std_lemma [simp]: |
|
645 "rec_eval rec_right_std [z] = (if right_std z then 1 else 0)" |
|
646 by (simp add: Let_def rec_right_std_def right_std_def) |
|
647 |
|
648 lemma std_lemma [simp]: |
|
649 "rec_eval rec_std [cf] = (if Std cf then 1 else 0)" |
|
650 by (simp add: rec_std_def) |
|
651 |
|
652 lemma final_lemma [simp]: |
|
653 "rec_eval rec_final [cf] = (if Final cf then 1 else 0)" |
|
654 by (simp add: rec_final_def) |
|
655 |
|
656 lemma stop_lemma [simp]: |
|
657 "rec_eval rec_stop [m, cf, k] = (if Stop m cf k then 1 else 0)" |
|
658 by (simp add: Let_def rec_stop_def) |
|
659 |
|
660 lemma halt_lemma [simp]: |
|
661 "rec_eval rec_halt [m, cf] = Halt m cf" |
|
662 by (simp add: rec_halt_def del: Stop.simps) |
|
663 |
668 lemma uf_lemma [simp]: |
664 lemma uf_lemma [simp]: |
669 "rec_eval rec_uf [m, cf] = UF m cf" |
665 "rec_eval rec_uf [m, cf] = UF m cf" |
670 by (simp add: rec_uf_def) |
666 by (simp add: rec_uf_def) |
671 |
667 |
672 |
668 |