thys/uncomputable.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 22 Jan 2013 14:38:56 +0000
changeset 61 7edbd5657702
parent 56 0838b0ac52ab
child 63 35fe8fe12e65
permissions -rw-r--r--
updated files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
(* Title: Turing machine's definition and its charater
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
   Author: XuJian <xujian817@hotmail.com>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
   Maintainer: Xujian
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
*)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
header {* Undeciablity of the {\em Halting problem} *}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
theory uncomputable
55
cd4ef33c8fb1 added turing_hoare
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 54
diff changeset
     9
imports Main turing_hoare
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
begin
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
text {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
  The {\em Copying} TM, which duplicates its input. 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
definition tcopy_init :: "instr list"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
"tcopy_init \<equiv> [(W0, 0), (R, 2), (R, 3), (R, 2),
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
               (W1, 3), (L, 4), (L, 4), (L, 0)]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
fun inv_init1 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
   "inv_init1 x (l, r) = (l = [] \<and> r = Oc\<up>x )"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
fun inv_init2 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
  where 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
  "inv_init2 x (l, r) = (\<exists> i j. i > 0 \<and> i + j = x \<and> l = Oc\<up>i \<and> r = Oc\<up>j)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
fun inv_init3 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
  "inv_init3 x (l, r) = (x > 0 \<and> l = Bk # Oc\<up>x \<and> tl r = [])"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
fun inv_init4 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
  "inv_init4 x (l, r) = (x > 0 \<and> ((l = Oc\<up>x \<and> r = [Bk, Oc]) \<or> (l = Oc\<up>(x - 1) \<and> r = [Oc, Bk, Oc])))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
fun inv_init0 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
  "inv_init0 x (l, r) = ((x >  Suc 0 \<and> l = Oc\<up>(x - 2) \<and> r = [Oc, Oc, Bk, Oc]) \<or>   
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
                        (x = 1 \<and> l = [] \<and> r = [Bk, Oc, Bk, Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
fun inv_init :: "nat \<Rightarrow> config \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
  "inv_init x (s, l, r) = (
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
         if s = 0 then inv_init0 x (l, r) 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
         else if s = Suc 0 then inv_init1 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
         else if s = 2 then inv_init2 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
         else if s = 3 then inv_init3 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
         else if s = 4 then inv_init4 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
         else False)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
declare inv_init.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
lemma numeral_4_eq_4: "4 = Suc 3"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
by arith
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
lemma [elim]: "\<lbrakk>0 < i; 0 < j\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
  \<exists>ia>0. ia + j - Suc 0 = i + j \<and> Oc # Oc \<up> i = Oc \<up> ia"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
apply(rule_tac x = "Suc i" in exI, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
lemma inv_init_step: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
  "\<lbrakk>inv_init x cf; x > 0\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
 \<Longrightarrow> inv_init x (step cf (tcopy_init, 0))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
apply(case_tac cf)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
apply(auto simp: inv_init.simps step.simps tcopy_init_def numeral_2_eq_2 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
  numeral_3_eq_3 numeral_4_eq_4 split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
apply(case_tac "hd c", auto simp: inv_init.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
apply(case_tac c, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
lemma inv_init_steps: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
  "\<lbrakk>inv_init x (s, l, r); x > 0\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
 \<Longrightarrow> inv_init x (steps (s, l, r) (tcopy_init, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
apply(induct stp, simp add: steps.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
apply(auto simp: step_red)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
apply(rule_tac inv_init_step, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
fun init_state :: "config \<Rightarrow> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
  "init_state (s, l, r) = (if s = 0 then 0
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
                             else 5 - s)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    85
fun init_step :: "config \<Rightarrow> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    86
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    87
  "init_step (s, l, r) = (if s = 2 then length r
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
                            else if s = 3 then if r = [] \<or> r = [Bk] then Suc 0 else 0
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    89
                            else if s = 4 then length l
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    90
                            else 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    91
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
fun init_measure :: "config \<Rightarrow> nat \<times> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    93
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
  "init_measure c = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
   (init_state c, init_step c)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
definition lex_pair :: "((nat \<times> nat) \<times> nat \<times> nat) set"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
  "lex_pair \<equiv> less_than <*lex*> less_than"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
definition init_LE :: "(config \<times> config) set"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
   "init_LE \<equiv> (inv_image lex_pair init_measure)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
lemma [simp]: "\<lbrakk>tl r = []; r \<noteq> []; r \<noteq> [Bk]\<rbrakk> \<Longrightarrow> r = [Oc]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
apply(case_tac r, auto, case_tac a, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
lemma wf_init_le: "wf init_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
by(auto intro:wf_inv_image simp:init_LE_def lex_pair_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
lemma init_halt: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
  "x > 0 \<Longrightarrow> \<exists> stp. is_final (steps (Suc 0, [], Oc\<up>x) (tcopy_init, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
proof(rule_tac LE = init_LE in halt_lemma)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
  show "wf init_LE" by(simp add: wf_init_le)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
  assume h: "0 < x"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
  show "\<forall>n. \<not> is_final (steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) n) \<longrightarrow>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
        (steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) (Suc n), 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   121
            steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) n) \<in> init_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
  proof(rule_tac allI, rule_tac impI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
    fix n
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
    assume a: "\<not> is_final (steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) n)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
    have b: "inv_init x (steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) n)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
      apply(rule_tac inv_init_steps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
      apply(simp_all add: inv_init.simps h)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
      done 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
    obtain s l r where c: "(steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) n) = (s, l, r)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
      apply(case_tac "steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) n", auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
    moreover hence "inv_init x (s, l, r)" 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   133
      using c b by simp
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   134
    ultimately show "(steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) (Suc n), 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   135
      steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) n) \<in> init_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   136
      using a 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   137
    proof(simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   138
      assume "inv_init x (s, l, r)" "0 < s"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   139
      thus "(step (s, l, r) (tcopy_init, 0), s, l, r) \<in> init_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   140
        apply(auto simp: inv_init.simps init_LE_def lex_pair_def step.simps tcopy_init_def numeral_2_eq_2
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
          numeral_3_eq_3 numeral_4_eq_4 split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
        apply(case_tac r, auto, case_tac a, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
        done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
    qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
  qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
    
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   148
lemma init_correct: 
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
   149
  "x > 0 \<Longrightarrow> {inv_init1 x} tcopy_init {inv_init0 x}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   150
proof(rule_tac HoareI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   151
  fix l r
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   152
  assume h: "0 < x"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
    "inv_init1 x (l, r)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
  hence "\<exists> stp. is_final (steps (Suc 0, [], Oc\<up>x) (tcopy_init, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   155
    by(erule_tac init_halt)    
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   156
  then obtain stp where "is_final (steps (Suc 0, [], Oc\<up>x) (tcopy_init, 0) stp)" ..
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   157
  moreover have "inv_init x (steps (Suc 0, [], Oc\<up>x) (tcopy_init, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   158
    apply(rule_tac inv_init_steps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
    using h by(simp_all add: inv_init.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
  ultimately show
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   161
    "\<exists>n. is_final (steps (1, l, r) (tcopy_init, 0) n) \<and> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   162
    inv_init0 x holds_for steps (1, l, r) (tcopy_init, 0) n"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   163
    using h
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
    apply(rule_tac x = stp in exI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   165
    apply(case_tac "(steps (Suc 0, [], Oc \<up> x) (tcopy_init, 0) stp)", simp add: inv_init.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   166
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   168
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
definition tcopy_loop :: "instr list"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   170
where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   171
"tcopy_loop \<equiv> [(R, 0), (R, 2),  (R, 3), (W0, 2),
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   172
                (R, 3), (R, 4), (W1, 5), (R, 4),
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
                 (L, 6), (L, 5), (L, 6), (L, 1)]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   174
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   175
fun inv_loop1_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   177
  "inv_loop1_loop x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
       (\<exists> i j. i + j + 1 = x \<and> l = Oc\<up>i \<and> r = Oc # Oc # Bk\<up>j @ Oc\<up>j \<and> j > 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   180
fun inv_loop1_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   182
  "inv_loop1_exit x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
      (l = [] \<and> r = Bk # Oc # Bk\<up>x @ Oc\<up>x \<and> x > 0 )"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   184
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   185
fun inv_loop1 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   186
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   187
  "inv_loop1 x (l, r) = (inv_loop1_loop x (l, r) \<or> inv_loop1_exit x (l, r))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   189
fun inv_loop2 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   191
  "inv_loop2 x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   192
       (\<exists> i j any. i + j = x \<and> x > 0 \<and> i > 0 \<and> j > 0 \<and> l = Oc\<up>i \<and> r = any#Bk\<up>j@Oc\<up>j)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
fun inv_loop3 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   196
  "inv_loop3 x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
         (\<exists> i j k t. i + j = x \<and> i > 0 \<and> j > 0 \<and>  k + t = Suc j \<and> l = Bk\<up>k@Oc\<up>i \<and> r = Bk\<up>t@Oc\<up>j)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
fun inv_loop4 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
  "inv_loop4 x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   202
           (\<exists> i j k t. i + j = x \<and> i > 0 \<and> j > 0 \<and>  k + t = j \<and> l = Oc\<up>k @ Bk\<up>(Suc j)@Oc\<up>i \<and> r = Oc\<up>t)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   203
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   204
fun inv_loop5_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   205
where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   206
  "inv_loop5_loop x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   207
          (\<exists> i j k t. i + j = Suc x \<and> i > 0 \<and> j > 0 \<and> k + t = j \<and> t > 0 \<and> l = Oc\<up>k@Bk\<up>j@Oc\<up>i \<and> r = Oc\<up>t)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   208
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   209
fun inv_loop5_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   210
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
  "inv_loop5_exit x (l, r) = (\<exists> i j. i + j = Suc x \<and> i > 0 \<and> j > 0 \<and>  l = Bk\<up>(j - 1)@Oc\<up>i \<and> r = Bk # Oc\<up>j)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   212
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   213
fun inv_loop5 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   214
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   215
  "inv_loop5 x (l, r) = (inv_loop5_loop x (l, r) \<or> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   216
                         inv_loop5_exit x (l, r))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
fun inv_loop6_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   220
  "inv_loop6_loop x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   221
     (\<exists> i j k t. i + j = Suc x \<and> i > 0 \<and> k + t + 1 = j \<and> l = Bk\<up>k @ Oc\<up>i \<and> r = Bk\<up>(Suc t) @ Oc\<up>j)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   222
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   223
fun inv_loop6_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   224
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   225
  "inv_loop6_exit x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   226
     (\<exists> i j. i + j = x \<and> j > 0 \<and> l = Oc\<up>i \<and> r = Oc # Bk\<up>j @ Oc\<up>j)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   227
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   228
fun inv_loop6 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   229
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   230
  "inv_loop6 x (l, r) = (inv_loop6_loop x (l, r) \<or> inv_loop6_exit x (l, r))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   231
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   232
fun inv_loop0 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   233
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   234
  "inv_loop0 x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   235
      (l = [Bk] \<and> r = Oc # Bk\<up>x @ Oc\<up>x \<and> x > 0 )"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   236
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   237
fun inv_loop :: "nat \<Rightarrow> config \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   238
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   239
  "inv_loop x (s, l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   240
         (if s = 0 then inv_loop0 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   241
          else if s = 1 then inv_loop1 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   242
          else if s = 2 then inv_loop2 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   243
          else if s = 3 then inv_loop3 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   244
          else if s = 4 then inv_loop4 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   245
          else if s = 5 then inv_loop5 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   246
          else if s = 6 then inv_loop6 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   247
          else False)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   248
       
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   249
declare inv_loop.simps[simp del] inv_loop1.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   250
        inv_loop2.simps[simp del] inv_loop3.simps[simp del] 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   251
        inv_loop4.simps[simp del] inv_loop5.simps[simp del] 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   252
        inv_loop6.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
lemma [elim]: "Bk # list = Oc \<up> t \<Longrightarrow> RR"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   254
apply(case_tac t, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
lemma numeral_5_eq_5: "5 = Suc 4" by arith
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
lemma numeral_6_eq_6: "6 = Suc (Suc 4)" by arith
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   261
lemma [simp]: "inv_loop1 x (b, []) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   262
by(simp add: inv_loop1.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   263
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   264
lemma [elim]: "\<lbrakk>0 < x; inv_loop2 x (b, [])\<rbrakk> \<Longrightarrow> inv_loop3 x (Bk # b, [])"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   265
apply(auto simp: inv_loop2.simps inv_loop3.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   266
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
lemma [elim]: "\<lbrakk>0 < x; inv_loop3 x (b, [])\<rbrakk> \<Longrightarrow> inv_loop3 x (Bk # b, [])"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
apply(auto simp: inv_loop3.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   270
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   271
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   272
lemma [elim]: "\<lbrakk>0 < x; inv_loop4 x (b, [])\<rbrakk> \<Longrightarrow> inv_loop5 x (b, [Oc])"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
apply(auto simp: inv_loop4.simps inv_loop5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   274
apply(rule_tac [!] x = i in exI, 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
      rule_tac [!] x  = "Suc j" in exI, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   276
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   277
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
lemma [elim]: "\<lbrakk>0 < x; inv_loop5 x ([], [])\<rbrakk> \<Longrightarrow> RR"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   279
apply(auto simp: inv_loop4.simps inv_loop5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   280
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   282
lemma [elim]: "\<lbrakk>0 < x; inv_loop5 x (b, []); b \<noteq> []\<rbrakk> \<Longrightarrow> RR"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   283
apply(auto simp: inv_loop4.simps inv_loop5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   284
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   285
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   286
lemma [elim]: "inv_loop6 x ([], []) \<Longrightarrow> RR"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   287
apply(auto simp: inv_loop6.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
thm inv_loop6_exit.simps
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   291
lemma [elim]: "inv_loop6 x (b, []) \<Longrightarrow> RR" 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   292
apply(auto simp: inv_loop6.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   295
lemma [elim]: "\<lbrakk>0 < x; inv_loop1 x (b, Bk # list)\<rbrakk> \<Longrightarrow> b = []"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   296
apply(auto simp: inv_loop1.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   297
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
lemma [elim]: "\<lbrakk>0 < x; inv_loop1 x (b, Bk # list)\<rbrakk> \<Longrightarrow> list = Oc # Bk \<up> x @ Oc \<up> x"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   300
apply(auto simp: inv_loop1.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   302
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   303
lemma [elim]: "\<lbrakk>0 < x; inv_loop2 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_loop3 x (Bk # b, list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   304
apply(auto simp: inv_loop2.simps inv_loop3.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
apply(rule_tac [!] x = i  in exI, rule_tac [!] x = j in exI, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   306
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   307
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
lemma [elim]: "Bk # list = Oc \<up> j \<Longrightarrow> RR"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   309
apply(case_tac j, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   310
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   312
lemma [elim]: "\<lbrakk>0 < x; inv_loop3 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_loop3 x (Bk # b, list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   313
apply(auto simp: inv_loop3.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   314
apply(rule_tac [!] x = i in exI, 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   315
      rule_tac [!] x = j in exI, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   316
apply(case_tac [!] t, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   317
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   318
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   319
lemma [elim]: "\<lbrakk>0 < x; inv_loop4 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_loop5 x (b, Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   320
apply(auto simp: inv_loop4.simps inv_loop5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   321
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   322
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   323
lemma [elim]: "\<lbrakk>0 < x; inv_loop5 x ([], Bk # list)\<rbrakk> \<Longrightarrow> inv_loop6 x ([], Bk # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   324
apply(auto simp: inv_loop6.simps inv_loop5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   325
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   326
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   327
lemma [simp]: "inv_loop5_loop x (b, Bk # list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   328
apply(auto simp: inv_loop5_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   329
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   330
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   331
lemma [simp]: "inv_loop6_exit x (b, Bk # list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   332
apply(auto simp: inv_loop6.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   333
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   334
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   335
declare inv_loop5_loop.simps[simp del]  inv_loop5_exit.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   336
       inv_loop6_loop.simps[simp del]  inv_loop6_exit.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   337
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
lemma [elim]:"\<lbrakk>0 < x; inv_loop5_exit x (b, Bk # list); b \<noteq> []; hd b = Bk\<rbrakk> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   339
          \<Longrightarrow> inv_loop6_loop x (tl b, Bk # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   340
apply(simp only: inv_loop5_exit.simps inv_loop6_loop.simps )
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   341
apply(erule_tac exE)+
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   342
apply(rule_tac x = i in exI, 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   343
      rule_tac x = j in exI,
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   344
      rule_tac x = "j - Suc (Suc 0)" in exI, 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   345
      rule_tac x = "Suc 0" in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   346
apply(case_tac [!] j, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   347
apply(case_tac [!] nat, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   348
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   349
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   350
lemma [simp]: "inv_loop6_loop x (b, Oc # Bk # list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   351
apply(auto simp: inv_loop6_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   352
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   353
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   354
lemma [elim]: "\<lbrakk>x > 0; inv_loop5_exit x (b, Bk # list); b \<noteq> []; hd b = Oc\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   355
  inv_loop6_exit x (tl b, Oc # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   356
apply(simp only: inv_loop5_exit.simps inv_loop6_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   357
apply(erule_tac exE)+
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   358
apply(rule_tac x = "x - 1" in exI, rule_tac x = 1 in exI, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   359
apply(case_tac j, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   360
apply(case_tac [!] nat, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   361
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   362
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   363
lemma [elim]: "\<lbrakk>0 < x; inv_loop5 x (b, Bk # list); b \<noteq> []\<rbrakk> \<Longrightarrow> inv_loop6 x (tl b, hd b # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   364
apply(simp add: inv_loop5.simps inv_loop6.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   365
apply(case_tac "hd b", simp_all, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   366
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   367
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   368
lemma  [simp]: "inv_loop6 x ([], Bk # xs) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   369
apply(simp add: inv_loop6.simps inv_loop6_loop.simps
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   370
                inv_loop6_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   371
apply(auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   372
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   373
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   374
lemma [elim]: "\<lbrakk>0 < x; inv_loop6 x ([], Bk # list)\<rbrakk> \<Longrightarrow> inv_loop6 x ([], Bk # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   375
apply(simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   376
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   377
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   378
lemma [simp]: "inv_loop6_exit x (b, Bk # list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   379
apply(simp add: inv_loop6_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   380
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   381
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   382
lemma [elim]: "\<lbrakk>0 < x; inv_loop6_loop x (b, Bk # list); b \<noteq> []; hd b = Bk\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   383
              \<Longrightarrow> inv_loop6_loop x (tl b, Bk # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   384
apply(simp only: inv_loop6_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   385
apply(erule_tac exE)+
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   386
apply(rule_tac x = i in exI, rule_tac x = j in exI, 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   387
      rule_tac x = "k - 1" in exI, rule_tac x = "Suc t" in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   388
apply(case_tac [!] k, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   389
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   390
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   391
lemma [elim]: "\<lbrakk>0 < x; inv_loop6_loop x (b, Bk # list); b \<noteq> []; hd b = Oc\<rbrakk> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   392
        \<Longrightarrow> inv_loop6_exit x (tl b, Oc # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   393
apply(simp only: inv_loop6_loop.simps inv_loop6_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   394
apply(erule_tac exE)+
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   395
apply(rule_tac x = "i - 1" in exI, rule_tac x = j in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   396
apply(case_tac [!] k, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   397
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   398
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   399
lemma [elim]: "\<lbrakk>0 < x; inv_loop6 x (b, Bk # list); b \<noteq> []\<rbrakk> \<Longrightarrow> inv_loop6 x (tl b, hd b # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   400
apply(simp add: inv_loop6.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   401
apply(case_tac "hd b", simp_all, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   402
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   403
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   404
lemma [elim]: "\<lbrakk>0 < x; inv_loop1 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_loop2 x (Oc # b, list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   405
apply(auto simp: inv_loop1.simps inv_loop2.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   406
apply(rule_tac x = "Suc i" in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   407
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   408
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   409
lemma [elim]: "\<lbrakk>0 < x; inv_loop2 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_loop2 x (b, Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   410
apply(auto simp: inv_loop2.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   411
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   412
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   413
lemma [elim]: "\<lbrakk>0 < x; inv_loop3 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_loop4 x (Oc # b, list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   414
apply(auto simp: inv_loop3.simps inv_loop4.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   415
apply(rule_tac [!] x = i in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   416
apply(rule_tac [!] x = "Suc 0" in exI, rule_tac [!] x = "j - 1" in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   417
apply(case_tac [!] t, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   418
apply(case_tac [!] j, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   419
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   420
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   421
lemma [elim]: "\<lbrakk>0 < x; inv_loop4 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_loop4 x (Oc # b, list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   422
apply(auto simp: inv_loop4.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   423
apply(rule_tac [!] x = "i" in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   424
apply(rule_tac [!] x = "Suc k" in exI, rule_tac [!] x = "t - 1" in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   425
apply(case_tac [!] t, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   426
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   427
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   428
lemma [simp]: "inv_loop5 x ([], list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   429
apply(auto simp: inv_loop5.simps inv_loop5_exit.simps inv_loop5_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   430
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   431
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   432
lemma [simp]: "inv_loop5_exit x (b, Oc # list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   433
apply(auto simp: inv_loop5_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   434
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   435
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   436
lemma [elim]: " \<lbrakk>inv_loop5_loop x (b, Oc # list); b \<noteq> []; hd b = Bk\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   437
  \<Longrightarrow> inv_loop5_exit x (tl b, Bk # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   438
apply(simp only: inv_loop5_loop.simps inv_loop5_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   439
apply(erule_tac exE)+
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   440
apply(rule_tac x = i in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   441
apply(case_tac [!] k, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   442
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   443
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   444
lemma [elim]: "\<lbrakk>inv_loop5_loop x (b, Oc # list); b \<noteq> []; hd b = Oc\<rbrakk> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   445
           \<Longrightarrow> inv_loop5_loop x (tl b, Oc # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   446
apply(simp only:  inv_loop5_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   447
apply(erule_tac exE)+
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   448
apply(rule_tac x = i in exI, rule_tac x = j in exI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   449
apply(rule_tac x = "k - 1" in exI, rule_tac x = "Suc t" in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   450
apply(case_tac [!] k, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   451
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   452
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   453
lemma [elim]: "\<lbrakk>inv_loop5 x (b, Oc # list); b \<noteq> []\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   454
  inv_loop5 x (tl b, hd b # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   455
apply(simp add: inv_loop5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   456
apply(case_tac "hd b", simp_all, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   457
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   458
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   459
lemma [elim]: "\<lbrakk>0 < x; inv_loop6 x ([], Oc # list)\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   460
               inv_loop1 x ([], Bk # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   461
apply(auto simp: inv_loop6.simps inv_loop1.simps 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   462
  inv_loop6_loop.simps inv_loop6_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   463
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   464
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   465
lemma [elim]: "\<lbrakk>0 < x; inv_loop6 x (b, Oc # list); b \<noteq> []\<rbrakk> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   466
           \<Longrightarrow> inv_loop1 x (tl b, hd b # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   467
apply(auto simp: inv_loop6.simps inv_loop1.simps 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   468
  inv_loop6_loop.simps inv_loop6_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   469
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   470
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   471
lemma inv_loop_step: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   472
  "\<lbrakk>inv_loop x cf; x > 0\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   473
 \<Longrightarrow> inv_loop x (step cf (tcopy_loop, 0))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   474
apply(case_tac cf, case_tac c, case_tac [2] aa)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   475
apply(auto simp: inv_loop.simps step.simps tcopy_loop_def numeral_2_eq_2  
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   476
  numeral_3_eq_3 numeral_4_eq_4 numeral_5_eq_5 numeral_6_eq_6 split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   477
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   478
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   479
lemma inv_loop_steps:
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   480
  "\<lbrakk>inv_loop x cf; x > 0\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   481
  \<Longrightarrow> inv_loop x (steps cf (tcopy_loop, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   482
apply(induct stp, simp add: steps.simps, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   483
apply(erule_tac inv_loop_step, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   484
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   485
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   486
fun loop_stage :: "config \<Rightarrow> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   487
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   488
  "loop_stage (s, l, r) = (if s = 0 then 0
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   489
                           else (Suc (length (takeWhile (\<lambda>a. a = Oc) (rev l @ r)))))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   490
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   491
fun loop_state :: "config \<Rightarrow> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   492
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   493
  "loop_state (s, l, r) = (if s = 2 \<and> hd r = Oc then 0
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   494
                           else if s = 1 then 1
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   495
                           else 10 - s)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   496
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   497
fun loop_step :: "config \<Rightarrow> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   498
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   499
  "loop_step (s, l, r) = (if s = 3 then length r
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   500
                          else if s = 4 then length r
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   501
                          else if s = 5 then length l 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   502
                          else if s = 6 then length l
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   503
                          else 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   504
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   505
definition lex_triple :: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   506
 "((nat \<times> (nat \<times> nat)) \<times> (nat \<times> (nat \<times> nat))) set"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   507
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   508
  "lex_triple \<equiv> less_than <*lex*> lex_pair"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   509
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   510
lemma wf_lex_triple: "wf lex_triple"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   511
  by (auto intro:wf_lex_prod simp:lex_triple_def lex_pair_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   512
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   513
fun loop_measure :: "config \<Rightarrow> nat \<times> nat \<times> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   514
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   515
  "loop_measure c = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   516
   (loop_stage c, loop_state c, loop_step c)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   517
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   518
definition loop_LE :: "(config \<times> config) set"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   519
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   520
   "loop_LE \<equiv> (inv_image lex_triple loop_measure)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   521
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   522
lemma wf_loop_le: "wf loop_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   523
by(auto intro:wf_inv_image simp: loop_LE_def wf_lex_triple)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   524
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   525
lemma [simp]: "inv_loop2 x ([], b) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   526
apply(auto simp: inv_loop2.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   527
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   528
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   529
lemma  [simp]: "inv_loop2 x (l', []) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   530
apply(auto simp: inv_loop2.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   531
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   532
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   533
lemma [simp]: "inv_loop3 x (b, []) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   534
apply(auto simp: inv_loop3.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   535
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   536
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   537
lemma [simp]: "inv_loop4 x ([], b) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   538
apply(auto simp: inv_loop4.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   539
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   540
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   541
lemma [elim]: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   542
  "\<lbrakk>inv_loop4 x (l', []); l' \<noteq> []; x > 0;
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   543
  length (takeWhile (\<lambda>a. a = Oc) (rev l' @ [Oc])) \<noteq> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   544
  length (takeWhile (\<lambda>a. a = Oc) (rev l'))\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   545
  \<Longrightarrow> length (takeWhile (\<lambda>a. a = Oc) (rev l' @ [Oc])) < length (takeWhile (\<lambda>a. a = Oc) (rev l'))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   546
apply(auto simp: inv_loop4.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   547
apply(case_tac [!] j, simp_all add: List.takeWhile_tail)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   548
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   549
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   550
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   551
lemma [elim]: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   552
  "\<lbrakk>inv_loop4 x (l', Bk # list); l' \<noteq> []; 0 < x;
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   553
   length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list)) \<noteq> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   554
    length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list))\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   555
    \<Longrightarrow> length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list)) < 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   556
    length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   557
apply(auto simp: inv_loop4.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   558
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   559
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   560
lemma takeWhile_replicate_append: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   561
  "P a \<Longrightarrow> takeWhile P (a\<up>x @ ys) = a\<up>x @ takeWhile P ys"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   562
apply(induct x, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   563
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   564
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   565
lemma takeWhile_replicate: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   566
  "P a \<Longrightarrow> takeWhile P (a\<up>x) = a\<up>x"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   567
by(induct x, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   568
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   569
lemma [elim]: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   570
   "\<lbrakk>inv_loop5 x (l', Bk # list); l' \<noteq> []; 0 < x;
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   571
   length (takeWhile (\<lambda>a. a = Oc) (rev (tl l') @ hd l' # Bk # list)) \<noteq>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   572
   length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list))\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   573
   \<Longrightarrow> length (takeWhile (\<lambda>a. a = Oc) (rev (tl l') @ hd l' # Bk # list)) < 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   574
   length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   575
apply(auto simp: inv_loop5.simps inv_loop5_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   576
apply(case_tac [!] j, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   577
apply(case_tac [!] "nat", simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   578
apply(case_tac  nata, simp_all add: List.takeWhile_tail)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   579
apply(simp add: takeWhile_replicate_append takeWhile_replicate)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   580
apply(case_tac  nata, simp_all add: List.takeWhile_tail)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   581
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   582
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   583
lemma [elim]: "\<lbrakk>inv_loop1 x (l', Oc # list)\<rbrakk> \<Longrightarrow> hd list = Oc"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   584
apply(auto simp: inv_loop1.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   585
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   586
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   587
lemma [elim]: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   588
  "\<lbrakk>inv_loop6 x (l', Bk # list); l' \<noteq> []; 0 < x;
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   589
  length (takeWhile (\<lambda>a. a = Oc) (rev (tl l') @ hd l' # Bk # list)) \<noteq> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   590
  length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list))\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   591
  \<Longrightarrow> length (takeWhile (\<lambda>a. a = Oc) (rev (tl l') @ hd l' # Bk # list)) < 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   592
  length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   593
apply(auto simp: inv_loop6.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   594
apply(case_tac l', simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   595
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   596
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   597
lemma [elim]:
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   598
  "\<lbrakk>inv_loop2 x (l', Oc # list); l' \<noteq> []; 0 < x\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   599
  length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list)) <
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   600
  length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   601
apply(auto simp: inv_loop2.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   602
apply(simp_all add: takeWhile_tail takeWhile_replicate_append
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   603
                takeWhile_replicate)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   604
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   605
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   606
lemma [elim]: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   607
  "\<lbrakk>inv_loop5 x (l', Oc # list); l' \<noteq> []; 0 < x;
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   608
  length (takeWhile (\<lambda>a. a = Oc) (rev (tl l') @ hd l' # Oc # list)) \<noteq> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   609
  length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list))\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   610
  \<Longrightarrow> length (takeWhile (\<lambda>a. a = Oc) (rev (tl l') @ hd l' # Oc # list)) < 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   611
  length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   612
apply(auto simp: inv_loop5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   613
apply(case_tac l', auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   614
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   615
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   616
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   617
lemma[elim]: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   618
  "\<lbrakk>inv_loop6 x (l', Oc # list); l' \<noteq> []; 0 < x;
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   619
  length (takeWhile (\<lambda>a. a = Oc) (rev (tl l') @ hd l' # Oc # list))
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   620
  \<noteq> length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list))\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   621
  \<Longrightarrow> length (takeWhile (\<lambda>a. a = Oc) (rev (tl l') @ hd l' # Oc # list)) < 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   622
      length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   623
apply(case_tac l')
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   624
apply(auto simp: inv_loop6.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   625
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   626
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   627
lemma loop_halt: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   628
  "\<lbrakk>x > 0; inv_loop x (Suc 0, l, r)\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   629
      \<exists> stp. is_final (steps (Suc 0, l, r) (tcopy_loop, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   630
proof(rule_tac LE = loop_LE in halt_lemma)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   631
  show "wf loop_LE" by(intro wf_loop_le)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   632
next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   633
  assume h: "0 < x"  and g: "inv_loop x (Suc 0, l, r)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   634
  show "\<forall>n. \<not> is_final (steps (Suc 0, l, r) (tcopy_loop, 0) n) \<longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   635
        (steps (Suc 0, l, r) (tcopy_loop, 0) (Suc n), steps (Suc 0, l, r) (tcopy_loop, 0) n) \<in> loop_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   636
  proof(rule_tac allI, rule_tac impI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   637
    fix n
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   638
    assume a: "\<not> is_final (steps (Suc 0, l, r) (tcopy_loop, 0) n)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   639
    obtain s' l' r' where d: "(steps (Suc 0, l, r) (tcopy_loop, 0) n) = (s', l', r')"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   640
      by(case_tac "(steps (Suc 0, l, r) (tcopy_loop, 0) n)", auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   641
    hence "inv_loop x (s', l', r') \<and> s' \<noteq> 0"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   642
      using h g
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   643
      apply(drule_tac stp = n in inv_loop_steps, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   644
      using a
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   645
      apply(simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   646
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   647
    hence "(step(s', l', r') (tcopy_loop, 0), s', l', r') \<in> loop_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   648
      using h 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   649
      apply(case_tac r', case_tac [2] a)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   650
      apply(auto simp: inv_loop.simps step.simps tcopy_loop_def 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   651
                       numeral_2_eq_2 numeral_3_eq_3 numeral_4_eq_4
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   652
                       numeral_5_eq_5 numeral_6_eq_6 loop_LE_def lex_triple_def lex_pair_def split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   653
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   654
    thus "(steps (Suc 0, l, r) (tcopy_loop, 0) (Suc n), 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   655
          steps (Suc 0, l, r) (tcopy_loop, 0) n) \<in> loop_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   656
      using d
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   657
      apply(simp add: step_red)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   658
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   659
  qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   660
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   661
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   662
lemma loop_correct:
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
   663
  "x > 0 \<Longrightarrow> {inv_loop1 x} tcopy_loop {inv_loop0 x}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   664
proof(rule_tac HoareI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   665
  fix l r
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   666
  assume h: "0 < x"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   667
    "inv_loop1 x (l, r)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   668
  hence "\<exists> stp. is_final (steps (Suc 0, l, r) (tcopy_loop, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   669
    apply(rule_tac loop_halt, simp_all add: inv_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   670
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   671
  then obtain stp where "is_final (steps (Suc 0, l, r) (tcopy_loop, 0) stp)" ..
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   672
  moreover have "inv_loop x (steps (Suc 0, l, r) (tcopy_loop, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   673
    apply(rule_tac inv_loop_steps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   674
    using h by(simp_all add: inv_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   675
  ultimately show
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   676
    "\<exists>n. is_final (steps (1, l, r) (tcopy_loop, 0) n) \<and> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   677
    inv_loop0 x holds_for steps (1, l, r) (tcopy_loop, 0) n"    
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   678
    using h
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   679
    apply(rule_tac x = stp in exI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   680
    apply(case_tac "(steps (Suc 0, l, r) (tcopy_loop, 0) stp)", 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   681
      simp add: inv_init.simps inv_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   682
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   683
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   684
  
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   685
definition tcopy_end :: "instr list"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   686
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   687
  "tcopy_end \<equiv> [(L, 0), (R, 2), (W1, 3), (L, 4),
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   688
                (R, 2), (R, 2), (L, 5), (W0, 4),
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   689
                (R, 0), (L, 5)]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   690
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   691
fun inv_end1 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   692
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   693
  "inv_end1 x (l, r) = (x > 0 \<and> l = [Bk] \<and> r = Oc # Bk\<up>x @ Oc\<up>x)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   694
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   695
fun inv_end2 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   696
  where
45
9192a969f044 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 44
diff changeset
   697
  "inv_end2 x (l, r) = (\<exists> i j. i + j = Suc x \<and> x > 0 \<and> l = Oc\<up>i @ [Bk] \<and> r = Bk\<up>j @ Oc\<up>x)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   698
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   699
fun inv_end3 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   700
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   701
  "inv_end3 x (l, r) =
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   702
        (\<exists> i j. x > 0 \<and> i + j = x \<and> l = Oc\<up>i @ [Bk] \<and> r = Oc # Bk\<up>j@ Oc\<up>x )"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   703
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   704
fun inv_end4 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   705
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   706
  "inv_end4 x (l, r) = (\<exists> any. x > 0 \<and> l = Oc\<up>x @ [Bk] \<and> r = any#Oc\<up>x)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   707
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   708
fun inv_end5_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   709
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   710
  "inv_end5_loop x (l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   711
         (\<exists> i j. i + j = x \<and> x > 0 \<and> j > 0 \<and> l = Oc\<up>i @ [Bk] \<and> r = Oc\<up>j @ Bk # Oc\<up>x)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   712
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   713
fun inv_end5_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   714
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   715
  "inv_end5_exit x (l, r) = (x > 0 \<and> l = [] \<and> r = Bk # Oc\<up>x @ Bk # Oc\<up>x)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   716
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   717
fun inv_end5 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   718
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   719
  "inv_end5 x (l, r) = (inv_end5_loop x (l, r) \<or> inv_end5_exit x (l, r))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   720
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   721
fun inv_end0 :: "nat \<Rightarrow> tape \<Rightarrow>  bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   722
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   723
  "inv_end0 x (l, r) = (x > 0 \<and> l = [Bk] \<and> r = Oc\<up>x @ Bk # Oc\<up>x)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   724
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   725
fun inv_end :: "nat \<Rightarrow> config \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   726
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   727
  "inv_end x (s, l, r) = (if s = 0 then inv_end0 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   728
                          else if s = 1 then inv_end1 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   729
                          else if s = 2 then inv_end2 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   730
                          else if s = 3 then inv_end3 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   731
                          else if s = 4 then inv_end4 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   732
                          else if s = 5 then inv_end5 x (l, r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   733
                          else False)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   734
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   735
declare inv_end.simps[simp del] inv_end1.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   736
        inv_end0.simps[simp del] inv_end2.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   737
        inv_end3.simps[simp del] inv_end4.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   738
        inv_end5.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   739
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   740
lemma [simp]:  "inv_end1 x (b, []) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   741
apply(auto simp: inv_end1.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   742
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   743
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   744
lemma [simp]: "inv_end2 x (b, []) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   745
apply(auto simp: inv_end2.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   746
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   747
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   748
lemma [simp]: "inv_end3 x (b, []) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   749
apply(auto simp: inv_end3.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   750
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   751
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   752
thm inv_end4.simps
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   753
lemma [simp]: "inv_end4 x (b, []) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   754
apply(auto simp: inv_end4.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   755
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   756
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   757
lemma [simp]: "inv_end5 x (b, []) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   758
apply(auto simp: inv_end5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   759
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   760
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   761
lemma [simp]: "inv_end1 x ([], list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   762
apply(auto simp: inv_end1.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   763
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   764
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   765
lemma [elim]: "\<lbrakk>0 < x; inv_end1 x (b, Bk # list); b \<noteq> []\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   766
  \<Longrightarrow> inv_end0 x (tl b, hd b # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   767
apply(auto simp: inv_end1.simps inv_end0.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   768
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   769
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   770
lemma [elim]: "\<lbrakk>0 < x; inv_end2 x (b, Bk # list)\<rbrakk> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   771
  \<Longrightarrow> inv_end3 x (b, Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   772
apply(auto simp: inv_end2.simps inv_end3.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   773
apply(rule_tac x = "j - 1" in exI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   774
apply(case_tac j, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   775
apply(case_tac x, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   776
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   777
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   778
lemma [elim]: "\<lbrakk>0 < x; inv_end3 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_end2 x (Bk # b, list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   779
apply(auto simp: inv_end2.simps inv_end3.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   780
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   781
  
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   782
lemma [elim]: "\<lbrakk>0 < x; inv_end4 x ([], Bk # list)\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   783
  inv_end5 x ([], Bk # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   784
apply(auto simp: inv_end4.simps inv_end5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   785
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   786
 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   787
lemma [elim]: "\<lbrakk>0 < x; inv_end4 x (b, Bk # list); b \<noteq> []\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   788
  inv_end5 x (tl b, hd b # Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   789
apply(auto simp: inv_end4.simps inv_end5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   790
apply(rule_tac x = 1 in exI, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   791
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   792
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   793
lemma [elim]: "\<lbrakk>0 < x; inv_end5 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_end0 x (Bk # b, list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   794
apply(auto simp: inv_end5.simps inv_end0.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   795
apply(case_tac [!] j, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   796
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   797
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   798
lemma [elim]: "\<lbrakk>0 < x; inv_end1 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_end2 x (Oc # b, list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   799
apply(auto simp: inv_end1.simps inv_end2.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   800
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   801
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   802
lemma [elim]: "\<lbrakk>0 < x; inv_end2 x ([], Oc # list)\<rbrakk> \<Longrightarrow>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   803
               inv_end4 x ([], Bk # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   804
apply(auto simp: inv_end2.simps inv_end4.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   805
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   806
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   807
lemma [elim]:  "\<lbrakk>0 < x; inv_end2 x (b, Oc # list); b \<noteq> []\<rbrakk> \<Longrightarrow>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   808
  inv_end4 x (tl b, hd b # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   809
apply(auto simp: inv_end2.simps inv_end4.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   810
apply(case_tac [!] j, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   811
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   812
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   813
lemma [elim]: "\<lbrakk>0 < x; inv_end3 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_end2 x (Oc # b, list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   814
apply(auto simp: inv_end2.simps inv_end3.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   815
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   816
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   817
lemma [elim]: "\<lbrakk>0 < x; inv_end4 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_end4 x (b, Bk # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   818
apply(auto simp: inv_end2.simps inv_end4.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   819
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   820
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   821
lemma [elim]: "\<lbrakk>0 < x; inv_end5 x ([], Oc # list)\<rbrakk> \<Longrightarrow> inv_end5 x ([], Bk # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   822
apply(auto simp: inv_end2.simps inv_end5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   823
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   824
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   825
declare inv_end5_loop.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   826
        inv_end5_exit.simps[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   827
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   828
lemma [simp]: "inv_end5_exit x (b, Oc # list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   829
apply(auto simp: inv_end5_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   830
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   831
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   832
lemma [simp]: "inv_end5_loop x (tl b, Bk # Oc # list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   833
apply(auto simp: inv_end5_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   834
apply(case_tac [!] j, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   835
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   836
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   837
lemma [elim]:
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   838
  "\<lbrakk>0 < x; inv_end5_loop x (b, Oc # list); b \<noteq> []; hd b = Bk\<rbrakk> \<Longrightarrow>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   839
  inv_end5_exit x (tl b, Bk # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   840
apply(auto simp: inv_end5_loop.simps inv_end5_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   841
apply(case_tac [!] i, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   842
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   843
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   844
lemma [elim]: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   845
  "\<lbrakk>0 < x; inv_end5_loop x (b, Oc # list); b \<noteq> []; hd b = Oc\<rbrakk> \<Longrightarrow>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   846
  inv_end5_loop x (tl b, Oc # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   847
apply(simp only: inv_end5_loop.simps inv_end5_exit.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   848
apply(erule_tac exE)+
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   849
apply(rule_tac x = "i - 1" in exI, 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   850
      rule_tac x = "Suc j" in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   851
apply(case_tac [!] i, simp_all)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   852
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   853
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   854
lemma [elim]: "\<lbrakk>0 < x; inv_end5 x (b, Oc # list); b \<noteq> []\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   855
  inv_end5 x (tl b, hd b # Oc # list)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   856
apply(simp add: inv_end2.simps inv_end5.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   857
apply(case_tac "hd b", simp_all, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   858
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   859
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   860
lemma inv_end_step:
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   861
  "\<lbrakk>x > 0;
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   862
 inv_end x cf\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   863
 \<Longrightarrow> inv_end x (step cf (tcopy_end, 0))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   864
apply(case_tac cf, case_tac c, case_tac [2] aa)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   865
apply(auto simp: inv_end.simps step.simps tcopy_end_def numeral_2_eq_2 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   866
  numeral_3_eq_3 numeral_4_eq_4 numeral_5_eq_5 split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   867
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   868
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   869
lemma inv_end_steps:
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   870
  "\<lbrakk>x > 0; inv_end x cf\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   871
\<Longrightarrow> inv_end x (steps cf (tcopy_end, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   872
apply(induct stp, simp add:steps.simps, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   873
apply(erule_tac inv_end_step, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   874
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   875
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   876
fun end_state :: "config \<Rightarrow> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   877
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   878
  "end_state (s, l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   879
       (if s = 0 then 0
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   880
        else if s = 1 then 5
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   881
        else if s = 2 \<or> s = 3 then 4
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   882
        else if s = 4 then 3 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   883
        else if s = 5 then 2
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   884
        else 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   885
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   886
fun end_stage :: "config \<Rightarrow> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   887
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   888
  "end_stage (s, l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   889
          (if s = 2 \<or> s = 3 then (length r)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   890
           else 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   891
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   892
fun end_step :: "config \<Rightarrow> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   893
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   894
  "end_step (s, l, r) = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   895
         (if s = 4 then (if hd r = Oc then 1 else 0)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   896
          else if s = 5 then length l
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   897
          else if s = 2 then 1
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   898
          else if s = 3 then 0
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   899
          else 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   900
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   901
fun end_measure :: "config \<Rightarrow> nat \<times> nat \<times> nat"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   902
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   903
  "end_measure c = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   904
   (end_state c, end_stage c, end_step c)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   905
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   906
definition end_LE :: "(config \<times> config) set"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   907
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   908
   "end_LE \<equiv> (inv_image lex_triple end_measure)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   909
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   910
lemma wf_end_le: "wf end_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   911
by(auto intro:wf_inv_image simp: end_LE_def wf_lex_triple)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   912
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   913
lemma [simp]: "inv_end5 x ([], Oc # list) = False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   914
apply(auto simp: inv_end5.simps inv_end5_loop.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   915
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   916
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   917
lemma end_halt: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   918
  "\<lbrakk>x > 0; inv_end x (Suc 0, l, r)\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   919
      \<exists> stp. is_final (steps (Suc 0, l, r) (tcopy_end, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   920
proof(rule_tac LE = end_LE in halt_lemma)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   921
  show "wf end_LE" by(intro wf_end_le)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   922
next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   923
  assume great: "0 < x"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   924
    and inv_start: "inv_end x (Suc 0, l, r)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   925
  show "\<forall>n. \<not> is_final (steps (Suc 0, l, r) (tcopy_end, 0) n) \<longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   926
    (steps (Suc 0, l, r) (tcopy_end, 0) (Suc n), steps (Suc 0, l, r) (tcopy_end, 0) n) \<in> end_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   927
  proof(rule_tac allI, rule_tac impI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   928
    fix n
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   929
    assume notfinal: "\<not> is_final (steps (Suc 0, l, r) (tcopy_end, 0) n)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   930
    obtain s' l' r' where d: "steps (Suc 0, l, r) (tcopy_end, 0) n = (s', l', r')"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   931
      apply(case_tac "steps (Suc 0, l, r) (tcopy_end, 0) n", auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   932
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   933
    hence "inv_end x (s', l', r') \<and> s' \<noteq> 0"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   934
      using great inv_start notfinal
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   935
      apply(drule_tac stp = n in inv_end_steps, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   936
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   937
    hence "(step (s', l', r') (tcopy_end, 0), s', l', r') \<in> end_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   938
      apply(case_tac r', case_tac [2] a)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   939
      apply(auto simp: inv_end.simps step.simps tcopy_end_def 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   940
                       numeral_2_eq_2 numeral_3_eq_3 numeral_4_eq_4 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   941
                       numeral_5_eq_5 numeral_6_eq_6 end_LE_def lex_triple_def lex_pair_def split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   942
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   943
    thus "(steps (Suc 0, l, r) (tcopy_end, 0) (Suc n), 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   944
      steps (Suc 0, l, r) (tcopy_end, 0) n) \<in> end_LE"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   945
      using d
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   946
      by simp
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   947
  qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   948
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   949
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   950
lemma end_correct:
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
   951
  "x > 0 \<Longrightarrow> {inv_end1 x} tcopy_end {inv_end0 x}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   952
proof(rule_tac HoareI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   953
  fix l r
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   954
  assume h: "0 < x"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   955
    "inv_end1 x (l, r)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   956
  hence "\<exists> stp. is_final (steps (Suc 0, l, r) (tcopy_end, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   957
    apply(rule_tac end_halt, simp_all add: inv_end.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   958
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   959
  then obtain stp where "is_final (steps (Suc 0, l, r) (tcopy_end, 0) stp)" ..
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   960
  moreover have "inv_end x (steps (Suc 0, l, r) (tcopy_end, 0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   961
    apply(rule_tac inv_end_steps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   962
    using h by(simp_all add: inv_end.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   963
  ultimately show
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   964
    "\<exists>n. is_final (steps (1, l, r) (tcopy_end, 0) n) \<and> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   965
    inv_end0 x holds_for steps (1, l, r) (tcopy_end, 0) n"        
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   966
    using h
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   967
    apply(rule_tac x = stp in exI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   968
    apply(case_tac "(steps (Suc 0, l, r) (tcopy_end, 0) stp)", 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   969
      simp add:  inv_end.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   970
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   971
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   972
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   973
definition tcopy :: "instr list"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   974
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   975
  "tcopy = ((tcopy_init |+| tcopy_loop) |+| tcopy_end)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   976
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   977
lemma [intro]: "tm_wf (tcopy_init, 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   978
by(auto simp: tm_wf.simps tcopy_init_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   979
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   980
lemma [intro]: "tm_wf (tcopy_loop, 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   981
by(auto simp: tm_wf.simps tcopy_loop_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   982
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   983
lemma [intro]: "tm_wf (tcopy_end, 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   984
by(auto simp: tm_wf.simps tcopy_end_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   985
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   986
lemma [intro]: "\<lbrakk>tm_wf (A, 0); tm_wf (B, 0)\<rbrakk> \<Longrightarrow> tm_wf (A |+| B, 0)"
56
0838b0ac52ab some small changes to turing and uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 55
diff changeset
   987
apply(auto simp: tm_wf.simps shift.simps adjust.simps tm_comp_length
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   988
                 tm_comp.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   989
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   990
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   991
lemma tcopy_correct1: 
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
   992
  "\<lbrakk>x > 0\<rbrakk> \<Longrightarrow> {inv_init1 x} tcopy {inv_end0 x}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   993
proof(simp add: tcopy_def, rule_tac Hoare_plus_halt)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   994
  show "inv_loop0 x \<mapsto> inv_end1 x"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   995
    by(auto simp: inv_end1.simps inv_loop1.simps assert_imp_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   996
next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   997
  show "tm_wf (tcopy_init |+| tcopy_loop, 0)" by auto
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   998
next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   999
  assume "0 < x"
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1000
  thus "{inv_init1 x} (tcopy_init |+| tcopy_loop) {inv_loop0 x}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1001
  proof(rule_tac Hoare_plus_halt)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1002
    show "inv_init0 x \<mapsto> inv_loop1 x"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1003
      apply(auto simp: inv_init0.simps inv_loop1.simps assert_imp_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1004
      apply(rule_tac x = "Suc 0" in exI, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1005
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1006
  next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1007
    show "tm_wf (tcopy_init, 0)" by auto
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1008
  next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1009
    assume "0 < x"
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1010
    thus "{inv_init1 x} tcopy_init {inv_init0 x}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1011
      by(erule_tac init_correct)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1012
  next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1013
    assume "0 < x"
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1014
    thus "{inv_loop1 x} tcopy_loop {inv_loop0 x}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1015
      by(erule_tac loop_correct)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1016
  qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1017
next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1018
  assume "0 < x"
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1019
  thus "{inv_end1 x} tcopy_end {inv_end0 x}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1020
    by(erule_tac end_correct)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1021
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1022
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1023
section {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1024
  The {\em Dithering} Turing Machine 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1025
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1026
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1027
text {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1028
  The {\em Dithering} TM, when the input is @{text "1"}, it will loop forever, otherwise, it will
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1029
  terminate.
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1030
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1031
definition dither :: "instr list"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1032
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1033
  "dither \<equiv> [(W0, 1), (R, 2), (L, 1), (L, 0)] "
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1034
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1035
lemma dither_halt_rs: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1036
  "\<exists> stp. steps (Suc 0, Bk\<up>m, [Oc, Oc]) (dither, 0) stp = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1037
                                 (0, Bk\<up>m, [Oc, Oc])"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1038
apply(rule_tac x = "Suc (Suc (Suc 0))" in exI)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1039
apply(simp add: dither_def steps.simps 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1040
                step.simps fetch.simps numeral_2_eq_2)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1041
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1042
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1043
lemma dither_unhalt_state: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1044
  "(steps (Suc 0, Bk\<up>m, [Oc]) (dither, 0) stp = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1045
   (Suc 0, Bk\<up>m, [Oc])) \<or> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1046
   (steps (Suc 0, Bk\<up>m, [Oc]) (dither, 0) stp = (2, Oc # Bk\<up>m, []))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1047
  apply(induct stp, simp add: steps.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1048
  apply(simp add: step_red, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1049
  apply(auto simp: step.simps fetch.simps dither_def numeral_2_eq_2)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1050
  done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1051
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1052
lemma dither_unhalt_rs: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1053
  "\<not> is_final (steps (Suc 0, Bk\<up>m, [Oc]) (dither,0) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1054
using dither_unhalt_state[of m stp]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1055
apply(auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1056
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1057
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1058
section {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1059
  The final diagnal arguments to show the undecidability of Halting problem.
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1060
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1061
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1062
text {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1063
  @{text "haltP tp x"} means TM @{text "tp"} terminates on input @{text "x"}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1064
  and the final configuration is standard.
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1065
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1066
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1067
definition haltP :: "tprog \<Rightarrow> nat list \<Rightarrow> bool"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1068
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1069
  "haltP t lm = (\<exists>n a b c. steps (Suc 0, [], <lm>) t n = (0, Bk\<up>a,  Oc\<up>b @ Bk\<up>c))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1070
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1071
lemma [intro]: "tm_wf (tcopy, 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1072
by(auto simp: tcopy_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1073
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1074
lemma [intro]: "tm_wf (dither, 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1075
apply(auto simp: tm_wf.simps dither_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1076
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1077
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1078
text {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1079
  The following lemma shows the meaning of @{text "tinres"} with respect to 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1080
  one step execution.
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1081
  *}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1082
lemma tinres_step: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1083
  "\<lbrakk>tinres l l'; step (ss, l, r) (t, 0) = (sa, la, ra); 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1084
                 step (ss, l', r) (t, 0) = (sb, lb, rb)\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1085
    \<Longrightarrow> tinres la lb \<and> ra = rb \<and> sa = sb"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1086
apply(case_tac ss, case_tac [!]r, case_tac [!] "a::cell")
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1087
apply(auto simp: step.simps fetch.simps
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1088
        split: if_splits )
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1089
apply(case_tac [!] "t ! (2 * nat)", 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1090
     auto simp: tinres_def split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1091
apply(case_tac [1-8] a, auto split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1092
apply(case_tac [!] "t ! (2 * nat)", 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1093
     auto simp: tinres_def split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1094
apply(case_tac [1-4] a, auto split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1095
apply(case_tac [!] "t ! Suc (2 * nat)", 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1096
     auto simp: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1097
apply(case_tac [!] aa, auto split: if_splits)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1098
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1099
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1100
text {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1101
  The following lemma shows the meaning of @{text "tinres"} with respect to 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1102
  many step execution.
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1103
  *}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1104
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1105
lemma tinres_steps: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1106
  "\<lbrakk>tinres l l'; steps (ss, l, r) (t, 0) stp = (sa, la, ra); 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1107
                 steps (ss, l', r) (t, 0) stp = (sb, lb, rb)\<rbrakk>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1108
    \<Longrightarrow> tinres la lb \<and> ra = rb \<and> sa = sb"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1109
apply(induct stp arbitrary: sa la ra sb lb rb, simp add: steps.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1110
apply(simp add: step_red)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1111
apply(case_tac "(steps (ss, l, r) (t, 0) stp)")
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1112
apply(case_tac "(steps (ss, l', r) (t, 0) stp)")
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1113
proof -
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1114
  fix stp sa la ra sb lb rb a b c aa ba ca
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1115
  assume ind: "\<And>sa la ra sb lb rb. \<lbrakk>steps (ss, l, r) (t, 0) stp = (sa, (la::cell list), ra); 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1116
          steps (ss, l', r) (t, 0) stp = (sb, lb, rb)\<rbrakk> \<Longrightarrow> tinres la lb \<and> ra = rb \<and> sa = sb"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1117
  and h: " tinres l l'" "step (steps (ss, l, r) (t, 0) stp) (t, 0) = (sa, la, ra)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1118
         "step (steps (ss, l', r) (t, 0) stp) (t, 0) = (sb, lb, rb)" "steps (ss, l, r) (t, 0) stp = (a, b, c)" 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1119
         "steps (ss, l', r) (t, 0) stp = (aa, ba, ca)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1120
  have "tinres b ba \<and> c = ca \<and> a = aa"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1121
    apply(rule_tac ind, simp_all add: h)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1122
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1123
  thus "tinres la lb \<and> ra = rb \<and> sa = sb"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1124
    apply(rule_tac l = b and l' = ba and r = c  and ss = a   
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1125
            and t = t in tinres_step)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1126
    using h
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1127
    apply(simp, simp, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1128
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1129
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1130
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1131
lemma length_eq: "xs = ys \<Longrightarrow> length xs = length ys"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1132
by auto
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1133
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1134
lemma tinres_ex1: "tinres (Bk \<up> nb) b \<Longrightarrow> \<exists>nb. b = Bk \<up> nb"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1135
apply(auto simp: tinres_def replicate_add[THEN sym])
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1136
apply(case_tac "nb \<ge> n")
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1137
apply(subgoal_tac "\<exists> d. nb = d + n", auto simp: replicate_add)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1138
apply arith
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1139
apply(drule_tac length_eq, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1140
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1141
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1142
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1143
text {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1144
  The following locale specifies that TM @{text "H"} can be used to solve 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1145
  the {\em Halting Problem} and @{text "False"} is going to be derived 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1146
  under this locale. Therefore, the undecidability of {\em Halting Problem}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1147
  is established. 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1148
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1149
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1150
locale uncomputable = 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1151
  -- {* The coding function of TM, interestingly, the detailed definition of this 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1152
  funciton @{text "code"} does not affect the final result. *}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1153
  fixes code :: "instr list \<Rightarrow> nat" 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1154
  -- {* 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1155
  The TM @{text "H"} is the one which is assummed being able to solve the Halting problem.
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1156
  *}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1157
  and H :: "instr list"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1158
  assumes h_wf[intro]: "tm_wf (H, 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1159
  -- {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1160
  The following two assumptions specifies that @{text "H"} does solve the Halting problem.
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1161
  *}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1162
  and h_case: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1163
  "\<And> M n. \<lbrakk>(haltP (M, 0) lm)\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1164
             \<exists> na nb. (steps (Suc 0, [], <code M # lm>) (H, 0) na = (0, Bk\<up>nb, [Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1165
  and nh_case: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1166
  "\<And> M n. \<lbrakk>(\<not> haltP (M, 0) lm)\<rbrakk> \<Longrightarrow>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1167
             \<exists> na nb. (steps (Suc 0, [],  <code M # lm>) (H, 0) na = (0, Bk\<up>nb, [Oc, Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1168
begin
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1169
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1170
lemma h_newcase: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1171
  "\<And> M n. haltP (M, 0) lm \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1172
  \<exists> na nb. (steps (Suc 0, Bk\<up>x , <code M # lm>) (H, 0) na = (0, Bk\<up>nb, [Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1173
proof -
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1174
  fix M n
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1175
  assume "haltP (M, 0) lm"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1176
  hence "\<exists> na nb. (steps (Suc 0, [], <code M # lm>) (H, 0) na
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1177
            = (0, Bk\<up>nb, [Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1178
    apply(erule_tac h_case)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1179
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1180
  from this obtain na nb where 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1181
    cond1:"(steps (Suc 0, [], <code M # lm>) (H, 0) na
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1182
            = (0, Bk\<up>nb, [Oc]))" by blast
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1183
  thus "\<exists> na nb. (steps (Suc 0, Bk\<up>x, <code M # lm>) (H, 0) na = (0, Bk\<up>nb, [Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1184
  proof(rule_tac x = na in exI, case_tac "steps (Suc 0, Bk\<up>x, <code M # lm>) (H, 0) na", simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1185
    fix a b c
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1186
    assume cond2: "steps (Suc 0, Bk\<up>x, <code M # lm>) (H, 0) na = (a, b, c)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1187
    have "tinres (Bk\<up>nb) b \<and> [Oc] = c \<and> 0 = a"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1188
    proof(rule_tac tinres_steps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1189
      show "tinres [] (Bk\<up>x)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1190
        apply(simp add: tinres_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1191
        apply(auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1192
        done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1193
    next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1194
      show "(steps (Suc 0, [], <code M # lm>) (H, 0) na
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1195
            = (0, Bk\<up>nb, [Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1196
        by(simp add: cond1)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1197
    next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1198
      show "steps (Suc 0, Bk\<up>x, <code M # lm>) (H, 0) na = (a, b, c)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1199
        by(simp add: cond2)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1200
    qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1201
    thus "a = 0 \<and> (\<exists>nb. b = (Bk\<up>nb)) \<and> c = [Oc]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1202
      by(auto elim: tinres_ex1)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1203
  qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1204
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1205
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1206
lemma nh_newcase: "\<And> M n. \<lbrakk>\<not> (haltP (M, 0) lm)\<rbrakk> \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1207
             \<exists> na nb. (steps (Suc 0, Bk\<up>x, <code M # lm>) (H, 0) na = (0, Bk\<up>nb, [Oc, Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1208
proof -
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1209
  fix M n
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1210
  assume "\<not> haltP (M, 0) lm"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1211
  hence "\<exists> na nb. (steps (Suc 0, [], <code M # lm>) (H, 0) na
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1212
            = (0, Bk\<up>nb, [Oc, Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1213
    apply(erule_tac nh_case)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1214
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1215
  from this obtain na nb where 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1216
    cond1: "(steps (Suc 0, [], <code M # lm>) (H, 0) na
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1217
            = (0, Bk\<up>nb, [Oc, Oc]))" by blast
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1218
  thus "\<exists> na nb. (steps (Suc 0, Bk\<up>x, <code M # lm>) (H, 0) na = (0, Bk\<up>nb, [Oc, Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1219
  proof(rule_tac x = na in exI, case_tac "steps (Suc 0, Bk\<up>x, <code M # lm>) (H, 0) na", simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1220
    fix a b c
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1221
    assume cond2: "steps (Suc 0, Bk\<up>x, <code M # lm>) (H, 0) na = (a, b, c)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1222
    have "tinres (Bk\<up>nb) b \<and> [Oc, Oc] = c \<and> 0 = a"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1223
    proof(rule_tac tinres_steps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1224
      show "tinres [] (Bk\<up>x)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1225
        apply(auto simp: tinres_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1226
        done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1227
    next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1228
      show "(steps (Suc 0, [], <code M # lm>) (H, 0) na
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1229
            = (0, Bk\<up>nb, [Oc, Oc]))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1230
        by(simp add: cond1)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1231
    next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1232
      show "steps (Suc 0, Bk\<up>x, <code M # lm>) (H, 0) na = (a, b, c)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1233
        by(simp add: cond2)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1234
    qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1235
    thus "a = 0 \<and> (\<exists>nb. b =  Bk\<up>nb) \<and> c = [Oc, Oc]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1236
      by(auto elim: tinres_ex1)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1237
  qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1238
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1239
   
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1240
(*  
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1241
lemma haltP_weaking: 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1242
  "haltP (tcontra H) (code (tcontra H)) \<Longrightarrow> 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1243
    \<exists>stp. isS0 (steps (Suc 0, [], Oc\<^bsup>code (tcontra H)\<^esup>) 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1244
          ((tcopy |+| H) |+| dither) stp)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1245
  apply(simp add: haltP_def, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1246
  apply(rule_tac x = n in exI, simp add: isS0_def tcontra_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1247
  done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1248
*)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1249
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1250
definition tcontra :: "instr list \<Rightarrow> instr list"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1251
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1252
  "tcontra h \<equiv> ((tcopy |+| h) |+| dither)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1253
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1254
declare replicate_Suc[simp del]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1255
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1256
lemma uh_h: "\<not> haltP (tcontra H, 0) [code (tcontra H)]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1257
       \<Longrightarrow> haltP (tcontra H, 0) [code (tcontra H)]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1258
proof(simp only: tcontra_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1259
  let ?tcontr = "(tcopy |+| H) |+| dither"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1260
  let ?cn = "Suc (code ?tcontr)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1261
  let ?P1 = "\<lambda> (l, r). (l = [] \<and> (r::cell list) = Oc\<up>(?cn))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1262
  let ?Q1 = "\<lambda> (l, r). (l = [Bk] \<and> r = Oc\<up>?cn @ Bk # Oc\<up>?cn)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1263
  let ?P2 = "\<lambda> (l, r). (l = [Bk] \<and> r = Oc\<up>?cn @ Bk # Oc\<up>?cn)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1264
  let ?Q2 = "\<lambda>(l, r). (\<exists>nd. l = Bk \<up> nd) \<and> r = [Oc, Oc]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1265
  let ?P3 = ?Q2
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1266
  let ?Q3 = ?P3
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1267
  assume h: "\<not> haltP (?tcontr, 0) [code ?tcontr]"
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1268
  have "{?P1} ?tcontr {?Q3}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1269
  proof(rule_tac Hoare_plus_halt, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1270
    show "?Q2 \<mapsto> ?P3"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1271
      apply(simp add: assert_imp_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1272
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1273
  next
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1274
    show "{?P1} (tcopy|+|H) {?Q2}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1275
    proof(rule_tac Hoare_plus_halt, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1276
      show "?Q1 \<mapsto> ?P2"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1277
        apply(simp add: assert_imp_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1278
        done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1279
    next
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1280
      show "{?P1} tcopy {?Q1}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1281
      proof -
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1282
        have g: "{inv_init1 ?cn} tcopy {inv_end0 ?cn}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1283
          by(rule_tac tcopy_correct1, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1284
        thus "?thesis"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1285
        proof(rule_tac Hoare_weak)           
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1286
          show "{inv_init1 ?cn} tcopy
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1287
            {inv_end0 ?cn} " using g by simp
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1288
        next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1289
          show "?P1 \<mapsto> inv_init1 (?cn)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1290
            apply(simp add: inv_init1.simps assert_imp_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1291
            done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1292
        next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1293
          show "inv_end0 ?cn \<mapsto> ?Q1"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1294
            apply(simp add: assert_imp_def inv_end0.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1295
            done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1296
        qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1297
      qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1298
    next
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1299
      show "{?P2} H {?Q2}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1300
        using Hoare_def nh_newcase[of ?tcontr "[code ?tcontr]" 1] h
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1301
        apply(auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1302
        apply(rule_tac x = na in exI)
47
251e192339b7 added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 45
diff changeset
  1303
        apply(simp add: replicate_Suc tape_of_nl_abv)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1304
        done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1305
    qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1306
  next
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1307
    show "{?P3} dither {?Q3}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1308
      using Hoare_def
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1309
    proof(auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1310
      fix nd
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1311
      show "\<exists>n. is_final (steps (Suc 0, Bk \<up> nd, [Oc, Oc]) (dither, 0) n) \<and>
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1312
        (\<lambda>(l, r). (\<exists>nd. l = Bk \<up> nd) \<and> r = [Oc, Oc])
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1313
        holds_for steps (Suc 0, Bk \<up> nd, [Oc, Oc]) (dither, 0) n"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1314
        using dither_halt_rs[of nd]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1315
        apply(auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1316
        apply(rule_tac x = stp in exI, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1317
        done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1318
    qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1319
  qed    
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1320
  thus "False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1321
    using h
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1322
    apply(auto simp: haltP_def Hoare_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1323
    apply(erule_tac x = n in allE)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1324
    apply(case_tac "steps (Suc 0, [], Oc \<up> ?cn) (?tcontr, 0) n")
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1325
    apply(simp, auto)
47
251e192339b7 added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 45
diff changeset
  1326
    apply(erule_tac x = nd in allE, erule_tac x = 2 in allE)
251e192339b7 added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 45
diff changeset
  1327
    apply(simp add: numeral_2_eq_2 replicate_Suc tape_of_nl_abv)
251e192339b7 added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 45
diff changeset
  1328
    apply(erule_tac x = 0 in allE, simp)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1329
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1330
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1331
  
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1332
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1333
lemma h_uh: "haltP (tcontra H, 0) [code (tcontra H)]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1334
       \<Longrightarrow> \<not> haltP (tcontra H, 0) [code (tcontra H)]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1335
proof(simp only: tcontra_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1336
  let ?tcontr = "(tcopy |+| H) |+| dither"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1337
  let ?cn = "Suc (code ?tcontr)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1338
  let ?P1 = "\<lambda> (l, r). (l = [] \<and> (r::cell list) = Oc\<up>(?cn))"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1339
  let ?Q1 = "\<lambda> (l, r). (l = [Bk] \<and> r = Oc\<up>?cn @ Bk # Oc\<up>?cn)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1340
  let ?P2 = "\<lambda> (l, r). (l = [Bk] \<and> r = Oc\<up>?cn @ Bk # Oc\<up>?cn)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1341
  let ?Q2 = "\<lambda>(l, r). (\<exists>nd. l = Bk \<up> nd) \<and> r = [Oc]"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1342
  let ?P3 = ?Q2
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1343
  assume h: "haltP (?tcontr, 0) [code ?tcontr]"
61
7edbd5657702 updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 56
diff changeset
  1344
  have "{?P1} ?tcontr \<up>"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1345
  proof(rule_tac Hoare_plus_unhalt, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1346
    show "?Q2 \<mapsto> ?P3"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1347
      apply(simp add: assert_imp_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1348
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1349
  next
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1350
    show "{?P1} (tcopy |+| H) {?Q2}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1351
    proof(rule_tac Hoare_plus_halt, auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1352
      show "?Q1 \<mapsto> ?P2"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1353
        apply(simp add: assert_imp_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1354
        done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1355
    next
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1356
      show "{?P1} tcopy {?Q1}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1357
      proof -
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1358
        have g: "{inv_init1 ?cn} tcopy {inv_end0 ?cn}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1359
          by(rule_tac tcopy_correct1, simp)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1360
        thus "?thesis"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1361
        proof(rule_tac Hoare_weak)           
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1362
          show "{inv_init1 ?cn} tcopy
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1363
            {inv_end0 ?cn} " using g by simp
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1364
        next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1365
          show "?P1 \<mapsto> inv_init1 (?cn)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1366
            apply(simp add: inv_init1.simps assert_imp_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1367
            done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1368
        next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1369
          show "inv_end0 ?cn \<mapsto> ?Q1"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1370
            apply(simp add: assert_imp_def inv_end0.simps)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1371
            done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1372
        qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1373
      qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1374
    next
54
e7d845acb0a7 changed slightly HOARE-def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 47
diff changeset
  1375
      show "{?P2} H {?Q2}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1376
        using Hoare_def h_newcase[of ?tcontr "[code ?tcontr]" 1] h
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1377
        apply(auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1378
        apply(rule_tac x = na in exI)
47
251e192339b7 added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 45
diff changeset
  1379
        apply(simp add: replicate_Suc tape_of_nl_abv)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1380
        done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1381
    qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1382
  next
61
7edbd5657702 updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 56
diff changeset
  1383
    show "{?P3} dither \<up>"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1384
      using Hoare_unhalt_def
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1385
    proof(auto)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1386
      fix nd n
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1387
      assume "is_final (steps (Suc 0, Bk \<up> nd, [Oc]) (dither, 0) n)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1388
      thus "False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1389
        using dither_unhalt_rs[of nd n]
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1390
        by simp
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1391
    qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1392
  qed    
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1393
  thus "\<not> True"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1394
    using h
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1395
    apply(auto simp: haltP_def Hoare_unhalt_def)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1396
    apply(erule_tac x = n in allE)
47
251e192339b7 added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 45
diff changeset
  1397
    apply(case_tac "steps (Suc 0, [], Oc \<up> ?cn) (?tcontr, 0) n")
251e192339b7 added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 45
diff changeset
  1398
    apply(simp add: tape_of_nl_abv)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1399
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1400
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1401
      
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1402
text {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1403
  @{text "False"} is finally derived.
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1404
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1405
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1406
lemma false: "False"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1407
using uh_h h_uh
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1408
by auto
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1409
end
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1410
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1411
end
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1412