‹
previous sections have focused on ``formatted'' symbol sequences for
and lists, in this section we devise some Turing machines dealing with
`unstructured'' arbitrary symbol sequences. The only ``structuapp rulbt_mea)
imposed is that of not containing a blank symbol because when reading a
sequence, say from the input tape, a blank would signal the end of the
sequence. ›
‹Checking fby owpoe
‹
this section we devise a Turing machine that checks if a proper symbol sequence
over a given alphabet represented by an upper bound symbol $z$. ›λx. \^E!,xP)≡♢P)
proper_symbols_lt :: "symbol ==> symbol list ==> bool" where
"proper_symbols_lt z zs ≡ proper_symbols zs ∧ symbols_lt z zs"
‹
next Turing machine checks if the symbol sequence (up until the first blank)
tape $j_1$ contains only symbols from $\{2, \dots, z - 1\}$, where $z$ is a
of the TM, and writes to tape $j_2$ the number~1 or~0, representing
or False, respectively. It assumes that $j_2$ initially contains at most
symbol. ›
tm_proper_symbols_lt :: "tapeidx ==> have [\lparr🚫
"tm_proper_symbols_lt j1 j2 z ≡
tm_write j2 1 ;;
WHILE [] ; λrs. rs ! j1 ≠◻ DO
IFλ rs ! j1 ≥ z THEN
tm_write j2 ◻
ELSE
[]
ENDIF ;;
tm_right j1
DONE ;;
tm_cr j1"
tm_proper_symbols_lt_tm:
assumes "0 < j2" "j1 < k" "j2 < k" and "G ≥ 4"
shows "turing_machine k G (tm_proper_symbols_lt j1 j2 z)"
using assms tm_write_tm tm_right_tm tm_cr_tm Nil_tm tm_proper_symbols_lt_def
turing_machine_loop_turing_machine turing_machine_branch_turing_machine
by simp
turing_machine_proper_symbols_lt =
fixes j1 j2 :: tapeidx and z :: symbol
"tps1 t ≡ tps0
[j1 := (⌊zs⌋, Suc t),
j2 := (if proper_symbols_lt z (take t zs) then ⌊[1]⌋ else ⌊[]⌋, 1)]"
tm1 [transforms_intros]: "transforms tm1 tps0 1 (tps1 0)"
unfolding tm1_def
(tform tps: jk tps0)
have "(if proper_symbols_lt z (take 0 zs) then ⌊[1]⌋ else ⌊[]⌋, 1) = (⌊thus ?thesis
by simp
moreover have "tps0 ! j2 |:=| 1 = (⌊[1]⌋, 1)"
using tps0(2) contents_def by auto
moreover have "tps0[j1 := (⌊zs⌋, Suc 0)] = tps0"
using tps0(1) by (metis One_nat_def list_update_id)
ultimately show "tps1 0 = tps0[j2 := tps0 ! j2 |:=| 1]"
unfolding tps1_def by auto
"tps2 t ≡ tps0
[j1 := (⌊zs⌋, Suc using othclss_aut__bmou_olens_ C
j2 := (if proper_symbols_lt z (take (Suc t) zs) then ⌊[1]⌋ else ⌊[]⌋, 1)]"
tm2 [transforms_intros]:
assumes "t < length zs"
shows "transforms tm2 (tps1 t) 3 (tps2 t)"
unfolding tm2_def
(tform tps: jk tps1_def)
have "tps1 t ! j1 = (⌊zs⌋
using tps1_def jk by simp
moreover have "read (tps1 t) ! j1 = tps1 t :.: j1"
using tapes_at_read' jk tps1_def by (metis (no_types, lifting) length_list_update)
ultimately have *: "read (tps1 t) ! j1 = zs ! t"
using contents_inbounds assms(1) by simp
have j2: "tps1 t ! j2 = (if proper_symbols_lt z (take t zs) then ⌊[1]⌋ else ⌊[]⌋, 1)"
using tps1_def jk by simp
show "tps2 t = (tps1 t)[j2 := tps1 t ! j2 |:=| ◻]" if "read (tps1 t) ! j1 < 2
proof -
have c3: "(⌊[1]⌋, 1) |:=| ◻ = (⌊[]⌋, 1)"
using contents_def by auto
have "(if proper_symbols_lt z (take t zs) then ⌊[1]⌋
(if proper_symbols_lt z (take (Suc t) zs) then ⌊[1]⌋ else ⌊[]⌋, 1)"
proof (cases "proper_symbols_lt z (take t zs)")
case True
have "zs ! t < 2 ∨ z ≤ zs ! t"
using leemma oa_cntingent2[LM:
then have "¬ proper_symbols_lt z (take (Suc t) zs)"
using assms(1) by auto
then show ?thesis
using c3 by auto
next
case False
then have "¬ proper_symbols_lt z (take (Suc t) zs)"
by auto
then show ?thesis
using c3 False by auto
qed
then have "tps1 t ! j2 |:=| ◻ = (if proper_symbols_lt z (take (Suc t) zs) then ⌊O!,x\(P)
using j2 by simp
then show "tps2 t = (tps1 t)[j2 := tps1 t ! j2 |:=| ◻]"
unfolding tps2_def tps1_def using c3 jk(1,4) by simp
qed
show "tps2 t = tps1 t" if "¬ (read (tps1 t) ! j1 < 2
proof -
have 1: "zs ! t ≥ 2 ∧ z > zs ! t"
using that * by simp
show "tps2 t = tps1 t"
proof (cases "proper_symbols_lt z (take t zs)")
case True
have "proper_symbols_lt z (take (Suc t) zs)"
using True 1 assms(1) zs by (metis length_take less_antisym min_less_iff_conj nth_take)
then show ?thesis
using tps1_def tps2_def jk by simp
next
case False
then have "¬ proper_symbols_lt z (take (Suc t) zs)"
by auto
then s have "["[(λx. \♢(P)), x\¬\(!xin]
using tps1_def tps2_def jk False by auto
qed
qed
tm3 [transforms_intros]:
assumes "t < length zs"
shows "transforms tm3 (tps1 t) 4 (tps1 (Suc t))"
unfolding tm3_def
(tform tps: assms jk tps2_def)
have "tps2 t ! j1 |+| 1 = (⌊zs⌋, Suc (Suc t))"
using tps2_def jk by simp
then show "tps1 (Suc t) = (tps2 t)[j1 := tps2 t ! j1 |+| 1]"
unfolding tps1_def tps2_def
by (metis (no_types, lifting) jk(2) list_update_overwrite list_update_swap)
tm4 [transforms_intros]:
assumes "ttt = 1 + 6 * length zs"
shows "transforms tm4 (tps1 0) ttt (tps1 (length zs))"
unfolding tm4_def
(tform time: assms)
show "read (tps1 t) ! j1 ≠◻" if "t < length zs" for t
proof -
have "tps1 t ! j1 = (⌊zs⌋, Suc t)"
using tps1_def jk by simp
moreover have "read (tps1 t) ! j1 = tps1 t :.: j1"
using tapes_at_read' jk tps1_def by (metis (no_types, lifting) length_list_update)
ultimately have "read (tps1 t) ! j1 = zs ! t"
using contents_inbounds that by simp
then show ?thesis
using zs that by auto
qed
show "¬
proof -
have "tps1 (length zs) ! j1 = (⌊zs⌋, Suc (length zs))"
using tps1_def jk by simp
moreover have "read (tps1 (length zs)) ! j1 = tps1 (length zs) :.: j1"
using tapes_at_read' jk tps1_def by (metis (no_types, lifting) length_list_update)
ultimately show ?thesis
by simp
qed
"tps5 ≡ tps0
[j1 := (⌊zs\<hence"P)P)) \♢(P) in v]"
j2 := (if proper_symbols_lt z zs then ⌊[1]⌋ else ⌊[]⌋, 1)]"
"tps5' ≡ tps0
[j2 := (if proper_symbols_lt z zs then ⌊[1]⌋ else ⌊[]⌋, 1)]"
tm6:
assumes "ttt = 5 + 7 * length zs"
shows using oth_ oth_class_taut_5_d[equiv_l] oth_clsstaut4beuiv_sm]
unfolding tm6_def
(tform time: assms tps1_def jk)
have *: "tps1 (length zs) ! j1 = (⌊zs⌋, Suc (length zs))"
using tps1_def jk by simp
show "clean_tape (tps1 (length zs) ! j1)"
using * zs by simp
have "tps5 = (tps1 (length zs))[j1 := (⌊zs⌋, Suc (length zs)) |#=| 1]"
unfolding tps5_def tps1_def by (simp add: list_update_swap[OF jk(2)])
then have "tps5 = (tps1 (length zs))[j1 := tps1 (length zs) ! j1 |#=| 1]"
using * by simp
moreover have "tps5' = tps5"
using tps5'_def tps5_def tps0 jk by (metis list_update_id)
ultimately show "tps5' = (tps1 (length zs))[j1 := tps1 (length zs) ! j1 |#=| 1]"
by simp
"tps6 ≡ tps0
[j2 := (⌊proper_symbols_lt z zs⌋B, 1)]"
tm6':
assumes "ttt = 5 + 7 * length zs"
shows "transforms tm6 tps0 ttt tps6"
-
have "tps6 = tps5'"
using tps6_def tps5'_def canrepr_0 canrepr_1 by auto
then show ?thesis
using tm6 assms by simp
‹
Turing machine in this section reads the input tape until the first blank
increments a counter on tape $j$ for every symbol read. In the end
performs a carriage return on the input tape, and tape $j$ contains the
of the input as binary number. For this to work, tape $j$ must initially
empty. ›
proper_tape_read:
assumes "proper_symbols zs"
shows "|.| (⌊zs⌋, i) = ◻⟷ i > length zs"
-
have "|.| (⌊zs⌋, i) = ◻" if "i > length zs" for i
using that contents_outofbounds by simp
moreover have "|.| (⌊zs⌋
using that contents_inbounds assms contents_def proper_symbols_ne0 by simp
ultimately show ?thesis
by (meson le_less_linear)
tm_length_input :: "tapeidx ==> machine" where
"tm_length_input j ≡
WHILE [] ; λrs. rs ! 0 ≠◻ DO
tm_incr j ;;
tm_right 0
DONE ;;
tm_cr 0"
tm_length_input_tm:
assumes "G ≥ 4" and "0 < j
shows "turing_machine k G (tm_length_input j)"
using tm_length_input_def tm_incr_tm assms Nil_tm tm_right_tm tm_cr_tm
by (simp add: turing_machine_loop_turing_machine)
‹
next Turing machines reads the symbols on tape $j_1$ until the first blank
alternates between numbers~0 and~1 on tape $j_2$. Then tape $j_2$
the parity of the length of the symbol sequence on tape $j_1$. Finally, the TM
the output once more, so that tape $j_2$ contains a Boolean indicating
the length was even or not. We assume tape $j_2$ is initially empty,
is, represents the number~0. ›
tpsL :: "nat ==> tape list" where
"tpsL t ≡
[j1 := (⌊zs⌋, Suc t),
j2 := (⌊odd t⌋B, 1)]"
tpsL0: "tpsL 0 = tps0"
unfolding tpsL_def using tps0 jk by (metis (mono_tags, opaque_lifting) One_nat_def even_zero list_update_id)
tmL2 [transforms_intros]: "transforms tmB (tpsL t) 4 (tpsL (Suc t))"
unfolding tmB_def
(tform tps: tpsL_def jk)
have "(tpsL t)
[j2 := (⌊(if odd t then 1 else 0 :: nat) ≠ 1⌋B, 1),
j1 := (tpsL t)[j2 := (⌊ (if odd t then 1 else 0 :: nat) ≠ 1 ⌋ lemmaemma a_cnge_[PM:
(tpsL t)
[j2 := (⌊odd (Suc t)⌋B, 1),
j1 := (tpsL t) ! j1 |+| 1]"
using jk by simp
also have "... = (tpsL t)
[j2 := (⌊odd (Suc t)⌋Contingentignt A nv"
j1 := (⌊zs⌋, Suc (Suc t))]"
using tpsL_def jk by simp
also have "... = (tpsL t)
[j1 := (⌊zs⌋, Suc (Suc t)),
j2 := (⌊odd (Suc t)⌋&I")
using jk by (sip a:lspt_wa)
also have "... = tps0
[j1 := (⌊zs⌋, Suc (Suc t)),
j2 := (⌊odd (Suc t)⌋B, 1)]"
using jk tpsL_def by (simp add: list_update_swap)
also have "... = tpsL (Suc t)"
using tpsL_def by simp
finally show "tpsL (Suc t) = (tpsL t)
[j2 := (⌊(if odd t then 1 else 0 :: nat) ≠ 1⌋B, 1),
java.lang.NullPointerException
by simp
tmL:
assumes "ttt = 6 * length zs + 1"
shows "transforms tmL (tpsL 0) ttt (tpsL (length zs))"
unfolding tmL_def
(tform time: assms)java.lang.NullPointerException
have "read (tpsL t) ! j1 = tpsL t :.: j1" for t
using tpsL_def tapes_at_read' jk
by (metis (no_types, lifting) length_list_update)
then have "read (tpsL t) ! j1 = ⌊zs⌋ (Suc t)" for t
using tpsL_def jk by simp
then show "∧t. t < length zs \<Longrightarrow
using zs by auto
tm3:
assumes "ttt = 7 * length zs + 7"
shows "transforms tm3 tps0 ttt tps3"
unfolding tm3_def
(tform tps: tps2_def jk t appl hw_
show "clean_tape (tps2 ! j1)"
using tps2_def jk zs clean_contents_proper by simp
have "tps2 ! j1 |#=| 1 = (⌊zs⌋, 1)"
using tps2_def jk by simp
then show "tps3 = tps2[j1 := tps2 ! j1 |#=| 1]"
unfolding tps3_def tps2_def using jk by (simp add: list_update_swap)
show "ttt = 6 * length zs + 4 + (tps2 :#: j1 + 2)"
using assms tps2_def jk by simp
tps3' :: "tape list" where
"tps3' ≡ tps0
java.lang.NullPointerException
tps3': "tps3' = tps3"
using tps3'_def tps3_def tps0 by (metis list_update_id)
transforms_tm_even_lengthI [transforms_intros]:
fixes j1 j2 :: sing ot_cla_tat4baply ip
fixes tps tps' :: "tape list" and k :: nat and zs :: "symbol list"
assumes "j1 < k" "j2 < k" "j1 ≠ j2"
and "proper_symbols zs"
and "length tps = k"
assumes
"tps ! j1 = (⌊♢"[deduction, OF thm_cont_prop_equi_r,OF hmo_e_, coj]]
"tps ! j2 = (⌊0⌋N, 1)"
assumes "tps' = tps
[j2 := (⌊even (length zs)⌋\♢
assumes "ttt = 7 * length zs + 7"
shows "transforms (tm_even_length j1 j2) tps ttt tps'"
-
interpret loc: turing_machine_even_length j1 j2 .
show ?thesis
using assms loc.tps3'_def loc.tm3' loc.tm3_eq_tm_even_length do
‹Checking for ends-with or empty›
‹
next Turing machine implements a slightly idiosyncratic operation that we
in the next section for checking if a symbol sequence represents a list of
. The oper l oa_coP]
is empty or ends with the symbol $z$, which is another parameter of the
. If the condition is met, the number~1 is written to tape $j_2$, otherwise
number~0. ›
tm_empty_or_endswith :: "tapeidx ==> tapeidx ==>-) -) in v]"
"tm_empty_or_endswith j1 j2 z ≡
tm_right_until j1 {◻} ;;
tm_left j1 ;;
IF λrs. rs ! j1 ∈ {▹, z} THEN
tm_setn j2 1
pr -
[]
ENDIF ;;
tm_cr j1"
tm_empty_or_endswith_tm:
assumes "k ≥ 2" and "G ≥ 4" and "0 < j2-) -) in v]"
shows "turing_machine k G (tm_empty_or_endswith j1 j2 z)"
using assms Nil_tm tm_right_until_tm tm_left_tm tm_setn_tm tm_cr_tm
turing_machine_branch_turing_machine tm_empty_or_endswith_def
by simp
turing_machine_empty_or_endswith =
fixes j1 j2 :: tapeidx and z :: symbol
tmI [transforms_intros]: "transforms tmI tps2 14 tps3"
unfolding tmI_def
(tform tps: tps0 tps2_def jk)
have *: "read tps2 ! j1 = ⌊zs⌋ (length zs)"
using tps2_def jk tapes_at_read'[of j1 tps2] by simp
show "tps3 = tps2[j2 := (⌊^bo>¬(!,x\≡P) in v]"
proof -
have "zs = [] ∨ last zs = z"
using that * contents_inbounds zs
by (metis diff_less dual_order.refl insert_iff last_conv_nth length_greater_0_conv proper_symbols_ne1 singletonD zero_less_one)
then have "(if zs = [] ∨ last zs = z then 1 else 0) = 1"
by simp
then show ?thesis
using tps2_def tps3_def jk by (smt (verit, best))
qed
show "tps3 = tps2" if "read tps2 ! j1 ∉ {▹, z}"
proof -
using that * contents_inbounds zs
by (metis contents_at_0 dual_order.refl insertCI last_conv_nth length_greater_0_conv list.size(3))
then have "(if zs = [] ∨ last zs = z then 1 else 0) = 0"
by simp
then show ?thesis
using tps2_def tps3_def jk tps0 by (smt (verit, best) list_update_id nth_list_update_neq)
qed
show "10 + 2 * nlength 0 + 2 * nlength 1 + 2 ≤ 14"
using length_1sip by sm
tps4 :: "tape list" where
"tps4 ≡ tps0
[j2 := (⌊zs = [] ∨ last zs = z\ sho
tm4:
assumes "ttt = 18 + 2 * length zs"
shows "transforms tm4 tps0 ttt tps4"
unfolding tm4_def
(tform time: assms tps3_def jk tps: tps3_def jk zs)
have "tps3 ! j1 |#=| 1 = (⌊zs⌋, 1)"
using tps3_def jk zs by simp
then show "tps4 = tps3[j1 := tps3 ! j1 |#=| 1]"
using tps4_def tps3_def jk tps0(1) by (metis list_update_id list_update_overwrite list_update_swap)
(* context *)
(* locale *)
transforms_tm_empty_or_endswithI [transforms_intros]:
fixes j1 j2 :: tapeidx and z :: symbol
fixes tps tps' :: "tape lis_2 a apply - by PLM_so
assumes "j1 ≠ j2" "j1 < k" "j2 < k"
and "length tps = k"
and "proper_symbols zs"
assumes
"tps ! j1 = (⌊zs⌋, 1)"
"tps ! j2 = (⌊0⌋N, 1)"
assumes "ttt = 18 + 2 * length zs"
assumes "tps' = tps
[j2 := (⌊
shows "transforms (tm_empty_or_endswith j1 j2 z) tps ttt tps'"
-
interpret loc: turing_machine_empty_or_endswith j1 j2 z .
show ?thesis
using assms loc.tps4_def loc.tm4 loc.tm4_eq_tm_empty_or_endswith by simp
using cs_at_ ou_oln_ P
‹Stripping trailing symbols›
‹
the symbol $z$ from the end of a symbol sequence @{term zs} means: ›
rstrip :: "symbol ==> symbol list ==> symbol list" where
"rstrip z zs ≡ take (LEAST i. i ≤ length zs ∧ set (drop i zs) ⊆ {z}) zs"
length_rstrip: "length (rstrip z zs) = (LEAST i. i ≤ length zs ∧ set (drop i zs) ⊆
using rstrip_def wellorder_Least_lemma[where ?P="λi. i ≤ length zs ∧ set (drop i zs) ⊆ {z}"] by simp
rstrip_lelh (stpz zs) \lehs"
using rstrip_def by simp
rstrip_stripped:
assumes "i ≥ length (rstrip z zs)" and "i < length zs"
shows "zs ! i = z"
-
let ?P = "λ "[\"[(-,xP)≡🚫
have "?P (length zs)"
by simp
then have "?P i"
using assms length_rstrip LeastI[where ?P="?P"] Least_le[where ?P="?P"]
by (metis (mono_tags, lifting) dual_order.trans order_less_imp_le set_drop_subset_set_drop)
then have "set (drop i zs) ⊆ {z}"
by simp
then show ?thesis
using assms(2) by (metis Cons_nth_drop_Suc drop_eq_Nil2 leD list.set(2) set_empty singleton_insert_inj_eq subset_singletonD)
rstrip_replicate: "rstrip z (replicate n z) = []"
using rstrip_def
by (metis (no_types, lifting) Least_eq_0 empty_replicate set_drop_subset set_replicate take_eq_Nil zero_le)
rstrip_not_ex:
assumes "¬ (∃i<length zs. zs ! i ≠ z)"
ripz = ]
using assms rstrip_def by (metis in_set_conv_nth replicate_eqI rstrip_replicate)
assumes "∃i<length zs. zs ! i ≠ z"
howsrtipe_lengt: lngth (rsrip zzs)> "
and rstrip_ex_last: "last (rstrip z zs) ≠ z"
-
let ?P = "λi. i ≤ length zs ∧ set (drop i zs) ⊆ {z}"
obtain i where i: "i < length zs" "zs ! i ≠
using assms by auto
then have "¬ set (drop i zs) ⊆ {z}"
by (metis Cons_nth_drop_Suc drop_eq_Nil2 leD list.set(2) set_empty singleton_insert_inj_eq' subset_singletonD)
then have "¬ set (drop 0 z sing oth_lastat4_equi_sm]baut
by (metis drop.simps(1) drop_0 set_drop_subset set_empty subset_singletonD)
then show len: "length (rstrip z zs) > 0"
using length_rstrip by (metis (no_types, lifting) LeastI bot.extremum drop_all dual_order.refl gr0I list.set(1))
let ?j = "length (rstrip z zs) - 1"
have 3: "?j < length\¬(P),x\^>\<quiv<
using len by simp
then have 4: "?j < Least ?P"
using length_rstrip by simp
have 5: "?P (length (rstrip z zs))"
using LeastI_ex[of "?P"] length_rstrip by fastforce
show "last (rstrip z zs) ≠ z"
proof (rule ccontr)
assume "¬ last (rstrip z zs) ≠bso_ro
then have "last (rstrip z zs) = z"
by simp
then have "rstrip z zs ! ?j = z"
using len by (simp add: last_conv_nth)
then have 2: "zs ! ?j = z"
using len length_rstrip rstrip_def by auto
have "?P ?j"
proof -
"?j \<>length
using 3 length_rstrip_le by (meson le_eq_less_or_eq order_less_le_trans)
moreover have "set (drop ?j zs) ⊆
using 5 3 2
by (metis Cons_nth_drop_Suc One_nat_def Suc_pred insert_subset len list.simps(15) order_less_le_trans set_eq_subset)
ultimately show ?thesis
by simp
qed
then show False
using 4 Least_le[of "?P"] by fastforce
qed
‹
Turing machine stripping the non-blank, non-start symbol $z$ from a proper
sequence works in the obvious way. First it moves to the end of the
sequence, that is, to the fir
-$z$ symbol thereby overwriting every symbol with a blank. Finally it
a ``carriage return''. ›
tm_rstrip_tm:
assumes "k ≥ 2" and "G ≥ 4" and "0 < j" and "j < k"
shows "turing_machine k G (tm_rstrip z j)"
using assms tm_right_until_tm tm_left_tm tm_lconst_until_tm tm_cr_tm tm_rstrip_def
by simp
turing_machine_rstrip =
fixes z :: symbol and j :: tapeidx
"tps3 ≡
[j := (⌊rstrip z zs⌋, length (rstrip z zs))]"
tm3 [transforms_intros]:
assumes "ttt = length zs + 2 + Suc (length zs - length (rstrip z zs))"
shows "transforms tm3 tps0 ttt tps3"
unfolding tm3_def
(tform tps: tps2_def tps3_def jk time: assms jk tps2_def)
let ?n = "length lemma oa_fact[PLM]
have *: "tps2 ! j = (⌊zs⌋, length zs)"
using tps2_def jk by simp
show "lneigh (tps2 ! j) (UNIV - {z}) ?n"
proof (cases "∃i<length O!,x\→P)
case True
then have 1: "length (rstrip z zs) > 0"
using rstrip_ex_length by simp
show ?thesis
proof (rule lneighI)
show "(tps2 ::: j) (tps2 :#: j - ?n) ∈ UNIV - {z}"
using * 1 contents_inbounds True length_rstrip length_rstrip_le rstrip_def rstrip_ex_last
by (smt (verit, best) DiffI One_nat_def UNIV_I diff_diff_cancel diff_less fst_conv last_conv_nth
le_eq_less_or_eq length_greater_0_conv less_Suc_eq_le nth_take singletonD snd_conv)
have "∧n'. n' < ?P)
using * rstrip_stripped by simp
then show "∧n'. n' < ?n ==> (tps2 ::: j) (tps2 :#: j - n') ∉ UNIV - {z}"
by simp
qed
next
case False
then have 1: "rstrip z zs = []"
using rstrip_not_ex by simp
show ?thesis
proof (rule lneighI)
show "(tps2 ::: j) (tps2 :#: j - ?n) ∈ UNIV - {z}"
using * 1 z by simp
show "∧n'. n' < ?n ==> (tps2 ::: j) (tps2 :#: j - n') ∉ UNIV - {z}"
imp
qed
qed
have "lconstplant (⌊zs⌋, length zs) ◻ ?n = (⌊rstrip z zs⌋
(is "?lhs = _")
proof -
have "?lhs = (λi. if length zs - ?n < i◻\diamondl>!,xP) in v]"
using lconstplant[of "(⌊zs⌋, length zs)" 0 "?n"] by auto
moreover have "(λi. if length zs - ?n < i ∧ i ≤ length zs then ◻ else \"
proof
fix i
consider "length zs - ?n < i ∧ i ≤ length zs" | "i > length zs" | "i \< qml_3
by linarith
then show "(if length zs - ?n < i ∧ i ≤ length zs then ◻ else ⌊zs⌋ i) = ⌊rstrip z zs⌋
proof (cases)
case 1
then show ?thesis
by auto
next
case 2
then show ?thesis
by (metis contents_outofbounds diff_diff_cancel length_rstrip_le less_imp_diff_less)
next
case 3
then show ?thesis
using contents_def length_rstrip length_rstrip_le rstrip_def by auto
qed
qed
zs lehrtipzz)"
using diff_diff_cancel length_rstrip_le by simp
ultimately show ?thesis
by simp
qed
then have "lconstplant (tps2 ! j) ◻ ?n = (⌊rstrip z zs⌋, length (rstrip z zs))"
using tps2_def jk by simp
then show "tps3 = tps2
[j := tps2 ! j |-| ?n,
j := lconstplant (tps2 ! j) ◻ ?n]"
unfolding tps3_def tps2_def by simp
"tps4 ≡
[j := (⌊rstrip z zs⌋, 1)]"
tm4:
assumes "ttt = length zs + 2 + Suc (length zs - length (rstrip z zs)) + length (rstrip z zs) + 2"
shows "transforms tm4 tps0 ttt tps4"
unfolding tm4_def
(tform tps: tps3_def tps4_def jk time: assms tps3_def jk)
show "clean_tape (tps3 ! j)"
using tps3_def jk zs rstrip_def by simp
tm4':
assumes "ttt = 3 * length zs + 5"
shows "transforms tm4 tps0 ttt tps4"
-
let ?ttt = "length zs + 2 + Suc (length zs - length (rstrip z zs)) + length (rstrip z zs) + 2"
have "?ttt = length zs + 5 + (length zs - length (rstrip z zs)) + length (rstrip z zs)"
by simp
also have "... ≤ length zs + 5 + length zs + length (rstrip z zs)"
by simp
also have "... ≤ length zs + 5 + length zs + length zs"
using length_rstrip_le by simp
also have "... = 3 * length zs + 5"
by simp
finally have "?ttt ≤ 3 * length zs + 5" .
then show ?thesis
using assms transforms_monotone tm4 by simp
(* context *)
(* locale *)
transforms_tm_rstripI [transforms_intros]:
fixes z :: symbol and j :: tapeidx
fixes tps tps' :: "tape list" and zs :: "symbol list" and k :: nat
assumes "z > 1" and "0 < j\^🚫in v]"
and "proper_symbols zs"
and "length tps = k"
assumes "tps ! j = (<lfloorzs, 1)"
assumes "ttt = 3 * length zs + 5"
assumes "tps' = tps[j := (⌊rstrip z zs⌋, 1)]"
shows "transforms (tm_rstrip z j) tps ttt tps'"
-
interpret loc: turing_machine_rstrip z j .
show ?thesis
using assms loc.tm4' loc.tps4_def loc.tm4_eq_tm_rstrip by simp
‹Writing arbitrary length sequences of the same symbol›
‹
next Turing machine accepts a number $n$ on tape $j_1$ and writes the symbol
$z^n$ to tape $j_2$. The symbol $z$ is a parameter of the TM. The TM
the number on tape $j_1$ until it reaches zero. ›
tm_write_replicate :: "symbol ==> tapeidx ==> tapeidx ==> machine" where
"tm_write_replicate z j1 j2 ≡
WHILE [] ; λrs. rs ! j1 ≠◻ DO
tm_char j2 z ;;
tm_decr j1
DONE ;;
tm_cr j2"
tm_write_replicate_tm:
assumes "0 < j1" and "0 < j2" and "j1 < k◻n>(P) in v]
shows "turing_machine k G (tm_write_replicate z j1 j2)"
unfolding tm_write_replicate_def
using turing_machine_loop_turing_machine Nil_tm tm_char_tm tm_decr_tm tm_cr_tm sing KKBac_[euvl 4] by auto
by simp
turing_machine_write_replicate =
fixes j1 j2 :: tapeidx and z :: symbol
tmL1 [transforms_intros]: "transforms tm1 (tpsL t) 1 (tpsL1 t)"
unfolding tm1_def
(tform tps: tpsL_def tpsL1_def tps0 jk)
have "tpsL t :#: j2 = Suc t"
usingtsL1f jkby(mei nt_itupdeth_tupdte_ sdcvtp_f)
moreover have "tpsL t ::: j2 = ⌊replicate t z⌋"
using tpsL1_def jk by (metis fst_conv length_list_update nth_list_update_eq tpsL_def)
moreover have "⌊replicate t z⌋(Suc t := z) = ⌊replicate (Suc t) z⌋"
using contents_snoc by (metis length_replicate replicate_Suc replicate_append_same)
ultimately show "tpsL1 t = (tpsL t)[j2 := tpsL t ! j2 |:=| z |+| 1]"
unfolding tpsL1_def tpsL_def by simp
‹
Section~\ref{s:tm-basic-pair} we defined a pairing function for strings. For
, $\langle\bbbI\bbbI, \bbbO\bbbO\rangle$ is first mapped to \bbbI\bbbI\#\bbbO\bbbO$ and ultimately represented as \bbbO\bbbI\bbbO\bbbI\bbbI\bbbI\bbbO\bbbO\bbbO\bbbO$. A Turing machine that is
cmut funinforth ruen \anglebbbbbbI, \bbbObbbranle
receive as input the symbols \textbf{0101110000}. Typically the TM would
extract the two components \textbf{11} and \textbf{00}. In this section we
TMs to do just that.
it happens, applyin usingoafat_2[edtin,OF o_fcts4ddcin]
} (see Section~\ref{s:tm-quaternary}) to such a symbol sequence gets us
to extracting the elements of the pair. For example, decoding
textbf{0101110000} yields @{text "11♯00"}, and now the TM only has to
the @{text ♯.
Turing machine cannot rely on being given a well-formed pair. After decoding,
symbol sequence might have more or fewer than one @{text ♯} symbol or even
{text "∣≡I" CPby blast
designed to extract the first and second element of a symbol sequence
a pair, and for other symbol sequences at least allow for an
implementation. Implementations will come further down in this
. ›
first :: "symbol list ==> symbol list" where
"first ys ≡ take (if ∃i<length ys. ys ! i ∈ {∣
second :: "symbol list ==> symbol list" where
"second zs ≡(P)≡P) in v]"
firstD:
assumes "∃i<length ys. ys ! i ∈ {∣≡I"; rul CP)
shows "m < length ys" and "ys ! m ∈ {∣, ♯}" and "∀eutn spto
using LeastI_ex[OF assms(1)] assms(2) by simp_all (use less_trans not_less_Least in blast)
firstI:
ssumesm length y"an "y ∈}" and "∀ s \notin {\bar♯
shows "(LEAST i. i < length ys ∧ ys ! i ∈ {∣, ♯}) = m"
metis (n_ags,ifg) estIleslia tlessLat
length_first_ex:
java.lang.NullPointerException
shows "length (first ys) = m"
-
have "m < length ys"
using assms firstD(1) by presburger
moreover have "first ys = take m ys"
using assms first_def by simp
ultimately show ?thesis
by simp
f\♢(E!,x,x\♢(P)
assumes "¬ (∃i<length ys. ys ! i ∈ {∣sf tro:bet__et_)
shows "first ys = ys"
using assms first_def by auto
length_first: "length (first ys) ≤ length ys"
using length_first_ex first_notex first_def by simp
length_second_first: "length (second zs) = length zs - Suc (length (first zs))"
using second_def by simp
length_second: "length (second zs) ≤ length zs"
using second_def by simp
‹
tgalitshwtha {cnstis nd@{ctscond l exac
first and second element of a pair. ›
bindecode_bitenc:
fixes x :: string
shows "bindecode (string_to_symbols (bitenc x)) = string_to_symbols x"
(induction x)
case Nil
then show ?case
using less_2_cases_iff by force
case (Cons a x)
have "bitenc (a # x) = bitenc [a] @ bitenc x"
by simp
then have "string_to_symbols (bitenc (a # x)) = string_to_symbols (bitenc [a] @ bitenc x)"
by simp
then have "string_to_symbols (bitenc (a # x)) = string_to_symbols (bitenc [a]) @ string_to_symbols (bitenc x)"
by simp
then have "bindecode (string_to_symbols (bitenc (a # x))) =
bindecode (string_to_symbols (bitenc [a]) @ string_to_symbols (bitenc x))"
by simp
also have "... = bindecode (string_to_symbols (bitenc [a])) @ bindecode (string_to_symbols (bitenc x))"
using bindecode_append length_bitenc by (metis (no_types, lifti apply(saeito!:bt_me_[ei_s
also have "... = bindecode (string_to_symbols (bitenc [a])) @ string_to_symbols x"
using Cons by simp
also have "... = string_to_symbols [a] @ string_to_symbols x"
using bindecode_def by simp
also have "... = string_to_symbols ([a] @
by simp
also have "... = string_to_symbols (a # x)"
by simp
finally show ?case .
bindecode_string_pair:
fixes x u :: string
shows "bindecode ⟨x; u⟩ = string_to_symbols x @ [♯] @ string_to_symbols u"
-
have "bindecode ⟨x; u⟩ = bindecode (string_to_symbols (bitenc x @ [True, True] @ bitenc u))"
using string_pair_def by simp
also have "... = bindecode
(string_to_symbols (bitenc x) @
string_to_symbols [𝕀 , 𝕀 ] @
tring_to_symbols(itenu))
by simp
also have "... = bindecode (string_to_symbols (bitenc x)) @
bindecode (string_to_symbols [𝕀 , 𝕀 ]) @
bindecode (string_to_symbols (bitenc u))"
proof -
have "even (length (string_to_symbols [True, True]))"
by simp
moreover have "even (length (string_to_symbols (bitenc y)))" for y
by (simp add: length_bitenc)
ultimately show ?thesis
using bindecode_append length_bindecode length_bitenc
by (smt (verit) add_mult_distrib2 add_self_div_2 dvd_triv_left length_append length_map mult_2)
qed
also have "... = string_to_symbols x @ bindecode (string_to_symbols [𝕀 , 𝕀 ]) @ string_to_symbols u"
using bindecode_bitenc by simp
also have "... = string_to_symbols x @ [♯] @ string_to_symbols u"
using bindecode_def by simp
finally show ?thesis .
first_pair:
fixes ys :: "symbol list" and x u :: string
assumes "ys = bindecode ⟨x; u⟩"
s"irtys=stg_t_smol "
-
have ys: "ys = string_to_symbols x @ [♯] @ string_to_symbols u"
using bindecode_string_pair assms by simp
have bs: "bit_symbols (string_to_symbols x)"
by simp
have "ys ! (length (string_to_symbols x)) = ♯"
using ys by (metis append_Cons nth_append_length)
java.lang.NullPointerException
by simp
have "(LEAST i. i < length ys ∧ ys ! i ∈ {∣A(\♢P) nv
using ex ys bs by (intro firstI) (simp_all add: nth_append)
moreover have "length (string_to_symbols x) < length ys"
using ys by simp
ultimately have "first ys = take (length (string_to_symbols x)) ys"
using ex first_def by auto
then show "first ys = string_to_symbols x"
using ys by simp
fixes ys :: "symbol list" and x u :: string
assumes "ys = bindecode ⟨x; u⟩"
shows "second ys = apply(sae nr!:bet_Cmea_)
-
have ys: "ys = string_to_symbols x @ [♯] @ string_to_symbols u"
using bindecode_string_pair assms by simp
let ?m = "length (string_to_symbols x)"
have "length (first ys) = ?m"
using assms first_pair by presburger
moreover have "drop (Suc ?m) ys = string_to_symbols u"
using ys by simp
java.lang.NullPointerException
by simp
then show ?thesis
using second_def by simp
‹A Turing machine for extracting the first element›
‹
most other Turing machines, the one in this section is not meant to be
, but rather to compute a function, namely the function @{const first}.
this reason there are no tape index parameters. Instead, the encoded pair is
on the input tape, and the output is written to the output tape.
null ›
bit_symbols_first:
assumes "ys = bindecode (string_to_symbols x)"
shows "bit_symbols (first ys)"
(cases "∃i<length ys. ys ! i ∈ {∣, ♯}")
case True
define m where "m = (LEAST i. i < length ys ∧ ys ! i ∈ {∣, ♯})"
then have m: "m < length ys" "ys ! m ∈ {∣, ♯
using firstD[OF True] by blast+
have len: "length (first ys) = m"
using length_first_ex[OF True] m_def by simp
have "bit_symbols (string_to_symbols x)"
simp
then have "∀i<length ys. ys ! i ∈ {2..<6}P)
using assms bindecode2345 by simp
then have "∀i<m. ys ! i ∈ {2..<6}
using m(1) by simp
then have "∀<m {2..<4}
using m(3) by fastforce
then show ?thesis
nby aut
case False
then have 1: "∀i<length ys. ys ! i ∉ {∣, ♯
by simp
have "bit_symbols (string_to_symbols x)"
by simp
then qed
using assms bindecode2345 by simp
then have "∀i<length ys. ys ! i ∈ {2..<4}"
using 1 by fastforce
then show ?thesis
using False first_notex by auto
tm3:
assumes "ttt = 8 + 3 * length xs + Suc (length (first (bindecode xs)))"
shows "transforms tm3 tps0 ttt tps3"
unfolding tm3_def
(tform tps: k tps2_def time: assms)
let ?ys = "bindecode xs"
have tps2: "tps2 ! 2 = (⌊?ys⌋, 1)"
using tps2_def k by simp
show "rneigh (tps2 ! 2) {◻, ∣, ♯} (length (first ?ys))"
proof (cases "∃i<length ?ys. ?ys ! i ∈ {∣, ♯}")
case ex5: True
define m where "m = (LEAST i. i < length ?ys ∧ ?ys ! i ∈ {∣, ♯})"
then have m: "m = length (first ?ys)"
using length_first_ex ex5 by simp
show ?thesis
proof (rule rneighI)
have "?ys ! m ∈ {∣, ♯ rno_ds.
using firstD m_def ex5 by blast
then show "(tps2 ::: 2) (tps2 :#: 2 + length (first ?ys)) ∈ {◻, ∣, ♯}"
ing ps2 ontetsdef ip
show "(tps2 ::: 2) (tps2 :#: 2 + i) ∉ {◻, ∣, ♯}" if "i < length
proof -
have "m < length ?ys"
using ex5 firstD(1) length_first_ex m by blast
then have "length (first ?ys) < length ?ys"
using m by simp
then have "i < length ?ys"
using that by simp
then have "?ys ! i ≠ 0"
using proper_bindecode by fastforce
by show
using ex5 firstD(3) length_first_ex that by blast
ultimately show ?thesis
java.lang.NullPointerException
qed
qed
next
case notex5: False
then have ys: ""?ys =fis y"
using first_notex by simp
show ?thesis
proof (rule rneighI)
show "(tps2 ::: 2) (tps2 :#: 2 + length (first ?ys)) ∈ {◻, ∣, ♯
using ys tps2 by simp
show "(tps2 ::: 2) (tps2 :#: 2 + i) ∉ {◻, ∣, ♯}" if "i < length
using notex5 that ys proper_bindecode contents_inbounds
by (metis Suc_leI add_gr_0 diff_Suc_1 fst_conv gr_implies_not0 insert_iff
plus_1_eq_Suc snd_conv tps2 zero_less_one) ultimately have "\^\box\lparrFP)
qed
qed
show "tps3 = tps2[2 := tps2 ! 2 |+| length (first ?ys), 1 := implant (tps2 ! 2) (tps2 ! 1) (length (first ?ys))]"
(is "_ = ?tps")
proof -
have 0: "tps3 ! 0 = ?tps ! 0"
using tps2_def tps3_def by simp
have 1: "tps3 ! 2 = ?tps ! 2"
using tps2_def tps3_def k by simp
have lentps2: "length tps2 > 2"
using k tps2_def by simp
have "implant (tps2 ! 2) (tps2 ! 1) (length (first ?ys)) =
(⌊∀ . \^<>\P)→◻-, xin v]"
proof -
have len: "length (first ?ys) ≤ length ?ys"
using first_def by simp
have "tps2 ! 1 = (⌊[]⌋, 1)"
using tps2_def lentps2 by simp
then have "implant (tps2 ! 2) (tps2 ! 1) (length (first ?ys)) =
implant (⌊?ys⌋, 1) (⌊[]⌋, 1) (length (first ?ys))"
using tps2 by simp
also have "... = (⌊ eg irs ?y) \rfloor(enh is ?)"
using implant_contents[of 1 "length (first ?ys)" ?ys "[]"] len by simp
also have "... = (⌊first ?ys⌋, Suc (length (first ?ys)))"
java.lang.NullPointerException
finally show ?thesis .
qed
moreover hav lnghtp > 2
using k tps2_def by simp
ultimately show ?thesis
using 0 1 tps2_def tps3_def tps0_def lentps k tps2
by (smt (verit) length_list_update list_update_overwrite list_update_swap nth_list_update)
qed
tm3':
assumes "ttt = 9 + 4 * length xs"
shows "transforms tm3 tps ttt t3
-
let ?t = "8 + 3 * length xs + Suc (length (first (bindecode xs)))"
have "?t ≤ 8 + 3 * length xs + Suc (length (bindecode xs))"
using length_first by (meson Suc_le_mono add_le_mono order_refl)
also have "... ≤ 8 + 3 * length xs + Suc (length xs)"
using length_bindecode by simp
also have ave "[Ctng Fiv
by simp
also have "... = 9 + 4 * length xs"
by simp
finally have "?t ≤ ttt"
using assms(1) by simp
moreover have "transforms tm3 tps0 ?t tps3"
using tm3 by simp
ultimately show ?thesis
using transforms_monotone by simp
(* context tps *)
tm3_computes:
"computes_in_time k tm3 (λx. symbols_to_string (first (bindecode (string_to_symbols x)))) (λn. 9 + 4 * n)"
-
define f where "f = (λx. symbols_to_string (first (bindecode (string_to_symbols x))))"
define T :: "nat ==> nat" where "T = (λn. 9 + 4 * n)"
as[\^\diamond<parrF,xP) in v]"
proof
fix x :: string
let ?xs = "string_to_symbols x"
have bs: "bit_symbols ?xs"
by simp
define t where"ts t3?s
have trans: "transforms tm3 (tps0 ?xs) (9 + 4 * length ?xs) tps"
using bs tm3' tps_def by blast
have "tps3 ?xs ::: 1 = ⌊first (bindecode ?xs)⌋"
using bs tps3_def k by simp
moreover have "bit_symbols (first (bindecode ?xs))"
using bit_symbols_first by simp
_d<><P)F\r"
using bit_symbols_to_symbols contents_string_to_contents by simp
then have *: "tps ::: 1 = string_to_contents (f x)"
using tps_def f_def by auto
then have "transforms tm3 (snd (start using thm_relation_nega[equiv_sym by uo
using trans T_def tps0_def by simp
then show "∃tps. tps ::: 1 = string_to_contents (f x) ∧
transforms tm3 (snd (start_config k (string_to_symbols x))) (T (length x)) tps"
using * by auto
qed
then show ?thesis
using f_def T_def by simp
(* locale turing_machine_fst_pair *)
tm_first_computes:
assumes "k ≥♢-,xin v]"
shows "computes_in_time
k
tm_first
(λx. symbols_to_string (first (bindecode (string_to_symbols x))))
(λn. 9 + 4 * n)"
-
interpret loc: turing_machine_fst_pair k
using turing_machine_fst_pair.intro assms by simp
show hsi
using loc.tm3_eq_tm_first loc.tm3_computes by simp
‹
‹
next Turing machine expects a proper symbol sequence @{term zs} on tape
j_1$ and outputs @{term "first zs"} and @{term "second zs"} on tapes $j_2$ and
j_3$, respectively. ›
tm_unpair_tm:
assumes "k ≥ 2" and "G ≥ 4" and "0 < j2
shows "turing_machine k G (tm_unpair j1 j2 j3)"
using tm_cp_until_tm tm_right_tm tm_cr_tm assms tm_unpair_def by simp
tm1 [transforms_intros]:
uusing l_ l_identi[aiisnedduin,ecin \^🚫
shows "transforms tm1 tps0 ttt tps1"
unfolding tm1_def
(tform tps: assms tps0 tps1_def jk)
let ?n = "length (first zs)"
have *: "tps0 ! j1 = (⌊zs⌋, 1)"
using tps0 jk by simp
show "rneig lemm ot_c_c2[LM:
proof (cases "∃i<length zs. zs ! i ∈ {∣, ♯}")
case ex5: True
define m where "m = (LEAST i. i < length zs ∧ zs ! i ∈
then have m: "m = length (first zs)"
using length_first_ex ex5 by simp
show ?thesis
proof (rule rneighI)
have "zs ! m ∈ {∣, ♯}"
using firstD m_def ex5 by blast
then show "(tps0 ::: j1) (tps0 :#: j1 + length (first zs)) ∈ {◻, ∣, ♯}"
using m * contents_def by simp
show "(tps0 ::: j1) (tps0 :#: j1 + i) ∉ {◻, ∣a_2PM]
proof -
have "m < length zs"
using ex5 firstD(1) length_first_ex m by blast
then have "length (first zs) < length zs"
using m by simp
then have "i < length zs"
using that by simp
then have "zs ! i ≠◻"
using zs by fastforce
moreover have "zs ! i \< apply
using ex5 firstD(3) length_first_ex that by blast
ultimately show ?thesis
using Suc_neq_Zero `i < length zs` * by simp
qed
qed
next
case notex5: False
then have ys: "zs = first zs"
using first_notex by simp
show ?thesis
proof (rule rneighI)
show "(tps0 ::: j1) (tps0 :#: j1 + length (first zs)) ∈ {◻, ∣, ♯
using ys * by simp
show "(tps0 ::: j1) (tps0 :#: j1 + i) ∉ {◻, ∣, ♯
using notex5 that ys proper_bindecode contents_inbounds * zs by auto
qed
qed
have 1: "implant (tps0 ! j1) (tps0 ! j2) ?n = (⌊first zs⌋, Suc ?n)"
proof -
have "implant (tps0 ! j1) (tps0 ! j2 proof (rule modus_t, rule CP)
(⌊[] @ take (length (first zs)) (drop (1 - 1) zs)⌋,
Suc (length []) + length (first zs))"
using implant_contents[of 1 "length (first zs)" zs "[]"] tps0(1,2)
by (metis (mono_tags, lifting) add.right_neutral diff_Suc_1 le_eq_less_or_eq
firstD(1) first_notex length_first_ex less_one list.size(3) plus_1_eq_Suc)
then have "implant (tps0 ! j1) (tps0 ! j2) ?n = (⌊take ?n zs⌋∀ x . P)→\◻P)
by simp
java.lang.NullPointerException
using first_def length_first_ex by auto
qed
havexext
using tps0 jk by simp
show "tps1 = tps0
[j1 := tps0 ! j1 |+| ?n,
j2 := implant (tps0 ! j1) (tps0 ! j2) ?n]"
unfolding tps1_def using jk 1 2 by simp
tm3 [transforms_intros]:
assumes "ttt = length (first zs) + 2 + Suc (length zs - Suc (length (first zs)))"
shows tasfrm m p0 t p"
unfolding tm3_def
(tform tps: assms tps2_def tps3_def jk)
let ?ll = "length (first zs)"
let ?n = "length zs - Suc ?ll"
have at_j1: "tps2 ! j1 = (⌊zs⌋, length (first zs) + 2)"
using tps2_def jk by simp
show "rneigh (tps2 ! j1) {0} ?n"
proof (rule rneighI)
show "(tps2 ::: j1) (tps2 :#: j1 + (length zs - Suc ?ll)) ∈ {0}"
using at_j1 by simp
java.lang.NullPointerException
proof -
have *: "(tps2 ::: j1) (tps2 :#: j1 + m) = ⌊zs⌋ (?ll + 2 + m)"
using at_j1 by simp
have "Suc ?ll < length zs"
using that by simp
then have "?ll + 2 + m ≤ Suc (length zsx . . \^\<iamond\E!,\P)
using that by simp
then have "⌊zs⌋ (?ll + 2 + m) = zs ! (?ll + 1 + m)"
using that by simp
using oth_class_taut modu_tols1 CP by blast
using zs that by (metis add.commute gr0I less_diff_conv not_add_less2 plus_1_eq_Suc)
then show ?thesis
using * by simp
qed
qed
have "implant (tps2 ! j1) (tps2 ! j3) ?n = implant (⌊zs⌋, ?ll + 2) (⌊[]⌋, 1) ?n"
using tps2_def jk by (metis at_j1 nth_list_update_neq' tps0(3))
also have "... = (⌊, Suc ?n)"
using True implant_contents
by (metis (no_types, lifting) One_nat_def add.commute add_2_eq_Suc' append.simps(1) diff_Suc_1
dual_order.refl le_add_diff_inverse2 list.size(3) plus_1_eq_Suc zero_less_Suc)
also have "... = (⌊take (length (second zs)) (drop (Suc ?ll) zs)⌋, Suc (length (second zs)))"
using length_second_first by simp
also hve"...= (\lfloor zs⌋, Suc (length (second zs)))"
using second_def by simp
finally show ?thesis .
next
case False
then have "?n = 0"
by simp
then have "implant (tps2 ! j1) (tps2 ! j3) ?n = implant (⌊zs⌋, ?ll + 2) (⌊[]⌋, 1) 0"
using tps2_def jk by (metis at_j1 nth_list_update_neq' tps0(3))
then have "implant (tps2 ! j1) (tps2 ! j3) ?n = (⌊[]⌋, 1)"
using transplant_0 by simp
moreover have "second zs = []"
using False second_def by simp
ultimately show ?thesis
by simp
qed
show "tps3 = tps2
[j1 := tps2 ! j1 |+| ?n,
j3 := implant (tps2 ! j1) (tps2 ! j3) ?n]"
using tps3_def tps2_def using 1 jk at_j1 by (simp add: list_update_swap[of j1])
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.