Theory TuringUnComputable_H2_original
subsubsection ‹Undecidability of the General Halting Problem H, Variant 2, original version›
theory TuringUnComputable_H2_original
imports
DitherTM
CopyTM
begin
text ‹The diagonal argument below shows the undecidability of a variant of the
General Halting Problem. Implicitly, we thus show that the General Halting Function
(the characteristic function of the Halting Problem) is not Turing computable.›
text ‹
The following locale specifies that some TM ‹H› can be used to decide
the {\em General Halting Problem} and ‹False› is going to be derived
under this locale. Therefore, the undecidability of the {\em General Halting Problem}
is established.
The proof makes use of the TMs ‹tm_copy› and ‹tm_dither›.
›
locale uncomputable =
fixes code :: "instr list ⇒ nat"
and H :: "instr list"
assumes h_composable[intro]: "composable_tm0 H"
and h_case:
"⋀ M ns. TMC_has_num_res M ns ⟹ ⦃(λtap. tap = ([Bk], <(code M, ns)>))⦄ H ⦃(λtap. ∃k. tap = (Bk ↑ k, <0::nat>))⦄"
and nh_case:
"⋀ M ns. ¬ TMC_has_num_res M ns ⟹ ⦃(λtap. tap = ([Bk], <(code M, ns)>))⦄ H ⦃(λtap. ∃k. tap = (Bk ↑ k, <1::nat>))⦄"
begin
abbreviation (input)
"pre_H_ass M ns ≡ λtap. tap = ([Bk], <(code M, ns::nat list)>)"
abbreviation (input)
"post_H_halt_ass ≡ λtap. ∃k. tap = (Bk ↑ k, <1::nat>)"
abbreviation (input)
"post_H_unhalt_ass ≡ λtap. ∃k. tap = (Bk ↑ k, <0::nat>)"
lemma H_halt:
assumes "¬ TMC_has_num_res M ns"
shows "⦃pre_H_ass M ns⦄ H ⦃post_H_halt_ass⦄"
using assms nh_case by auto
lemma H_unhalt:
assumes " TMC_has_num_res M ns"
shows "⦃pre_H_ass M ns⦄ H ⦃post_H_unhalt_ass⦄"
using assms h_case by auto
definition
"tcontra ≡ (tm_copy |+| H) |+| tm_dither"
abbreviation
"code_tcontra ≡ code tcontra"
lemma tcontra_unhalt:
assumes "¬ TMC_has_num_res tcontra [code tcontra]"
shows "False"
proof -
define P1 where "P1 ≡ λtap. tap = ([]::cell list, <code_tcontra>)"
define P2 where "P2 ≡ λtap. tap = ([Bk], <(code_tcontra, code_tcontra)>)"
define P3 where "P3 ≡ λtap. ∃k. tap = (Bk ↑ k, <1::nat>)"
have H_composable: "composable_tm0 (tm_copy |+| H)" by auto
have first: "⦃P1⦄ (tm_copy |+| H) ⦃P3⦄"
proof (cases rule: Hoare_plus_halt)
case A_halt
show "⦃P1⦄ tm_copy ⦃P2⦄" unfolding P1_def P2_def tape_of_nat_def
by (rule tm_copy_correct)
next
case B_halt
show "⦃P2⦄ H ⦃P3⦄"
unfolding P2_def P3_def
using H_halt[OF assms]
by (simp add: tape_of_prod_def tape_of_list_def)
qed (simp)
have second: "⦃P3⦄ tm_dither ⦃P3⦄" unfolding P3_def
by (rule tm_dither_halts)
have "⦃P1⦄ tcontra ⦃P3⦄"
unfolding tcontra_def
by (rule Hoare_plus_halt[OF first second H_composable])
with assms show "False"
unfolding P1_def P3_def
unfolding TMC_has_num_res_def
unfolding Hoare_halt_def
apply(auto) apply(rename_tac n)
apply(drule_tac x = n in spec)
apply(case_tac "steps0 (Suc 0, [], <code tcontra>) tcontra n")
apply(auto simp add: tape_of_list_def)
by (metis append_Nil2 replicate_0)
qed
lemma tcontra_halt:
assumes " TMC_has_num_res tcontra [code tcontra]"
shows "False"
proof -
define P1 where "P1 ≡ λtap. tap = ([]::cell list, <code_tcontra>)"
define P2 where "P2 ≡ λtap. tap = ([Bk], <(code_tcontra, code_tcontra)>)"
define Q3 where "Q3 ≡ λtap. ∃k. tap = (Bk ↑ k, <0::nat>)"
have H_composable: "composable_tm0 (tm_copy |+| H)" by auto
have first: "⦃P1⦄ (tm_copy |+| H) ⦃Q3⦄"
proof (cases rule: Hoare_plus_halt)
case A_halt
show "⦃P1⦄ tm_copy ⦃P2⦄" unfolding P1_def P2_def tape_of_nat_def
by (rule tm_copy_correct)
next
case B_halt
then show "⦃P2⦄ H ⦃Q3⦄"
unfolding P2_def Q3_def using H_unhalt[OF assms]
by(simp add: tape_of_prod_def tape_of_list_def)
qed (simp)
have second: "⦃Q3⦄ tm_dither ↑" unfolding Q3_def
by (rule tm_dither_loops)
have "⦃P1⦄ tcontra ↑"
unfolding tcontra_def
by (rule Hoare_plus_unhalt[OF first second H_composable])
with assms show "False"
unfolding P1_def
unfolding TMC_has_num_res_def
unfolding Hoare_halt_def Hoare_unhalt_def
by (auto simp add: tape_of_list_def)
qed
text ‹
Thus ‹False› is derivable.
›
lemma false: "False"
using tcontra_halt tcontra_unhalt
by auto
end
end