diff -r 860f05037c36 -r fe7a257bdff4 thys/uncomputable.thy --- a/thys/uncomputable.thy Wed Jan 30 02:29:47 2013 +0000 +++ b/thys/uncomputable.thy Wed Jan 30 03:33:05 2013 +0000 @@ -895,16 +895,18 @@ proof - have "{inv_begin1 x} tcopy_begin {inv_begin0 x}" by (metis assms begin_correct) - moreover - have "{inv_loop1 x} tcopy_loop {inv_loop0 x}" - by (metis assms loop_correct) - moreover + moreover have "inv_begin0 x \ inv_loop1 x" unfolding assert_imp_def unfolding inv_begin0.simps inv_loop1.simps unfolding inv_loop1_loop.simps inv_loop1_exit.simps apply(auto simp add: numeral Cons_eq_append_conv) by (rule_tac x = "Suc 0" in exI, auto) + ultimately have "{inv_begin1 x} tcopy_begin {inv_loop1 x}" + by (rule_tac Hoare_consequence) (auto) + moreover + have "{inv_loop1 x} tcopy_loop {inv_loop0 x}" + by (metis assms loop_correct) ultimately have "{inv_begin1 x} (tcopy_begin |+| tcopy_loop) {inv_loop0 x}" by (rule_tac Hoare_plus_halt) (auto) @@ -912,7 +914,7 @@ have "{inv_end1 x} tcopy_end {inv_end0 x}" by (metis assms end_correct) moreover - have "inv_loop0 x \ inv_end1 x" + have "inv_loop0 x = inv_end1 x" by(auto simp: inv_end1.simps inv_loop1.simps assert_imp_def) ultimately show "{inv_begin1 x} tcopy {inv_end0 x}" @@ -955,10 +957,10 @@ (* invariants of dither *) abbreviation (input) - "dither_halt_inv \ \tp. (\n. tp = (Bk \ n, <1::nat>))" + "dither_halt_inv \ \tp. \k. tp = (Bk \ k, <1::nat>)" abbreviation (input) - "dither_unhalt_inv \ \tp. (\n. tp = (Bk \ n, <0::nat>))" + "dither_unhalt_inv \ \tp. \k. tp = (Bk \ k, <0::nat>)" lemma dither_loops_aux: "(steps0 (1, Bk \ m, [Oc]) dither stp = (1, Bk \ m, [Oc])) \ @@ -974,7 +976,6 @@ apply(auto simp add: numeral tape_of_nat_abv) by (metis Suc_neq_Zero is_final_eq) - lemma dither_halts_aux: shows "steps0 (1, Bk \ m, [Oc, Oc]) dither 2 = (0, Bk \ m, [Oc, Oc])" unfolding dither_def @@ -988,7 +989,6 @@ by (metis (lifting, mono_tags) holds_for.simps is_final_eq prod.cases) - section {* The diagnal argument below shows the undecidability of Halting problem *} text {* @@ -998,7 +998,7 @@ definition haltP :: "tprog0 \ nat list \ bool" where - "haltP p lm \ {(\tp. tp = ([], ))} p {(\tp. (\k n. tp = (Bk \ k, )))}" + "haltP p ns \ {(\tp. tp = ([], ))} p {(\tp. (\k n. tp = (Bk \ k, )))}" lemma [intro, simp]: "tm_wf0 tcopy" by (auto simp: tcopy_def) @@ -1026,9 +1026,9 @@ The following two assumptions specifies that @{text "H"} does solve the Halting problem. *} and h_case: - "\ M lm. haltP M lm \ {(\tp. tp = ([Bk], ))} H {(\tp. \n. tp = (Bk \ n, <0::nat>))}" + "\ M ns. haltP M ns \ {(\tp. tp = ([Bk], ))} H {(\tp. \k. tp = (Bk \ k, <0::nat>))}" and nh_case: - "\ M lm. \ haltP M lm \ {(\tp. tp = ([Bk], ))} H {(\tp. \n. tp = (Bk \ n, <1::nat>))}" + "\ M ns. \ haltP M ns \ {(\tp. tp = ([Bk], ))} H {(\tp. \k. tp = (Bk \ k, <1::nat>))}" begin (* invariants for H *) @@ -1036,10 +1036,10 @@ "pre_H_inv M n \ \tp. tp = ([Bk], <[code M, n]>)" abbreviation - "post_H_halt_inv \ \tp. \n. tp = (Bk \ n, <1::nat>)" + "post_H_halt_inv \ \tp. \k. tp = (Bk \ k, <1::nat>)" abbreviation - "post_H_unhalt_inv \ \tp. \n. tp = (Bk \ n, <0::nat>)" + "post_H_unhalt_inv \ \tp. \k. tp = (Bk \ k, <0::nat>)" lemma H_halt_inv: @@ -1067,7 +1067,7 @@ (* invariants *) def P1 \ "\tp. tp = ([]::cell list, <[code_tcontra]>)" def P2 \ "\tp. tp = ([Bk], <[code_tcontra, code_tcontra]>)" - def P3 \ "\tp. \n. tp = (Bk \ n, <1::nat>)" + def P3 \ "\tp. \k. tp = (Bk \ k, <1::nat>)" (* {P1} tcopy {P2} {P2} H {P3} @@ -1081,7 +1081,7 @@ (* {P1} (tcopy |+| H) {P3} *) have first: "{P1} (tcopy |+| H) {P3}" - proof (cases rule: Hoare_plus_halt_simple) + proof (cases rule: Hoare_plus_halt) case A_halt (* of tcopy *) show "{P1} tcopy {P2}" unfolding P1_def P2_def by (rule tcopy_correct) @@ -1099,7 +1099,7 @@ (* {P1} tcontra {P3} *) have "{P1} tcontra {P3}" unfolding tcontra_def - by (rule Hoare_plus_halt_simple[OF first second H_wf]) + by (rule Hoare_plus_halt[OF first second H_wf]) with assms show "False" unfolding P1_def P3_def @@ -1120,7 +1120,7 @@ (* invariants *) def P1 \ "\tp. tp = ([]::cell list, <[code_tcontra]>)" def P2 \ "\tp. tp = ([Bk], <[code_tcontra, code_tcontra]>)" - def Q3 \ "\tp. \n. tp = (Bk \ n, <0::nat>)" + def Q3 \ "\tp. \k. tp = (Bk \ k, <0::nat>)" (* {P1} tcopy {P2} {P2} H {Q3} @@ -1134,7 +1134,7 @@ (* {P1} (tcopy |+| H) {Q3} *) have first: "{P1} (tcopy |+| H) {Q3}" - proof (cases rule: Hoare_plus_halt_simple) + proof (cases rule: Hoare_plus_halt) case A_halt (* of tcopy *) show "{P1} tcopy {P2}" unfolding P1_def P2_def by (rule tcopy_correct) @@ -1152,7 +1152,7 @@ (* {P1} tcontra loops *) have "{P1} tcontra \" unfolding tcontra_def - by (rule Hoare_plus_unhalt_simple[OF first second H_wf]) + by (rule Hoare_plus_unhalt[OF first second H_wf]) with assms show "False" unfolding P1_def