thys/Uncomputable.thy
author Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
Mon, 07 Jan 2019 13:44:19 +0100
changeset 292 293e9c6f22e1
parent 291 93db7414931d
permissions -rwxr-xr-x
Added myself to the comments at the start of all files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
168
d7570dbf9f06 small changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
     1
(* Title: thys/Uncomputable.thy
d7570dbf9f06 small changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
     2
   Author: Jian Xu, Xingyuan Zhang, and Christian Urban
292
293e9c6f22e1 Added myself to the comments at the start of all files
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 291
diff changeset
     3
   Modifications: Sebastiaan Joosten
44
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
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
     6
chapter {* Undeciablity of the 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
     7
163
67063c5365e1 changed theory names to uppercase
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
     8
theory Uncomputable
67063c5365e1 changed theory names to uppercase
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 141
diff changeset
     9
imports 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
lemma numeral:
35fe8fe12e65 small updates
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 61
diff changeset
    13
  shows "1 = Suc 0"
35fe8fe12e65 small updates
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 61
diff changeset
    14
  and "2 = Suc 1"
35fe8fe12e65 small updates
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 61
diff changeset
    15
  and "3 = Suc 2"
35fe8fe12e65 small updates
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 61
diff changeset
    16
  and "4 = Suc 3" 
35fe8fe12e65 small updates
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 61
diff changeset
    17
  and "5 = Suc 4" 
112
fea23f9a9d85 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 109
diff changeset
    18
  and "6 = Suc 5" 
fea23f9a9d85 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 109
diff changeset
    19
  and "7 = Suc 6"
fea23f9a9d85 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 109
diff changeset
    20
  and "8 = Suc 7" 
fea23f9a9d85 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 109
diff changeset
    21
  and "9 = Suc 8" 
168
d7570dbf9f06 small changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    22
  and "10 = Suc 9"
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
    23
  and "11 = Suc 10"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
    24
  and "12 = Suc 11"
168
d7570dbf9f06 small changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    25
by simp_all
63
35fe8fe12e65 small updates
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 61
diff changeset
    26
168
d7570dbf9f06 small changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    27
text {* The Copying TM, which duplicates its input. *}
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    29
definition 
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    30
  tcopy_begin :: "instr list"
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    31
where
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    32
  "tcopy_begin \<equiv> [(W0, 0), (R, 2), (R, 3), (R, 2),
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    33
                 (W1, 3), (L, 4), (L, 4), (L, 0)]"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    34
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    35
definition 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    36
  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
    37
where
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    38
  "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
    39
                 (R, 3), (R, 4), (W1, 5), (R, 4),
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    40
                 (L, 6), (L, 5), (L, 6), (L, 1)]"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    41
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    42
definition 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    43
  tcopy_end :: "instr list"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    44
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    45
  "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
    46
                (R, 2), (R, 2), (L, 5), (W0, 4),
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    47
                (R, 0), (L, 5)]"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    48
92
b9d0dd18c81e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 91
diff changeset
    49
definition 
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    50
  tcopy :: "instr list"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    51
where
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    52
  "tcopy \<equiv> (tcopy_begin |+| tcopy_loop) |+| tcopy_end"
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    53
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
    54
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    55
(* tcopy_begin *)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
71
8c7f10b3da7b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 70
diff changeset
    57
fun 
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    58
  inv_begin0 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    59
  inv_begin1 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    60
  inv_begin2 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    61
  inv_begin3 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    62
  inv_begin4 :: "nat \<Rightarrow> tape \<Rightarrow> bool"
71
8c7f10b3da7b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 70
diff changeset
    63
where
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    64
  "inv_begin0 n (l, r) = ((n > 1 \<and> (l, r) = (Oc \<up> (n - 2), [Oc, Oc, Bk, Oc])) \<or>   
95
5317c92ff2a7 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
    65
                          (n = 1 \<and> (l, r) = ([], [Bk, Oc, Bk, Oc])))"
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    66
| "inv_begin1 n (l, r) = ((l, r) = ([], Oc \<up> n))"
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    67
| "inv_begin2 n (l, r) = (\<exists> i j. i > 0 \<and> i + j = n \<and> (l, r) = (Oc \<up> i, Oc \<up> j))"
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    68
| "inv_begin3 n (l, r) = (n > 0 \<and> (l, tl r) = (Bk # Oc \<up> n, []))"
95
5317c92ff2a7 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
    69
| "inv_begin4 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
    70
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    71
fun inv_begin :: "nat \<Rightarrow> config \<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
    72
  where
97
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
    73
  "inv_begin n (s, tp) = 
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
    74
        (if s = 0 then inv_begin0 n tp else
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
    75
         if s = 1 then inv_begin1 n tp else
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
    76
         if s = 2 then inv_begin2 n tp else
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
    77
         if s = 3 then inv_begin3 n tp else
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
    78
         if s = 4 then inv_begin4 n tp 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
         else False)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
    81
lemma inv_begin_step_E: "\<lbrakk>0 < i; 0 < j\<rbrakk> \<Longrightarrow> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
  \<exists>ia>0. ia + j - Suc 0 = i + j \<and> Oc # Oc \<up> i = Oc \<up> ia"
95
5317c92ff2a7 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
    83
by (rule_tac x = "Suc i" in exI, simp)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    85
lemma inv_begin_step: 
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
    86
  assumes "inv_begin n cf"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
    87
  and "n > 0"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
    88
  shows "inv_begin n (step0 cf tcopy_begin)"
95
5317c92ff2a7 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
    89
using assms
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    90
unfolding tcopy_begin_def
168
d7570dbf9f06 small changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    91
apply(cases cf)
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
    92
apply(auto simp: numeral split: if_splits elim:inv_begin_step_E)
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
    93
apply(case_tac "hd c")
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
    94
apply(auto)
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
    95
apply(case_tac c)
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
    96
apply(simp_all)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
    99
lemma inv_begin_steps: 
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   100
  assumes "inv_begin n cf"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   101
  and "n > 0"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   102
  shows "inv_begin n (steps0 cf tcopy_begin stp)"
95
5317c92ff2a7 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
   103
apply(induct stp)
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   104
apply(simp add: assms)
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   105
apply(auto simp del: steps.simps)
95
5317c92ff2a7 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
   106
apply(rule_tac inv_begin_step)
5317c92ff2a7 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
   107
apply(simp_all add: assms)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
102
cdef5b1072fe updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   110
lemma begin_partial_correctness:
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   111
  assumes "is_final (steps0 (1, [], Oc \<up> n) tcopy_begin stp)"
103
294576baaeed updated theories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 102
diff changeset
   112
  shows "0 < n \<Longrightarrow> {inv_begin1 n} tcopy_begin {inv_begin0 n}"
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   113
proof(rule_tac Hoare_haltI)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   114
  fix l r
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   115
  assume h: "0 < n" "inv_begin1 n (l, r)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   116
  have "inv_begin n (steps0 (1, [], Oc \<up> n) tcopy_begin stp)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   117
    using h by (rule_tac inv_begin_steps) (simp_all add: inv_begin.simps)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   118
  then show
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   119
    "\<exists>stp. is_final (steps0 (1, l, r) tcopy_begin stp) \<and> 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   120
    inv_begin0 n holds_for steps (1, l, r) (tcopy_begin, 0) stp"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   121
    using h assms
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   122
    apply(rule_tac x = stp in exI)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   123
    apply(case_tac "(steps0 (1, [], Oc \<up> n) tcopy_begin stp)", simp add: inv_begin.simps)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   124
    done
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   125
qed
102
cdef5b1072fe updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 99
diff changeset
   126
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   127
fun measure_begin_state :: "config \<Rightarrow> nat"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
  where
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   129
  "measure_begin_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
   130
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   131
fun measure_begin_step :: "config \<Rightarrow> nat"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
  where
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   133
  "measure_begin_step (s, l, r) = 
81
2e9881578cb2 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 80
diff changeset
   134
        (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
   135
         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
   136
         if s = 4 then length l 
2e9881578cb2 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 80
diff changeset
   137
         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
   138
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   139
definition
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   140
  "measure_begin = measures [measure_begin_state, measure_begin_step]"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   142
lemma wf_measure_begin:
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   143
  shows "wf measure_begin" 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   144
unfolding measure_begin_def 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   145
by auto
81
2e9881578cb2 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 80
diff changeset
   146
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   147
lemma measure_begin_induct [case_names Step]: 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   148
  "\<lbrakk>\<And>n. \<not> P (f n) \<Longrightarrow> (f (Suc n), (f n)) \<in> measure_begin\<rbrakk> \<Longrightarrow> \<exists>n. P (f n)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   149
using wf_measure_begin
97
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
   150
by (metis wf_iff_no_infinite_down_chain)
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
   151
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   152
lemma begin_halts: 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   153
  assumes h: "x > 0"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   154
  shows "\<exists> stp. is_final (steps0 (1, [], Oc \<up> x) tcopy_begin stp)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   155
proof (induct rule: measure_begin_induct) 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   156
  case (Step n)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   157
  have "\<not> is_final (steps0 (1, [], Oc \<up> x) tcopy_begin n)" by fact
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   158
  moreover
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   159
  have "inv_begin x (steps0 (1, [], Oc \<up> x) tcopy_begin n)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   160
    by (rule_tac inv_begin_steps) (simp_all add: inv_begin.simps h)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   161
  moreover
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   162
  obtain s l r where eq: "(steps0 (1, [], Oc \<up> x) tcopy_begin n) = (s, l, r)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   163
    by (metis measure_begin_state.cases)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   164
  ultimately 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   165
  have "(step0 (s, l, r) tcopy_begin, s, l, r) \<in> measure_begin"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   166
    apply(auto simp: measure_begin_def tcopy_begin_def numeral split: if_splits)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   167
    apply(subgoal_tac "r = [Oc]")
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   168
    apply(auto)
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   169
    by (metis cell.exhaust list.exhaust list.sel(3))
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   170
  then 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   171
  show "(steps0 (1, [], Oc \<up> x) tcopy_begin (Suc n), steps0 (1, [], Oc \<up> x) tcopy_begin n) \<in> measure_begin"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   172
    using eq by (simp only: step_red)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
qed
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   174
94
aeaf1374dc67 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   175
lemma begin_correct: 
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   176
  shows "0 < n \<Longrightarrow> {inv_begin1 n} tcopy_begin {inv_begin0 n}"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   177
using begin_partial_correctness begin_halts by blast
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   179
declare tm_comp.simps [simp del] 
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   180
declare adjust.simps[simp del] 
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   181
declare shift.simps[simp del]
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   182
declare tm_wf.simps[simp del]
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   183
declare step.simps[simp del]
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   184
declare steps.simps[simp del]
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   185
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
   186
(* 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
   187
81
2e9881578cb2 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 80
diff changeset
   188
fun 
2e9881578cb2 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 80
diff changeset
   189
  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
   190
  inv_loop1_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   191
  inv_loop5_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   192
  inv_loop5_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   193
  inv_loop6_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   194
  inv_loop6_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool"
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   195
where
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   196
  "inv_loop1_loop n (l, r) = (\<exists> i j. i + j + 1 = n \<and> (l, r) = (Oc\<up>i, Oc#Oc#Bk\<up>j @ Oc\<up>j) \<and> j > 0)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   197
| "inv_loop1_exit n (l, r) = (0 < n \<and> (l, r) = ([], Bk#Oc#Bk\<up>n @ Oc\<up>n))"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   198
| "inv_loop5_loop x (l, r) = 
84
4c8325c64dab updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 83
diff changeset
   199
     (\<exists> i j k t. i + j = Suc x \<and> i > 0 \<and> j > 0 \<and> k + t = j \<and> t > 0 \<and> (l, r) = (Oc\<up>k@Bk\<up>j@Oc\<up>i, Oc\<up>t))"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   200
| "inv_loop5_exit x (l, r) = 
84
4c8325c64dab updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 83
diff changeset
   201
     (\<exists> i j. i + j = Suc x \<and> i > 0 \<and> j > 0 \<and> (l, r) = (Bk\<up>(j - 1)@Oc\<up>i, Bk # Oc\<up>j))"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   202
| "inv_loop6_loop x (l, r) = 
84
4c8325c64dab updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 83
diff changeset
   203
     (\<exists> i j k t. i + j = Suc x \<and> i > 0 \<and> k + t + 1 = j \<and> (l, r) = (Bk\<up>k @ Oc\<up>i, Bk\<up>(Suc t) @ Oc\<up>j))"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   204
| "inv_loop6_exit x (l, r) = 
84
4c8325c64dab updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 83
diff changeset
   205
     (\<exists> i j. i + j = x \<and> j > 0 \<and> (l, r) = (Oc\<up>i, Oc#Bk\<up>j @ Oc\<up>j))"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   206
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   207
fun 
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   208
  inv_loop0 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
81
2e9881578cb2 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 80
diff changeset
   209
  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
   210
  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
   211
  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
   212
  inv_loop4 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   213
  inv_loop5 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   214
  inv_loop6 :: "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
   215
where
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   216
  "inv_loop0 n (l, r) =  (0 < n \<and> (l, r) = ([Bk], Oc # Bk\<up>n @ Oc\<up>n))"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   217
| "inv_loop1 n (l, r) = (inv_loop1_loop n (l, r) \<or> inv_loop1_exit n (l, r))"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   218
| "inv_loop2 n (l, r) = (\<exists> i j any. i + j = n \<and> n > 0 \<and> i > 0 \<and> j > 0 \<and> (l, r) = (Oc\<up>i, any#Bk\<up>j@Oc\<up>j))"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   219
| "inv_loop3 n (l, r) = 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   220
     (\<exists> i j k t. i + j = n \<and> i > 0 \<and> j > 0 \<and>  k + t = Suc j \<and> (l, r) = (Bk\<up>k@Oc\<up>i, Bk\<up>t@Oc\<up>j))"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   221
| "inv_loop4 n (l, r) = 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   222
     (\<exists> i j k t. i + j = n \<and> i > 0 \<and> j > 0 \<and>  k + t = j \<and> (l, r) = (Oc\<up>k @ Bk\<up>(Suc j)@Oc\<up>i, Oc\<up>t))"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   223
| "inv_loop5 n (l, r) = (inv_loop5_loop n (l, r) \<or> inv_loop5_exit n (l, r))"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   224
| "inv_loop6 n (l, r) = (inv_loop6_loop n (l, r) \<or> inv_loop6_exit 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
   225
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   226
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
   227
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   228
  "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
   229
         (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
   230
          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
   231
          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
   232
          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
   233
          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
   234
          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
   235
          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
   236
          else False)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   237
       
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   238
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
   239
        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
   240
        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
   241
        inv_loop6.simps[simp del]
81
2e9881578cb2 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 80
diff changeset
   242
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   243
lemma Bk_no_Oc_repeatE[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
   244
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
   245
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   246
lemma inv_loop3_Bk_empty_via_2[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
   247
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
   248
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   249
lemma inv_loop3_Bk_empty[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
   250
by (auto simp: inv_loop3.simps)
2e9881578cb2 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 80
diff changeset
   251
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   252
lemma inv_loop5_Oc_empty_via_4[elim]: "\<lbrakk>0 < x; inv_loop4 x (b, [])\<rbrakk> \<Longrightarrow> inv_loop5 x (b, [Oc])"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
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
   254
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
   255
      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
   256
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   258
lemma inv_loop1_Bk[elim]: "\<lbrakk>0 < x; inv_loop1 x (b, Bk # list)\<rbrakk> \<Longrightarrow> list = Oc # Bk \<up> x @ Oc \<up> x"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   259
by (auto simp: inv_loop1.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   261
lemma inv_loop3_Bk_via_2[elim]: "\<lbrakk>0 < x; inv_loop2 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_loop3 x (Bk # b, list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   262
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
   263
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
   264
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   265
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   266
lemma inv_loop3_Bk_move[elim]: "\<lbrakk>0 < x; inv_loop3 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_loop3 x (Bk # b, list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
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
   268
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
   269
      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
   270
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
   271
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   272
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   273
lemma inv_loop5_Oc_via_4_Bk[elim]: "\<lbrakk>0 < x; inv_loop4 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_loop5 x (b, Oc # list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   274
by (auto simp: inv_loop4.simps inv_loop5.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   276
lemma inv_loop6_Bk_via_5[elim]: "\<lbrakk>0 < x; inv_loop5 x ([], Bk # list)\<rbrakk> \<Longrightarrow> inv_loop6 x ([], Bk # Bk # list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   277
by (auto simp: inv_loop6.simps inv_loop5.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   279
lemma inv_loop5_loop_no_Bk[simp]: "inv_loop5_loop x (b, Bk # list) = False"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   280
by (auto simp: inv_loop5.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   282
lemma inv_loop6_exit_no_Bk[simp]: "inv_loop6_exit x (b, Bk # list) = False"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   283
by (auto simp: inv_loop6.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   284
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   285
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
   286
       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
   287
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   288
lemma inv_loop6_loopBk_via_5[elim]:"\<lbrakk>0 < x; inv_loop5_exit x (b, Bk # list); b \<noteq> []; hd b = Bk\<rbrakk> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
          \<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
   290
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
   291
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
   292
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
   293
      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
   294
      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
   295
      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
   296
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
   297
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
   298
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   300
lemma inv_loop6_loop_no_Oc_Bk[simp]: "inv_loop6_loop x (b, Oc # Bk # list) = False"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   301
by (auto simp: inv_loop6_loop.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   302
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   303
lemma inv_loop6_exit_Oc_Bk_via_5[elim]: "\<lbrakk>x > 0; inv_loop5_exit x (b, Bk # list); b \<noteq> []; hd b = Oc\<rbrakk> \<Longrightarrow> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   304
  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
   305
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
   306
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
   307
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
   308
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
   309
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
   310
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   312
lemma inv_loop6_Bk_tail_via_5[elim]: "\<lbrakk>0 < x; inv_loop5 x (b, Bk # list); b \<noteq> []\<rbrakk> \<Longrightarrow> inv_loop6 x (tl b, hd b # Bk # list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   313
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
   314
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
   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
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   317
lemma inv_loop6_loop_Bk_Bk_drop[elim]: "\<lbrakk>0 < x; inv_loop6_loop x (b, Bk # list); b \<noteq> []; hd b = Bk\<rbrakk>
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   318
              \<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
   319
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
   320
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
   321
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
   322
      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
   323
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
   324
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   325
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   326
lemma inv_loop6_exit_Oc_Bk_via_loop6[elim]: "\<lbrakk>0 < x; inv_loop6_loop x (b, Bk # list); b \<noteq> []; hd b = Oc\<rbrakk> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   327
        \<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
   328
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
   329
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
   330
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
   331
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
   332
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   333
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   334
lemma inv_loop6_Bk_tail[elim]: "\<lbrakk>0 < x; inv_loop6 x (b, Bk # list); b \<noteq> []\<rbrakk> \<Longrightarrow> inv_loop6 x (tl b, hd b # Bk # list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   335
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
   336
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
   337
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   339
lemma inv_loop2_Oc_via_1[elim]: "\<lbrakk>0 < x; inv_loop1 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_loop2 x (Oc # b, list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   340
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
   341
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
   342
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   343
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   344
lemma inv_loop2_Bk_via_Oc[elim]: "\<lbrakk>0 < x; inv_loop2 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_loop2 x (b, Bk # list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   345
by (auto simp: inv_loop2.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   346
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   347
lemma inv_loop4_Oc_via_3[elim]: "\<lbrakk>0 < x; inv_loop3 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_loop4 x (Oc # b, list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   348
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
   349
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
   350
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
   351
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
   352
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
   353
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   354
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   355
lemma inv_loop4_Oc_move[elim]: "\<lbrakk>0 < x; inv_loop4 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_loop4 x (Oc # b, list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   356
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
   357
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
   358
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
   359
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
   360
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   361
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   362
lemma inv_loop5_exit_no_Oc[simp]: "inv_loop5_exit x (b, Oc # list) = False"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   363
by (auto simp: inv_loop5_exit.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   364
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   365
lemma inv_loop5_exit_Bk_Oc_via_loop[elim]: " \<lbrakk>inv_loop5_loop x (b, Oc # list); b \<noteq> []; hd b = Bk\<rbrakk>
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   366
  \<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
   367
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
   368
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
   369
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
   370
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
   371
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   372
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   373
lemma inv_loop5_loop_Oc_Oc_drop[elim]: "\<lbrakk>inv_loop5_loop x (b, Oc # list); b \<noteq> []; hd b = Oc\<rbrakk> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   374
           \<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
   375
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
   376
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
   377
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
   378
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
   379
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
   380
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   381
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   382
lemma inv_loop5_Oc_tl[elim]: "\<lbrakk>inv_loop5 x (b, Oc # list); b \<noteq> []\<rbrakk> \<Longrightarrow> inv_loop5 x (tl b, hd b # Oc # list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   383
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
   384
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
   385
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   386
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   387
lemma inv_loop1_Bk_Oc_via_6[elim]: "\<lbrakk>0 < x; inv_loop6 x ([], Oc # list)\<rbrakk> \<Longrightarrow> inv_loop1 x ([], Bk # Oc # list)"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   388
apply(auto simp: inv_loop6.simps inv_loop1.simps 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   389
  inv_loop6_loop.simps inv_loop6_exit.simps)
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   390
done
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   391
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   392
lemma inv_loop1_Oc_via_6[elim]: "\<lbrakk>0 < x; inv_loop6 x (b, Oc # list); b \<noteq> []\<rbrakk> 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   393
           \<Longrightarrow> inv_loop1 x (tl b, hd b # Oc # list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   394
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
   395
  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
   396
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   397
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   398
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   399
lemma inv_loop_nonempty[simp]:
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   400
  "inv_loop1 x (b, []) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   401
  "inv_loop2 x ([], b) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   402
  "inv_loop2 x (l', []) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   403
  "inv_loop3 x (b, []) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   404
  "inv_loop4 x ([], b) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   405
  "inv_loop5 x ([], list) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   406
  "inv_loop6 x ([], Bk # xs) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   407
  by (auto simp: inv_loop1.simps inv_loop2.simps inv_loop3.simps inv_loop4.simps 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   408
   inv_loop5.simps inv_loop6.simps inv_loop5_exit.simps inv_loop5_loop.simps
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   409
   inv_loop6_loop.simps)
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   410
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   411
lemma inv_loop_nonemptyE[elim]:
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   412
  "\<lbrakk>inv_loop5 x (b, [])\<rbrakk> \<Longrightarrow> RR" "inv_loop6 x (b, []) \<Longrightarrow> RR" 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   413
  "\<lbrakk>inv_loop1 x (b, Bk # list)\<rbrakk> \<Longrightarrow> b = []"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   414
  by (auto simp: inv_loop4.simps inv_loop5.simps inv_loop5_exit.simps inv_loop5_loop.simps
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   415
 inv_loop6.simps inv_loop6_exit.simps inv_loop6_loop.simps inv_loop1.simps)
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   416
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   417
lemma inv_loop6_Bk_Bk_drop[elim]: "\<lbrakk>inv_loop6 x ([], Bk # list)\<rbrakk> \<Longrightarrow> inv_loop6 x ([], Bk # Bk # list)"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   418
  by (simp)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   419
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   420
lemma inv_loop_step: 
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   421
  "\<lbrakk>inv_loop x cf; x > 0\<rbrakk> \<Longrightarrow> inv_loop x (step cf (tcopy_loop, 0))"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   422
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
   423
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
   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 inv_loop_steps:
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   427
  "\<lbrakk>inv_loop x cf; x > 0\<rbrakk> \<Longrightarrow> inv_loop x (steps cf (tcopy_loop, 0) stp)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   428
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
   429
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
   430
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   431
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   432
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
   433
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   434
  "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
   435
                           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
   436
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   437
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
   438
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   439
  "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
   440
                           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
   441
                           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
   442
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   443
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
   444
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   445
  "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
   446
                          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
   447
                          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
   448
                          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
   449
                          else 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   450
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   451
definition measure_loop :: "(config \<times> config) set"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   452
  where
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   453
   "measure_loop = measures [loop_stage, loop_state, loop_step]"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   454
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   455
lemma wf_measure_loop: "wf measure_loop"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   456
unfolding measure_loop_def
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   457
by (auto)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   458
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   459
lemma measure_loop_induct [case_names Step]: 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   460
  "\<lbrakk>\<And>n. \<not> P (f n) \<Longrightarrow> (f (Suc n), (f n)) \<in> measure_loop\<rbrakk> \<Longrightarrow> \<exists>n. P (f n)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   461
using wf_measure_loop
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   462
by (metis wf_iff_no_infinite_down_chain)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   463
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   464
lemma inv_loop4_not_just_Oc[elim]: 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   465
  "\<lbrakk>inv_loop4 x (l', []);
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   466
  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
   467
  length (takeWhile (\<lambda>a. a = Oc) (rev l'))\<rbrakk>
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   468
  \<Longrightarrow> RR"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   469
  "\<lbrakk>inv_loop4 x (l', Bk # list);
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   470
   length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list)) \<noteq> 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   471
    length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list))\<rbrakk>
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   472
    \<Longrightarrow> RR"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   473
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
   474
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
   475
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   476
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   477
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
   478
  "P a \<Longrightarrow> takeWhile P (a\<up>x @ ys) = a\<up>x @ takeWhile P ys"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   479
by (induct x, auto)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   480
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   481
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
   482
  "P a \<Longrightarrow> takeWhile P (a\<up>x) = a\<up>x"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   483
by (induct x, auto)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   484
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   485
lemma inv_loop5_Bk_E[elim]: 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   486
   "\<lbrakk>inv_loop5 x (l', Bk # list); l' \<noteq> []; 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   487
   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
   488
   length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list))\<rbrakk>
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   489
   \<Longrightarrow> RR"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   490
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
   491
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
   492
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
   493
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
   494
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
   495
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
   496
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   497
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   498
lemma inv_loop1_hd_Oc[elim]: "\<lbrakk>inv_loop1 x (l', Oc # list)\<rbrakk> \<Longrightarrow> hd list = Oc"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   499
by (auto simp: inv_loop1.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   500
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   501
lemma inv_loop6_not_just_Bk[elim]: 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   502
  "\<lbrakk>inv_loop6 x (l', Bk # list); l' \<noteq> [];
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   503
  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
   504
  length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Bk # list))\<rbrakk>
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   505
  \<Longrightarrow> RR"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   506
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
   507
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
   508
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   509
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   510
lemma inv_loop2_OcE[elim]:
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   511
  "\<lbrakk>inv_loop2 x (l', Oc # list); l' \<noteq> []\<rbrakk> \<Longrightarrow> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   512
  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
   513
  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
   514
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
   515
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
   516
                takeWhile_replicate)
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   517
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   518
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   519
lemma inv_loop5_OcE[elim]: 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   520
  "\<lbrakk>inv_loop5 x (l', Oc # list); l' \<noteq> [];
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   521
  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
   522
  length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list))\<rbrakk>
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   523
  \<Longrightarrow> RR"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   524
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
   525
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
   526
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   527
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   528
lemma inv_loop6_OcE[elim]: 
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   529
  "\<lbrakk>inv_loop6 x (l', Oc # list); l' \<noteq> []; 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   530
  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
   531
  \<noteq> length (takeWhile (\<lambda>a. a = Oc) (rev l' @ Oc # list))\<rbrakk>
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   532
  \<Longrightarrow> RR"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   533
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
   534
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
   535
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   536
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   537
lemma loop_halts: 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   538
  assumes h: "n > 0" "inv_loop n (1, l, r)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   539
  shows "\<exists> stp. is_final (steps0 (1, l, r) tcopy_loop stp)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   540
proof (induct rule: measure_loop_induct) 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   541
  case (Step stp)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   542
  have "\<not> is_final (steps0 (1, l, r) tcopy_loop stp)" by fact
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   543
  moreover
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   544
  have "inv_loop n (steps0 (1, l, r) tcopy_loop stp)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   545
    by (rule_tac inv_loop_steps) (simp_all only: h)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   546
  moreover
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   547
  obtain s l' r' where eq: "(steps0 (1, l, r) tcopy_loop stp) = (s, l', r')"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   548
    by (metis measure_begin_state.cases)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   549
  ultimately 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   550
  have "(step0 (s, l', r') tcopy_loop, s, l', r') \<in> measure_loop"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   551
    using h(1)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   552
    apply(case_tac r')
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   553
    apply(case_tac [2] a)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   554
    apply(auto simp: inv_loop.simps step.simps tcopy_loop_def numeral measure_loop_def split: if_splits)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   555
    done
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   556
  then 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   557
  show "(steps0 (1, l, r) tcopy_loop (Suc stp), steps0 (1, l, r) tcopy_loop stp) \<in> measure_loop"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   558
    using eq by (simp only: step_red)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   559
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   560
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   561
lemma loop_correct:
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   562
  assumes "0 < n"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   563
  shows "{inv_loop1 n} tcopy_loop {inv_loop0 n}"
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   564
  using assms
71
8c7f10b3da7b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 70
diff changeset
   565
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
   566
  fix l r
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   567
  assume h: "0 < n" "inv_loop1 n (l, r)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   568
  then obtain stp where k: "is_final (steps0 (1, l, r) tcopy_loop stp)" 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   569
    using loop_halts
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   570
    apply(simp add: inv_loop.simps)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   571
    apply(blast)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   572
    done
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   573
  moreover
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   574
  have "inv_loop n (steps0 (1, l, r) tcopy_loop stp)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   575
    using h 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   576
    by (rule_tac inv_loop_steps) (simp_all add: inv_loop.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   577
  ultimately show
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   578
    "\<exists>stp. is_final (steps0 (1, l, r) tcopy_loop stp) \<and> 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   579
    inv_loop0 n holds_for steps0 (1, l, r) tcopy_loop stp"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   580
    using h(1) 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   581
    apply(rule_tac x = stp in exI)
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   582
    apply(case_tac "(steps0 (1, l, r) tcopy_loop stp)")
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   583
    apply(simp add: inv_loop.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   584
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   585
qed
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
   586
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
   587
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   588
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   589
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
   590
(* 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
   591
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   592
fun
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   593
  inv_end5_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   594
  inv_end5_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool" 
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   595
where  
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   596
  "inv_end5_loop x (l, r) = 
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   597
     (\<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)"
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   598
| "inv_end5_exit x (l, r) = (x > 0 \<and> l = [] \<and> r = Bk # Oc\<up>x @ Bk # 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
   599
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   600
fun 
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   601
  inv_end0 :: "nat \<Rightarrow> tape \<Rightarrow>  bool" and
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   602
  inv_end1 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   603
  inv_end2 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   604
  inv_end3 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   605
  inv_end4 :: "nat \<Rightarrow> tape \<Rightarrow> bool" and 
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   606
  inv_end5 :: "nat \<Rightarrow> tape \<Rightarrow> bool" 
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   607
where
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   608
  "inv_end0 n (l, r) = (n > 0 \<and> (l, r) = ([Bk], Oc\<up>n @ Bk # Oc\<up>n))"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   609
| "inv_end1 n (l, r) = (n > 0 \<and> (l, r) = ([Bk], Oc # Bk\<up>n @ Oc\<up>n))"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   610
| "inv_end2 n (l, r) = (\<exists> i j. i + j = Suc n \<and> n > 0 \<and> l = Oc\<up>i @ [Bk] \<and> r = Bk\<up>j @ Oc\<up>n)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   611
| "inv_end3 n (l, r) =
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   612
     (\<exists> i j. n > 0 \<and> i + j = n \<and> l = Oc\<up>i @ [Bk] \<and> r = Oc # Bk\<up>j@ Oc\<up>n)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   613
| "inv_end4 n (l, r) = (\<exists> any. n > 0 \<and> l = Oc\<up>n @ [Bk] \<and> r = any#Oc\<up>n)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   614
| "inv_end5 n (l, r) = (inv_end5_loop n (l, r) \<or> inv_end5_exit 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
   615
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   616
fun 
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   617
  inv_end :: "nat \<Rightarrow> config \<Rightarrow> bool"
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   618
where
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   619
  "inv_end n (s, l, r) = (if s = 0 then inv_end0 n (l, r)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   620
                          else if s = 1 then inv_end1 n (l, r)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   621
                          else if s = 2 then inv_end2 n (l, r)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   622
                          else if s = 3 then inv_end3 n (l, r)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   623
                          else if s = 4 then inv_end4 n (l, r)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   624
                          else if s = 5 then inv_end5 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
   625
                          else False)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   626
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   627
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
   628
        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
   629
        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
   630
        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
   631
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   632
lemma inv_end_nonempty[simp]:
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   633
  "inv_end1 x (b, []) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   634
  "inv_end1 x ([], list) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   635
  "inv_end2 x (b, []) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   636
  "inv_end3 x (b, []) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   637
  "inv_end4 x (b, []) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   638
  "inv_end5 x (b, []) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   639
  "inv_end5 x ([], Oc # list) = False"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   640
by (auto simp: inv_end1.simps inv_end2.simps inv_end3.simps inv_end4.simps inv_end5.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   641
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   642
lemma inv_end0_Bk_via_1[elim]: "\<lbrakk>0 < x; inv_end1 x (b, Bk # list); b \<noteq> []\<rbrakk>
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   643
  \<Longrightarrow> inv_end0 x (tl b, hd b # Bk # list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   644
by (auto simp: inv_end1.simps inv_end0.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   645
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   646
lemma inv_end3_Oc_via_2[elim]: "\<lbrakk>0 < x; inv_end2 x (b, Bk # list)\<rbrakk> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   647
  \<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
   648
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
   649
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
   650
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
   651
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
   652
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   653
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   654
lemma inv_end2_Bk_via_3[elim]: "\<lbrakk>0 < x; inv_end3 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_end2 x (Bk # b, list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   655
by (auto simp: inv_end2.simps inv_end3.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   656
  
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   657
lemma inv_end5_Bk_via_4[elim]: "\<lbrakk>0 < x; inv_end4 x ([], Bk # list)\<rbrakk> \<Longrightarrow> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   658
  inv_end5 x ([], Bk # Bk # list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   659
by (auto simp: inv_end4.simps inv_end5.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   660
 
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   661
lemma inv_end5_Bk_tail_via_4[elim]: "\<lbrakk>0 < x; inv_end4 x (b, Bk # list); b \<noteq> []\<rbrakk> \<Longrightarrow> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   662
  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
   663
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
   664
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
   665
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   666
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   667
lemma inv_end0_Bk_via_5[elim]: "\<lbrakk>0 < x; inv_end5 x (b, Bk # list)\<rbrakk> \<Longrightarrow> inv_end0 x (Bk # b, list)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   668
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
   669
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
   670
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   671
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   672
lemma inv_end2_Oc_via_1[elim]: "\<lbrakk>0 < x; inv_end1 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_end2 x (Oc # b, list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   673
by (auto simp: inv_end1.simps inv_end2.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   674
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   675
lemma inv_end4_Bk_Oc_via_2[elim]: "\<lbrakk>0 < x; inv_end2 x ([], Oc # list)\<rbrakk> \<Longrightarrow>
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   676
               inv_end4 x ([], Bk # Oc # list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   677
by (auto simp: inv_end2.simps inv_end4.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   678
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   679
lemma inv_end4_Oc_via_2[elim]:  "\<lbrakk>0 < x; inv_end2 x (b, Oc # list); b \<noteq> []\<rbrakk> \<Longrightarrow>
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   680
  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
   681
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
   682
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
   683
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   684
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   685
lemma inv_end2_Oc_via_3[elim]: "\<lbrakk>0 < x; inv_end3 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_end2 x (Oc # b, list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   686
by (auto simp: inv_end2.simps inv_end3.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   687
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   688
lemma inv_end4_Bk_via_Oc[elim]: "\<lbrakk>0 < x; inv_end4 x (b, Oc # list)\<rbrakk> \<Longrightarrow> inv_end4 x (b, Bk # list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   689
by (auto simp: inv_end2.simps inv_end4.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   690
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   691
lemma inv_end5_Bk_drop_Oc[elim]: "\<lbrakk>0 < x; inv_end5 x ([], Oc # list)\<rbrakk> \<Longrightarrow> inv_end5 x ([], Bk # Oc # list)"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   692
by (auto simp: inv_end2.simps inv_end5.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   693
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   694
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
   695
        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
   696
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   697
lemma inv_end5_exit_no_Oc[simp]: "inv_end5_exit x (b, Oc # list) = False"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   698
by (auto simp: inv_end5_exit.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   699
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   700
lemma inv_end5_loop_no_Bk_Oc[simp]: "inv_end5_loop x (tl b, Bk # Oc # list) = False"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   701
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
   702
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
   703
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   704
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   705
lemma inv_end5_exit_Bk_Oc_via_loop[elim]:
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   706
  "\<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
   707
  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
   708
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
   709
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
   710
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   711
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   712
lemma inv_end5_loop_Oc_Oc_drop[elim]: 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   713
  "\<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
   714
  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
   715
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
   716
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
   717
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
   718
      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
   719
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
   720
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   721
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   722
lemma inv_end5_Oc_tail[elim]: "\<lbrakk>0 < x; inv_end5 x (b, Oc # list); b \<noteq> []\<rbrakk> \<Longrightarrow> 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   723
  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
   724
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
   725
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
   726
done
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
lemma inv_end_step:
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   729
  "\<lbrakk>x > 0; inv_end x cf\<rbrakk> \<Longrightarrow> inv_end x (step cf (tcopy_end, 0))"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   730
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
   731
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
   732
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   733
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   734
lemma inv_end_steps:
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   735
  "\<lbrakk>x > 0; inv_end x cf\<rbrakk> \<Longrightarrow> inv_end x (steps cf (tcopy_end, 0) stp)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   736
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
   737
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
   738
done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   739
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   740
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
   741
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   742
  "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
   743
       (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
   744
        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
   745
        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
   746
        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
   747
        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
   748
        else 0)"
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
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
   751
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   752
  "end_stage (s, l, r) = 
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   753
          (if s = 2 \<or> s = 3 then (length r) 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
   754
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   755
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
   756
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   757
  "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
   758
         (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
   759
          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
   760
          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
   761
          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
   762
          else 0)"
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   763
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   764
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
   765
  where
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   766
   "end_LE = measures [end_state, end_stage, end_step]"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   767
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   768
lemma wf_end_le: "wf end_LE"
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   769
unfolding end_LE_def
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   770
by (auto)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   771
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   772
lemma halt_lemma: 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   773
  "\<lbrakk>wf LE; \<forall>n. (\<not> P (f n) \<longrightarrow> (f (Suc n), (f n)) \<in> LE)\<rbrakk> \<Longrightarrow> \<exists>n. P (f n)"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   774
by (metis wf_iff_no_infinite_down_chain)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   775
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   776
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
   777
  "\<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
   778
      \<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
   779
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
   780
  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
   781
next
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   782
  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
   783
    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
   784
  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
   785
    (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
   786
  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
   787
    fix n
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   788
    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
   789
    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
   790
      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
   791
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   792
    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
   793
      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
   794
      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
   795
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   796
    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
   797
      apply(case_tac r', case_tac [2] a)
96
bd320b5365e2 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
   798
      apply(auto simp: inv_end.simps step.simps tcopy_end_def numeral end_LE_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
   799
      done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   800
    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
   801
      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
   802
      using d
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   803
      by simp
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   804
  qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   805
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   806
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   807
lemma end_correct:
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   808
  "n > 0 \<Longrightarrow> {inv_end1 n} tcopy_end {inv_end0 n}"
71
8c7f10b3da7b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 70
diff changeset
   809
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
   810
  fix l r
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   811
  assume h: "0 < n"
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   812
    "inv_end1 n (l, r)"
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   813
  then have "\<exists> stp. is_final (steps0 (1, l, r) tcopy_end stp)"
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   814
    by (simp add: end_halt inv_end.simps)
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   815
  then obtain stp where "is_final (steps0 (1, l, r) tcopy_end stp)" ..
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   816
  moreover have "inv_end n (steps0 (1, l, r) tcopy_end stp)"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   817
    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
   818
    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
   819
  ultimately show
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   820
    "\<exists>stp. is_final (steps (1, l, r) (tcopy_end, 0) stp) \<and> 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   821
    inv_end0 n holds_for steps (1, l, r) (tcopy_end, 0) stp"        
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   822
    using h
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   823
    apply(rule_tac x = stp in exI)
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   824
    apply(case_tac "(steps0 (1, l, r) tcopy_end stp)") 
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   825
    apply(simp add: inv_end.simps)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   826
    done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   827
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   828
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
   829
(* tcopy *)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   830
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   831
lemma tm_wf_tcopy[intro]:
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   832
  "tm_wf (tcopy_begin, 0)"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   833
  "tm_wf (tcopy_loop, 0)"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   834
  "tm_wf (tcopy_end, 0)"
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   835
by (auto simp: tm_wf.simps tcopy_end_def tcopy_loop_def tcopy_begin_def)
44
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 tcopy_correct1: 
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   838
  assumes "0 < x"
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   839
  shows "{inv_begin1 x} tcopy {inv_end0 x}"
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   840
proof -
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   841
  have "{inv_begin1 x} tcopy_begin {inv_begin0 x}"
94
aeaf1374dc67 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   842
    by (metis assms begin_correct) 
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   843
  moreover 
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   844
  have "inv_begin0 x \<mapsto> inv_loop1 x"
97
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
   845
    unfolding assert_imp_def
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
   846
    unfolding inv_begin0.simps inv_loop1.simps
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
   847
    unfolding inv_loop1_loop.simps inv_loop1_exit.simps
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
   848
    apply(auto simp add: numeral Cons_eq_append_conv)
d6f04e3e9894 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 96
diff changeset
   849
    by (rule_tac x = "Suc 0" in exI, auto)
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   850
  ultimately have "{inv_begin1 x} tcopy_begin {inv_loop1 x}"
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   851
    by (rule_tac Hoare_consequence) (auto)
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   852
  moreover
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   853
  have "{inv_loop1 x} tcopy_loop {inv_loop0 x}"
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   854
    by (metis assms loop_correct) 
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   855
  ultimately 
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   856
  have "{inv_begin1 x} (tcopy_begin |+| tcopy_loop) {inv_loop0 x}"
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   857
    by (rule_tac Hoare_plus_halt) (auto)
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   858
  moreover 
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   859
  have "{inv_end1 x} tcopy_end {inv_end0 x}"
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   860
    by (metis assms end_correct) 
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   861
  moreover 
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   862
  have "inv_loop0 x = inv_end1 x"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   863
    by(auto simp: inv_end1.simps inv_loop1.simps assert_imp_def)
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   864
  ultimately 
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   865
  show "{inv_begin1 x} tcopy {inv_end0 x}"
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   866
    unfolding tcopy_def
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   867
    by (rule_tac Hoare_plus_halt) (auto)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   868
qed
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   869
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   870
abbreviation (input)
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   871
  "pre_tcopy n \<equiv> \<lambda>tp. tp = ([]::cell list, Oc \<up> (Suc n))"
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   872
abbreviation (input)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   873
  "post_tcopy n \<equiv> \<lambda>tp. tp= ([Bk], <(n, n::nat)>)"
69
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   874
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   875
lemma tcopy_correct:
69
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   876
  shows "{pre_tcopy n} tcopy {post_tcopy n}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   877
proof -
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
   878
  have "{inv_begin1 (Suc n)} tcopy {inv_end0 (Suc n)}"
69
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   879
    by (rule tcopy_correct1) (simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   880
  moreover
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   881
  have "pre_tcopy n = inv_begin1 (Suc n)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   882
    by (auto)
69
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   883
  moreover
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   884
  have "inv_end0 (Suc n) = post_tcopy n"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   885
    unfolding fun_eq_iff
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   886
    by (auto simp add: inv_end0.simps tape_of_nat_def tape_of_prod_def)
69
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   887
  ultimately
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   888
  show "{pre_tcopy n} tcopy {post_tcopy n}" 
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
   889
    by simp
69
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   890
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   891
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   892
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 68
diff changeset
   893
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
   894
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   895
text {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   896
  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
   897
  terminate.
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   898
*}
66
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
   899
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   900
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
   901
  where
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   902
  "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
   903
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   904
(* invariants of dither *)
94
aeaf1374dc67 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   905
abbreviation (input)
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   906
  "dither_halt_inv \<equiv> \<lambda>tp. \<exists>k. tp = (Bk \<up> k, <1::nat>)"
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   907
94
aeaf1374dc67 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 93
diff changeset
   908
abbreviation (input)
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   909
  "dither_unhalt_inv \<equiv> \<lambda>tp. \<exists>k. tp = (Bk \<up> k, <0::nat>)"
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   910
80
eb589fa73fc1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
   911
lemma dither_loops_aux: 
66
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
   912
  "(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
   913
   (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
   914
  apply(induct stp)
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   915
  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
   916
  done
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   917
66
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
   918
lemma dither_loops:
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   919
  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
   920
apply(rule Hoare_unhaltI)
80
eb589fa73fc1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
   921
using dither_loops_aux
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   922
apply(auto simp add: numeral tape_of_nat_def)
80
eb589fa73fc1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
   923
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
   924
eb589fa73fc1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
   925
lemma dither_halts_aux: 
91
2068654bdf54 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 89
diff changeset
   926
  shows "steps0 (1, Bk \<up> m, [Oc, Oc]) dither 2 = (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
   927
unfolding dither_def
80
eb589fa73fc1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
   928
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
   929
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
   930
lemma dither_halts:
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
   931
  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
   932
apply(rule Hoare_haltI)
80
eb589fa73fc1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
   933
using dither_halts_aux
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   934
apply(auto simp add: tape_of_nat_def)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   935
by (metis (lifting, mono_tags) holds_for.simps is_final_eq)
66
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
   936
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
   937
80
eb589fa73fc1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
   938
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
   939
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   940
text {*
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   941
  @{text "halts tp x"} means TM @{text "tp"} terminates on input @{text "x"}
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   942
  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
   943
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   944
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   945
definition halts :: "tprog0 \<Rightarrow> nat list \<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
   946
  where
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   947
  "halts p ns \<equiv> {(\<lambda>tp. tp = ([], <ns>))} p {(\<lambda>tp. (\<exists>k n l. tp = (Bk \<up> k,  <n::nat> @ Bk \<up> l)))}"
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
   948
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   949
lemma tm_wf0_tcopy[intro, simp]: "tm_wf0 tcopy"
82
c470f1705baa simplified uncomputable-locale
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 81
diff changeset
   950
by (auto simp: tcopy_def)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   951
291
93db7414931d More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 288
diff changeset
   952
lemma tm_wf0_dither[intro, simp]: "tm_wf0 dither"
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
   953
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
   954
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   955
text {*
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   956
  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
   957
  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
   958
  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
   959
  is established. 
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   960
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   961
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   962
locale uncomputable = 
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   963
  (* The coding function of TM, interestingly, the detailed definition of this 
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   964
  funciton @{text "code"} does not affect the final result. *)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   965
  fixes code :: "instr list \<Rightarrow> nat" 
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   966
  (* 
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   967
  The TM @{text "H"} is the one which is assummed being able to solve the Halting problem.
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   968
  *)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   969
  and H :: "instr list"
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   970
  assumes h_wf[intro]: "tm_wf0 H"
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   971
  (*
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   972
  The following two assumptions specifies that @{text "H"} does solve the Halting problem.
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
   973
  *)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   974
  and h_case: 
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   975
  "\<And> M ns. halts M ns \<Longrightarrow> {(\<lambda>tp. tp = ([Bk], <(code M, ns)>))} H {(\<lambda>tp. \<exists>k. tp = (Bk \<up> k, <0::nat>))}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   976
  and nh_case: 
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   977
  "\<And> M ns. \<not> halts M ns \<Longrightarrow> {(\<lambda>tp. tp = ([Bk], <(code M, ns)>))} H {(\<lambda>tp. \<exists>k. tp = (Bk \<up> k, <1::nat>))}"
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   978
begin
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   979
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   980
(* invariants for H *)
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   981
abbreviation (input)
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   982
  "pre_H_inv M ns \<equiv> \<lambda>tp. tp = ([Bk], <(code M, ns::nat list)>)"
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   983
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   984
abbreviation (input)
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   985
  "post_H_halt_inv \<equiv> \<lambda>tp. \<exists>k. tp = (Bk \<up> k, <1::nat>)"
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   986
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   987
abbreviation (input)
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
   988
  "post_H_unhalt_inv \<equiv> \<lambda>tp. \<exists>k. tp = (Bk \<up> k, <0::nat>)"
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   989
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   990
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   991
lemma H_halt_inv:
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   992
  assumes "\<not> halts M ns" 
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   993
  shows "{pre_H_inv M ns} H {post_H_halt_inv}"
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
   994
using assms nh_case by auto
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   995
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
   996
lemma H_unhalt_inv:
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
   997
  assumes "halts M ns" 
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
   998
  shows "{pre_H_inv M ns} H {post_H_unhalt_inv}"
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
   999
using assms h_case by auto
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1000
   
67
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1001
(* TM that produces the contradiction and its code *)
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1002
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1003
definition
67
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1004
  "tcontra \<equiv> (tcopy |+| H) |+| dither"
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1005
abbreviation
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1006
  "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
  1007
67
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1008
(* 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
  1009
lemma tcontra_unhalt: 
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
  1010
  assumes "\<not> halts tcontra [code tcontra]"
66
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
  1011
  shows "False"
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1012
proof -
64
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1013
  (* invariants *)
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1014
  define P1 where "P1 \<equiv> \<lambda>tp. tp = ([]::cell list, <code_tcontra>)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1015
  define P2 where "P2 \<equiv> \<lambda>tp. tp = ([Bk], <(code_tcontra, code_tcontra)>)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1016
  define P3 where "P3 \<equiv> \<lambda>tp. \<exists>k. tp = (Bk \<up> k, <1::nat>)"
64
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1017
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1018
  (*
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1019
  {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
  1020
  ----------------------------
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1021
     {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
  1022
  ------------------------------------------------
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
  1023
                 {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
  1024
  *)
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1025
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1026
  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
  1027
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1028
  (* {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
  1029
  have first: "{P1} (tcopy |+| H) {P3}" 
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
  1030
  proof (cases rule: Hoare_plus_halt)
64
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1031
    case A_halt (* of tcopy *)
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1032
    show "{P1} tcopy {P2}" unfolding P1_def P2_def tape_of_nat_def
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1033
      by (rule tcopy_correct)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1034
  next
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
  1035
    case B_halt (* of H *)
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
  1036
    show "{P2} H {P3}"
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1037
      unfolding P2_def P3_def 
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1038
      using H_halt_inv[OF assms]
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1039
      by (simp add: tape_of_prod_def tape_of_list_def)
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1040
  qed (simp)
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1041
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1042
  (* {P3} dither {P3} *)
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1043
  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
  1044
    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
  1045
  
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1046
  (* {P1} tcontra {P3} *)
67
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1047
  have "{P1} tcontra {P3}" 
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1048
    unfolding tcontra_def
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
  1049
    by (rule Hoare_plus_halt[OF first second H_wf])
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1050
67
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1051
  with assms show "False"
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
  1052
    unfolding P1_def P3_def
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
  1053
    unfolding halts_def
71
8c7f10b3da7b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 70
diff changeset
  1054
    unfolding Hoare_halt_def 
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1055
    apply(auto)    
84
4c8325c64dab updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 83
diff changeset
  1056
    apply(drule_tac x = n in spec)
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1057
    apply(case_tac "steps0 (Suc 0, [], <code tcontra>) tcontra n")
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1058
    apply(auto simp add: tape_of_list_def)
141
4d7a568bd911 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 112
diff changeset
  1059
    by (metis append_Nil2 replicate_0)
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1060
qed
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1061
67
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1062
(* 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
  1063
lemma tcontra_halt: 
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
  1064
  assumes "halts tcontra [code tcontra]"
66
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
  1065
  shows "False"
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1066
proof - 
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1067
  (* invariants *)
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1068
  define P1 where "P1 \<equiv> \<lambda>tp. tp = ([]::cell list, <code_tcontra>)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1069
  define P2 where "P2 \<equiv> \<lambda>tp. tp = ([Bk], <(code_tcontra, code_tcontra)>)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1070
  define Q3 where "Q3 \<equiv> \<lambda>tp. \<exists>k. tp = (Bk \<up> k, <0::nat>)"
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1071
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1072
  (*
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1073
  {P1} tcopy {P2}  {P2} H {Q3} 
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1074
  ----------------------------
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1075
     {P1} (tcopy |+| H) {Q3}     {Q3} dither loops
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1076
  ------------------------------------------------
68
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 67
diff changeset
  1077
               {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
  1078
  *)
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1079
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1080
  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
  1081
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1082
  (* {P1} (tcopy |+| H) {Q3} *)
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1083
  have first: "{P1} (tcopy |+| H) {Q3}" 
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
  1084
  proof (cases rule: Hoare_plus_halt)
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1085
    case A_halt (* of tcopy *)
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1086
    show "{P1} tcopy {P2}" unfolding P1_def P2_def tape_of_nat_def
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1087
      by (rule tcopy_correct)
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1088
  next
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
  1089
    case B_halt (* of H *)
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1090
    then show "{P2} H {Q3}"
105
2cae8a39803e updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 103
diff changeset
  1091
      unfolding P2_def Q3_def using H_unhalt_inv[OF assms]
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1092
      by(simp add: tape_of_prod_def tape_of_list_def)
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1093
  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
  1094
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1095
  (* {P3} dither loops *)
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1096
  have second: "{Q3} dither \<up>" unfolding Q3_def 
64
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1097
    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
  1098
  
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1099
  (* {P1} tcontra loops *)
67
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1100
  have "{P1} tcontra \<up>" 
93
f2bda6ba4952 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 92
diff changeset
  1101
    unfolding tcontra_def
99
fe7a257bdff4 updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 97
diff changeset
  1102
    by (rule Hoare_plus_unhalt[OF first second H_wf])
65
0349fa7f5595 also polished uh_h proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 64
diff changeset
  1103
66
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
  1104
  with assms show "False"
70
2363eb91d9fd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 69
diff changeset
  1105
    unfolding P1_def
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 168
diff changeset
  1106
    unfolding halts_def
89
c67e8ed4c865 updated uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 84
diff changeset
  1107
    unfolding Hoare_halt_def Hoare_unhalt_def
288
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 169
diff changeset
  1108
    by (auto simp add: tape_of_list_def)
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1109
qed
109
4635641e77cb updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
  1110
63
35fe8fe12e65 small updates
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 61
diff changeset
  1111
      
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1112
text {*
64
5c74f6b38a63 updated h_uh proof in uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 63
diff changeset
  1113
  @{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
  1114
*}
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1115
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1116
lemma false: "False"
67
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1117
using tcontra_halt tcontra_unhalt 
140489a4020e using some abbreviations
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 66
diff changeset
  1118
by auto
63
35fe8fe12e65 small updates
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 61
diff changeset
  1119
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1120
end
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1121
66
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
  1122
declare replicate_Suc[simp del]
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
  1123
4a3cd7d70ec2 tuned more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 65
diff changeset
  1124
44
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1125
end
2f765afc1f7e added Jian's new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1126