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