thys/UTM.thy
author Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
Fri, 21 Dec 2018 15:30:24 +0100
changeset 291 93db7414931d
parent 288 a9003e6d0463
child 292 293e9c6f22e1
permissions -rwxr-xr-x
More naming of lemmas, cleanup of Abacus and NatBijection
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 166
diff changeset
     1
(* Title: thys/UTM.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 166
diff changeset
     2
   Author: Jian Xu, Xingyuan Zhang, and Christian Urban
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 166
diff changeset
     3
*)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 166
diff changeset
     4
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: 285
diff changeset
     5
chapter {* Construction of a Universal Turing Machine *}
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 166
diff changeset
     6
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
theory UTM
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: 285
diff changeset
     8
imports Recursive Abacus UF HOL.GCD Turing_Hoare
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
begin
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
section {* Wang coding of input arguments *}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
text {*
166
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    14
  The direct compilation of the universal function @{text "rec_F"} can
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    15
  not give us UTM, because @{text "rec_F"} is of arity 2, where the
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    16
  first argument represents the Godel coding of the TM being simulated
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    17
  and the second argument represents the right number (in Wang's
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    18
  coding) of the TM tape.  (Notice, left number is always @{text "0"}
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    19
  at the very beginning). However, UTM needs to simulate the execution
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    20
  of any TM which may very well take many input arguments. Therefore,
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    21
  a initialization TM needs to run before the TM compiled from @{text
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    22
  "rec_F"}, and the sequential composition of these two TMs will give
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    23
  rise to the UTM we are seeking. The purpose of this initialization
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    24
  TM is to transform the multiple input arguments of the TM being
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    25
  simulated into Wang's coding, so that it can be consumed by the TM
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    26
  compiled from @{text "rec_F"} as the second argument.
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    27
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    28
  However, this initialization TM (named @{text "t_wcode"}) can not be
169
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 166
diff changeset
    29
  constructed by compiling from any recursive function, because every
166
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    30
  recursive function takes a fixed number of input arguments, while
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    31
  @{text "t_wcode"} needs to take varying number of arguments and
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    32
  tranform them into Wang's coding. Therefore, this section give a
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    33
  direct construction of @{text "t_wcode"} with just some parts being
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    34
  obtained from recursive functions.
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
\newlength{\basewidth}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
\settowidth{\basewidth}{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
\newlength{\baseheight}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
\settoheight{\baseheight}{$B:R$}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
\newcommand{\vsep}{5\baseheight}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
The TM used to generate the Wang's code of input arguments is divided into three TMs
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
    43
 executed sequentially, namely $prepare$, $mainwork$ and $adjust$\<exclamdown>\<pounds>According to the
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
 convention, start state of ever TM is fixed to state $1$ while the final state is
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
 fixed to $0$.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
The input and output of $prepare$ are illustrated respectively by Figure
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
\ref{prepare_input} and \ref{prepare_output}.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
  [tbox/.style = {draw, thick, inner sep = 5pt}]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
  \node (1) [tbox, text height = 3.5pt, right = -0.9pt of 0] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
  \node (2) [tbox, right = -0.9pt of 1] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
  \node (3) [tbox, right = -0.9pt of 2] {\wuhao $a_1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
  \node (4) [tbox, right = -0.9pt of 3] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
  \node (5) [tbox, right = -0.9pt of 4] {\wuhao $a_2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
  \node (6) [right = -0.9pt of 5] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
  \node (7) [tbox, right = -0.9pt of 6] {\wuhao $a_n$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
  \draw [->, >=latex, thick] (1)+(0, -4\baseheight) -- (1);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
\caption{The input of TM $prepare$} \label{prepare_input}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
  \node (1) [draw, text height = 3.5pt, right = -0.9pt of 0, thick, inner sep = 5pt] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
  \node (2) [draw, right = -0.9pt of 1, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
  \node (3) [draw, right = -0.9pt of 2, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
  \node (4) [draw, right = -0.9pt of 3, thick, inner sep = 5pt] {\wuhao $a_1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
  \node (5) [draw, right = -0.9pt of 4, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
  \node (6) [draw, right = -0.9pt of 5, thick, inner sep = 5pt] {\wuhao $a_2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
  \node (7) [right = -0.9pt of 6] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
  \node (8) [draw, right = -0.9pt of 7, thick, inner sep = 5pt] {\wuhao $a_n$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
  \node (9) [draw, right = -0.9pt of 8, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
  \node (10) [draw, right = -0.9pt of 9, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
  \node (11) [draw, right = -0.9pt of 10, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    85
  \draw [->, >=latex, thick] (10)+(0, -4\baseheight) -- (10);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    86
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    87
\caption{The output of TM $prepare$} \label{prepare_output}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    89
166
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    90
As shown in Figure \ref{prepare_input}, the input of $prepare$ is the
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    91
same as the the input of UTM, where $m$ is the Godel coding of the TM
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    92
being interpreted and $a_1$ through $a_n$ are the $n$ input arguments
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    93
of the TM under interpretation. The purpose of $purpose$ is to
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    94
transform this initial tape layout to the one shown in Figure
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    95
\ref{prepare_output}, which is convenient for the generation of Wang's
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    96
codding of $a_1, \ldots, a_n$. The coding procedure starts from $a_n$
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    97
and ends after $a_1$ is encoded. The coding result is stored in an
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    98
accumulator at the end of the tape (initially represented by the $1$
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
    99
two blanks right to $a_n$ in Figure \ref{prepare_output}). In Figure
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
   100
\ref{prepare_output}, arguments $a_1, \ldots, a_n$ are separated by
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
   101
two blanks on both ends with the rest so that movement conditions can
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
   102
be implemented conveniently in subsequent TMs, because, by convention,
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
   103
two consecutive blanks are usually used to signal the end or start of
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
   104
a large chunk of data. The diagram of $prepare$ is given in Figure
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
   105
\ref{prepare_diag}.
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
\scalebox{0.9}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
     \node[circle,draw] (1) {$1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
     \node[circle,draw] (2) at ($(1)+(0.3\basewidth, 0)$) {$2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
     \node[circle,draw] (3) at ($(2)+(0.3\basewidth, 0)$) {$3$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
     \node[circle,draw] (4) at ($(3)+(0.3\basewidth, 0)$) {$4$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
     \node[circle,draw] (5) at ($(4)+(0.3\basewidth, 0)$) {$5$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
     \node[circle,draw] (6) at ($(5)+(0.3\basewidth, 0)$) {$6$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
     \node[circle,draw] (7) at ($(6)+(0.3\basewidth, 0)$) {$7$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
     \node[circle,draw] (8) at ($(7)+(0.3\basewidth, 0)$) {$0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   121
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
     \draw [->, >=latex] (1) edge [loop above] node[above] {$S_1:L$} (1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
     \draw [->, >=latex] (1) -- node[above] {$S_0:S_1$} (2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
     \draw [->, >=latex] (2) edge [loop above] node[above] {$S_1:R$} (2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
     \draw [->, >=latex] (2) -- node[above] {$S_0:L$} (3)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
     \draw [->, >=latex] (3) edge[loop above] node[above] {$S_1:S_0$} (3)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
     \draw [->, >=latex] (3) -- node[above] {$S_0:R$} (4)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   133
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   134
     \draw [->, >=latex] (4) edge[loop above] node[above] {$S_0:R$} (4)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   135
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   136
     \draw [->, >=latex] (4) -- node[above] {$S_0:R$} (5)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   137
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   138
     \draw [->, >=latex] (5) edge[loop above] node[above] {$S_1:R$} (5)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   139
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   140
     \draw [->, >=latex] (5) -- node[above] {$S_0:R$} (6)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
     \draw [->, >=latex] (6) edge[bend left = 50] node[below] {$S_1:R$} (5)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
     \draw [->, >=latex] (6) -- node[above] {$S_0:R$} (7)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
     \draw [->, >=latex] (7) edge[loop above] node[above] {$S_0:S_1$} (7)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   148
     \draw [->, >=latex] (7) -- node[above] {$S_1:L$} (8)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   149
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   150
 \end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   151
\caption{The diagram of TM $prepare$} \label{prepare_diag}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   152
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
The purpose of TM $mainwork$ is to compute the Wang's encoding of $a_1, \ldots, a_n$. Every bit of $a_1, \ldots, a_n$, including the separating bits, is processed from left to right.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   155
In order to detect the termination condition when the left most bit of $a_1$ is reached,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   156
TM $mainwork$ needs to look ahead and consider three different situations at the start of
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   157
every iteration:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   158
\begin{enumerate}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
    \item The TM configuration for the first situation is shown in Figure \ref{mainwork_case_one_input},
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
        where the accumulator is stored in $r$, both of the next two bits
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   161
        to be encoded are $1$. The configuration at the end of the iteration
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   162
        is shown in Figure \ref{mainwork_case_one_output}, where the first 1-bit has been
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   163
        encoded and cleared. Notice that the accumulator has been changed to
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
        $(r+1) \times 2$ to reflect the encoded bit.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   165
    \item The TM configuration for the second situation is shown in Figure
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   166
        \ref{mainwork_case_two_input},
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
        where the accumulator is stored in $r$, the next two bits
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   168
        to be encoded are $1$ and $0$. After the first
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
        $1$-bit was encoded and cleared, the second $0$-bit is difficult to detect
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   170
        and process. To solve this problem, these two consecutive bits are
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   171
        encoded in one iteration.  In this situation, only the first $1$-bit needs
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   172
        to be cleared since the second one is cleared by definition.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
        The configuration at the end of the iteration
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   174
        is shown in Figure \ref{mainwork_case_two_output}.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   175
        Notice that the accumulator has been changed to
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
        $(r+1) \times 4$ to reflect the two encoded bits.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   177
    \item The third situation corresponds to the case when the last bit of $a_1$ is reached.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
        The TM configurations at the start and end of the iteration are shown in
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
        Figure \ref{mainwork_case_three_input} and \ref{mainwork_case_three_output}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   180
        respectively. For this situation, only the read write head needs to be moved to
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
        the left to prepare a initial configuration for TM $adjust$ to start with.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   182
\end{enumerate}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
The diagram of $mainwork$ is given in Figure \ref{mainwork_diag}. The two rectangular nodes
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   184
labeled with $2 \times x$ and $4 \times x$ are two TMs compiling from recursive functions
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   185
so that we do not have to design and verify two quite complicated TMs.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   186
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   187
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   189
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   191
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   192
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
  \node (1) [draw, text height = 3.9pt, right = -0.9pt of 0, thick, inner sep = 5pt] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
  \node (2) [draw, right = -0.9pt of 1, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
  \node (3) [draw, right = -0.9pt of 2, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   196
  \node (4) [draw, right = -0.9pt of 3, thick, inner sep = 5pt] {\wuhao $a_1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
  \node (5) [draw, right = -0.9pt of 4, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
  \node (6) [draw, right = -0.9pt of 5, thick, inner sep = 5pt] {\wuhao $a_2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
  \node (7) [right = -0.9pt of 6] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
  \node (8) [draw, right = -0.9pt of 7, thick, inner sep = 5pt] {\wuhao $a_i$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
  \node (9) [draw, right = -0.9pt of 8, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   202
  \node (10) [draw, right = -0.9pt of 9, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   203
  \node (11) [draw, right = -0.9pt of 10, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   204
  \node (12) [right = -0.9pt of 11] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   205
  \node (13) [draw, right = -0.9pt of 12, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   206
  \node (14) [draw, text height = 3.9pt, right = -0.9pt of 13, thick, inner sep = 5pt] {\wuhao $r$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   207
  \draw [->, >=latex, thick] (13)+(0, -4\baseheight) -- (13);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   208
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   209
\caption{The first situation for TM $mainwork$ to consider} \label{mainwork_case_one_input}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   210
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   212
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   213
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   214
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   215
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   216
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
  \node (1) [draw, text height = 3.9pt, right = -0.9pt of 0, thick, inner sep = 5pt] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
  \node (2) [draw, right = -0.9pt of 1, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   220
  \node (3) [draw, right = -0.9pt of 2, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   221
  \node (4) [draw, right = -0.9pt of 3, thick, inner sep = 5pt] {\wuhao $a_1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   222
  \node (5) [draw, right = -0.9pt of 4, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   223
  \node (6) [draw, right = -0.9pt of 5, thick, inner sep = 5pt] {\wuhao $a_2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   224
  \node (7) [right = -0.9pt of 6] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   225
  \node (8) [draw, right = -0.9pt of 7, thick, inner sep = 5pt] {\wuhao $a_i$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   226
  \node (9) [draw, right = -0.9pt of 8, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   227
  \node (10) [draw, right = -0.9pt of 9, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   228
  \node (11) [draw, right = -0.9pt of 10, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   229
  \node (12) [right = -0.9pt of 11] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   230
  \node (13) [draw, right = -0.9pt of 12, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   231
  \node (14) [draw, text height = 2.7pt, right = -0.9pt of 13, thick, inner sep = 5pt] {\wuhao $(r+1) \times 2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   232
  \draw [->, >=latex, thick] (13)+(0, -4\baseheight) -- (13);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   233
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   234
\caption{The output for the first case of TM $mainwork$'s processing}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   235
\label{mainwork_case_one_output}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   236
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   237
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   238
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   239
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   240
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   241
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   242
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   243
  \node (1) [draw, text height = 3.9pt, right = -0.9pt of 0, thick, inner sep = 5pt] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   244
  \node (2) [draw, right = -0.9pt of 1, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   245
  \node (3) [draw, right = -0.9pt of 2, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   246
  \node (4) [draw, right = -0.9pt of 3, thick, inner sep = 5pt] {\wuhao $a_1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   247
  \node (5) [draw, right = -0.9pt of 4, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   248
  \node (6) [draw, right = -0.9pt of 5, thick, inner sep = 5pt] {\wuhao $a_2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   249
  \node (7) [right = -0.9pt of 6] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   250
  \node (8) [draw, right = -0.9pt of 7, thick, inner sep = 5pt] {\wuhao $a_i$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   251
  \node (9) [draw, right = -0.9pt of 8, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   252
  \node (10) [draw, right = -0.9pt of 9, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
  \node (11) [draw, right = -0.9pt of 10, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   254
  \node (12) [draw, right = -0.9pt of 11, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
  \node (13) [right = -0.9pt of 12] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
  \node (14) [draw, right = -0.9pt of 13, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
  \node (15) [draw, text height = 3.9pt, right = -0.9pt of 14, thick, inner sep = 5pt] {\wuhao $r$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
  \draw [->, >=latex, thick] (14)+(0, -4\baseheight) -- (14);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
\caption{The second situation for TM $mainwork$ to consider} \label{mainwork_case_two_input}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   261
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   262
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   263
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   264
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   265
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   266
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
  \node (1) [draw, text height = 3.9pt, right = -0.9pt of 0, thick, inner sep = 5pt] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
  \node (2) [draw, right = -0.9pt of 1, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   270
  \node (3) [draw, right = -0.9pt of 2, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   271
  \node (4) [draw, right = -0.9pt of 3, thick, inner sep = 5pt] {\wuhao $a_1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   272
  \node (5) [draw, right = -0.9pt of 4, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
  \node (6) [draw, right = -0.9pt of 5, thick, inner sep = 5pt] {\wuhao $a_2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   274
  \node (7) [right = -0.9pt of 6] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
  \node (8) [draw, right = -0.9pt of 7, thick, inner sep = 5pt] {\wuhao $a_i$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   276
  \node (9) [draw, right = -0.9pt of 8, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   277
  \node (10) [draw, right = -0.9pt of 9, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
  \node (11) [draw, right = -0.9pt of 10, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   279
  \node (12) [draw, right = -0.9pt of 11, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   280
  \node (13) [right = -0.9pt of 12] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
  \node (14) [draw, right = -0.9pt of 13, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   282
  \node (15) [draw, text height = 2.7pt, right = -0.9pt of 14, thick, inner sep = 5pt] {\wuhao $(r+1) \times 4$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   283
  \draw [->, >=latex, thick] (14)+(0, -4\baseheight) -- (14);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   284
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   285
\caption{The output for the second case of TM $mainwork$'s processing}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   286
\label{mainwork_case_two_output}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   287
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   291
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   292
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
  \node (1) [draw, text height = 3.9pt, right = -0.9pt of 0, thick, inner sep = 5pt] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   295
  \node (2) [draw, right = -0.9pt of 1, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   296
  \node (3) [draw, right = -0.9pt of 2, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   297
  \node (4) [draw, right = -0.9pt of 3, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
  \node (5) [draw, right = -0.9pt of 4, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
  \node (6) [right = -0.9pt of 5] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   300
  \node (7) [draw, right = -0.9pt of 6, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
  \node (8) [draw, text height = 3.9pt, right = -0.9pt of 7, thick, inner sep = 5pt] {\wuhao $r$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   302
  \draw [->, >=latex, thick] (7)+(0, -4\baseheight) -- (7);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   303
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   304
\caption{The third situation for TM $mainwork$ to consider} \label{mainwork_case_three_input}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   306
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   307
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   308
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   309
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   310
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   311
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   312
  \node (1) [draw, text height = 3.9pt, right = -0.9pt of 0, thick, inner sep = 5pt] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   313
  \node (2) [draw, right = -0.9pt of 1, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   314
  \node (3) [draw, right = -0.9pt of 2, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   315
  \node (4) [draw, right = -0.9pt of 3, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   316
  \node (5) [draw, right = -0.9pt of 4, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   317
  \node (6) [right = -0.9pt of 5] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   318
  \node (7) [draw, right = -0.9pt of 6, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   319
  \node (8) [draw, text height = 3.9pt, right = -0.9pt of 7, thick, inner sep = 5pt] {\wuhao $r$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   320
  \draw [->, >=latex, thick] (3)+(0, -4\baseheight) -- (3);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   321
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   322
\caption{The output for the third case of TM $mainwork$'s processing}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   323
\label{mainwork_case_three_output}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   324
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   325
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   326
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   327
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   328
\scalebox{0.9}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   329
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   330
     \node[circle,draw] (1) {$1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   331
     \node[circle,draw] (2) at ($(1)+(0.3\basewidth, 0)$) {$2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   332
     \node[circle,draw] (3) at ($(2)+(0.3\basewidth, 0)$) {$3$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   333
     \node[circle,draw] (4) at ($(3)+(0.3\basewidth, 0)$) {$4$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   334
     \node[circle,draw] (5) at ($(4)+(0.3\basewidth, 0)$) {$5$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   335
     \node[circle,draw] (6) at ($(5)+(0.3\basewidth, 0)$) {$6$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   336
     \node[circle,draw] (7) at ($(2)+(0, -7\baseheight)$) {$7$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   337
     \node[circle,draw] (8) at ($(7)+(0, -7\baseheight)$) {$8$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
     \node[circle,draw] (9) at ($(8)+(0.3\basewidth, 0)$) {$9$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   339
     \node[circle,draw] (10) at ($(9)+(0.3\basewidth, 0)$) {$10$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   340
     \node[circle,draw] (11) at ($(10)+(0.3\basewidth, 0)$) {$11$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   341
     \node[circle,draw] (12) at ($(11)+(0.3\basewidth, 0)$) {$12$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   342
     \node[draw] (13) at ($(6)+(0.3\basewidth, 0)$) {$2 \times x$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   343
     \node[circle,draw] (14) at ($(13)+(0.3\basewidth, 0)$) {$j_1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   344
     \node[draw] (15) at ($(12)+(0.3\basewidth, 0)$) {$4 \times x$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   345
     \node[draw] (16) at ($(15)+(0.3\basewidth, 0)$) {$j_2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   346
     \node[draw] (17) at ($(7)+(0.3\basewidth, 0)$) {$0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   347
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   348
     \draw [->, >=latex] (1) edge[loop left] node[above] {$S_0:L$} (1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   349
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   350
     \draw [->, >=latex] (1) -- node[above] {$S_1:L$} (2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   351
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   352
     \draw [->, >=latex] (2) -- node[above] {$S_1:R$} (3)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   353
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   354
     \draw [->, >=latex] (2) -- node[left] {$S_1:L$} (7)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   355
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   356
     \draw [->, >=latex] (3) edge[loop above] node[above] {$S_1:S_0$} (3)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   357
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   358
     \draw [->, >=latex] (3) -- node[above] {$S_0:R$} (4)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   359
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   360
     \draw [->, >=latex] (4) edge[loop above] node[above] {$S_0:R$} (4)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   361
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   362
     \draw [->, >=latex] (4) -- node[above] {$S_1:R$} (5)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   363
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   364
     \draw [->, >=latex] (5) edge[loop above] node[above] {$S_1:R$} (5)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   365
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   366
     \draw [->, >=latex] (5) -- node[above] {$S_0:S_1$} (6)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   367
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   368
     \draw [->, >=latex] (6) edge[loop above] node[above] {$S_1:L$} (6)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   369
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   370
     \draw [->, >=latex] (6) -- node[above] {$S_0:R$} (13)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   371
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   372
     \draw [->, >=latex] (13) -- (14)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   373
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   374
     \draw (14) -- ($(14)+(0, 6\baseheight)$) -- ($(1) + (0, 6\baseheight)$) node [above,midway] {$S_1:L$}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   375
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   376
     \draw [->, >=latex] ($(1) + (0, 6\baseheight)$) -- (1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   377
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   378
     \draw [->, >=latex] (7) -- node[above] {$S_0:R$} (17)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   379
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   380
     \draw [->, >=latex] (7) -- node[left] {$S_1:R$} (8)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   381
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   382
     \draw [->, >=latex] (8) -- node[above] {$S_0:R$} (9)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   383
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   384
     \draw [->, >=latex] (9) -- node[above] {$S_0:R$} (10)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   385
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   386
     \draw [->, >=latex] (10) -- node[above] {$S_1:R$} (11)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   387
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   388
     \draw [->, >=latex] (10) edge[loop above] node[above] {$S_0:R$} (10)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   389
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   390
     \draw [->, >=latex] (11) edge[loop above] node[above] {$S_1:R$} (11)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   391
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   392
     \draw [->, >=latex] (11) -- node[above] {$S_0:S_1$} (12)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   393
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   394
     \draw [->, >=latex] (12) -- node[above] {$S_0:R$} (15)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   395
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   396
     \draw [->, >=latex] (12) edge[loop above] node[above] {$S_1:L$} (12)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   397
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   398
     \draw [->, >=latex] (15) -- (16)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   399
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   400
     \draw (16) -- ($(16)+(0, -4\baseheight)$) -- ($(1) + (0, -18\baseheight)$) node [below,midway] {$S_1:L$}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   401
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   402
     \draw [->, >=latex] ($(1) + (0, -18\baseheight)$) -- (1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   403
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   404
 \end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   405
\caption{The diagram of TM $mainwork$} \label{mainwork_diag}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   406
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   407
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   408
The purpose of TM $adjust$ is to encode the last bit of $a_1$. The initial and final configuration
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   409
of this TM are shown in Figure \ref{adjust_initial} and \ref{adjust_final} respectively.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   410
The diagram of TM $adjust$ is shown in Figure \ref{adjust_diag}.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   411
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   412
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   413
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   414
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   415
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   416
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   417
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   418
  \node (1) [draw, text height = 3.9pt, right = -0.9pt of 0, thick, inner sep = 5pt] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   419
  \node (2) [draw, right = -0.9pt of 1, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   420
  \node (3) [draw, right = -0.9pt of 2, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   421
  \node (4) [draw, right = -0.9pt of 3, thick, inner sep = 5pt] {\wuhao $1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   422
  \node (5) [draw, right = -0.9pt of 4, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   423
  \node (6) [right = -0.9pt of 5] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   424
  \node (7) [draw, right = -0.9pt of 6, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   425
  \node (8) [draw, text height = 3.9pt, right = -0.9pt of 7, thick, inner sep = 5pt] {\wuhao $r$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   426
  \draw [->, >=latex, thick] (3)+(0, -4\baseheight) -- (3);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   427
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   428
\caption{Initial configuration of TM $adjust$} \label{adjust_initial}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   429
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   430
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   431
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   432
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   433
\scalebox{1.2}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   434
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   435
  \node (0) {};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   436
  \node (1) [draw, text height = 3.9pt, right = -0.9pt of 0, thick, inner sep = 5pt] {\wuhao $m$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   437
  \node (2) [draw, right = -0.9pt of 1, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   438
  \node (3) [draw, text height = 2.9pt, right = -0.9pt of 2, thick, inner sep = 5pt] {\wuhao $r+1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   439
  \node (4) [draw, right = -0.9pt of 3, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   440
  \node (5) [draw, right = -0.9pt of 4, thick, inner sep = 5pt] {\wuhao $0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   441
  \node (6) [right = -0.9pt of 5] {\ldots \ldots};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   442
  \draw [->, >=latex, thick] (1)+(0, -4\baseheight) -- (1);
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   443
\end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   444
\caption{Final configuration of TM $adjust$} \label{adjust_final}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   445
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   446
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   447
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   448
\begin{figure}[h!]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   449
\centering
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   450
\scalebox{0.9}{
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   451
\begin{tikzpicture}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   452
     \node[circle,draw] (1) {$1$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   453
     \node[circle,draw] (2) at ($(1)+(0.3\basewidth, 0)$) {$2$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   454
     \node[circle,draw] (3) at ($(2)+(0.3\basewidth, 0)$) {$3$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   455
     \node[circle,draw] (4) at ($(3)+(0.3\basewidth, 0)$) {$4$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   456
     \node[circle,draw] (5) at ($(4)+(0.3\basewidth, 0)$) {$5$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   457
     \node[circle,draw] (6) at ($(5)+(0.3\basewidth, 0)$) {$6$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   458
     \node[circle,draw] (7) at ($(6)+(0.3\basewidth, 0)$) {$7$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   459
     \node[circle,draw] (8) at ($(4)+(0, -7\baseheight)$) {$8$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   460
     \node[circle,draw] (9) at ($(8)+(0.3\basewidth, 0)$) {$9$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   461
     \node[circle,draw] (10) at ($(9)+(0.3\basewidth, 0)$) {$10$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   462
     \node[circle,draw] (11) at ($(10)+(0.3\basewidth, 0)$) {$11$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   463
     \node[circle,draw] (12) at ($(11)+(0.3\basewidth, 0)$) {$0$};
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   464
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   465
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   466
     \draw [->, >=latex] (1) -- node[above] {$S_1:R$} (2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   467
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   468
     \draw [->, >=latex] (1) edge[loop above] node[above] {$S_0:S_1$} (1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   469
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   470
     \draw [->, >=latex] (2) -- node[above] {$S_1:R$} (3)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   471
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   472
     \draw [->, >=latex] (3) edge[loop above] node[above] {$S_0:R$} (3)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   473
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   474
     \draw [->, >=latex] (3) -- node[above] {$S_1:R$} (4)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   475
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   476
     \draw [->, >=latex] (4) -- node[above] {$S_1:L$} (5)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   477
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   478
     \draw [->, >=latex] (4) -- node[right] {$S_0:L$} (8)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   479
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   480
     \draw [->, >=latex] (5) -- node[above] {$S_0:L$} (6)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   481
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   482
     \draw [->, >=latex] (5) edge[loop above] node[above] {$S_1:S_0$} (5)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   483
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   484
     \draw [->, >=latex] (6) -- node[above] {$S_1:R$} (7)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   485
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   486
     \draw [->, >=latex] (6) edge[loop above] node[above] {$S_0:L$} (6)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   487
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   488
     \draw (7) -- ($(7)+(0, 6\baseheight)$) -- ($(2) + (0, 6\baseheight)$) node [above,midway] {$S_0:S_1$}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   489
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   490
     \draw [->, >=latex] ($(2) + (0, 6\baseheight)$) -- (2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   491
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   492
     \draw [->, >=latex] (8) edge[loop left] node[left] {$S_1:S_0$} (8)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   493
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   494
     \draw [->, >=latex] (8) -- node[above] {$S_0:L$} (9)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   495
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   496
     \draw [->, >=latex] (9) edge[loop above] node[above] {$S_0:L$} (9)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   497
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   498
     \draw [->, >=latex] (9) -- node[above] {$S_1:L$} (10)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   499
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   500
     \draw [->, >=latex] (10) edge[loop above] node[above] {$S_0:L$} (10)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   501
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   502
     \draw [->, >=latex] (10) -- node[above] {$S_0:L$} (11)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   503
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   504
     \draw [->, >=latex] (11) edge[loop above] node[above] {$S_1:L$} (11)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   505
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   506
     \draw [->, >=latex] (11) -- node[above] {$S_0:R$} (12)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   507
     ;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   508
 \end{tikzpicture}}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   509
\caption{Diagram of TM $adjust$} \label{adjust_diag}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   510
\end{figure}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   511
*}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   512
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   513
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   514
definition rec_twice :: "recf"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   515
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   516
  "rec_twice = Cn 1 rec_mult [id 1 0, constn 2]"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   517
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   518
definition rec_fourtimes  :: "recf"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   519
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   520
  "rec_fourtimes = Cn 1 rec_mult [id 1 0, constn 4]"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   521
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   522
definition abc_twice :: "abc_prog"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   523
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   524
  "abc_twice = (let (aprog, ary, fp) = rec_ci rec_twice in 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   525
                       aprog [+] dummy_abc ((Suc 0)))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   526
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   527
definition abc_fourtimes :: "abc_prog"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   528
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   529
  "abc_fourtimes = (let (aprog, ary, fp) = rec_ci rec_fourtimes in 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   530
                       aprog [+] dummy_abc ((Suc 0)))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   531
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   532
definition twice_ly :: "nat list"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   533
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   534
  "twice_ly = layout_of abc_twice"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   535
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   536
definition fourtimes_ly :: "nat list"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   537
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   538
  "fourtimes_ly = layout_of abc_fourtimes"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   539
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   540
definition t_twice_compile :: "instr list"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   541
where
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   542
  "t_twice_compile= (tm_of abc_twice @ (shift (mopup 1) (length (tm_of abc_twice) div 2)))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   543
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   544
definition t_twice :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   545
  where
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
   546
  "t_twice = adjust0 t_twice_compile"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   547
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   548
definition t_fourtimes_compile :: "instr list"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   549
where
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   550
  "t_fourtimes_compile= (tm_of abc_fourtimes @ (shift (mopup 1) (length (tm_of abc_fourtimes) div 2)))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   551
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   552
definition t_fourtimes :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   553
  where
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
   554
  "t_fourtimes = adjust0 t_fourtimes_compile"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   555
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   556
definition t_twice_len :: "nat"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   557
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   558
  "t_twice_len = length t_twice div 2"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   559
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   560
definition t_wcode_main_first_part:: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   561
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   562
  "t_wcode_main_first_part \<equiv> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   563
                   [(L, 1), (L, 2), (L, 7), (R, 3),
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   564
                    (R, 4), (W0, 3), (R, 4), (R, 5),
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   565
                    (W1, 6), (R, 5), (R, 13), (L, 6),
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   566
                    (R, 0), (R, 8), (R, 9), (Nop, 8),
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   567
                    (R, 10), (W0, 9), (R, 10), (R, 11), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   568
                    (W1, 12), (R, 11), (R, t_twice_len + 14), (L, 12)]"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   569
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   570
definition t_wcode_main :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   571
  where
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   572
  "t_wcode_main = (t_wcode_main_first_part @ shift t_twice 12 @ [(L, 1), (L, 1)]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   573
                    @ shift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)])"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   574
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   575
fun bl_bin :: "cell list \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   576
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   577
  "bl_bin [] = 0" 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   578
| "bl_bin (Bk # xs) = 2 * bl_bin xs"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   579
| "bl_bin (Oc # xs) = Suc (2 * bl_bin xs)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   580
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   581
declare bl_bin.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   582
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   583
type_synonym bin_inv_t = "cell list \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   584
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   585
fun wcode_before_double :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   586
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   587
  "wcode_before_double ires rs (l, r) =
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   588
     (\<exists> ln rn. l = Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   589
               r = Oc\<up>((Suc (Suc rs))) @ Bk\<up>(rn ))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   590
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   591
declare wcode_before_double.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   592
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   593
fun wcode_after_double :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   594
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   595
  "wcode_after_double ires rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   596
     (\<exists> ln rn. l = Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   597
         r = Oc\<up>(Suc (Suc (Suc 2*rs))) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   598
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   599
declare wcode_after_double.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   600
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   601
fun wcode_on_left_moving_1_B :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   602
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   603
  "wcode_on_left_moving_1_B ires rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   604
     (\<exists> ml mr rn. l = Bk\<up>(ml) @ Oc # Oc # ires \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   605
               r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   606
               ml + mr > Suc 0 \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   607
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   608
declare wcode_on_left_moving_1_B.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   609
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   610
fun wcode_on_left_moving_1_O :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   611
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   612
  "wcode_on_left_moving_1_O ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   613
     (\<exists> ln rn.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   614
               l = Oc # ires \<and> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   615
               r = Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   616
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   617
declare wcode_on_left_moving_1_O.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   618
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   619
fun wcode_on_left_moving_1 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   620
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   621
  "wcode_on_left_moving_1 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   622
          (wcode_on_left_moving_1_B ires rs (l, r) \<or> wcode_on_left_moving_1_O ires rs (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   623
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   624
declare wcode_on_left_moving_1.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   625
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   626
fun wcode_on_checking_1 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   627
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   628
   "wcode_on_checking_1 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   629
    (\<exists> ln rn. l = ires \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   630
              r = Oc # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   631
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   632
fun wcode_erase1 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   633
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   634
"wcode_erase1 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   635
       (\<exists> ln rn. l = Oc # ires \<and> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   636
                 tl r = Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   637
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   638
declare wcode_erase1.simps [simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   639
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   640
fun wcode_on_right_moving_1 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   641
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   642
  "wcode_on_right_moving_1 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   643
       (\<exists> ml mr rn.        
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   644
             l = Bk\<up>(ml) @ Oc # ires \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   645
             r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   646
             ml + mr > Suc 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   647
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   648
declare wcode_on_right_moving_1.simps [simp del] 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   649
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   650
declare wcode_on_right_moving_1.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   651
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   652
fun wcode_goon_right_moving_1 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   653
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   654
  "wcode_goon_right_moving_1 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   655
      (\<exists> ml mr ln rn. 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   656
            l = Oc\<up>(ml) @ Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   657
            r = Oc\<up>(mr) @ Bk\<up>(rn) \<and>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   658
            ml + mr = Suc rs)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   659
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   660
declare wcode_goon_right_moving_1.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   661
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   662
fun wcode_backto_standard_pos_B :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   663
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   664
  "wcode_backto_standard_pos_B ires rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   665
          (\<exists> ln rn. l =  Bk # Bk\<up>(ln) @ Oc # ires \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   666
               r =  Bk # Oc\<up>((Suc (Suc rs))) @ Bk\<up>(rn ))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   667
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   668
declare wcode_backto_standard_pos_B.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   669
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   670
fun wcode_backto_standard_pos_O :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   671
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   672
   "wcode_backto_standard_pos_O ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   673
        (\<exists> ml mr ln rn. 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   674
            l = Oc\<up>(ml) @ Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   675
            r = Oc\<up>(mr) @ Bk\<up>(rn) \<and>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   676
            ml + mr = Suc (Suc rs) \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   677
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   678
declare wcode_backto_standard_pos_O.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   679
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   680
fun wcode_backto_standard_pos :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   681
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   682
  "wcode_backto_standard_pos ires rs (l, r) = (wcode_backto_standard_pos_B ires rs (l, r) \<or>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   683
                                            wcode_backto_standard_pos_O ires rs (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   684
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   685
declare wcode_backto_standard_pos.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   686
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   687
lemma bin_wc_eq: "bl_bin xs = bl2wc xs"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   688
proof(induct xs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   689
  show " bl_bin [] = bl2wc []" 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   690
    apply(simp add: bl_bin.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   691
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   692
next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   693
  fix a xs
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   694
  assume "bl_bin xs = bl2wc xs"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   695
  thus " bl_bin (a # xs) = bl2wc (a # xs)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   696
    apply(case_tac a, simp_all add: bl_bin.simps bl2wc.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   697
    apply(simp_all add: bl2nat.simps bl2nat_double)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   698
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   699
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   700
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   701
lemma tape_of_nl_append_one: "lm \<noteq> [] \<Longrightarrow>  <lm @ [a]> = <lm> @ Bk # Oc\<up>Suc a"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   702
apply(induct lm, auto simp: tape_of_nl_cons split:if_splits)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   703
done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   704
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   705
lemma tape_of_nl_rev: "rev (<lm::nat list>) = (<rev lm>)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   706
apply(induct lm, simp, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   707
apply(auto simp: tape_of_nl_cons tape_of_nl_append_one split: if_splits)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   708
apply(simp add: exp_ind[THEN sym])
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   709
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   710
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: 285
diff changeset
   711
lemma exp_1[simp]: "a\<up>(Suc 0) = [a]" 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   712
by(simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   713
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   714
lemma tape_of_nl_cons_app1: "(<a # xs @ [b]>) = (Oc\<up>(Suc a) @ Bk # (<xs@ [b]>))"
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: 285
diff changeset
   715
apply(case_tac xs; simp add: tape_of_list_def tape_of_nat_list.simps tape_of_nat_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   716
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   717
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   718
lemma bl_bin_bk_oc[simp]:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   719
  "bl_bin (xs @ [Bk, Oc]) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   720
  bl_bin xs + 2*2^(length xs)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   721
apply(simp add: bin_wc_eq)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   722
using bl2nat_cons_oc[of "xs @ [Bk]"]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   723
apply(simp add: bl2nat_cons_bk bl2wc.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   724
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   725
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   726
lemma tape_of_nat[simp]: "(<a::nat>) = Oc\<up>(Suc a)"
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: 285
diff changeset
   727
apply(simp add: tape_of_nat_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   728
done
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   729
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   730
lemma tape_of_nl_cons_app2: "(<c # xs @ [b]>) = (<c # xs> @ Bk # Oc\<up>(Suc b))"
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: 285
diff changeset
   731
proof(induct "length xs" arbitrary: xs c, simp add: tape_of_list_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   732
  fix x xs c
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   733
  assume ind: "\<And>xs c. x = length xs \<Longrightarrow> <c # xs @ [b]> = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   734
    <c # xs> @ Bk # Oc\<up>(Suc b)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   735
    and h: "Suc x = length (xs::nat list)" 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   736
  show "<c # xs @ [b]> = <c # xs> @ Bk # Oc\<up>(Suc b)"
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: 285
diff changeset
   737
  proof(case_tac xs, simp add: tape_of_list_def  tape_of_nat_list.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   738
    fix a list
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   739
    assume g: "xs = a # list"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   740
    hence k: "<a # list @ [b]> =  <a # list> @ Bk # Oc\<up>(Suc b)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   741
      apply(rule_tac ind)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   742
      using h
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   743
      apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   744
      done
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   745
    from g and k show "<c # xs @ [b]> = <c # xs> @ Bk # Oc\<up>(Suc b)"
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: 285
diff changeset
   746
      apply(simp add: tape_of_list_def tape_of_nat_list.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   747
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   748
  qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   749
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   750
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: 285
diff changeset
   751
lemma length_2_elems[simp]: "length (<aa # a # list>) = Suc (Suc aa) + length (<a # list>)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   752
apply(simp add: tape_of_list_def tape_of_nat_list.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   753
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   754
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: 285
diff changeset
   755
lemma bl_bin_addition[simp]: "bl_bin (Oc\<up>(Suc aa) @ Bk # tape_of_nat_list (a # lista) @ [Bk, Oc]) =
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   756
              bl_bin (Oc\<up>(Suc aa) @ Bk # tape_of_nat_list (a # lista)) + 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   757
              2* 2^(length (Oc\<up>(Suc aa) @ Bk # tape_of_nat_list (a # lista)))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   758
using bl_bin_bk_oc[of "Oc\<up>(Suc aa) @ Bk # tape_of_nat_list (a # lista)"]
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   759
apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   760
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   761
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   762
declare replicate_Suc[simp del]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   763
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: 285
diff changeset
   764
lemma bl_bin_2[simp]: 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   765
  "bl_bin (<aa # list>) + (4 * rs + 4) * 2 ^ (length (<aa # list>) - Suc 0)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   766
  = bl_bin (Oc\<up>(Suc aa) @ Bk # <list @ [0]>) + rs * (2 * 2 ^ (aa + length (<list @ [0]>)))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   767
apply(case_tac "list", simp add: add_mult_distrib)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   768
apply(simp add: tape_of_nl_cons_app2 add_mult_distrib)
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: 285
diff changeset
   769
apply(simp add: tape_of_list_def tape_of_nat_list.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   770
done
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   771
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   772
lemma tape_of_nl_app_Suc: "((<list @ [Suc ab]>)) = (<list @ [ab]>) @ [Oc]"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   773
apply(induct list)
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: 285
diff changeset
   774
apply(simp add: tape_of_list_def tape_of_nat_list.simps exp_ind)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   775
apply(case_tac list)
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: 285
diff changeset
   776
apply(simp_all add:tape_of_list_def tape_of_nat_list.simps exp_ind)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   777
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   778
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: 285
diff changeset
   779
lemma bl_bin_3[simp]: "bl_bin (Oc # Oc\<up>(aa) @ Bk # <list @ [ab]> @ [Oc])
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   780
              = bl_bin (Oc # Oc\<up>(aa) @ Bk # <list @ [ab]>) +
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   781
              2^(length (Oc # Oc\<up>(aa) @ Bk # <list @ [ab]>))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   782
apply(simp add: bin_wc_eq)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   783
apply(simp add: bl2nat_cons_oc bl2wc.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   784
using bl2nat_cons_oc[of "Oc # Oc\<up>(aa) @ Bk # <list @ [ab]>"]
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   785
apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   786
done
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: 285
diff changeset
   787
lemma bl_bin_4[simp]: "bl_bin (Oc # Oc\<up>(aa) @ Bk # <list @ [ab]>) + (4 * 2 ^ (aa + length (<list @ [ab]>)) +
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   788
         4 * (rs * 2 ^ (aa + length (<list @ [ab]>)))) =
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   789
       bl_bin (Oc # Oc\<up>(aa) @ Bk # <list @ [Suc ab]>) +
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   790
         rs * (2 * 2 ^ (aa + length (<list @ [Suc ab]>)))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   791
apply(simp add: tape_of_nl_app_Suc)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   792
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   793
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   794
declare tape_of_nat[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   795
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   796
fun wcode_double_case_inv :: "nat \<Rightarrow> bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   797
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   798
  "wcode_double_case_inv st ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   799
          (if st = Suc 0 then wcode_on_left_moving_1 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   800
          else if st = Suc (Suc 0) then wcode_on_checking_1 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   801
          else if st = 3 then wcode_erase1 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   802
          else if st = 4 then wcode_on_right_moving_1 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   803
          else if st = 5 then wcode_goon_right_moving_1 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   804
          else if st = 6 then wcode_backto_standard_pos ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   805
          else if st = 13 then wcode_before_double ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   806
          else False)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   807
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   808
declare wcode_double_case_inv.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   809
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   810
fun wcode_double_case_state :: "config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   811
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   812
  "wcode_double_case_state (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   813
   13 - st"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   814
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   815
fun wcode_double_case_step :: "config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   816
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   817
  "wcode_double_case_step (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   818
      (if st = Suc 0 then (length l)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   819
      else if st = Suc (Suc 0) then (length r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   820
      else if st = 3 then 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   821
                 if hd r = Oc then 1 else 0
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   822
      else if st = 4 then (length r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   823
      else if st = 5 then (length r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   824
      else if st = 6 then (length l)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   825
      else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   826
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   827
fun wcode_double_case_measure :: "config \<Rightarrow> nat \<times> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   828
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   829
  "wcode_double_case_measure (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   830
     (wcode_double_case_state (st, l, r), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   831
      wcode_double_case_step (st, l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   832
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   833
definition wcode_double_case_le :: "(config \<times> config) set"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   834
  where "wcode_double_case_le \<equiv> (inv_image lex_pair wcode_double_case_measure)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   835
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: 285
diff changeset
   836
lemma wf_lex_pair[intro]: "wf lex_pair"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   837
by(auto intro:wf_lex_prod simp:lex_pair_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   838
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   839
lemma wf_wcode_double_case_le[intro]: "wf wcode_double_case_le"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   840
by(auto intro:wf_inv_image simp: wcode_double_case_le_def )
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   841
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: 285
diff changeset
   842
lemma fetch_t_wcode_main[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   843
  "fetch t_wcode_main (Suc 0) Bk = (L, Suc 0)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   844
  "fetch t_wcode_main (Suc 0) Oc = (L, Suc (Suc 0))"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   845
  "fetch t_wcode_main (Suc (Suc 0)) Oc = (R, 3)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   846
  "fetch t_wcode_main (Suc (Suc 0)) Bk = (L, 7)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   847
  "fetch t_wcode_main (Suc (Suc (Suc 0))) Bk = (R, 4)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   848
  "fetch t_wcode_main (Suc (Suc (Suc 0))) Oc = (W0, 3)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   849
  "fetch t_wcode_main 4 Bk = (R, 4)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   850
  "fetch t_wcode_main 4 Oc = (R, 5)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   851
  "fetch t_wcode_main 5 Oc = (R, 5)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   852
  "fetch t_wcode_main 5 Bk = (W1, 6)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   853
  "fetch t_wcode_main 6 Bk = (R, 13)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   854
  "fetch t_wcode_main 6 Oc = (L, 6)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   855
  "fetch t_wcode_main 7 Oc = (R, 8)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   856
  "fetch t_wcode_main 7 Bk = (R, 0)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   857
  "fetch t_wcode_main 8 Bk = (R, 9)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   858
  "fetch t_wcode_main 9 Bk = (R, 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: 285
diff changeset
   859
  "fetch t_wcode_main 9 Oc = (W0, 9)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   860
  "fetch t_wcode_main 10 Bk = (R, 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: 285
diff changeset
   861
  "fetch t_wcode_main 10 Oc = (R, 11)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   862
  "fetch t_wcode_main 11 Bk = (W1, 12)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   863
  "fetch t_wcode_main 11 Oc = (R, 11)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   864
  "fetch t_wcode_main 12 Oc = (L, 12)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   865
  "fetch t_wcode_main 12 Bk = (R, t_twice_len + 14)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   866
by(auto simp: t_wcode_main_def t_wcode_main_first_part_def fetch.simps numeral)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   867
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   868
declare wcode_on_checking_1.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   869
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   870
lemmas wcode_double_case_inv_simps = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   871
  wcode_on_left_moving_1.simps wcode_on_left_moving_1_O.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   872
  wcode_on_left_moving_1_B.simps wcode_on_checking_1.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   873
  wcode_erase1.simps wcode_on_right_moving_1.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   874
  wcode_goon_right_moving_1.simps wcode_backto_standard_pos.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   875
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   876
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: 285
diff changeset
   877
lemma wcode_on_left_moving_1[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   878
  "wcode_on_left_moving_1 ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   879
  "wcode_on_left_moving_1 ires rs (b, r) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   880
by(auto simp: wcode_on_left_moving_1.simps wcode_on_left_moving_1_B.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   881
                wcode_on_left_moving_1_O.simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   882
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   883
lemma wcode_on_left_moving_1E[elim]: "\<lbrakk>wcode_on_left_moving_1 ires rs (b, Bk # list);
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   884
                tl b = aa \<and> hd b # Bk # list = ba\<rbrakk> \<Longrightarrow> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   885
               wcode_on_left_moving_1 ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   886
apply(simp only: wcode_on_left_moving_1.simps wcode_on_left_moving_1_O.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   887
                wcode_on_left_moving_1_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   888
apply(erule_tac disjE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   889
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   890
apply(case_tac ml, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   891
apply(rule_tac x = "mr - Suc (Suc 0)" in exI, rule_tac x = rn in exI)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   892
apply(case_tac mr, simp, case_tac nat, simp, simp add: exp_ind)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   893
apply(rule_tac disjI1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   894
apply(rule_tac x = nat in exI, rule_tac x = "Suc mr" in exI, rule_tac x = rn in exI, 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   895
      simp, simp add: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   896
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   897
apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   898
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   899
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   900
declare replicate_Suc[simp]
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   901
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: 285
diff changeset
   902
lemma wcode_on_moving_1_Elim[elim]: 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   903
  "\<lbrakk>wcode_on_left_moving_1 ires rs (b, Oc # list); tl b = aa \<and> hd b # Oc # list = ba\<rbrakk> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   904
    \<Longrightarrow> wcode_on_checking_1 ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   905
apply(simp only: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   906
apply(erule_tac disjE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   907
apply(erule_tac [!] exE)+
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   908
apply(case_tac mr, simp, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   909
done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   910
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: 285
diff changeset
   911
lemma wcode_on_checking_1_Elim[elim]: "\<lbrakk>wcode_on_checking_1 ires rs (b, Oc # ba);Oc # b = aa \<and> list = ba\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   912
  \<Longrightarrow> wcode_erase1 ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   913
apply(simp only: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   914
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   915
apply(rule_tac x = ln in exI, rule_tac x = rn in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   916
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   917
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: 285
diff changeset
   918
lemma wcode_on_checking_1_simp[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   919
  "wcode_on_checking_1 ires rs (b, []) = False" 
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   920
  "wcode_on_checking_1 ires rs (b, Bk # list) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   921
by(auto simp: wcode_double_case_inv_simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   922
  
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   923
lemma wcode_erase1_nonempty_snd[simp]: "wcode_erase1 ires rs (b, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   924
apply(simp add: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   925
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   926
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: 285
diff changeset
   927
lemma wcode_on_right_moving_1_nonempty_snd[simp]: "wcode_on_right_moving_1 ires rs (b, []) = False"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   928
apply(simp add: wcode_double_case_inv_simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   929
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   930
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: 285
diff changeset
   931
lemma wcode_on_right_moving_1_BkE[elim]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
   932
 "\<lbrakk>wcode_on_right_moving_1 ires rs (b, Bk # ba);  Bk # b = aa \<and> list = b\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   933
  wcode_on_right_moving_1 ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   934
apply(simp only: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   935
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   936
apply(rule_tac x = "Suc ml" in exI, rule_tac x = "mr - Suc 0" in exI,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   937
      rule_tac x = rn in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   938
apply(simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   939
apply(case_tac mr, simp, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   940
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   941
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: 285
diff changeset
   942
lemma wcode_on_right_moving_1_OcE[elim]: 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   943
  "\<lbrakk>wcode_on_right_moving_1 ires rs (b, Oc # ba); Oc # b = aa \<and> list = ba\<rbrakk> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   944
  \<Longrightarrow> wcode_goon_right_moving_1 ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   945
apply(simp only: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   946
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   947
apply(rule_tac x = "Suc 0" in exI, rule_tac x = "rs" in exI,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   948
      rule_tac x = "ml - Suc (Suc 0)" in exI, rule_tac x = rn in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   949
apply(case_tac mr, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   950
apply(case_tac ml, simp, case_tac nat, simp, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   951
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   952
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: 285
diff changeset
   953
lemma wcode_erase1_BkE[elim]: "\<lbrakk>wcode_erase1 ires rs (b, Bk # ba); Bk # b = aa \<and> list = ba; c = Bk # ba\<rbrakk> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   954
  \<Longrightarrow> wcode_on_right_moving_1 ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   955
apply(simp only: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   956
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   957
apply(rule_tac x = "Suc 0" in exI, rule_tac x = "Suc (Suc ln)" in exI, 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   958
      rule_tac x = rn in exI, simp add: exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   959
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   960
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: 285
diff changeset
   961
lemma wcode_erase1_OcE[elim]: "\<lbrakk>wcode_erase1 ires rs (aa, Oc # list);  b = aa \<and> Bk # list = ba\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   962
  wcode_erase1 ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   963
apply(simp only: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   964
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   965
apply(rule_tac x = ln in exI, rule_tac x = rn in exI, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   966
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   967
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: 285
diff changeset
   968
lemma wcode_goon_right_moving_1_emptyE[elim]: "\<lbrakk>wcode_goon_right_moving_1 ires rs (aa, []); b = aa \<and> [Oc] = ba\<rbrakk> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   969
              \<Longrightarrow> wcode_backto_standard_pos ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   970
apply(simp only: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   971
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   972
apply(rule_tac disjI2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   973
apply(simp only:wcode_backto_standard_pos_O.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   974
apply(rule_tac x = ml in exI, rule_tac x = "Suc 0" in exI, rule_tac x = ln in exI,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   975
      rule_tac x = rn in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   976
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   977
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: 285
diff changeset
   978
lemma wcode_goon_right_moving_1_BkE[elim]: 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   979
  "\<lbrakk>wcode_goon_right_moving_1 ires rs (aa, Bk # list);  b = aa \<and> Oc # list = ba\<rbrakk>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   980
  \<Longrightarrow> wcode_backto_standard_pos ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   981
apply(simp only: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   982
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   983
apply(rule_tac disjI2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   984
apply(simp only:wcode_backto_standard_pos_O.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   985
apply(rule_tac x = ml in exI, rule_tac x = "Suc 0" in exI, rule_tac x = ln in exI,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   986
      rule_tac x = "rn - Suc 0" in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   987
apply(case_tac mr, simp, case_tac rn, simp, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   988
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   989
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: 285
diff changeset
   990
lemma wcode_goon_right_moving_1_OcE[elim]: "\<lbrakk>wcode_goon_right_moving_1 ires rs (b, Oc # ba);  Oc # b = aa \<and> list = ba\<rbrakk> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   991
  \<Longrightarrow> wcode_goon_right_moving_1 ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   992
apply(simp only: wcode_double_case_inv_simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   993
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   994
apply(rule_tac x = "Suc ml" in exI, rule_tac x = "mr - Suc 0" in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   995
      rule_tac x = ln in exI, rule_tac x = rn in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   996
apply(simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
   997
apply(case_tac mr, simp, case_tac rn, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   998
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   999
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: 285
diff changeset
  1000
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1001
lemma wcode_backto_standard_pos_BkE[elim]: "\<lbrakk>wcode_backto_standard_pos ires rs (b, Bk # ba); Bk # b = aa \<and> list = ba\<rbrakk> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1002
  \<Longrightarrow> wcode_before_double ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1003
apply(simp only: wcode_double_case_inv_simps wcode_backto_standard_pos_B.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1004
                 wcode_backto_standard_pos_O.simps wcode_before_double.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1005
apply(erule_tac disjE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1006
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1007
apply(rule_tac x = ln in exI, rule_tac x = rn in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1008
apply(auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1009
apply(case_tac [!] mr, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1010
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1011
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: 285
diff changeset
  1012
lemma wcode_backto_standard_pos_no_Oc[simp]: "wcode_backto_standard_pos ires rs ([], Oc # list) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1013
apply(auto simp: wcode_backto_standard_pos.simps wcode_backto_standard_pos_B.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1014
                 wcode_backto_standard_pos_O.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1015
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1016
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: 285
diff changeset
  1017
lemma wcode_backto_standard_pos_nonempty_snd[simp]: "wcode_backto_standard_pos ires rs (b, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1018
apply(auto simp: wcode_backto_standard_pos.simps wcode_backto_standard_pos_B.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1019
                 wcode_backto_standard_pos_O.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1020
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1021
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: 285
diff changeset
  1022
lemma wcode_backto_standard_pos_OcE[elim]: "\<lbrakk>wcode_backto_standard_pos ires rs (b, Oc # list); tl b = aa; hd b # Oc # list =  ba\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1023
       \<Longrightarrow> wcode_backto_standard_pos ires rs (aa, ba)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1024
apply(simp only:  wcode_backto_standard_pos.simps wcode_backto_standard_pos_B.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1025
                 wcode_backto_standard_pos_O.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1026
apply(erule_tac disjE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1027
apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1028
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1029
apply(case_tac ml, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1030
apply(rule_tac disjI1, rule_tac conjI)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1031
apply(rule_tac x = ln  in exI, simp, rule_tac x = rn in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1032
apply(rule_tac disjI2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1033
apply(rule_tac x = nat in exI, rule_tac x = "Suc mr" in exI, rule_tac x = ln in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1034
      rule_tac x = rn in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1035
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1036
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1037
declare nth_of.simps[simp del] fetch.simps[simp del]
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1038
lemma wcode_double_case_first_correctness:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1039
  "let P = (\<lambda> (st, l, r). st = 13) in 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1040
       let Q = (\<lambda> (st, l, r). wcode_double_case_inv st ires rs (l, r)) in 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1041
       let f = (\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp) in
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1042
       \<exists> n .P (f n) \<and> Q (f (n::nat))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1043
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1044
  let ?P = "(\<lambda> (st, l, r). st = 13)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1045
  let ?Q = "(\<lambda> (st, l, r). wcode_double_case_inv st ires rs (l, r))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1046
  let ?f = "(\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1047
  have "\<exists> n. ?P (?f n) \<and> ?Q (?f (n::nat))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1048
  proof(rule_tac halt_lemma2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1049
    show "wf wcode_double_case_le"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1050
      by auto
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1051
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1052
    show "\<forall> na. \<not> ?P (?f na) \<and> ?Q (?f na) \<longrightarrow>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1053
                   ?Q (?f (Suc na)) \<and> (?f (Suc na), ?f na) \<in> wcode_double_case_le"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1054
    proof(rule_tac allI, case_tac "?f na", simp add: step_red)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1055
      fix na a b c
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1056
      show "a \<noteq> 13 \<and> wcode_double_case_inv a ires rs (b, c) \<longrightarrow>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1057
               (case step0 (a, b, c) t_wcode_main of (st, x) \<Rightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1058
                   wcode_double_case_inv st ires rs x) \<and> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1059
                (step0 (a, b, c) t_wcode_main, a, b, c) \<in> wcode_double_case_le"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1060
        apply(rule_tac impI, simp add: wcode_double_case_inv.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1061
        apply(auto split: if_splits simp: step.simps, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1062
              case_tac [!] c, simp_all, case_tac [!] "(c::cell list)!0")
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1063
        apply(simp_all add: wcode_double_case_inv.simps wcode_double_case_le_def
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1064
                                        lex_pair_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1065
        apply(auto split: if_splits)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1066
        done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1067
    qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1068
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1069
    show "?Q (?f 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1070
      apply(simp add: steps.simps wcode_double_case_inv.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1071
                                  wcode_on_left_moving_1.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1072
                                  wcode_on_left_moving_1_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1073
      apply(rule_tac disjI1)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1074
      apply(rule_tac x = "Suc m" in exI, simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1075
      apply(rule_tac x = "Suc 0" in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1076
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1077
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1078
    show "\<not> ?P (?f 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1079
      apply(simp add: steps.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1080
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1081
  qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1082
  thus "let P = \<lambda>(st, l, r). st = 13;
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1083
    Q = \<lambda>(st, l, r). wcode_double_case_inv st ires rs (l, r);
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1084
    f = steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1085
    in \<exists>n. P (f n) \<and> Q (f n)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1086
    apply(simp add: Let_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1087
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1088
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1089
    
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1090
lemma tm_append_shift_append_steps: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1091
"\<lbrakk>steps0 (st, l, r) tp stp = (st', l', r'); 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1092
  0 < st';
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1093
  length tp1 mod 2 = 0
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1094
  \<rbrakk>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1095
  \<Longrightarrow> steps0 (st + length tp1 div 2, l, r) (tp1 @ shift tp (length tp1 div 2) @ tp2) stp 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1096
  = (st' + length tp1 div 2, l', r')"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1097
proof -
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1098
  assume h: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1099
    "steps0 (st, l, r) tp stp = (st', l', r')"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1100
    "0 < st'"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1101
    "length tp1 mod 2 = 0 "
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1102
  from h have 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1103
    "steps (st + length tp1 div 2, l, r) (tp1 @ shift tp (length tp1 div 2), 0) stp = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1104
                            (st' + length tp1 div 2, l', r')"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1105
    by(rule_tac tm_append_second_steps_eq, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1106
  then have "steps (st + length tp1 div 2, l, r) ((tp1 @ shift tp (length tp1 div 2)) @ tp2, 0) stp = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1107
                            (st' + length tp1 div 2, l', r')"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1108
    using h
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1109
    apply(rule_tac tm_append_first_steps_eq, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1110
    done
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1111
  thus "?thesis"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1112
    by simp
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1113
qed 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1114
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1115
declare start_of.simps[simp del]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1116
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1117
lemma twice_lemma: "rec_exec rec_twice [rs] = 2*rs"
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1118
by(auto simp: rec_twice_def rec_exec.simps)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1119
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1120
lemma t_twice_correct: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1121
  "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1122
  (tm_of abc_twice @ shift (mopup (Suc 0)) ((length (tm_of abc_twice) div 2))) stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1123
  (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1124
proof(case_tac "rec_ci rec_twice")
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1125
  fix a b c
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1126
  assume h: "rec_ci rec_twice = (a, b, c)"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1127
  have "\<exists>stp m l. steps0 (Suc 0, Bk # Bk # ires, <[rs]> @ Bk\<up>(n)) (tm_of abc_twice @ shift (mopup (length [rs])) 
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1128
    (length (tm_of abc_twice) div 2)) stp = (0, Bk\<up>(m) @ Bk # Bk # ires, Oc\<up>(Suc (rec_exec rec_twice [rs])) @ Bk\<up>(l))"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1129
    thm  recursive_compile_to_tm_correct1
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1130
  proof(rule_tac recursive_compile_to_tm_correct1)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1131
    show "rec_ci rec_twice = (a, b, c)" by (simp add: h)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1132
  next
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1133
    show "terminate rec_twice [rs]"
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1134
      apply(rule_tac primerec_terminate, auto)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1135
      apply(simp add: rec_twice_def, auto simp: constn.simps numeral_2_eq_2)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1136
      by(auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1137
  next
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1138
    show "tm_of abc_twice = tm_of (a [+] dummy_abc (length [rs]))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1139
      using h
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1140
      by(simp add: abc_twice_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1141
  qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1142
  thus "?thesis"
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: 285
diff changeset
  1143
    apply(simp add: tape_of_list_def tape_of_nat_def rec_exec.simps twice_lemma)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1144
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1145
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1146
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  1147
declare adjust.simps[simp]
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1148
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1149
lemma adjust_fetch0: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1150
  "\<lbrakk>0 < a; a \<le> length ap div 2;  fetch ap a b = (aa, 0)\<rbrakk>
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1151
  \<Longrightarrow> fetch (adjust0 ap) a b = (aa, Suc (length ap div 2))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1152
apply(case_tac b, auto simp: fetch.simps nth_of.simps nth_map
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1153
                       split: if_splits)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1154
apply(case_tac [!] a, auto simp: fetch.simps nth_of.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1155
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1156
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1157
lemma adjust_fetch_norm: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1158
  "\<lbrakk>st > 0;  st \<le> length tp div 2; fetch ap st b = (aa, ns); ns \<noteq> 0\<rbrakk>
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1159
 \<Longrightarrow>  fetch (adjust0 ap) st b = (aa, ns)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1160
 apply(case_tac b, auto simp: fetch.simps nth_of.simps nth_map
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1161
                       split: if_splits)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1162
apply(case_tac [!] st, auto simp: fetch.simps nth_of.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1163
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1164
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  1165
declare adjust.simps[simp del]
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  1166
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1167
lemma adjust_step_eq: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1168
  assumes exec: "step0 (st,l,r) ap = (st', l', r')"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1169
  and wf_tm: "tm_wf (ap, 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1170
  and notfinal: "st' > 0"
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1171
  shows "step0 (st, l, r) (adjust0 ap) = (st', l', r')"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1172
  using assms
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1173
proof -
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1174
  have "st > 0"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1175
    using assms
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1176
    by(case_tac st, simp_all add: step.simps fetch.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1177
  moreover hence "st \<le> (length ap) div 2"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1178
    using assms
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1179
    apply(case_tac "st \<le> (length ap) div 2", simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1180
    apply(case_tac st, auto simp: step.simps fetch.simps)
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  1181
    apply(case_tac "read r", simp_all add: fetch.simps 
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  1182
      nth_of.simps adjust.simps tm_wf.simps split: if_splits)
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  1183
    apply(auto simp: mod_ex2)
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  1184
    done    
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1185
  ultimately have "fetch (adjust0 ap) st (read r) = fetch ap st (read r)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1186
    using assms
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1187
    apply(case_tac "fetch ap st (read r)")
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1188
    apply(drule_tac adjust_fetch_norm, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1189
    apply(simp add: step.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1190
    done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1191
  thus "?thesis"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1192
    using exec
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1193
    by(simp add: step.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1194
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1195
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1196
declare adjust.simps[simp del]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1197
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1198
lemma adjust_steps_eq: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1199
  assumes exec: "steps0 (st,l,r) ap stp = (st', l', r')"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1200
  and wf_tm: "tm_wf (ap, 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1201
  and notfinal: "st' > 0"
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1202
  shows "steps0 (st, l, r) (adjust0 ap) stp = (st', l', r')"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1203
  using exec notfinal
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1204
proof(induct stp arbitrary: st' l' r')
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1205
  case 0
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1206
  thus "?case"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1207
    by(simp add: steps.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1208
next
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1209
  case (Suc stp st' l' r')
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1210
  have ind: "\<And>st' l' r'. \<lbrakk>steps0 (st, l, r) ap stp = (st', l', r'); 0 < st'\<rbrakk> 
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1211
    \<Longrightarrow> steps0 (st, l, r) (adjust0 ap) stp = (st', l', r')" by fact
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1212
  have h: "steps0 (st, l, r) ap (Suc stp) = (st', l', r')" by fact
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1213
  have g:   "0 < st'" by fact
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1214
  obtain st'' l'' r'' where a: "steps0 (st, l, r) ap stp = (st'', l'', r'')"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1215
    by (metis prod_cases3)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1216
  hence c:"0 < st''"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1217
    using h g
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1218
    apply(simp add: step_red)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1219
    apply(case_tac st'', auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1220
    done
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1221
  hence b: "steps0 (st, l, r) (adjust0 ap) stp = (st'', l'', r'')"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1222
    using a
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1223
    by(rule_tac ind, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1224
  thus "?case"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1225
    using assms a b h g
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1226
    apply(simp add: step_red) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1227
    apply(rule_tac adjust_step_eq, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1228
    done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1229
qed 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1230
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1231
lemma adjust_halt_eq:
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1232
  assumes exec: "steps0 (1, l, r) ap stp = (0, l', r')"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1233
  and tm_wf: "tm_wf (ap, 0)" 
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1234
  shows "\<exists> stp. steps0 (Suc 0, l, r) (adjust0 ap) stp = 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1235
        (Suc (length ap div 2), l', r')"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1236
proof -
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1237
  have "\<exists> stp. \<not> is_final (steps0 (1, l, r) ap stp) \<and> (steps0 (1, l, r) ap (Suc stp) = (0, l', r'))"
166
99a180fd4194 removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 163
diff changeset
  1238
    using exec
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1239
    by(erule_tac before_final)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1240
  then obtain stpa where a: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1241
    "\<not> is_final (steps0 (1, l, r) ap stpa) \<and> (steps0 (1, l, r) ap (Suc stpa) = (0, l', r'))" ..
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1242
  obtain sa la ra where b:"steps0 (1, l, r) ap stpa = (sa, la, ra)"  by (metis prod_cases3)
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1243
  hence c: "steps0 (Suc 0, l, r) (adjust0 ap) stpa = (sa, la, ra)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1244
    using assms a
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1245
    apply(rule_tac adjust_steps_eq, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1246
    done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1247
  have d: "sa \<le> length ap div 2"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1248
    using steps_in_range[of  "(l, r)" ap stpa] a tm_wf b
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1249
    by(simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1250
  obtain ac ns where e: "fetch ap sa (read ra) = (ac, ns)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1251
    by (metis prod.exhaust)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1252
  hence f: "ns = 0"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1253
    using b a
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1254
    apply(simp add: step_red step.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1255
    done
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1256
  have k: "fetch (adjust0 ap) sa (read ra) = (ac, Suc (length ap div 2))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1257
    using a b c d e f
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1258
    apply(rule_tac adjust_fetch0, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1259
    done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1260
  from a b e f k and c show "?thesis"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1261
    apply(rule_tac x = "Suc stpa" in exI)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1262
    apply(simp add: step_red, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1263
    apply(simp add: step.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1264
    done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1265
qed    
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1266
   
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1267
declare tm_wf.simps[simp del]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1268
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: 285
diff changeset
  1269
lemma tm_wf_t_twice_compile [simp]: "tm_wf (t_twice_compile, 0)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1270
apply(simp only: t_twice_compile_def)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1271
apply(rule_tac wf_tm_from_abacus, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1272
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1273
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1274
lemma t_twice_change_term_state:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1275
  "\<exists> stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) t_twice stp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1276
     = (Suc t_twice_len, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1277
proof -
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1278
  have "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1279
    (tm_of abc_twice @ shift (mopup (Suc 0)) ((length (tm_of abc_twice) div 2))) stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1280
    (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1281
    by(rule_tac t_twice_correct)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1282
  then obtain stp ln rn where " steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1283
    (tm_of abc_twice @ shift (mopup (Suc 0)) ((length (tm_of abc_twice) div 2))) stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1284
    (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))" by blast
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1285
  hence "\<exists> stp. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1286
    (adjust0 t_twice_compile) stp
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1287
     = (Suc (length t_twice_compile div 2), Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1288
    apply(rule_tac stp = stp in adjust_halt_eq)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1289
    apply(simp add: t_twice_compile_def, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1290
    done
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1291
  then obtain stpb where 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1292
    "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1293
    (adjust0 t_twice_compile) stpb
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1294
     = (Suc (length t_twice_compile div 2), Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))" ..
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1295
  thus "?thesis"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1296
    apply(simp add: t_twice_def t_twice_len_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1297
    by metis
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1298
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1299
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: 285
diff changeset
  1300
lemma length_t_wcode_main_first_part_even[intro]: "length t_wcode_main_first_part mod 2 = 0"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1301
apply(auto simp: t_wcode_main_first_part_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1302
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1303
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1304
lemma t_twice_append_pre:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1305
  "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) t_twice stp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1306
  = (Suc t_twice_len, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1307
   \<Longrightarrow> steps0 (Suc 0 + length t_wcode_main_first_part div 2, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1308
     (t_wcode_main_first_part @ shift t_twice (length t_wcode_main_first_part div 2) @
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1309
      ([(L, 1), (L, 1)] @ shift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)])) stp 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1310
    = (Suc (t_twice_len) + length t_wcode_main_first_part div 2, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1311
             Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1312
by(rule_tac tm_append_shift_append_steps, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1313
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1314
lemma t_twice_append:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1315
  "\<exists> stp ln rn. steps0 (Suc 0 + length t_wcode_main_first_part div 2, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1316
     (t_wcode_main_first_part @ shift t_twice (length t_wcode_main_first_part div 2) @
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1317
      ([(L, 1), (L, 1)] @ shift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)])) stp 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1318
    = (Suc (t_twice_len) + length t_wcode_main_first_part div 2, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1319
  using t_twice_change_term_state[of ires rs n]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1320
  apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1321
  apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1322
  apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1323
  apply(drule_tac t_twice_append_pre)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1324
  apply(rule_tac x = stp in exI, rule_tac x = ln in exI, rule_tac x = rn in exI)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1325
  apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1326
  done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1327
  
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1328
lemma mopup_mod2: "length (mopup k) mod 2  = 0"
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: 285
diff changeset
  1329
  by(auto simp: mopup.simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1330
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1331
lemma fetch_t_wcode_main_Oc[simp]: "fetch t_wcode_main (Suc (t_twice_len + length t_wcode_main_first_part div 2)) Oc
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1332
     = (L, Suc 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1333
apply(subgoal_tac "length (t_twice) mod 2 = 0")
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1334
apply(simp add: t_wcode_main_def nth_append fetch.simps t_wcode_main_first_part_def 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1335
  nth_of.simps t_twice_len_def, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1336
apply(simp add: t_twice_def t_twice_compile_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1337
using mopup_mod2[of 1]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1338
apply(simp)
285
447b433b67fa added things --- in messy state
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 248
diff changeset
  1339
done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1340
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1341
lemma wcode_jump1: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1342
  "\<exists> stp ln rn. steps0 (Suc (t_twice_len) + length t_wcode_main_first_part div 2,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1343
                       Bk\<up>(m) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(n))
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1344
     t_wcode_main stp 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1345
    = (Suc 0, Bk\<up>(ln) @ Bk # ires, Bk # Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1346
apply(rule_tac x = "Suc 0" in exI, rule_tac x = "m" in exI, rule_tac x = n in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1347
apply(simp add: steps.simps step.simps exp_ind)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1348
apply(case_tac m, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1349
apply(simp add: exp_ind[THEN sym])
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1350
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1351
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: 285
diff changeset
  1352
lemma wcode_main_first_part_len[simp]:
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1353
  "length t_wcode_main_first_part = 24"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1354
  apply(simp add: t_wcode_main_first_part_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1355
  done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1356
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1357
lemma wcode_double_case: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1358
  shows "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1359
          (Suc 0, Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1360
proof -
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1361
  have "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1362
          (13,  Bk # Bk # Bk\<up>(ln) @ Oc # ires, Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1363
    using wcode_double_case_first_correctness[of ires rs m n]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1364
    apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1365
    apply(erule_tac exE)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1366
    apply(case_tac "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1367
           Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main na",
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1368
          auto simp: wcode_double_case_inv.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1369
                     wcode_before_double.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1370
    apply(rule_tac x = na in exI, rule_tac x = ln in exI, rule_tac x = rn in exI)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1371
    apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1372
    done    
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1373
  from this obtain stpa lna rna where stp1: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1374
    "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stpa = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1375
    (13, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rna))" by blast
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1376
  have "\<exists> stp ln rn. steps0 (13, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rna)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1377
    (13 + t_twice_len, Bk # Bk # Bk\<up>(ln) @ Oc # ires, Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1378
    using t_twice_append[of "Bk\<up>(lna) @ Oc # ires" "Suc rs" rna]
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1379
    apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1380
    apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1381
    apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1382
    apply(simp add: wcode_main_first_part_len)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1383
    apply(rule_tac x = stp in exI, rule_tac x = "ln + lna" in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1384
          rule_tac x = rn in exI)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1385
    apply(simp add: t_wcode_main_def)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1386
    apply(simp add: replicate_Suc[THEN sym] replicate_add [THEN sym] del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1387
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1388
  from this obtain stpb lnb rnb where stp2: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1389
    "steps0 (13, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rna)) t_wcode_main stpb =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1390
    (13 + t_twice_len, Bk # Bk # Bk\<up>(lnb) @ Oc # ires, Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rnb))" by blast
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1391
  have "\<exists>stp ln rn. steps0 (13 + t_twice_len, Bk # Bk # Bk\<up>(lnb) @ Oc # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1392
    Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rnb)) t_wcode_main stp = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1393
       (Suc 0,  Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1394
    using wcode_jump1[of lnb "Oc # ires" "Suc rs" rnb]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1395
    apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1396
    apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1397
    apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1398
    apply(rule_tac x = stp in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1399
          rule_tac x = ln in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1400
          rule_tac x = rn in exI, simp add:wcode_main_first_part_len t_wcode_main_def)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1401
    apply(subgoal_tac "Bk\<up>(lnb) @ Bk # Bk # Oc # ires = Bk # Bk # Bk\<up>(lnb) @ Oc # ires", simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1402
    apply(simp add: replicate_Suc[THEN sym] exp_ind[THEN sym] del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1403
    apply(simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1404
    apply(simp add: replicate_Suc[THEN sym] exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1405
    done               
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1406
  from this obtain stpc lnc rnc where stp3: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1407
    "steps0 (13 + t_twice_len, Bk # Bk # Bk\<up>(lnb) @ Oc # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1408
    Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rnb)) t_wcode_main stpc = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1409
       (Suc 0,  Bk # Bk\<up>(lnc) @ Oc # ires, Bk # Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rnc))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1410
    by blast
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1411
  from stp1 stp2 stp3 show "?thesis"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1412
    apply(rule_tac x = "stpa + stpb + stpc" in exI, rule_tac x = lnc in exI,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1413
         rule_tac x = rnc in exI)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1414
    apply(simp add: steps_add)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1415
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1416
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1417
    
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1418
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1419
(* Begin: fourtime_case*)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1420
fun wcode_on_left_moving_2_B :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1421
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1422
  "wcode_on_left_moving_2_B ires rs (l, r) =
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1423
     (\<exists> ml mr rn. l = Bk\<up>(ml) @ Oc # Bk # Oc # ires \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1424
                 r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1425
                 ml + mr > Suc 0 \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1426
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1427
fun wcode_on_left_moving_2_O :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1428
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1429
  "wcode_on_left_moving_2_O ires rs (l, r) =
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1430
     (\<exists> ln rn. l = Bk # Oc # ires \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1431
               r = Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1432
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1433
fun wcode_on_left_moving_2 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1434
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1435
  "wcode_on_left_moving_2 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1436
      (wcode_on_left_moving_2_B ires rs (l, r) \<or> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1437
      wcode_on_left_moving_2_O ires rs (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1438
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1439
fun wcode_on_checking_2 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1440
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1441
  "wcode_on_checking_2 ires rs (l, r) =
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1442
       (\<exists> ln rn. l = Oc#ires \<and> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1443
                 r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1444
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1445
fun wcode_goon_checking :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1446
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1447
  "wcode_goon_checking ires rs (l, r) =
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1448
       (\<exists> ln rn. l = ires \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1449
                 r = Oc # Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1450
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1451
fun wcode_right_move :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1452
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1453
  "wcode_right_move ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1454
     (\<exists> ln rn. l = Oc # ires \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1455
                 r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1456
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1457
fun wcode_erase2 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1458
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1459
  "wcode_erase2 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1460
        (\<exists> ln rn. l = Bk # Oc # ires \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1461
                 tl r = Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1462
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1463
fun wcode_on_right_moving_2 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1464
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1465
  "wcode_on_right_moving_2 ires rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1466
        (\<exists> ml mr rn. l = Bk\<up>(ml) @ Oc # ires \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1467
                     r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and> ml + mr > Suc 0)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1468
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1469
fun wcode_goon_right_moving_2 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1470
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1471
  "wcode_goon_right_moving_2 ires rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1472
        (\<exists> ml mr ln rn. l = Oc\<up>(ml) @ Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1473
                        r = Oc\<up>(mr) @ Bk\<up>(rn) \<and> ml + mr = Suc rs)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1474
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1475
fun wcode_backto_standard_pos_2_B :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1476
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1477
  "wcode_backto_standard_pos_2_B ires rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1478
           (\<exists> ln rn. l = Bk # Bk\<up>(ln) @ Oc # ires \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1479
                     r = Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1480
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1481
fun wcode_backto_standard_pos_2_O :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1482
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1483
  "wcode_backto_standard_pos_2_O ires rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1484
          (\<exists> ml mr ln rn. l = Oc\<up>(ml )@ Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1485
                          r = Oc\<up>(mr) @ Bk\<up>(rn) \<and> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1486
                          ml + mr = (Suc (Suc rs)) \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1487
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1488
fun wcode_backto_standard_pos_2 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1489
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1490
  "wcode_backto_standard_pos_2 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1491
           (wcode_backto_standard_pos_2_O ires rs (l, r) \<or> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1492
           wcode_backto_standard_pos_2_B ires rs (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1493
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1494
fun wcode_before_fourtimes :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1495
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1496
  "wcode_before_fourtimes ires rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1497
          (\<exists> ln rn. l = Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1498
                    r = Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1499
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1500
declare wcode_on_left_moving_2_B.simps[simp del] wcode_on_left_moving_2.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1501
        wcode_on_left_moving_2_O.simps[simp del] wcode_on_checking_2.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1502
        wcode_goon_checking.simps[simp del] wcode_right_move.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1503
        wcode_erase2.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1504
        wcode_on_right_moving_2.simps[simp del] wcode_goon_right_moving_2.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1505
        wcode_backto_standard_pos_2_B.simps[simp del] wcode_backto_standard_pos_2_O.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1506
        wcode_backto_standard_pos_2.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1507
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1508
lemmas wcode_fourtimes_invs = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1509
       wcode_on_left_moving_2_B.simps wcode_on_left_moving_2.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1510
        wcode_on_left_moving_2_O.simps wcode_on_checking_2.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1511
        wcode_goon_checking.simps wcode_right_move.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1512
        wcode_erase2.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1513
        wcode_on_right_moving_2.simps wcode_goon_right_moving_2.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1514
        wcode_backto_standard_pos_2_B.simps wcode_backto_standard_pos_2_O.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1515
        wcode_backto_standard_pos_2.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1516
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1517
fun wcode_fourtimes_case_inv :: "nat \<Rightarrow> bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1518
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1519
  "wcode_fourtimes_case_inv st ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1520
           (if st = Suc 0 then wcode_on_left_moving_2 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1521
            else if st = Suc (Suc 0) then wcode_on_checking_2 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1522
            else if st = 7 then wcode_goon_checking ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1523
            else if st = 8 then wcode_right_move ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1524
            else if st = 9 then wcode_erase2 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1525
            else if st = 10 then wcode_on_right_moving_2 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1526
            else if st = 11 then wcode_goon_right_moving_2 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1527
            else if st = 12 then wcode_backto_standard_pos_2 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1528
            else if st = t_twice_len + 14 then wcode_before_fourtimes ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1529
            else False)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1530
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1531
declare wcode_fourtimes_case_inv.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1532
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1533
fun wcode_fourtimes_case_state :: "config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1534
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1535
  "wcode_fourtimes_case_state (st, l, r) = 13 - st"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1536
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1537
fun wcode_fourtimes_case_step :: "config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1538
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1539
  "wcode_fourtimes_case_step (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1540
         (if st = Suc 0 then length l
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1541
          else if st = 9 then 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1542
           (if hd r = Oc then 1
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1543
            else 0)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1544
          else if st = 10 then length r
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1545
          else if st = 11 then length r
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1546
          else if st = 12 then length l
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1547
          else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1548
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1549
fun wcode_fourtimes_case_measure :: "config \<Rightarrow> nat \<times> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1550
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1551
  "wcode_fourtimes_case_measure (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1552
     (wcode_fourtimes_case_state (st, l, r), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1553
      wcode_fourtimes_case_step (st, l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1554
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1555
definition wcode_fourtimes_case_le :: "(config \<times> config) set"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1556
  where "wcode_fourtimes_case_le \<equiv> (inv_image lex_pair wcode_fourtimes_case_measure)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1557
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1558
lemma wf_wcode_fourtimes_case_le[intro]: "wf wcode_fourtimes_case_le"
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: 285
diff changeset
  1559
by(auto simp: wcode_fourtimes_case_le_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: 285
diff changeset
  1560
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1561
lemma nonempty_snd [simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1562
  "wcode_on_left_moving_2 ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1563
  "wcode_on_checking_2 ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1564
  "wcode_goon_checking ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1565
  "wcode_right_move ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1566
  "wcode_erase2 ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1567
  "wcode_on_right_moving_2 ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1568
  "wcode_backto_standard_pos_2 ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1569
  "wcode_on_checking_2 ires rs (b, Oc # list) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1570
  by(auto simp: wcode_fourtimes_invs) 
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1571
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1572
lemma wcode_on_left_moving_2[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1573
 "wcode_on_left_moving_2 ires rs (b, Bk # list) \<Longrightarrow>  wcode_on_left_moving_2 ires rs (tl b, hd b # Bk # list)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1574
apply(simp only: wcode_fourtimes_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1575
apply(erule_tac disjE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1576
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1577
apply(case_tac ml, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1578
apply(rule_tac x = "mr - (Suc (Suc 0))" in exI, rule_tac x = rn in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1579
apply(case_tac mr, simp, case_tac nat, simp, simp add: exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1580
apply(rule_tac disjI1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1581
apply(rule_tac x = nat in exI, rule_tac x = "Suc mr" in exI, rule_tac x = rn in exI,
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1582
      simp add: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1583
apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1584
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1585
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: 285
diff changeset
  1586
lemma wcode_goon_checking_via_2 [simp]: "wcode_on_checking_2 ires rs (b, Bk # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1587
       \<Longrightarrow>   wcode_goon_checking ires rs (tl b, hd b # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1588
apply(simp only: wcode_fourtimes_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1589
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: 285
diff changeset
  1590
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1591
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1592
lemma wcode_erase2_via_move [simp]: "wcode_right_move ires rs (b, Bk # list) \<Longrightarrow>  wcode_erase2 ires rs (Bk # b, list)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1593
apply(auto simp:wcode_fourtimes_invs )
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1594
apply(rule_tac x = ln in exI, rule_tac x = rn in exI, simp)
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: 285
diff changeset
  1595
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1596
lemma wcode_on_right_moving_2_via_erase2[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1597
 "wcode_erase2 ires rs (b, Bk # list) \<Longrightarrow> wcode_on_right_moving_2 ires rs (Bk # b, list)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1598
apply(auto simp:wcode_fourtimes_invs )
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1599
apply(rule_tac x = "Suc (Suc 0)" in exI, simp add: exp_ind)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1600
apply(rule_tac x =  "Suc (Suc ln)" in exI, simp add: exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1601
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1602
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: 285
diff changeset
  1603
lemma wcode_on_right_moving_2_move_Bk[simp]: "wcode_on_right_moving_2 ires rs (b, Bk # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1604
       \<Longrightarrow> wcode_on_right_moving_2 ires rs (Bk # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1605
apply(auto simp: wcode_fourtimes_invs)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1606
apply(rule_tac x = "Suc ml" in exI, simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1607
apply(rule_tac x = "mr - 1" in exI, case_tac mr,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: 285
diff changeset
  1608
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1609
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1610
lemma wcode_backto_standard_pos_2_via_right[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1611
 "wcode_goon_right_moving_2 ires rs (b, Bk # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1612
                 wcode_backto_standard_pos_2 ires rs (b, Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1613
apply(simp add: wcode_fourtimes_invs, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1614
apply(rule_tac x = ml in exI, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1615
apply(rule_tac x = "Suc 0" in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1616
apply(case_tac mr, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1617
apply(rule_tac x = "rn - 1" in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1618
apply(case_tac rn, simp, simp)
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: 285
diff changeset
  1619
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1620
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1621
lemma wcode_on_checking_2_via_left[simp]: "wcode_on_left_moving_2 ires rs (b, Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1622
                     wcode_on_checking_2 ires rs (tl b, hd b # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1623
apply(auto simp: wcode_fourtimes_invs)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1624
apply(case_tac [!] mr, simp_all)
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: 285
diff changeset
  1625
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1626
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1627
lemma wcode_backto_standard_pos_2_empty_via_right[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1628
 "wcode_goon_right_moving_2 ires rs (b, []) \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1629
              wcode_backto_standard_pos_2 ires rs (b, [Oc])"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1630
apply(simp only: wcode_fourtimes_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1631
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1632
apply(rule_tac disjI1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1633
apply(rule_tac x = ml in exI, rule_tac x = "Suc 0" in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1634
      rule_tac x = ln in exI, rule_tac x = rn in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1635
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1636
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: 285
diff changeset
  1637
lemma wcode_goon_checking_cases[simp]: "wcode_goon_checking ires rs (b, Oc # list) \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1638
  (b = [] \<longrightarrow> wcode_right_move ires rs ([Oc], list)) \<and>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1639
  (b \<noteq> [] \<longrightarrow> wcode_right_move ires rs (Oc # b, list))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1640
apply(simp only: wcode_fourtimes_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1641
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1642
apply(auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1643
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1644
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: 285
diff changeset
  1645
lemma wcode_right_move_no_Oc[simp]: "wcode_right_move ires rs (b, Oc # list) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1646
apply(auto simp: wcode_fourtimes_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1647
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1648
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: 285
diff changeset
  1649
lemma wcode_erase2_Bk_via_Oc[simp]: "wcode_erase2 ires rs (b, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1650
       \<Longrightarrow> wcode_erase2 ires rs (b, Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1651
apply(auto simp: wcode_fourtimes_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1652
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1653
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: 285
diff changeset
  1654
lemma wcode_goon_right_moving_2_Oc_move[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1655
 "wcode_on_right_moving_2 ires rs (b, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1656
       \<Longrightarrow> wcode_goon_right_moving_2 ires rs (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1657
apply(auto simp: wcode_fourtimes_invs)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1658
apply(case_tac mr, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1659
apply(rule_tac x = "Suc 0" in exI, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1660
apply(rule_tac x = "ml - 2" in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1661
apply(case_tac ml, simp, case_tac nat, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1662
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1663
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: 285
diff changeset
  1664
lemma wcode_backto_standard_pos_2_exists[simp]: "wcode_backto_standard_pos_2 ires rs (b, Bk # list)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1665
       \<Longrightarrow> (\<exists>ln. b = Bk # Bk\<up>(ln) @ Oc # ires) \<and> (\<exists>rn. list = Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1666
apply(simp add: wcode_fourtimes_invs, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1667
apply(case_tac [!] mr, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1668
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1669
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: 285
diff changeset
  1670
lemma wcode_goon_right_moving_2_move_Oc[simp]: "wcode_goon_right_moving_2 ires rs (b, Oc # list) \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1671
       wcode_goon_right_moving_2 ires rs (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1672
apply(simp only:wcode_fourtimes_invs, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1673
apply(rule_tac x = "Suc ml" in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1674
apply(rule_tac x = "mr - 1" in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1675
apply(case_tac mr, case_tac rn, 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: 285
diff changeset
  1676
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1677
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1678
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1679
lemma wcode_backto_standard_pos_2_Oc_mv_hd[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1680
 "wcode_backto_standard_pos_2 ires rs (b, Oc # list)    
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1681
            \<Longrightarrow> wcode_backto_standard_pos_2 ires rs (tl b, hd b # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1682
apply(simp only: wcode_fourtimes_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1683
apply(erule_tac disjE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1684
apply(erule_tac exE)+
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1685
apply(case_tac ml, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1686
apply(rule_tac x = nat in exI, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1687
apply(rule_tac x = "Suc mr" in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1688
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1689
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: 285
diff changeset
  1690
lemma nonempty_fst[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1691
  "wcode_on_left_moving_2 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1692
  "wcode_on_checking_2 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1693
  "wcode_goon_checking ires rs (b, Bk # list) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1694
  "wcode_right_move ires rs (b, Bk # list) \<Longrightarrow> b\<noteq> []" 
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1695
  "wcode_erase2 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1696
  "wcode_on_right_moving_2 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1697
  "wcode_goon_right_moving_2 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1698
  "wcode_backto_standard_pos_2 ires rs (b, Bk # list) \<Longrightarrow>  b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1699
  "wcode_on_left_moving_2 ires rs (b, Oc # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1700
  "wcode_goon_right_moving_2 ires rs (b, []) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1701
  "wcode_erase2 ires rs (b, Oc # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1702
  "wcode_on_right_moving_2 ires rs (b, Oc # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1703
  "wcode_goon_right_moving_2 ires rs (b, Oc # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1704
  "wcode_backto_standard_pos_2 ires rs (b, Oc # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1705
  by(auto simp: wcode_fourtimes_invs)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1706
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1707
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1708
lemma wcode_fourtimes_case_first_correctness:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1709
 shows "let P = (\<lambda> (st, l, r). st = t_twice_len + 14) in 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1710
  let Q = (\<lambda> (st, l, r). wcode_fourtimes_case_inv st ires rs (l, r)) in 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1711
  let f = (\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp) in
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1712
  \<exists> n .P (f n) \<and> Q (f (n::nat))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1713
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1714
  let ?P = "(\<lambda> (st, l, r). st = t_twice_len + 14)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1715
  let ?Q = "(\<lambda> (st, l, r). wcode_fourtimes_case_inv st ires rs (l, r))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1716
  let ?f = "(\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1717
  have "\<exists> n . ?P (?f n) \<and> ?Q (?f (n::nat))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1718
  proof(rule_tac halt_lemma2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1719
    show "wf wcode_fourtimes_case_le"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1720
      by auto
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1721
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1722
    show "\<forall> na. \<not> ?P (?f na) \<and> ?Q (?f na) \<longrightarrow>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1723
                  ?Q (?f (Suc na)) \<and> (?f (Suc na), ?f na) \<in> wcode_fourtimes_case_le"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1724
    apply(rule_tac allI,
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1725
     case_tac "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main na", simp,
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1726
     rule_tac impI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1727
    apply(simp add: step_red step.simps, case_tac c, simp, case_tac [2] aa, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1728
    apply(simp_all add: wcode_fourtimes_case_inv.simps
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1729
                        wcode_fourtimes_case_le_def lex_pair_def split: if_splits)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1730
    apply(auto simp: wcode_backto_standard_pos_2.simps wcode_backto_standard_pos_2_O.simps
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1731
      wcode_backto_standard_pos_2_B.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1732
    apply(case_tac mr, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1733
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1734
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1735
    show "?Q (?f 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1736
      apply(simp add: steps.simps wcode_fourtimes_case_inv.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1737
      apply(simp add: wcode_on_left_moving_2.simps wcode_on_left_moving_2_B.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1738
                      wcode_on_left_moving_2_O.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1739
      apply(rule_tac x = "Suc m" in exI, simp )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1740
      apply(rule_tac x ="Suc 0" in exI, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1741
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1742
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1743
    show "\<not> ?P (?f 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1744
      apply(simp add: steps.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1745
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1746
  qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1747
  thus "?thesis"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1748
    apply(erule_tac exE, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1749
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1750
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1751
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1752
definition t_fourtimes_len :: "nat"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1753
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1754
  "t_fourtimes_len = (length t_fourtimes div 2)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1755
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: 285
diff changeset
  1756
lemma primerec_rec_fourtimes_1[intro]: "primerec rec_fourtimes (Suc 0)"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1757
apply(auto simp: rec_fourtimes_def numeral_4_eq_4 constn.simps)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1758
by auto
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1759
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1760
lemma fourtimes_lemma: "rec_exec rec_fourtimes [rs] = 4 * rs"
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1761
by(simp add: rec_exec.simps rec_fourtimes_def)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1762
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1763
lemma t_fourtimes_correct: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1764
  "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1765
    (tm_of abc_fourtimes @ shift (mopup 1) (length (tm_of abc_fourtimes) div 2)) stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1766
       (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1767
proof(case_tac "rec_ci rec_fourtimes")
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1768
  fix a b c
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1769
  assume h: "rec_ci rec_fourtimes = (a, b, c)"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1770
  have "\<exists>stp m l. steps0 (Suc 0, Bk # Bk # ires, <[rs]> @ Bk\<up>(n)) (tm_of abc_fourtimes @ shift (mopup (length [rs])) 
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1771
    (length (tm_of abc_fourtimes) div 2)) stp = (0, Bk\<up>(m) @ Bk # Bk # ires, Oc\<up>(Suc (rec_exec rec_fourtimes [rs])) @ Bk\<up>(l))"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1772
    thm recursive_compile_to_tm_correct1
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1773
  proof(rule_tac recursive_compile_to_tm_correct1)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1774
    show "rec_ci rec_fourtimes = (a, b, c)" by (simp add: h)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1775
  next
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1776
    show "terminate rec_fourtimes [rs]"
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  1777
      apply(rule_tac primerec_terminate)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1778
      by auto
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1779
  next
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1780
    show "tm_of abc_fourtimes = tm_of (a [+] dummy_abc (length [rs]))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1781
      using h
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1782
      by(simp add: abc_fourtimes_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1783
  qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1784
  thus "?thesis"
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: 285
diff changeset
  1785
    apply(simp add: tape_of_list_def tape_of_nat_def fourtimes_lemma)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1786
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1787
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1788
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1789
lemma wf_fourtimes[intro]: "tm_wf (t_fourtimes_compile, 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1790
apply(simp only: t_fourtimes_compile_def)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1791
apply(rule_tac wf_tm_from_abacus, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1792
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1793
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1794
lemma t_fourtimes_change_term_state:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1795
  "\<exists> stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) t_fourtimes stp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1796
     = (Suc t_fourtimes_len, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1797
proof -
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1798
  have "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1799
    (tm_of abc_fourtimes @ shift (mopup 1) ((length (tm_of abc_fourtimes) div 2))) stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1800
    (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1801
    by(rule_tac t_fourtimes_correct)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1802
  then obtain stp ln rn where 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1803
    "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1804
    (tm_of abc_fourtimes @ shift (mopup 1) ((length (tm_of abc_fourtimes) div 2))) stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1805
    (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))" by blast
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1806
  hence "\<exists> stp. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1807
    (adjust0 t_fourtimes_compile) stp
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1808
     = (Suc (length t_fourtimes_compile div 2), Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1809
    apply(rule_tac stp = stp in adjust_halt_eq)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1810
    apply(simp add: t_fourtimes_compile_def, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1811
    done
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1812
  then obtain stpb where 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1813
    "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  1814
    (adjust0 t_fourtimes_compile) stpb
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1815
     = (Suc (length t_fourtimes_compile div 2), Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))" ..
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1816
  thus "?thesis"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1817
    apply(simp add: t_fourtimes_def t_fourtimes_len_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1818
    by metis
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1819
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1820
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: 285
diff changeset
  1821
lemma length_t_twice_even[intro]: "is_even (length t_twice)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1822
  by(auto simp: t_twice_def t_twice_compile_def intro!:mopup_mod2)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1823
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1824
lemma t_fourtimes_append_pre:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1825
  "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) t_fourtimes stp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1826
  = (Suc t_fourtimes_len, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1827
   \<Longrightarrow> steps0 (Suc 0 + length (t_wcode_main_first_part @ 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1828
              shift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1829
       Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1830
     ((t_wcode_main_first_part @ 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1831
  shift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) @ 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1832
  shift t_fourtimes (length (t_wcode_main_first_part @ 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1833
  shift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2) @ ([(L, 1), (L, 1)])) stp 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1834
  = ((Suc t_fourtimes_len) + length (t_wcode_main_first_part @ 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1835
  shift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1836
  Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
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: 285
diff changeset
  1837
  using length_t_twice_even
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1838
  by(intro tm_append_shift_append_steps, auto)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1839
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1840
lemma split_26_even[simp]: "(26 + l::nat) div 2 = l div 2 + 13" by(simp)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1841
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1842
lemma t_twice_len_plust_14[simp]: "t_twice_len + 14 =  14 + length (shift t_twice 12) div 2"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1843
apply(simp add: t_twice_def t_twice_len_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1844
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1845
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1846
lemma t_fourtimes_append:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1847
  "\<exists> stp ln rn. 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1848
  steps0 (Suc 0 + length (t_wcode_main_first_part @ shift t_twice
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1849
  (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2, 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1850
  Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1851
  ((t_wcode_main_first_part @ shift t_twice (length t_wcode_main_first_part div 2) @
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1852
  [(L, 1), (L, 1)]) @ shift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)]) stp 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1853
  = (Suc t_fourtimes_len + length (t_wcode_main_first_part @ shift t_twice
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1854
  (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2, Bk\<up>(ln) @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1855
                                                                 Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1856
  using t_fourtimes_change_term_state[of ires rs n]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1857
  apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1858
  apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1859
  apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1860
  apply(drule_tac t_fourtimes_append_pre)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1861
  apply(rule_tac x = stp in exI, rule_tac x = ln in exI, rule_tac x = rn in exI)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1862
  apply(simp add: t_twice_len_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1863
  done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1864
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1865
lemma even_fourtimes_len: "length t_fourtimes mod 2 = 0"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1866
apply(auto simp: t_fourtimes_def t_fourtimes_compile_def)
285
447b433b67fa added things --- in messy state
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 248
diff changeset
  1867
by (metis mopup_mod2)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1868
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: 285
diff changeset
  1869
lemma t_twice_even[simp]: "2 * (length t_twice div 2) = length t_twice"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1870
using length_t_twice_even by arith
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1871
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  1872
lemma t_fourtimes_even[simp]: "2 * (length t_fourtimes div 2) = length t_fourtimes"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1873
using even_fourtimes_len
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1874
by arith
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1875
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: 285
diff changeset
  1876
lemma fetch_t_wcode_14_Oc: "fetch t_wcode_main (14 + length t_twice div 2 + t_fourtimes_len) Oc
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1877
             = (L, Suc 0)" 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1878
apply(subgoal_tac "14 = Suc 13")
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1879
apply(simp only: fetch.simps add_Suc nth_of.simps t_wcode_main_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: 285
diff changeset
  1880
apply(simp add:length_t_twice_even t_fourtimes_len_def nth_append)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1881
by arith
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1882
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: 285
diff changeset
  1883
lemma fetch_t_wcode_14_Bk: "fetch t_wcode_main (14 + length t_twice div 2 + t_fourtimes_len) Bk
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1884
             = (L, Suc 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1885
apply(subgoal_tac "14 = Suc 13")
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1886
apply(simp only: fetch.simps add_Suc nth_of.simps t_wcode_main_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: 285
diff changeset
  1887
apply(simp add:length_t_twice_even t_fourtimes_len_def nth_append)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1888
by arith
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1889
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: 285
diff changeset
  1890
lemma fetch_t_wcode_14 [simp]: "fetch t_wcode_main (14 + length t_twice div 2 + t_fourtimes_len) b
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1891
             = (L, Suc 0)"
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: 285
diff changeset
  1892
apply(case_tac b, simp_all add:fetch_t_wcode_14_Bk fetch_t_wcode_14_Oc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1893
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1894
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1895
lemma wcode_jump2: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1896
  "\<exists> stp ln rn. steps0 (t_twice_len + 14 + t_fourtimes_len
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1897
  , Bk # Bk # Bk\<up>(lnb) @ Oc # ires, Oc\<up>(Suc (4 * rs + 4)) @ Bk\<up>(rnb)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1898
  (Suc 0, Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (4 * rs + 4)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1899
apply(rule_tac x = "Suc 0" in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1900
apply(simp add: steps.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1901
apply(rule_tac x = lnb in exI, rule_tac x = rnb in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1902
apply(simp add: step.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1903
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1904
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1905
lemma wcode_fourtimes_case:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1906
  shows "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1907
  steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1908
  (Suc 0, Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1909
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1910
  have "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1911
  steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1912
  (t_twice_len + 14, Bk # Bk # Bk\<up>(ln) @ Oc # ires, Oc\<up>(Suc (rs + 1)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1913
    using wcode_fourtimes_case_first_correctness[of ires rs m n]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1914
    apply(simp add: wcode_fourtimes_case_inv.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1915
    apply(rule_tac x = na in exI, rule_tac x = ln in exI,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1916
          rule_tac x = rn in exI)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1917
    apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1918
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1919
  from this obtain stpa lna rna where stp1:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1920
    "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stpa =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1921
  (t_twice_len + 14, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (rs + 1)) @ Bk\<up>(rna))" by blast
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1922
  have "\<exists>stp ln rn. steps0 (t_twice_len + 14, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (rs + 1)) @ Bk\<up>(rna))
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1923
                     t_wcode_main stp =
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1924
          (t_twice_len + 14 + t_fourtimes_len, Bk # Bk # Bk\<up>(ln) @ Oc # ires,  Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1925
    using t_fourtimes_append[of " Bk\<up>(lna) @ Oc # ires" "rs + 1" rna]
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1926
    apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1927
    apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1928
    apply(erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1929
    apply(simp add: t_wcode_main_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1930
    apply(rule_tac x = stp in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1931
          rule_tac x = "ln + lna" in exI,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1932
          rule_tac x = rn in exI, simp)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  1933
    apply(simp add: replicate_Suc[THEN sym] replicate_add[THEN sym] del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1934
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1935
  from this obtain stpb lnb rnb where stp2:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1936
    "steps0 (t_twice_len + 14, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (rs + 1)) @ Bk\<up>(rna))
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1937
                     t_wcode_main stpb =
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1938
       (t_twice_len + 14 + t_fourtimes_len, Bk # Bk # Bk\<up>(lnb) @ Oc # ires,  Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rnb))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1939
    by blast
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1940
  have "\<exists>stp ln rn. steps0 (t_twice_len + 14 + t_fourtimes_len,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1941
    Bk # Bk # Bk\<up>(lnb) @ Oc # ires,  Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rnb))
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1942
    t_wcode_main stp =
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1943
    (Suc 0, Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1944
    apply(rule wcode_jump2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1945
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1946
  from this obtain stpc lnc rnc where stp3: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1947
    "steps0 (t_twice_len + 14 + t_fourtimes_len,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1948
    Bk # Bk # Bk\<up>(lnb) @ Oc # ires,  Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rnb))
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1949
    t_wcode_main stpc =
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1950
    (Suc 0, Bk # Bk\<up>(lnc) @ Oc # ires, Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rnc))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1951
    by blast
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1952
  from stp1 stp2 stp3 show "?thesis"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1953
    apply(rule_tac x = "stpa + stpb + stpc" in exI,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1954
          rule_tac x = lnc in exI, rule_tac x = rnc in exI)
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: 285
diff changeset
  1955
    apply(simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1956
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1957
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1958
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1959
fun wcode_on_left_moving_3_B :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1960
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1961
  "wcode_on_left_moving_3_B ires rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1962
       (\<exists> ml mr rn. l = Bk\<up>(ml) @ Oc # Bk # Bk # ires \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1963
                    r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1964
                    ml + mr > Suc 0 \<and> mr > 0 )"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1965
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1966
fun wcode_on_left_moving_3_O :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1967
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1968
  "wcode_on_left_moving_3_O ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1969
         (\<exists> ln rn. l = Bk # Bk # ires \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1970
                   r = Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1971
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1972
fun wcode_on_left_moving_3 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1973
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1974
  "wcode_on_left_moving_3 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1975
       (wcode_on_left_moving_3_B ires rs (l, r) \<or>  
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1976
        wcode_on_left_moving_3_O ires rs (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1977
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1978
fun wcode_on_checking_3 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1979
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1980
  "wcode_on_checking_3 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1981
         (\<exists> ln rn. l = Bk # ires \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1982
             r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1983
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1984
fun wcode_goon_checking_3 :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1985
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1986
  "wcode_goon_checking_3 ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1987
         (\<exists> ln rn. l = ires \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1988
             r = Bk # Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1989
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1990
fun wcode_stop :: "bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1991
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1992
  "wcode_stop ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1993
          (\<exists> ln rn. l = Bk # ires \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  1994
             r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1995
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1996
fun wcode_halt_case_inv :: "nat \<Rightarrow> bin_inv_t"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1997
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1998
  "wcode_halt_case_inv st ires rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1999
          (if st = 0 then wcode_stop ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2000
           else if st = Suc 0 then wcode_on_left_moving_3 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2001
           else if st = Suc (Suc 0) then wcode_on_checking_3 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2002
           else if st = 7 then wcode_goon_checking_3 ires rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2003
           else False)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2004
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2005
fun wcode_halt_case_state :: "config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2006
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2007
  "wcode_halt_case_state (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2008
           (if st = 1 then 5
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2009
            else if st = Suc (Suc 0) then 4
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2010
            else if st = 7 then 3
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2011
            else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2012
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2013
fun wcode_halt_case_step :: "config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2014
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2015
  "wcode_halt_case_step (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2016
         (if st = 1 then length l
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2017
         else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2018
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2019
fun wcode_halt_case_measure :: "config \<Rightarrow> nat \<times> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2020
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2021
  "wcode_halt_case_measure (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2022
     (wcode_halt_case_state (st, l, r), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2023
      wcode_halt_case_step (st, l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2024
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2025
definition wcode_halt_case_le :: "(config \<times> config) set"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2026
  where "wcode_halt_case_le \<equiv> (inv_image lex_pair wcode_halt_case_measure)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2027
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2028
lemma wf_wcode_halt_case_le[intro]: "wf wcode_halt_case_le"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2029
by(auto intro:wf_inv_image simp: wcode_halt_case_le_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2030
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2031
declare wcode_on_left_moving_3_B.simps[simp del] wcode_on_left_moving_3_O.simps[simp del]  
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2032
        wcode_on_checking_3.simps[simp del] wcode_goon_checking_3.simps[simp del] 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2033
        wcode_on_left_moving_3.simps[simp del] wcode_stop.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2034
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2035
lemmas wcode_halt_invs = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2036
  wcode_on_left_moving_3_B.simps wcode_on_left_moving_3_O.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2037
  wcode_on_checking_3.simps wcode_goon_checking_3.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2038
  wcode_on_left_moving_3.simps wcode_stop.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2039
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: 285
diff changeset
  2040
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2041
lemma wcode_on_left_moving_3_mv_Bk[simp]: "wcode_on_left_moving_3 ires rs (b, Bk # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2042
 \<Longrightarrow> wcode_on_left_moving_3 ires rs (tl b, hd b # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2043
apply(simp only: wcode_halt_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2044
apply(erule_tac disjE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2045
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2046
apply(case_tac ml, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2047
apply(rule_tac x = "mr - 2" in exI, rule_tac x = rn in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2048
apply(case_tac mr, simp, simp add: exp_ind del: replicate_Suc)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2049
apply(case_tac nat, simp, simp add: exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2050
apply(rule_tac disjI1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2051
apply(rule_tac x = nat in exI, rule_tac x = "Suc mr" in exI, 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2052
      rule_tac x = rn in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2053
apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2054
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2055
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: 285
diff changeset
  2056
lemma wcode_goon_checking_3_cases[simp]: "wcode_goon_checking_3 ires rs (b, Bk # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2057
  (b = [] \<longrightarrow> wcode_stop ires rs ([Bk], list)) \<and>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2058
  (b \<noteq> [] \<longrightarrow> wcode_stop ires rs (Bk # b, list))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2059
apply(auto simp: wcode_halt_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2060
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2061
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: 285
diff changeset
  2062
lemma wcode_on_checking_3_mv_Oc[simp]: "wcode_on_left_moving_3 ires rs (b, Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2063
               wcode_on_checking_3 ires rs (tl b, hd b # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2064
apply(simp add:wcode_halt_invs, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2065
apply(case_tac [!] mr, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2066
done     
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2067
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: 285
diff changeset
  2068
lemma wcode_3_nonempty[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2069
  "wcode_on_left_moving_3 ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2070
  "wcode_on_checking_3 ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2071
  "wcode_goon_checking_3 ires rs (b, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2072
  "wcode_on_left_moving_3 ires rs (b, Oc # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2073
  "wcode_on_checking_3 ires rs (b, Oc # list) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2074
  "wcode_on_left_moving_3 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2075
  "wcode_on_checking_3 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2076
  "wcode_goon_checking_3 ires rs (b, Oc # list) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2077
  by(auto simp: wcode_halt_invs)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2078
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2079
lemma wcode_goon_checking_3_mv_Bk[simp]: "wcode_on_checking_3 ires rs (b, Bk # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2080
  wcode_goon_checking_3 ires rs (tl b, hd b # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2081
apply(auto simp: wcode_halt_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2082
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2083
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2084
lemma t_halt_case_correctness: 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2085
shows "let P = (\<lambda> (st, l, r). st = 0) in 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2086
       let Q = (\<lambda> (st, l, r). wcode_halt_case_inv st ires rs (l, r)) in 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2087
       let f = (\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp) in
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2088
       \<exists> n .P (f n) \<and> Q (f (n::nat))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2089
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2090
  let ?P = "(\<lambda> (st, l, r). st = 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2091
  let ?Q = "(\<lambda> (st, l, r). wcode_halt_case_inv st ires rs (l, r))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2092
  let ?f = "(\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2093
  have "\<exists> n. ?P (?f n) \<and> ?Q (?f (n::nat))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2094
  proof(rule_tac halt_lemma2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2095
    show "wf wcode_halt_case_le" by auto
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2096
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2097
    show "\<forall> na. \<not> ?P (?f na) \<and> ?Q (?f na) \<longrightarrow> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2098
                    ?Q (?f (Suc na)) \<and> (?f (Suc na), ?f na) \<in> wcode_halt_case_le"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2099
      apply(rule_tac allI, rule_tac impI, case_tac "?f na")
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2100
      apply(simp add: step_red step.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2101
      apply(case_tac c, simp, case_tac [2] aa)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2102
      apply(simp_all split: if_splits add: wcode_halt_case_le_def lex_pair_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2103
      done      
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2104
  next 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2105
    show "?Q (?f 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2106
      apply(simp add: steps.simps wcode_halt_invs)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2107
      apply(rule_tac x = "Suc m" in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2108
      apply(rule_tac x = "Suc 0" in exI, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2109
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2110
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2111
    show "\<not> ?P (?f 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2112
      apply(simp add: steps.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2113
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2114
  qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2115
  thus "?thesis"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2116
    apply(auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2117
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2118
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2119
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2120
declare wcode_halt_case_inv.simps[simp del]
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: 285
diff changeset
  2121
lemma leading_Oc[intro]: "\<exists> xs. (<rev list @ [aa::nat]> :: cell list) = Oc # xs"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2122
apply(case_tac "rev list", simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2123
apply(simp add: tape_of_nl_cons)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2124
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2125
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2126
lemma wcode_halt_case:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2127
  "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n))
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2128
  t_wcode_main stp  = (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2129
  using t_halt_case_correctness[of ires rs m n]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2130
apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2131
apply(erule_tac exE)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2132
apply(case_tac "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2133
                Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main na")
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2134
apply(auto simp: wcode_halt_case_inv.simps wcode_stop.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2135
apply(rule_tac x = na in exI, rule_tac x = ln in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2136
      rule_tac x = rn in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2137
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2138
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: 285
diff changeset
  2139
lemma bl_bin_one[simp]: "bl_bin [Oc] = 1"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2140
apply(simp add: bl_bin.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2141
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2142
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: 285
diff changeset
  2143
lemma twice_power[intro]: "2 * 2 ^ a = Suc (Suc (2 * bl_bin (Oc \<up> a)))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2144
apply(induct a, auto simp: bl_bin.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2145
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2146
declare replicate_Suc[simp del]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2147
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2148
lemma t_wcode_main_lemma_pre:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2149
  "\<lbrakk>args \<noteq> []; lm = <args::nat list>\<rbrakk> \<Longrightarrow> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2150
       \<exists> stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ rev lm @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2151
                    stp
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2152
      = (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin lm + rs * 2^(length lm - 1) ) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2153
proof(induct "length args" arbitrary: args lm rs m n, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2154
  fix x args lm rs m n
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2155
  assume ind:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2156
    "\<And>args lm rs m n.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2157
    \<lbrakk>x = length args; (args::nat list) \<noteq> []; lm = <args>\<rbrakk>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2158
    \<Longrightarrow> \<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2159
    steps0 (Suc 0, Bk # Bk\<up>(m) @ rev lm @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2160
    (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin lm + rs * 2 ^ (length lm - 1)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2161
    and h: "Suc x = length args" "(args::nat list) \<noteq> []" "lm = <args>"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2162
  from h have "\<exists> (a::nat) xs. args = xs @ [a]"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2163
    apply(rule_tac x = "last args" in exI)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2164
    apply(rule_tac x = "butlast args" in exI, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2165
    done    
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2166
  from this obtain a xs where "args = xs @ [a]" by blast
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2167
  from h and this show
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2168
    "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2169
    steps0 (Suc 0, Bk # Bk\<up>(m) @ rev lm @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2170
    (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin lm + rs * 2 ^ (length lm - 1)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2171
  proof(case_tac "xs::nat list", simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2172
    show "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2173
          steps0 (Suc 0, Bk # Bk \<up> m @ Oc \<up> Suc a @ Bk # Bk # ires, Bk # Oc \<up> Suc rs @ Bk \<up> n) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2174
          (0, Bk # ires, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> (bl_bin (Oc \<up> Suc a) + rs * 2 ^ a) @ Bk \<up> rn)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2175
    proof(induct "a" arbitrary: m n rs ires, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2176
      fix m n rs ires
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2177
      show "\<exists>stp ln rn.
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2178
          steps0 (Suc 0, Bk # Bk \<up> m @ Oc # Bk # Bk # ires, Bk # Oc \<up> Suc rs @ Bk \<up> n) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2179
          (0, Bk # ires, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> Suc rs @ Bk \<up> rn)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2180
          apply(rule_tac wcode_halt_case)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2181
        done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2182
    next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2183
      fix a m n rs ires
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2184
      assume ind2:
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2185
        "\<And>m n rs ires.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2186
           \<exists>stp ln rn.
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2187
              steps0 (Suc 0, Bk # Bk \<up> m @ Oc \<up> Suc a @ Bk # Bk # ires, Bk # Oc \<up> Suc rs @ Bk \<up> n) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2188
              (0, Bk # ires, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> (bl_bin (Oc \<up> Suc a) + rs * 2 ^ a) @ Bk \<up> rn)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2189
      show " \<exists>stp ln rn.
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2190
          steps0 (Suc 0, Bk # Bk \<up> m @ Oc \<up> Suc (Suc a) @ Bk # Bk # ires, Bk # Oc \<up> Suc rs @ Bk \<up> n) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2191
          (0, Bk # ires, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> (bl_bin (Oc \<up> Suc (Suc a)) + rs * 2 ^ Suc a) @ Bk \<up> rn)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2192
      proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2193
        have "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2194
          steps0 (Suc 0, Bk # Bk\<up>(m) @ rev (<Suc a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2195
          (Suc 0, Bk # Bk\<up>(ln) @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2196
          apply(simp add: tape_of_nat)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2197
          using wcode_double_case[of m "Oc\<up>(a) @ Bk # Bk # ires" rs n]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2198
          apply(simp add: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2199
          done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2200
        from this obtain stpa lna rna where stp1:  
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2201
          "steps0 (Suc 0, Bk # Bk\<up>(m) @ rev (<Suc a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stpa =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2202
          (Suc 0, Bk # Bk\<up>(lna) @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rna))" by blast
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2203
        moreover have 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2204
          "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2205
          steps0 (Suc 0,  Bk # Bk\<up>(lna) @ rev (<a::nat>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rna)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2206
          (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<a>) + (2*rs + 2)  * 2 ^ a) @ Bk\<up>(rn))"
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: 285
diff changeset
  2207
          using ind2[of lna ires "2*rs + 2" rna] by(simp add: tape_of_list_def tape_of_nat_def)   
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2208
        from this obtain stpb lnb rnb where stp2:  
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2209
          "steps0 (Suc 0,  Bk # Bk\<up>(lna) @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rna)) t_wcode_main stpb =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2210
          (0, Bk # ires, Bk # Oc # Bk\<up>(lnb) @ Bk # Bk # Oc\<up>(bl_bin (<a>) + (2*rs + 2)  * 2 ^ a) @ Bk\<up>(rnb))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2211
          by blast
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2212
        from stp1 and stp2 show "?thesis"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2213
          apply(rule_tac x = "stpa + stpb" in exI,
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: 285
diff changeset
  2214
            rule_tac x = lnb in exI, rule_tac x = rnb in exI, simp add: tape_of_nat_def)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2215
          apply(simp add:  bl_bin.simps replicate_Suc)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2216
          apply(auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2217
          done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2218
      qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2219
    qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2220
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2221
    fix aa list
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2222
    assume g: "Suc x = length args" "args \<noteq> []" "lm = <args>" "args = xs @ [a::nat]" "xs = (aa::nat) # list"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2223
    thus "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ rev lm @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2224
      (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin lm + rs * 2 ^ (length lm - 1)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2225
    proof(induct a arbitrary: m n rs args lm, simp_all add: tape_of_nl_rev, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2226
        simp only: tape_of_nl_cons_app1, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2227
      fix m n rs args lm
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2228
      have "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2229
        steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # rev (<(aa::nat) # list>) @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2230
        Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2231
        (Suc 0, Bk # Bk\<up>(ln) @ rev (<aa # list>) @ Bk # Bk # ires, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2232
        Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2233
        proof(simp add: tape_of_nl_rev)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2234
          have "\<exists> xs. (<rev list @ [aa]>) = Oc # xs" by auto           
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2235
          from this obtain xs where "(<rev list @ [aa]>) = Oc # xs" ..
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2236
          thus "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2237
            steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # <rev list @ [aa]> @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2238
            Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2239
            (Suc 0, Bk # Bk\<up>(ln) @ <rev list @ [aa]> @ Bk # Bk # ires, Bk # Oc\<up>(5 + 4 * rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2240
            apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2241
            using wcode_fourtimes_case[of m "xs @ Bk # Bk # ires" rs n]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2242
            apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2243
            done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2244
        qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2245
      from this obtain stpa lna rna where stp1:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2246
        "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # rev (<aa # list>) @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2247
        Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stpa =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2248
        (Suc 0, Bk # Bk\<up>(lna) @ rev (<aa # list>) @ Bk # Bk # ires, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2249
        Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rna))" by blast
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2250
      from g have 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2251
        "\<exists> stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(lna) @ rev (<(aa::nat) # list>) @ Bk # Bk # ires, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2252
        Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rna)) t_wcode_main stp = (0, Bk # ires, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2253
        Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<aa#list>)+ (4*rs + 4) * 2^(length (<aa#list>) - 1) ) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2254
         apply(rule_tac args = "(aa::nat)#list" in ind, simp_all)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2255
         done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2256
       from this obtain stpb lnb rnb where stp2:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2257
         "steps0 (Suc 0, Bk # Bk\<up>(lna) @ rev (<(aa::nat) # list>) @ Bk # Bk # ires, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2258
         Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rna)) t_wcode_main stpb = (0, Bk # ires, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2259
         Bk # Oc # Bk\<up>(lnb) @ Bk # Bk # Oc\<up>(bl_bin (<aa#list>)+ (4*rs + 4) * 2^(length (<aa#list>) - 1) ) @ Bk\<up>(rnb))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2260
         by blast
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2261
       from stp1 and stp2 and h
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2262
       show "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2263
         steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # <rev list @ [aa]> @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2264
         Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2265
         (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk #
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2266
         Bk # Oc\<up>(bl_bin (Oc\<up>(Suc aa) @ Bk # <list @ [0]>) + rs * (2 * 2 ^ (aa + length (<list @ [0]>)))) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2267
         apply(rule_tac x = "stpa + stpb" in exI, rule_tac x = lnb in exI,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2268
           rule_tac x = rnb in exI, simp add: steps_add tape_of_nl_rev)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2269
         done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2270
     next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2271
       fix ab m n rs args lm
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2272
       assume ind2:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2273
         "\<And> m n rs args lm.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2274
         \<lbrakk>lm = <aa # list @ [ab]>; args = aa # list @ [ab]\<rbrakk>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2275
         \<Longrightarrow> \<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2276
         steps0 (Suc 0, Bk # Bk\<up>(m) @ <ab # rev list @ [aa]> @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2277
         Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2278
         (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk #
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2279
         Bk # Oc\<up>(bl_bin (<aa # list @ [ab]>) + rs * 2 ^ (length (<aa # list @ [ab]>) - Suc 0)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2280
         and k: "args = aa # list @ [Suc ab]" "lm = <aa # list @ [Suc ab]>"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2281
       show "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2282
         steps0 (Suc 0, Bk # Bk\<up>(m) @ <Suc ab # rev list @ [aa]> @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2283
         Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2284
         (0, Bk # ires,Bk # Oc # Bk\<up>(ln) @ Bk # 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2285
         Bk # Oc\<up>(bl_bin (<aa # list @ [Suc ab]>) + rs * 2 ^ (length (<aa # list @ [Suc ab]>) - Suc 0)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2286
       proof(simp add: tape_of_nl_cons_app1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2287
         have "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2288
           steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc\<up>(Suc (Suc ab)) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2289
           Bk # Oc # Oc\<up>(rs) @ Bk\<up>(n)) t_wcode_main stp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2290
           = (Suc 0, Bk # Bk\<up>(ln) @ Oc\<up>(Suc ab) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2291
           Bk # Oc\<up>(Suc (2*rs + 2)) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2292
           using wcode_double_case[of m "Oc\<up>(ab) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2293
                                      rs n]
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2294
           apply(simp add: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2295
           done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2296
         from this obtain stpa lna rna where stp1:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2297
           "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc\<up>(Suc (Suc ab)) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2298
           Bk # Oc # Oc\<up>(rs) @ Bk\<up>(n)) t_wcode_main stpa
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2299
           = (Suc 0, Bk # Bk\<up>(lna) @ Oc\<up>(Suc ab) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2300
           Bk # Oc\<up>(Suc (2*rs + 2)) @ Bk\<up>(rna))" by blast
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2301
         from k have 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2302
           "\<exists> stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(lna) @ <ab # rev list @ [aa]> @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2303
           Bk # Oc\<up>(Suc (2*rs + 2)) @ Bk\<up>(rna)) t_wcode_main stp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2304
           = (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk #
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2305
           Bk # Oc\<up>(bl_bin (<aa # list @ [ab]> ) +  (2*rs + 2)* 2^(length (<aa # list @ [ab]>) - Suc 0)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2306
           apply(rule_tac ind2, simp_all)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2307
           done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2308
         from this obtain stpb lnb rnb where stp2: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2309
           "steps0 (Suc 0, Bk # Bk\<up>(lna) @  <ab # rev list @ [aa]> @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2310
           Bk # Oc\<up>(Suc (2*rs + 2)) @ Bk\<up>(rna)) t_wcode_main stpb
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2311
           = (0, Bk # ires, Bk # Oc # Bk\<up>(lnb) @ Bk #
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2312
           Bk # Oc\<up>(bl_bin (<aa # list @ [ab]> ) +  (2*rs + 2)* 2^(length (<aa # list @ [ab]>) - Suc 0)) @ Bk\<up>(rnb))" 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2313
           by blast
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2314
         from stp1 and stp2 show 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2315
           "\<exists>stp ln rn.
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2316
           steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc\<up>(Suc (Suc ab)) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2317
           Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2318
           (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2319
           Oc\<up>(bl_bin (Oc\<up>(Suc aa) @ Bk # <list @ [Suc ab]>) + rs * (2 * 2 ^ (aa + length (<list @ [Suc ab]>)))) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2320
           @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2321
           apply(rule_tac x = "stpa + stpb" in exI, rule_tac x = lnb in exI,
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2322
             rule_tac x = rnb in exI, simp add: steps_add tape_of_nl_cons_app1 replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2323
           done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2324
       qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2325
     qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2326
   qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2327
 qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2328
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2329
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2330
definition t_wcode_prepare :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2331
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2332
  "t_wcode_prepare \<equiv> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2333
         [(W1, 2), (L, 1), (L, 3), (R, 2), (R, 4), (W0, 3),
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2334
          (R, 4), (R, 5), (R, 6), (R, 5), (R, 7), (R, 5),
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2335
          (W1, 7), (L, 0)]"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2336
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2337
fun wprepare_add_one :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2338
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2339
  "wprepare_add_one m lm (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2340
      (\<exists> rn. l = [] \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2341
               (r = <m # lm> @ Bk\<up>(rn) \<or> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2342
                r = Bk # <m # lm> @ Bk\<up>(rn)))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2343
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2344
fun wprepare_goto_first_end :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2345
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2346
  "wprepare_goto_first_end m lm (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2347
      (\<exists> ml mr rn. l = Oc\<up>(ml) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2348
                      r = Oc\<up>(mr) @ Bk # <lm> @ Bk\<up>(rn) \<and>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2349
                      ml + mr = Suc (Suc m))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2350
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2351
fun wprepare_erase :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow>  bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2352
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2353
  "wprepare_erase m lm (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2354
     (\<exists> rn. l = Oc\<up>(Suc m) \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2355
               tl r = Bk # <lm> @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2356
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2357
fun wprepare_goto_start_pos_B :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2358
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2359
  "wprepare_goto_start_pos_B m lm (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2360
     (\<exists> rn. l = Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2361
               r = Bk # <lm> @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2362
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2363
fun wprepare_goto_start_pos_O :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2364
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2365
  "wprepare_goto_start_pos_O m lm (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2366
     (\<exists> rn. l = Bk # Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2367
               r = <lm> @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2368
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2369
fun wprepare_goto_start_pos :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2370
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2371
  "wprepare_goto_start_pos m lm (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2372
       (wprepare_goto_start_pos_B m lm (l, r) \<or>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2373
        wprepare_goto_start_pos_O m lm (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2374
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2375
fun wprepare_loop_start_on_rightmost :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2376
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2377
  "wprepare_loop_start_on_rightmost m lm (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2378
     (\<exists> rn mr. rev l @ r = Oc\<up>(Suc m) @ Bk # Bk # <lm> @ Bk\<up>(rn) \<and> l \<noteq> [] \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2379
                       r = Oc\<up>(mr) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2380
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2381
fun wprepare_loop_start_in_middle :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2382
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2383
  "wprepare_loop_start_in_middle m lm (l, r) =
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2384
     (\<exists> rn (mr:: nat) (lm1::nat list). 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2385
  rev l @ r = Oc\<up>(Suc m) @ Bk # Bk # <lm> @ Bk\<up>(rn) \<and> l \<noteq> [] \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2386
  r = Oc\<up>(mr) @ Bk # <lm1> @ Bk\<up>(rn) \<and> lm1 \<noteq> [])"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2387
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2388
fun wprepare_loop_start :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2389
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2390
  "wprepare_loop_start m lm (l, r) = (wprepare_loop_start_on_rightmost m lm (l, r) \<or> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2391
                                      wprepare_loop_start_in_middle m lm (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2392
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2393
fun wprepare_loop_goon_on_rightmost :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2394
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2395
  "wprepare_loop_goon_on_rightmost m lm (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2396
     (\<exists> rn. l = Bk # <rev lm> @ Bk # Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2397
               r = Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2398
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2399
fun wprepare_loop_goon_in_middle :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2400
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2401
  "wprepare_loop_goon_in_middle m lm (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2402
     (\<exists> rn (mr:: nat) (lm1::nat list). 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2403
  rev l @ r = Oc\<up>(Suc m) @ Bk # Bk # <lm> @ Bk\<up>(rn) \<and> l \<noteq> [] \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2404
                     (if lm1 = [] then r = Oc\<up>(mr) @ Bk\<up>(rn) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2405
                     else r = Oc\<up>(mr) @ Bk # <lm1> @ Bk\<up>(rn)) \<and> mr > 0)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2406
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2407
fun wprepare_loop_goon :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2408
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2409
  "wprepare_loop_goon m lm (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2410
              (wprepare_loop_goon_in_middle m lm (l, r) \<or> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2411
               wprepare_loop_goon_on_rightmost m lm (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2412
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2413
fun wprepare_add_one2 :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2414
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2415
  "wprepare_add_one2 m lm (l, r) =
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2416
          (\<exists> rn. l = Bk # Bk # <rev lm> @ Bk # Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2417
               (r = [] \<or> tl r = Bk\<up>(rn)))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2418
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2419
fun wprepare_stop :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2420
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2421
  "wprepare_stop m lm (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2422
         (\<exists> rn. l = Bk # <rev lm> @ Bk # Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2423
               r = Bk # Oc # Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2424
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2425
fun wprepare_inv :: "nat \<Rightarrow> nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2426
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2427
  "wprepare_inv st m lm (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2428
        (if st = 0 then wprepare_stop m lm (l, r) 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2429
         else if st = Suc 0 then wprepare_add_one m lm (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2430
         else if st = Suc (Suc 0) then wprepare_goto_first_end m lm (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2431
         else if st = Suc (Suc (Suc 0)) then wprepare_erase m lm (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2432
         else if st = 4 then wprepare_goto_start_pos m lm (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2433
         else if st = 5 then wprepare_loop_start m lm (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2434
         else if st = 6 then wprepare_loop_goon m lm (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2435
         else if st = 7 then wprepare_add_one2 m lm (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2436
         else False)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2437
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2438
fun wprepare_stage :: "config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2439
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2440
  "wprepare_stage (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2441
      (if st \<ge> 1 \<and> st \<le> 4 then 3
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2442
       else if st = 5 \<or> st = 6 then 2
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2443
       else 1)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2444
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2445
fun wprepare_state :: "config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2446
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2447
  "wprepare_state (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2448
       (if st = 1 then 4
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2449
        else if st = Suc (Suc 0) then 3
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2450
        else if st = Suc (Suc (Suc 0)) then 2
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2451
        else if st = 4 then 1
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2452
        else if st = 7 then 2
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2453
        else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2454
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2455
fun wprepare_step :: "config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2456
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2457
  "wprepare_step (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2458
      (if st = 1 then (if hd r = Oc then Suc (length l)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2459
                       else 0)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2460
       else if st = Suc (Suc 0) then length r
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2461
       else if st = Suc (Suc (Suc 0)) then (if hd r = Oc then 1
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2462
                            else 0)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2463
       else if st = 4 then length r
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2464
       else if st = 5 then Suc (length r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2465
       else if st = 6 then (if r = [] then 0 else Suc (length r))
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2466
       else if st = 7 then (if (r \<noteq> [] \<and> hd r = Oc) then 0
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2467
                            else 1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2468
       else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2469
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2470
fun wcode_prepare_measure :: "config \<Rightarrow> nat \<times> nat \<times> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2471
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2472
  "wcode_prepare_measure (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2473
     (wprepare_stage (st, l, r), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2474
      wprepare_state (st, l, r), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2475
      wprepare_step (st, l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2476
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2477
definition wcode_prepare_le :: "(config \<times> config) set"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2478
  where "wcode_prepare_le \<equiv> (inv_image lex_triple wcode_prepare_measure)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2479
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2480
lemma wf_wcode_prepare_le[intro]: "wf wcode_prepare_le"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2481
by(auto intro:wf_inv_image simp: wcode_prepare_le_def 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2482
           lex_triple_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2483
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2484
declare wprepare_add_one.simps[simp del] wprepare_goto_first_end.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2485
        wprepare_erase.simps[simp del] wprepare_goto_start_pos.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2486
        wprepare_loop_start.simps[simp del] wprepare_loop_goon.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2487
        wprepare_add_one2.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2488
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2489
lemmas wprepare_invs = wprepare_add_one.simps wprepare_goto_first_end.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2490
        wprepare_erase.simps wprepare_goto_start_pos.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2491
        wprepare_loop_start.simps wprepare_loop_goon.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2492
        wprepare_add_one2.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2493
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2494
declare wprepare_inv.simps[simp del]
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: 285
diff changeset
  2495
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2496
lemma fetch_t_wcode_prepare[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2497
  "fetch t_wcode_prepare (Suc 0) Bk = (W1, 2)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2498
  "fetch t_wcode_prepare (Suc 0) Oc = (L, 1)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2499
  "fetch t_wcode_prepare (Suc (Suc 0)) Bk = (L, 3)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2500
  "fetch t_wcode_prepare (Suc (Suc 0)) Oc = (R, 2)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2501
  "fetch t_wcode_prepare (Suc (Suc (Suc 0))) Bk = (R, 4)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2502
  "fetch t_wcode_prepare (Suc (Suc (Suc 0))) Oc = (W0, 3)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2503
  "fetch t_wcode_prepare 4 Bk = (R, 4)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2504
  "fetch t_wcode_prepare 4 Oc = (R, 5)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2505
  "fetch t_wcode_prepare 5 Oc = (R, 5)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2506
  "fetch t_wcode_prepare 5 Bk = (R, 6)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2507
  "fetch t_wcode_prepare 6 Oc = (R, 5)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2508
  "fetch t_wcode_prepare 6 Bk = (R, 7)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2509
  "fetch t_wcode_prepare 7 Oc = (L, 0)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2510
  "fetch t_wcode_prepare 7 Bk = (W1, 7)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2511
  unfolding fetch.simps t_wcode_prepare_def nth_of.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2512
  numeral by auto
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2513
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2514
lemma wprepare_add_one_nonempty_snd[simp]: "lm \<noteq> [] \<Longrightarrow> wprepare_add_one m lm (b, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2515
apply(simp add: wprepare_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2516
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2517
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: 285
diff changeset
  2518
lemma wprepare_goto_first_end_nonempty_snd[simp]: "lm \<noteq> [] \<Longrightarrow> wprepare_goto_first_end m lm (b, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2519
apply(simp add: wprepare_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2520
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2521
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: 285
diff changeset
  2522
lemma wprepare_erase_nonempty_snd[simp]: "lm \<noteq> [] \<Longrightarrow> wprepare_erase m lm (b, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2523
apply(simp add: wprepare_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2524
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2525
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: 285
diff changeset
  2526
lemma wprepare_goto_start_pos_nonempty_snd[simp]: "lm \<noteq> [] \<Longrightarrow> wprepare_goto_start_pos m lm (b, []) = False"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2527
apply(simp add: wprepare_invs)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2528
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2529
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: 285
diff changeset
  2530
lemma wprepare_loop_start_empty_nonempty_fst[simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start m lm (b, [])\<rbrakk> \<Longrightarrow> b \<noteq> []"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2531
apply(simp add: wprepare_invs)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2532
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2533
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: 285
diff changeset
  2534
lemma rev_eq: "rev xs = rev ys \<Longrightarrow> xs = ys" by auto
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2535
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2536
lemma wprepare_loop_goon_Bk_empty_snd[simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start m lm (b, [])\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2537
                                  wprepare_loop_goon m lm (Bk # b, [])"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2538
apply(simp only: wprepare_invs)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2539
apply(erule_tac disjE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2540
apply(rule_tac disjI2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2541
apply(simp add: wprepare_loop_start_on_rightmost.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2542
                wprepare_loop_goon_on_rightmost.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2543
apply(rule_tac rev_eq, simp add: tape_of_nl_rev)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2544
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2545
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: 285
diff changeset
  2546
lemma wprepare_loop_goon_nonempty_fst[simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_goon m lm (b, [])\<rbrakk> \<Longrightarrow> b \<noteq> []"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2547
apply(simp only: wprepare_invs, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2548
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2549
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: 285
diff changeset
  2550
lemma wprepare_add_one2_Bk_empty[simp]:"\<lbrakk>lm \<noteq> []; wprepare_loop_goon m lm (b, [])\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2551
  wprepare_add_one2 m lm (Bk # b, [])"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2552
apply(simp only: wprepare_invs, auto split: if_splits)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2553
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2554
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: 285
diff changeset
  2555
lemma wprepare_add_one2_nonempty_fst[simp]: "wprepare_add_one2 m lm (b, []) \<Longrightarrow> b \<noteq> []"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2556
apply(simp only: wprepare_invs, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2557
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2558
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: 285
diff changeset
  2559
lemma wprepare_add_one2_Oc[simp]: "wprepare_add_one2 m lm (b, []) \<Longrightarrow> wprepare_add_one2 m lm (b, [Oc])"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2560
apply(simp only: wprepare_invs, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2561
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2562
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: 285
diff changeset
  2563
lemma Bk_not_tape_start[simp]: "(Bk # list = <(m::nat) # lm> @ ys) = False"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2564
apply(case_tac lm, auto simp: tape_of_nl_cons replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2565
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2566
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: 285
diff changeset
  2567
lemma wprepare_goto_first_end_cases[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2568
 "\<lbrakk>lm \<noteq> []; wprepare_add_one m lm (b, Bk # list)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2569
       \<Longrightarrow> (b = [] \<longrightarrow> wprepare_goto_first_end m lm ([], Oc # list)) \<and> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2570
           (b \<noteq> [] \<longrightarrow> wprepare_goto_first_end m lm (b, Oc # list))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2571
apply(simp only: wprepare_invs)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2572
apply(auto simp: tape_of_nl_cons split: if_splits)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2573
apply(rule_tac x = 0 in exI, simp add: replicate_Suc)
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: 285
diff changeset
  2574
apply(case_tac lm, simp, simp add: tape_of_list_def tape_of_nat_list.simps replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2575
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2576
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: 285
diff changeset
  2577
lemma wprepare_goto_first_end_Bk_nonempty_fst[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2578
  "wprepare_goto_first_end m lm (b, Bk # list) \<Longrightarrow> b \<noteq> []"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2579
apply(simp only: wprepare_invs , auto simp: replicate_Suc)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2580
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2581
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2582
declare replicate_Suc[simp]
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2583
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: 285
diff changeset
  2584
lemma wprepare_erase_elem_Bk_rest[simp]: "wprepare_goto_first_end m lm (b, Bk # list) \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2585
                          wprepare_erase m lm (tl b, hd b # Bk # list)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2586
apply(simp only: wprepare_invs, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2587
apply(case_tac mr, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2588
apply(case_tac mr, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2589
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2590
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: 285
diff changeset
  2591
lemma wprepare_erase_Bk_nonempty_fst[simp]: "wprepare_erase m lm (b, Bk # list) \<Longrightarrow> b \<noteq> []"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2592
apply(simp only: wprepare_invs, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2593
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2594
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: 285
diff changeset
  2595
lemma wprepare_goto_start_pos_Bk[simp]: "wprepare_erase m lm (b, Bk # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2596
                           wprepare_goto_start_pos m lm (Bk # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2597
apply(simp only: wprepare_invs, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2598
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2599
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: 285
diff changeset
  2600
lemma wprepare_add_one_Bk_nonempty_snd[simp]: "\<lbrakk>wprepare_add_one m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> list \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2601
apply(simp only: wprepare_invs)
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: 285
diff changeset
  2602
apply(case_tac lm, simp_all add: tape_of_list_def tape_of_nat_def, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2603
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2604
    
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: 285
diff changeset
  2605
lemma wprepare_goto_first_end_nonempty_snd_tl[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2606
 "\<lbrakk>lm \<noteq> [];  wprepare_goto_first_end m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> list \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2607
apply(simp only: wprepare_invs, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2608
apply(case_tac mr, simp_all)
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: 285
diff changeset
  2609
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2610
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2611
lemma wprepare_erase_Bk_nonempty_list[simp]: "\<lbrakk>lm \<noteq> []; wprepare_erase m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> list \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2612
apply(simp only: wprepare_invs, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2613
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2614
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: 285
diff changeset
  2615
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2616
lemma wprepare_goto_start_pos_Bk_nonempty[simp]: "\<lbrakk>lm \<noteq> [];  wprepare_goto_start_pos m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> list \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2617
  by(cases lm;cases list;simp only: wprepare_invs, auto)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2618
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2619
lemma wprepare_goto_start_pos_Bk_nonempty_fst[simp]: "\<lbrakk>lm \<noteq> [];  wprepare_goto_start_pos m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> b \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2620
apply(simp only: wprepare_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2621
apply(auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2622
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2623
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: 285
diff changeset
  2624
lemma wprepare_loop_goon_Bk_nonempty[simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_goon m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> b \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2625
apply(simp only: wprepare_invs, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2626
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2627
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: 285
diff changeset
  2628
lemma wprepare_loop_goon_wprepare_add_one2_cases[simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_goon m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2629
  (list = [] \<longrightarrow> wprepare_add_one2 m lm (Bk # b, [])) \<and> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2630
  (list \<noteq> [] \<longrightarrow> wprepare_add_one2 m lm (Bk # b, list))"
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: 285
diff changeset
  2631
  unfolding wprepare_invs
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2632
apply(cases list;auto split:nat.split if_splits)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2633
apply(case_tac [1-3] mr, simp_all add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2634
apply(case_tac mr, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2635
apply(case_tac [1-2] mr, simp_all add: )
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: 285
diff changeset
  2636
apply(case_tac rn, force, case_tac nat, auto simp: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2637
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2638
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: 285
diff changeset
  2639
lemma wprepare_add_one2_nonempty[simp]: "wprepare_add_one2 m lm (b, Bk # list) \<Longrightarrow> b \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2640
apply(simp only: wprepare_invs, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2641
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2642
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: 285
diff changeset
  2643
lemma wprepare_add_one2_cases[simp]: "wprepare_add_one2 m lm (b, Bk # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2644
      (list = [] \<longrightarrow> wprepare_add_one2 m lm (b, [Oc])) \<and> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2645
      (list \<noteq> [] \<longrightarrow> wprepare_add_one2 m lm (b, Oc # list))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2646
apply(simp only:  wprepare_invs, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2647
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2648
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: 285
diff changeset
  2649
lemma wprepare_goto_first_end_cases_Oc[simp]: "wprepare_goto_first_end m lm (b, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2650
       \<Longrightarrow> (b = [] \<longrightarrow> wprepare_goto_first_end m lm ([Oc], list)) \<and> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2651
           (b \<noteq> [] \<longrightarrow> wprepare_goto_first_end m lm (Oc # b, list))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2652
apply(simp only:  wprepare_invs, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2653
apply(rule_tac x = 1 in exI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2654
apply(case_tac mr, simp_all add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2655
apply(case_tac ml, simp_all add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2656
apply(rule_tac x = "Suc ml" in exI, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2657
apply(rule_tac x = "mr - 1" in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2658
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2659
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: 285
diff changeset
  2660
lemma wprepare_erase_nonempty[simp]: "wprepare_erase m lm (b, Oc # list) \<Longrightarrow> b \<noteq> []"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2661
apply(simp only: wprepare_invs, auto simp: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2662
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2663
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: 285
diff changeset
  2664
lemma wprepare_erase_Bk[simp]: "wprepare_erase m lm (b, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2665
  \<Longrightarrow> wprepare_erase m lm (b, Bk # list)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2666
apply(simp  only:wprepare_invs, auto simp: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2667
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2668
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: 285
diff changeset
  2669
lemma wprepare_goto_start_pos_Bk_move[simp]: "\<lbrakk>lm \<noteq> []; wprepare_goto_start_pos m lm (b, Bk # list)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2670
       \<Longrightarrow> wprepare_goto_start_pos m lm (Bk # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2671
apply(simp only:wprepare_invs, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2672
apply(case_tac [!] lm, simp, simp_all)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2673
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2674
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: 285
diff changeset
  2675
lemma wprepare_loop_start_b_nonempty[simp]: "wprepare_loop_start m lm (b, aa) \<Longrightarrow> b \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2676
apply(simp only:wprepare_invs, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2677
done
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: 285
diff changeset
  2678
lemma exists_exp_of_Bk[elim]: "Bk # list = Oc\<up>(mr) @ Bk\<up>(rn)  \<Longrightarrow> \<exists>rn. list = Bk\<up>(rn)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2679
apply(case_tac mr, simp_all)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2680
apply(case_tac rn, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2681
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2682
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: 285
diff changeset
  2683
lemma wprepare_loop_start_in_middle_Bk_False[simp]: "wprepare_loop_start_in_middle m lm (b, [Bk]) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2684
apply(simp add: wprepare_loop_start_in_middle.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2685
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2686
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2687
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2688
declare wprepare_loop_start_in_middle.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2689
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2690
declare wprepare_loop_start_on_rightmost.simps[simp del] 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2691
        wprepare_loop_goon_in_middle.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2692
        wprepare_loop_goon_on_rightmost.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2693
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: 285
diff changeset
  2694
lemma wprepare_loop_goon_in_middle_Bk_False[simp]: "wprepare_loop_goon_in_middle m lm (Bk # b, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2695
apply(simp add: wprepare_loop_goon_in_middle.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2696
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2697
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: 285
diff changeset
  2698
lemma wprepare_loop_goon_Bk[simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start m lm (b, [Bk])\<rbrakk> \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2699
  wprepare_loop_goon m lm (Bk # b, [])"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2700
apply(simp only: wprepare_invs, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2701
apply(simp add: wprepare_loop_goon_on_rightmost.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2702
  wprepare_loop_start_on_rightmost.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2703
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2704
apply(rule_tac rev_eq)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2705
apply(simp add: tape_of_nl_rev)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2706
apply(simp add: exp_ind replicate_Suc[THEN sym] del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2707
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2708
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: 285
diff changeset
  2709
lemma wprepare_loop_goon_in_middle_Bk_False2[simp]: "wprepare_loop_start_on_rightmost m lm (b, Bk # a # lista)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2710
 \<Longrightarrow> wprepare_loop_goon_in_middle m lm (Bk # b, a # lista) = False"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2711
apply(auto simp: wprepare_loop_start_on_rightmost.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2712
                 wprepare_loop_goon_in_middle.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2713
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2714
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: 285
diff changeset
  2715
lemma wprepare_loop_goon_on_rightbmost_Bk_False[simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start_on_rightmost m lm (b, Bk # a # lista)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2716
    \<Longrightarrow> wprepare_loop_goon_on_rightmost m lm (Bk # b, a # lista)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2717
apply(simp only: wprepare_loop_start_on_rightmost.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2718
                 wprepare_loop_goon_on_rightmost.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2719
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2720
apply(simp add: tape_of_nl_rev)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2721
apply(simp add: replicate_Suc[THEN sym] exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2722
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2723
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: 285
diff changeset
  2724
lemma wprepare_loop_goon_on_rightbmost_Bk_False_2[simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start_in_middle m lm (b, Bk # a # lista)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2725
  \<Longrightarrow> wprepare_loop_goon_on_rightmost m lm (Bk # b, a # lista) = False"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2726
apply(simp add: wprepare_loop_start_in_middle.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2727
                wprepare_loop_goon_on_rightmost.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2728
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2729
apply(case_tac  "lm1::nat list", simp_all, case_tac  list, simp)
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: 285
diff changeset
  2730
apply(simp add: tape_of_list_def tape_of_nat_list.simps tape_of_nat_def )
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2731
apply(case_tac [!] rna, simp_all add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2732
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2733
apply(case_tac lm1, simp, case_tac list, simp)
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: 285
diff changeset
  2734
apply(simp_all add: tape_of_list_def tape_of_nat_list.simps  tape_of_nat_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2735
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2736
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: 285
diff changeset
  2737
lemma wprepare_loop_goon_in_middle_Bk_False3[simp]: 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2738
  "\<lbrakk>lm \<noteq> []; wprepare_loop_start_in_middle m lm (b, Bk # a # lista)\<rbrakk> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2739
  \<Longrightarrow> wprepare_loop_goon_in_middle m lm (Bk # b, a # lista)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2740
apply(simp add: wprepare_loop_start_in_middle.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2741
               wprepare_loop_goon_in_middle.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2742
apply(rule_tac x = rn in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2743
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2744
apply(case_tac lm1, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2745
apply(rule_tac x = "Suc aa" in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2746
apply(rule_tac x = list in exI)
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: 285
diff changeset
  2747
apply(case_tac list, simp_all add: tape_of_list_def  tape_of_nat_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2748
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2749
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: 285
diff changeset
  2750
lemma wprepare_loop_goon_Bk2[simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start m lm (b, Bk # a # lista)\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2751
  wprepare_loop_goon m lm (Bk # b, a # lista)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2752
apply(simp add: wprepare_loop_start.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2753
                wprepare_loop_goon.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2754
apply(erule_tac disjE, simp, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2755
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2756
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2757
lemma start_2_goon:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2758
  "\<lbrakk>lm \<noteq> []; wprepare_loop_start m lm (b, Bk # list)\<rbrakk> \<Longrightarrow>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2759
   (list = [] \<longrightarrow> wprepare_loop_goon m lm (Bk # b, [])) \<and>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2760
  (list \<noteq> [] \<longrightarrow> wprepare_loop_goon m lm (Bk # b, list))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2761
apply(case_tac list, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2762
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2763
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2764
lemma add_one_2_add_one: "wprepare_add_one m lm (b, Oc # list)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2765
  \<Longrightarrow> (hd b = Oc \<longrightarrow> (b = [] \<longrightarrow> wprepare_add_one m lm ([], Bk # Oc # list)) \<and>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2766
                     (b \<noteq> [] \<longrightarrow> wprepare_add_one m lm (tl b, Oc # Oc # list))) \<and>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2767
  (hd b \<noteq> Oc \<longrightarrow> (b = [] \<longrightarrow> wprepare_add_one m lm ([], Bk # Oc # list)) \<and>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2768
                 (b \<noteq> [] \<longrightarrow> wprepare_add_one m lm (tl b, hd b # Oc # list)))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2769
apply(simp only: wprepare_add_one.simps, 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: 285
diff changeset
  2770
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2771
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2772
lemma wprepare_loop_start_on_rightmost_Oc[simp]: "wprepare_loop_start_on_rightmost m lm (b, Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2773
  wprepare_loop_start_on_rightmost m lm (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2774
apply(simp add: wprepare_loop_start_on_rightmost.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2775
apply(rule_tac x = rn in exI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2776
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2777
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2778
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: 285
diff changeset
  2779
lemma wprepare_loop_start_in_middle_Oc[simp]: "wprepare_loop_start_in_middle m lm (b, Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2780
                wprepare_loop_start_in_middle m lm (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2781
apply(simp add: wprepare_loop_start_in_middle.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2782
apply(rule_tac x = rn in exI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2783
apply(case_tac mr, simp, simp add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2784
apply(rule_tac x = nat in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2785
apply(rule_tac x = lm1 in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2786
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2787
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2788
lemma start_2_start: "wprepare_loop_start m lm (b, Oc # list) \<Longrightarrow> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2789
       wprepare_loop_start m lm (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2790
apply(simp add: wprepare_loop_start.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2791
apply(erule_tac disjE, simp_all )
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2792
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2793
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: 285
diff changeset
  2794
lemma wprepare_loop_goon_Oc_nonempty[simp]: "wprepare_loop_goon m lm (b, Oc # list) \<Longrightarrow> b \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2795
apply(simp add: wprepare_loop_goon.simps     
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2796
                wprepare_loop_goon_in_middle.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2797
                wprepare_loop_goon_on_rightmost.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2798
apply(auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2799
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2800
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: 285
diff changeset
  2801
lemma wprepare_goto_start_pos_Oc_nonempty[simp]: "wprepare_goto_start_pos m lm (b, Oc # list) \<Longrightarrow> b \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2802
apply(simp add: wprepare_goto_start_pos.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2803
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2804
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: 285
diff changeset
  2805
lemma wprepare_loop_goon_on_rightmost_Oc_False[simp]: "wprepare_loop_goon_on_rightmost m lm (b, Oc # list) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2806
apply(simp add: wprepare_loop_goon_on_rightmost.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2807
done
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  2808
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2809
lemma wprepare_loop1: "\<lbrakk>rev b @ Oc\<up>(mr) =  Oc\<up>(Suc m) @ Bk # Bk # <lm>; 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2810
         b \<noteq> []; 0 < mr; Oc # list = Oc\<up>(mr) @ Bk\<up>(rn)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2811
       \<Longrightarrow> wprepare_loop_start_on_rightmost m lm (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2812
apply(simp add: wprepare_loop_start_on_rightmost.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2813
apply(rule_tac x = rn in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2814
apply(case_tac mr, simp, simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2815
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2816
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2817
lemma wprepare_loop2: "\<lbrakk>rev b @ Oc\<up>(mr) @ Bk # <a # lista> = Oc\<up>(Suc m) @ Bk # Bk # <lm>;
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2818
                b \<noteq> []; Oc # list = Oc\<up>(mr) @ Bk # <(a::nat) # lista> @ Bk\<up>(rn)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2819
       \<Longrightarrow>  wprepare_loop_start_in_middle m lm (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2820
apply(simp add: wprepare_loop_start_in_middle.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2821
apply(rule_tac x = rn in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2822
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2823
apply(rule_tac x = nat in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2824
apply(rule_tac x = "a#lista" in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2825
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2826
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: 285
diff changeset
  2827
lemma wprepare_loop_goon_in_middle_cases[simp]: "wprepare_loop_goon_in_middle m lm (b, Oc # list) \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2828
                wprepare_loop_start_on_rightmost m lm (Oc # b, list) \<or>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2829
                wprepare_loop_start_in_middle m lm (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2830
apply(simp add: wprepare_loop_goon_in_middle.simps split: if_splits)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2831
apply(case_tac lm1, simp_all add: wprepare_loop1 wprepare_loop2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2832
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2833
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: 285
diff changeset
  2834
lemma wprepare_loop_start_Oc[simp]: "wprepare_loop_goon m lm (b, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2835
  \<Longrightarrow>  wprepare_loop_start m lm (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2836
apply(simp add: wprepare_loop_goon.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2837
                wprepare_loop_start.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2838
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2839
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: 285
diff changeset
  2840
lemma wprepare_add_one_b[simp]: "wprepare_add_one m lm (b, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2841
       \<Longrightarrow> b = [] \<longrightarrow> wprepare_add_one m lm ([], Bk # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2842
apply(auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2843
apply(simp add: wprepare_add_one.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2844
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2845
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: 285
diff changeset
  2846
lemma wprepare_loop_start_on_rightmost_Oc2[simp]: "wprepare_goto_start_pos m [a] (b, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2847
              \<Longrightarrow> wprepare_loop_start_on_rightmost m [a] (Oc # b, list) "
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2848
apply(auto simp: wprepare_goto_start_pos.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2849
                 wprepare_loop_start_on_rightmost.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2850
apply(rule_tac x = rn in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2851
apply(simp add: replicate_Suc[THEN sym] exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2852
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2853
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: 285
diff changeset
  2854
lemma wprepare_loop_start_in_middle_2_Oc[simp]:  "wprepare_goto_start_pos m (a # aa # listaa) (b, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2855
       \<Longrightarrow>wprepare_loop_start_in_middle m (a # aa # listaa) (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2856
apply(auto simp: wprepare_goto_start_pos.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2857
                 wprepare_loop_start_in_middle.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2858
apply(rule_tac x = rn in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2859
apply(simp add: exp_ind[THEN sym])
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2860
apply(rule_tac x = a in exI, rule_tac x = "aa#listaa" in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2861
apply(simp add: tape_of_nl_cons)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2862
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2863
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: 285
diff changeset
  2864
lemma wprepare_loop_start_Oc2[simp]: "\<lbrakk>lm \<noteq> []; wprepare_goto_start_pos m lm (b, Oc # list)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2865
       \<Longrightarrow> wprepare_loop_start m lm (Oc # b, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2866
apply(case_tac lm, simp_all)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2867
apply(case_tac lista, simp_all add: wprepare_loop_start.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2868
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2869
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: 285
diff changeset
  2870
lemma wprepare_add_one2_Oc_nonempty[simp]: "wprepare_add_one2 m lm (b, Oc # list) \<Longrightarrow> b \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2871
apply(auto simp: wprepare_add_one2.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2872
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2873
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2874
lemma add_one_2_stop:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2875
  "wprepare_add_one2 m lm (b, Oc # list)      
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2876
  \<Longrightarrow>  wprepare_stop m lm (tl b, hd b # Oc # list)"
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: 285
diff changeset
  2877
apply(simp add: wprepare_add_one2.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2878
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2879
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2880
declare wprepare_stop.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2881
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2882
lemma wprepare_correctness:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2883
  assumes h: "lm \<noteq> []"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2884
  shows "let P = (\<lambda> (st, l, r). st = 0) in 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2885
  let Q = (\<lambda> (st, l, r). wprepare_inv st m lm (l, r)) in 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2886
  let f = (\<lambda> stp. steps0 (Suc 0, [], (<m # lm>)) t_wcode_prepare stp) in
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2887
    \<exists> n .P (f n) \<and> Q (f n)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2888
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2889
  let ?P = "(\<lambda> (st, l, r). st = 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2890
  let ?Q = "(\<lambda> (st, l, r). wprepare_inv st m lm (l, r))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2891
  let ?f = "(\<lambda> stp. steps0 (Suc 0, [], (<m # lm>)) t_wcode_prepare stp)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2892
  have "\<exists> n. ?P (?f n) \<and> ?Q (?f n)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2893
  proof(rule_tac halt_lemma2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2894
    show "wf wcode_prepare_le" by auto
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2895
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2896
    show "\<forall> n. \<not> ?P (?f n) \<and> ?Q (?f n) \<longrightarrow> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2897
                 ?Q (?f (Suc n)) \<and> (?f (Suc n), ?f n) \<in> wcode_prepare_le"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2898
      using h
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2899
      apply(rule_tac allI, rule_tac impI, case_tac "?f n", 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2900
            simp add: step_red step.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2901
      apply(case_tac c, simp, case_tac [2] aa)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2902
      apply(simp_all add: wprepare_inv.simps wcode_prepare_le_def lex_triple_def lex_pair_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: 285
diff changeset
  2903
                 split: if_splits) (* slow *)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2904
      apply(simp_all add: start_2_goon  start_2_start
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2905
                           add_one_2_add_one add_one_2_stop)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2906
      apply(auto simp: wprepare_add_one2.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2907
      done   
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2908
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2909
    show "?Q (?f 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2910
      apply(simp add: steps.simps wprepare_inv.simps wprepare_invs)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2911
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2912
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2913
    show "\<not> ?P (?f 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2914
      apply(simp add: steps.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2915
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2916
  qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2917
  thus "?thesis"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2918
    apply(auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2919
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2920
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2921
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: 285
diff changeset
  2922
lemma tm_wf_t_wcode_prepare[intro]: "tm_wf (t_wcode_prepare, 0)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2923
apply(simp add:tm_wf.simps t_wcode_prepare_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: 285
diff changeset
  2924
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2925
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2926
lemma is_28_even[intro]: "(28 + (length t_twice_compile + length t_fourtimes_compile)) mod 2 = 0"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2927
  by(auto simp: t_twice_compile_def t_fourtimes_compile_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: 285
diff changeset
  2928
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2929
lemma b_le_28[elim]: "(a, b) \<in> set t_wcode_main_first_part \<Longrightarrow>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2930
  b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2931
apply(auto simp: t_wcode_main_first_part_def t_twice_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2932
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2933
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2934
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2935
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: 285
diff changeset
  2936
lemma tm_wf_change_termi:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2937
  assumes "tm_wf (tp, 0)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2938
  shows "list_all (\<lambda>(acn, st). (st \<le> Suc (length tp div 2))) (adjust0 tp)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2939
proof -
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2940
  { fix acn st 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: 285
diff changeset
  2941
    assume "tp ! n = (acn, st)" "n < length tp" "0 < st"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2942
    hence "(acn, st)\<in>set tp" by (metis nth_mem)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2943
    with assms tm_wf.simps have "st \<le> length tp div 2 + 0" by auto
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2944
    hence "st \<le> Suc (length tp div 2)" by auto
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2945
  }
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2946
  thus ?thesis
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2947
    by(auto simp: tm_wf.simps List.list_all_length adjust.simps split: if_splits prod.split)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2948
qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2949
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2950
lemma tm_wf_shift:
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2951
         "list_all (\<lambda>(acn, st). (st \<le> y)) tp \<Longrightarrow>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2952
          list_all (\<lambda>(acn, st). (st \<le> y + off)) (shift tp off) "
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2953
apply(auto simp: tm_wf.simps List.list_all_length)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2954
apply(erule_tac x = n in allE, simp add: length_shift)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2955
apply(case_tac "tp!n", auto simp: shift.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2956
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2957
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2958
declare length_tp'[simp del]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2959
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: 285
diff changeset
  2960
lemma length_mopup_1[simp]: "length (mopup (Suc 0)) = 16"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2961
apply(auto simp: mopup.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2962
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2963
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: 285
diff changeset
  2964
lemma twice_plus_28_elim[elim]: "(a, b) \<in> set (shift (adjust0 t_twice_compile) 12) \<Longrightarrow> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2965
  b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2966
apply(simp add: t_twice_compile_def t_fourtimes_compile_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2967
proof -
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2968
  assume g: "(a, b)
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2969
    \<in> set (shift
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2970
            (adjust
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2971
              (tm_of abc_twice @
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2972
               shift (mopup (Suc 0)) (length (tm_of abc_twice) div 2))
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2973
              (Suc ((length (tm_of abc_twice) + 16) div 2)))
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2974
            12)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2975
  moreover have "length (tm_of abc_twice) mod 2 = 0" by auto
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2976
  moreover have "length (tm_of abc_fourtimes) mod 2 = 0" by auto
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2977
  ultimately have "list_all (\<lambda>(acn, st). (st \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2)) 
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2978
    (shift (adjust0 t_twice_compile) 12)"
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2979
  proof(auto simp add: mod_ex1 del: adjust.simps)
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: 285
diff changeset
  2980
    assume "even (length (tm_of abc_twice))"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2981
    then obtain q where q:"length (tm_of abc_twice) = 2 * q" by auto
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2982
    assume "even (length (tm_of abc_fourtimes))"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2983
    then obtain qa where qa:"length (tm_of abc_fourtimes) = 2 * qa" by auto
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2984
    note h = q qa
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2985
    hence "list_all (\<lambda>(acn, st). st \<le> (18 + (q + qa)) + 12) (shift (adjust0 t_twice_compile) 12)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2986
    proof(rule_tac tm_wf_shift t_twice_compile_def)
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2987
      have "list_all (\<lambda>(acn, st). st \<le> Suc (length t_twice_compile div 2)) (adjust0 t_twice_compile)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2988
        by(rule_tac tm_wf_change_termi, auto)
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  2989
      thus "list_all (\<lambda>(acn, st). st \<le> 18 + (q + qa)) (adjust0 t_twice_compile)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2990
        using h
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2991
        apply(simp add: t_twice_compile_def, auto simp: List.list_all_length)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2992
        done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2993
    qed
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: 285
diff changeset
  2994
    thus "list_all (\<lambda>(acn, st). st \<le> 30 + (length (tm_of abc_twice) div 2 + length (tm_of abc_fourtimes) div 2))
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  2995
     (shift (adjust0 t_twice_compile) 12)" using h
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2996
      by simp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2997
  qed
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2998
  thus "b \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  2999
    using g
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3000
    apply(auto simp:t_twice_compile_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3001
    apply(simp add: Ball_set[THEN sym])
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3002
    apply(erule_tac x = "(a, b)" in ballE, simp, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3003
    done
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3004
qed 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3005
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: 285
diff changeset
  3006
lemma length_plus_28_elim2[elim]: "(a, b) \<in> set (shift (adjust0 t_fourtimes_compile) (t_twice_len + 13)) 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3007
  \<Longrightarrow> b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3008
apply(simp add: t_twice_compile_def t_fourtimes_compile_def t_twice_len_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3009
proof -
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3010
  assume g: "(a, b)
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3011
    \<in> set (shift
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: 285
diff changeset
  3012
             (adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) (length (tm_of abc_fourtimes) div 2))
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3013
               (Suc ((length (tm_of abc_fourtimes) + 16) div 2)))
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3014
             (length t_twice div 2 + 13))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3015
  moreover have "length (tm_of abc_twice) mod 2 = 0" by auto
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3016
  moreover have "length (tm_of abc_fourtimes) mod 2 = 0" by auto
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3017
  ultimately have "list_all (\<lambda>(acn, st). (st \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2)) 
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3018
    (shift (adjust0 (tm_of abc_fourtimes @ shift (mopup (Suc 0))
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3019
    (length (tm_of abc_fourtimes) div 2))) (length t_twice div 2 + 13))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3020
  proof(auto simp: mod_ex1 t_twice_def t_twice_compile_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: 285
diff changeset
  3021
    assume "even (length (tm_of abc_twice))"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3022
    then obtain q where q:"length (tm_of abc_twice) = 2 * q" by auto
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3023
    assume "even (length (tm_of abc_fourtimes))"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3024
    then obtain qa where qa:"length (tm_of abc_fourtimes) = 2 * qa" by auto
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3025
    note h = q qa
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3026
    hence "list_all (\<lambda>(acn, st). st \<le> (9 + qa + (21 + q)))
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3027
      (shift (adjust0 (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)) (21 + q))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3028
    proof(rule_tac tm_wf_shift t_twice_compile_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3029
      have "list_all (\<lambda>(acn, st). st \<le> Suc (length (tm_of abc_fourtimes @ shift 
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3030
        (mopup (Suc 0)) qa) div 2)) (adjust0 (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3031
        apply(rule_tac tm_wf_change_termi)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3032
        using wf_fourtimes h
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3033
        apply(simp add: t_fourtimes_compile_def)
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3034
        done
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3035
      thus "list_all (\<lambda>(acn, st). st \<le> 9 + qa)
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3036
        (adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3037
          (Suc (length (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa) div
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3038
                2)))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3039
        using h
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3040
        apply(simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3041
        done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3042
    qed
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: 285
diff changeset
  3043
    thus "list_all
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3044
     (\<lambda>(acn, st). st \<le> 30 + (length (tm_of abc_twice) div 2 + length (tm_of abc_fourtimes) div 2))
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3045
     (shift
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3046
       (adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) (length (tm_of abc_fourtimes) div 2))
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3047
         (9 + length (tm_of abc_fourtimes) div 2))
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3048
       (21 + length (tm_of abc_twice) div 2))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3049
      apply(subgoal_tac "qa + q = q + qa")
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3050
      apply(simp add: h)
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3051
      apply(simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3052
      done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3053
  qed
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3054
  thus "b \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3055
    using g
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3056
    apply(simp add: Ball_set[THEN sym])
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3057
    apply(erule_tac x = "(a, b)" in ballE, simp, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3058
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3059
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3060
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: 285
diff changeset
  3061
lemma tm_wf_t_wcode_main[intro]: "tm_wf (t_wcode_main, 0)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3062
by(auto simp: t_wcode_main_def tm_wf.simps
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3063
                 t_twice_def t_fourtimes_def del: List.list_all_iff)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3064
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3065
declare tm_comp.simps[simp del]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3066
lemma tm_wf_comp: "\<lbrakk>tm_wf (A, 0); tm_wf (B, 0)\<rbrakk> \<Longrightarrow> tm_wf (A |+| B, 0)"
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: 285
diff changeset
  3067
 by(auto simp: tm_wf.simps shift.simps adjust.simps tm_comp_length
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3068
                 tm_comp.simps) auto
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3069
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3070
lemma prepare_mainpart_lemma:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3071
  "args \<noteq> [] \<Longrightarrow> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3072
  \<exists> stp ln rn. steps0 (Suc 0, [], <m # args>) (t_wcode_prepare |+| t_wcode_main) stp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3073
              = (0,  Bk # Oc\<up>(Suc m), Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<args>)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3074
proof -
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3075
  let ?P1 = "(\<lambda> (l, r). (l::cell list) = [] \<and> r = <m # args>)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3076
  let ?Q1 = "(\<lambda> (l, r). wprepare_stop m args (l, r))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3077
  let ?P2 = ?Q1
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3078
  let ?Q2 = "(\<lambda> (l, r). (\<exists> ln rn. l = Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3079
                           r =  Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<args>)) @ Bk\<up>(rn)))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3080
  let ?P3 = "\<lambda> tp. False"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3081
  assume h: "args \<noteq> []"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3082
  have "{?P1} t_wcode_prepare |+| t_wcode_main {?Q2}"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3083
  proof(rule_tac Hoare_plus_halt)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3084
    show "{?P1} t_wcode_prepare {?Q1}"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3085
    proof(rule_tac Hoare_haltI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3086
      show "\<exists>n. is_final (steps0 (Suc 0, [], <m # args>) t_wcode_prepare n) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3087
        wprepare_stop m args holds_for steps0 (Suc 0, [], <m # args>) t_wcode_prepare n"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3088
        using wprepare_correctness[of args m] h
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3089
        apply(auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3090
        apply(rule_tac x = n in exI, simp add: wprepare_inv.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3091
        done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3092
    qed
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3093
  next
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3094
    show "{?P2} t_wcode_main {?Q2}"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3095
    proof(rule_tac Hoare_haltI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3096
      fix l r
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3097
      assume "wprepare_stop m args (l, r)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3098
      thus "\<exists>n. is_final (steps0 (Suc 0, l, r) t_wcode_main n) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3099
              (\<lambda>(l, r). l = Bk # Oc # Oc \<up> m \<and> (\<exists>ln rn. r = Bk # Oc # Bk \<up> ln @ 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3100
        Bk # Bk # Oc \<up> bl_bin (<args>) @ Bk \<up> rn)) holds_for steps0 (Suc 0, l, r) t_wcode_main n"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3101
      proof(auto simp: wprepare_stop.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3102
        fix rn
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3103
        show " \<exists>n. is_final (steps0 (Suc 0, Bk # <rev args> @ Bk # Bk # Oc # Oc \<up> m, Bk # Oc # Bk \<up> rn) t_wcode_main n) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3104
          (\<lambda>(l, r). l = Bk # Oc # Oc \<up> m \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3105
          (\<exists>ln rn. r = Bk # Oc # Bk \<up> ln @
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3106
          Bk # Bk # Oc \<up> bl_bin (<args>) @
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3107
          Bk \<up> rn)) holds_for steps0 (Suc 0, Bk # <rev args> @ Bk # Bk # Oc # Oc \<up> m, Bk # Oc # Bk \<up> rn) t_wcode_main n"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3108
          using t_wcode_main_lemma_pre[of "args" "<args>" 0 "Oc\<up>(Suc m)" 0 rn] h
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3109
          apply(auto simp: tape_of_nl_rev)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3110
          apply(rule_tac x = stp in exI, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3111
          done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3112
      qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3113
    qed
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3114
  next
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3115
    show "tm_wf0 t_wcode_prepare"
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3116
      by auto
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3117
  qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3118
  thus "?thesis"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3119
    apply(auto simp: Hoare_halt_def)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3120
    apply(rule_tac x = n in exI)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3121
    apply(case_tac "(steps0 (Suc 0, [], <m # args>)
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  3122
      (adjust0 t_wcode_prepare @ shift t_wcode_main (length t_wcode_prepare div 2)) n)")
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3123
    apply(auto simp: tm_comp.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3124
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3125
qed
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3126
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3127
definition tinres :: "cell list \<Rightarrow> cell list \<Rightarrow> bool"
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3128
  where
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  3129
  "tinres xs ys = (\<exists>n. xs = ys @ Bk \<up> n \<or> ys = xs @ Bk \<up> n)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3130
   
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: 285
diff changeset
  3131
lemma tinres_fetch_congr[simp]:  "tinres r r' \<Longrightarrow> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3132
  fetch t ss (read r) = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3133
  fetch t ss (read r')"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3134
apply(simp add: fetch.simps, auto split: if_splits simp: tinres_def)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3135
apply(case_tac [!] n, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3136
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3137
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: 285
diff changeset
  3138
lemma nonempty_hd_tinres[simp]: "\<lbrakk>tinres r r'; r \<noteq> []; r' \<noteq> []\<rbrakk> \<Longrightarrow> hd r = hd r'"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3139
apply(auto simp: tinres_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3140
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3141
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: 285
diff changeset
  3142
lemma tinres_nonempty[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3143
  "\<lbrakk>tinres r []; r \<noteq> []\<rbrakk> \<Longrightarrow> hd r = Bk"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3144
  "\<lbrakk>tinres [] r'; r' \<noteq> []\<rbrakk> \<Longrightarrow> hd r' = Bk"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3145
  "\<lbrakk>tinres r [];  r \<noteq> []\<rbrakk> \<Longrightarrow> tinres (tl r) []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3146
  "tinres r r' \<Longrightarrow> tinres (b # r) (b # r')"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3147
  by(auto simp: tinres_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: 285
diff changeset
  3148
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3149
lemma ex_move_tl[intro]: "\<exists>na. tl r = tl (r @ Bk\<up>(n)) @ Bk\<up>(na) \<or> tl (r @ Bk\<up>(n)) = tl r @ Bk\<up>(na)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3150
apply(case_tac r, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3151
apply(case_tac n, simp, simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3152
apply(rule_tac x = nat in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3153
apply(rule_tac x = n in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3154
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3155
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: 285
diff changeset
  3156
lemma tinres_tails[simp]: "tinres r r' \<Longrightarrow> tinres (tl r) (tl r')"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3157
apply(auto simp: tinres_def)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3158
apply(case_tac r', simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3159
apply(case_tac n, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3160
apply(rule_tac x = nat in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3161
apply(rule_tac x = n in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3162
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3163
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: 285
diff changeset
  3164
lemma tinres_empty[simp]: 
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3165
  "\<lbrakk>tinres [] r'\<rbrakk> \<Longrightarrow> tinres [] (tl r')"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3166
  "tinres r [] \<Longrightarrow> tinres (Bk # tl r) [Bk]"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3167
  "tinres r [] \<Longrightarrow> tinres (Oc # tl r) [Oc]"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3168
  by(auto simp: tinres_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: 285
diff changeset
  3169
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3170
lemma tinres_step2:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3171
  assumes "tinres r r'" "step0 (ss, l, r) t = (sa, la, ra)" "step0 (ss, l, r') t = (sb, lb, rb)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3172
  shows "la = lb \<and> tinres ra rb \<and> sa = sb"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3173
proof (cases "fetch t ss (read r')")
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3174
  case (Pair a b)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3175
  have sa:"sa = sb" using assms Pair by(force simp: step.simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3176
  have "la = lb \<and> tinres ra rb" using assms Pair
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3177
    by(cases a, auto simp: step.simps split: if_splits)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3178
  thus ?thesis using sa by auto
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3179
qed
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3180
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3181
lemma tinres_steps2: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3182
  "\<lbrakk>tinres r r'; steps0 (ss, l, r) t stp = (sa, la, ra); steps0 (ss, l, r') t stp = (sb, lb, rb)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3183
    \<Longrightarrow> la = lb \<and> tinres ra rb \<and> sa = sb"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3184
apply(induct stp arbitrary: sa la ra sb lb rb, simp add: steps.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3185
apply(simp add: step_red)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3186
apply(case_tac "(steps0 (ss, l, r) t stp)")
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3187
apply(case_tac "(steps0 (ss, l, r') t stp)")
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3188
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3189
  fix stp sa la ra sb lb rb a b c aa ba ca
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3190
  assume ind: "\<And>sa la ra sb lb rb. \<lbrakk>steps0 (ss, l, r) t stp = (sa, la, ra); 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3191
    steps0 (ss, l, r') t stp = (sb, lb, rb)\<rbrakk> \<Longrightarrow> la = lb \<and> tinres ra rb \<and> sa = sb"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3192
  and h: " tinres r r'" "step0 (steps0 (ss, l, r) t stp) t = (sa, la, ra)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3193
         "step0 (steps0 (ss, l, r') t stp) t = (sb, lb, rb)" "steps0 (ss, l, r) t stp = (a, b, c)" 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3194
         "steps0 (ss, l, r') t stp = (aa, ba, ca)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3195
  have "b = ba \<and> tinres c ca \<and> a = aa"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3196
    apply(rule_tac ind, simp_all add: h)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3197
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3198
  thus "la = lb \<and> tinres ra rb \<and> sa = sb"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3199
    apply(rule_tac l = b  and r = c  and ss = a and r' = ca   
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3200
            and t = t in tinres_step2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3201
    using h
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3202
    apply(simp, simp, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3203
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3204
qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3205
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3206
definition t_wcode_adjust :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3207
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3208
  "t_wcode_adjust = [(W1, 1), (R, 2), (Nop, 2), (R, 3), (R, 3), (R, 4), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3209
                   (L, 8), (L, 5), (L, 6), (W0, 5), (L, 6), (R, 7), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3210
                   (W1, 2), (Nop, 7), (L, 9), (W0, 8), (L, 9), (L, 10), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3211
                    (L, 11), (L, 10), (R, 0), (L, 11)]"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3212
                 
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: 285
diff changeset
  3213
lemma fetch_t_wcode_adjust[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3214
  "fetch t_wcode_adjust (Suc 0) Bk = (W1, 1)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3215
  "fetch t_wcode_adjust (Suc 0) Oc = (R, 2)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3216
  "fetch t_wcode_adjust (Suc (Suc 0)) Oc = (R, 3)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3217
  "fetch t_wcode_adjust (Suc (Suc (Suc 0))) Oc = (R, 4)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3218
  "fetch t_wcode_adjust  (Suc (Suc (Suc 0))) Bk = (R, 3)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3219
  "fetch t_wcode_adjust 4 Bk = (L, 8)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3220
  "fetch t_wcode_adjust 4 Oc = (L, 5)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3221
  "fetch t_wcode_adjust 5 Oc = (W0, 5)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3222
  "fetch t_wcode_adjust 5 Bk = (L, 6)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3223
  "fetch t_wcode_adjust 6 Oc = (R, 7)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3224
  "fetch t_wcode_adjust 6 Bk = (L, 6)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3225
  "fetch t_wcode_adjust 7 Bk = (W1, 2)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3226
  "fetch t_wcode_adjust 8 Bk = (L, 9)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3227
  "fetch t_wcode_adjust 8 Oc = (W0, 8)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3228
  "fetch t_wcode_adjust 9 Oc = (L, 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: 285
diff changeset
  3229
  "fetch t_wcode_adjust 9 Bk = (L, 9)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3230
  "fetch t_wcode_adjust 10 Bk = (L, 11)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3231
  "fetch t_wcode_adjust 10 Oc = (L, 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: 285
diff changeset
  3232
  "fetch t_wcode_adjust 11 Oc = (L, 11)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3233
  "fetch t_wcode_adjust 11 Bk = (R, 0)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3234
by(auto simp: fetch.simps t_wcode_adjust_def nth_of.simps numeral)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3235
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3236
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3237
fun wadjust_start :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3238
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3239
  "wadjust_start m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3240
         (\<exists> ln rn. l = Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3241
                   tl r = Oc # Bk\<up>(ln) @ Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3242
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3243
fun wadjust_loop_start :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3244
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3245
  "wadjust_loop_start m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3246
          (\<exists> ln rn ml mr. l = Oc\<up>(ml) @ Bk # Oc\<up>(Suc m)  \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3247
                          r = Oc # Bk\<up>(ln) @ Bk # Oc\<up>(mr) @ Bk\<up>(rn) \<and>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3248
                          ml + mr = Suc (Suc rs) \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3249
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3250
fun wadjust_loop_right_move :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3251
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3252
  "wadjust_loop_right_move m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3253
   (\<exists> ml mr nl nr rn. l = Bk\<up>(nl) @ Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3254
                      r = Bk\<up>(nr) @ Oc\<up>(mr) @ Bk\<up>(rn) \<and>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3255
                      ml + mr = Suc (Suc rs) \<and> mr > 0 \<and>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3256
                      nl + nr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3257
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3258
fun wadjust_loop_check :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3259
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3260
  "wadjust_loop_check m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3261
  (\<exists> ml mr ln rn. l = Oc # Bk\<up>(ln) @ Bk # Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3262
                  r = Oc\<up>(mr) @ Bk\<up>(rn) \<and> ml + mr = (Suc rs))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3263
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3264
fun wadjust_loop_erase :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3265
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3266
  "wadjust_loop_erase m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3267
    (\<exists> ml mr ln rn. l = Bk\<up>(ln) @ Bk # Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3268
                    tl r = Oc\<up>(mr) @ Bk\<up>(rn) \<and> ml + mr = (Suc rs) \<and> mr > 0)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3269
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3270
fun wadjust_loop_on_left_moving_O :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3271
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3272
  "wadjust_loop_on_left_moving_O m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3273
      (\<exists> ml mr ln rn. l = Oc\<up>(ml) @ Bk # Oc\<up>(Suc m )\<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3274
                      r = Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(mr) @ Bk\<up>(rn) \<and>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3275
                      ml + mr = Suc rs \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3276
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3277
fun wadjust_loop_on_left_moving_B :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3278
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3279
  "wadjust_loop_on_left_moving_B m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3280
      (\<exists> ml mr nl nr rn. l = Bk\<up>(nl) @ Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3281
                         r = Bk\<up>(nr) @ Bk # Bk # Oc\<up>(mr) @ Bk\<up>(rn) \<and> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3282
                         ml + mr = Suc rs \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3283
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3284
fun wadjust_loop_on_left_moving :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3285
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3286
  "wadjust_loop_on_left_moving m rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3287
       (wadjust_loop_on_left_moving_O m rs (l, r) \<or>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3288
       wadjust_loop_on_left_moving_B m rs (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3289
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3290
fun wadjust_loop_right_move2 :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3291
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3292
  "wadjust_loop_right_move2 m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3293
        (\<exists> ml mr ln rn. l = Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3294
                        r = Bk\<up>(ln) @ Bk # Bk # Oc\<up>(mr) @ Bk\<up>(rn) \<and>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3295
                        ml + mr = Suc rs \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3296
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3297
fun wadjust_erase2 :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3298
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3299
  "wadjust_erase2 m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3300
     (\<exists> ln rn. l = Bk\<up>(ln) @ Bk # Oc # Oc\<up>(Suc rs) @ Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3301
                     tl r = Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3302
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3303
fun wadjust_on_left_moving_O :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3304
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3305
  "wadjust_on_left_moving_O m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3306
        (\<exists> rn. l = Oc\<up>(Suc rs) @ Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3307
                  r = Oc # Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3308
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3309
fun wadjust_on_left_moving_B :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3310
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3311
  "wadjust_on_left_moving_B m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3312
         (\<exists> ln rn. l = Bk\<up>(ln) @ Oc # Oc\<up>(Suc rs) @ Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3313
                   r = Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3314
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3315
fun wadjust_on_left_moving :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3316
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3317
  "wadjust_on_left_moving m rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3318
      (wadjust_on_left_moving_O m rs (l, r) \<or>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3319
       wadjust_on_left_moving_B m rs (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3320
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3321
fun wadjust_goon_left_moving_B :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3322
  where 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3323
  "wadjust_goon_left_moving_B m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3324
        (\<exists> rn. l = Oc\<up>(Suc m) \<and> 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3325
               r = Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3326
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3327
fun wadjust_goon_left_moving_O :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3328
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3329
  "wadjust_goon_left_moving_O m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3330
      (\<exists> ml mr rn. l = Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3331
                      r = Oc\<up>(mr) @ Bk\<up>(rn) \<and> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3332
                      ml + mr = Suc (Suc rs) \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3333
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3334
fun wadjust_goon_left_moving :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3335
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3336
  "wadjust_goon_left_moving m rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3337
            (wadjust_goon_left_moving_B m rs (l, r) \<or>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3338
             wadjust_goon_left_moving_O m rs (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3339
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3340
fun wadjust_backto_standard_pos_B :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3341
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3342
  "wadjust_backto_standard_pos_B m rs (l, r) =
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3343
        (\<exists> rn. l = [] \<and> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3344
               r = Bk # Oc\<up>(Suc m )@ Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3345
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3346
fun wadjust_backto_standard_pos_O :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3347
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3348
  "wadjust_backto_standard_pos_O m rs (l, r) = 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3349
      (\<exists> ml mr rn. l = Oc\<up>(ml) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3350
                      r = Oc\<up>(mr) @ Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn) \<and> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3351
                      ml + mr = Suc m \<and> mr > 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3352
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3353
fun wadjust_backto_standard_pos :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3354
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3355
  "wadjust_backto_standard_pos m rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3356
        (wadjust_backto_standard_pos_B m rs (l, r) \<or> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3357
        wadjust_backto_standard_pos_O m rs (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3358
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3359
fun wadjust_stop :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3360
where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3361
  "wadjust_stop m rs (l, r) =
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3362
        (\<exists> rn. l = [Bk] \<and> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3363
               r = Oc\<up>(Suc m )@ Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3364
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3365
declare wadjust_start.simps[simp del]  wadjust_loop_start.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3366
        wadjust_loop_right_move.simps[simp del]  wadjust_loop_check.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3367
        wadjust_loop_erase.simps[simp del] wadjust_loop_on_left_moving.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3368
        wadjust_loop_right_move2.simps[simp del] wadjust_erase2.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3369
        wadjust_on_left_moving_O.simps[simp del] wadjust_on_left_moving_B.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3370
        wadjust_on_left_moving.simps[simp del] wadjust_goon_left_moving_B.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3371
        wadjust_goon_left_moving_O.simps[simp del] wadjust_goon_left_moving.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3372
        wadjust_backto_standard_pos.simps[simp del] wadjust_backto_standard_pos_B.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3373
        wadjust_backto_standard_pos_O.simps[simp del] wadjust_stop.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3374
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3375
fun wadjust_inv :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3376
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3377
  "wadjust_inv st m rs (l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3378
       (if st = Suc 0 then wadjust_start m rs (l, r) 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3379
        else if st = Suc (Suc 0) then wadjust_loop_start m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3380
        else if st = Suc (Suc (Suc 0)) then wadjust_loop_right_move m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3381
        else if st = 4 then wadjust_loop_check m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3382
        else if st = 5 then wadjust_loop_erase m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3383
        else if st = 6 then wadjust_loop_on_left_moving m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3384
        else if st = 7 then wadjust_loop_right_move2 m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3385
        else if st = 8 then wadjust_erase2 m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3386
        else if st = 9 then wadjust_on_left_moving m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3387
        else if st = 10 then wadjust_goon_left_moving m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3388
        else if st = 11 then wadjust_backto_standard_pos m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3389
        else if st = 0 then wadjust_stop m rs (l, r)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3390
        else False
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3391
)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3392
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3393
declare wadjust_inv.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3394
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3395
fun wadjust_phase :: "nat \<Rightarrow> config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3396
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3397
  "wadjust_phase rs (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3398
         (if st = 1 then 3 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3399
          else if st \<ge> 2 \<and> st \<le> 7 then 2
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3400
          else if st \<ge> 8 \<and> st \<le> 11 then 1
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3401
          else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3402
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3403
fun wadjust_stage :: "nat \<Rightarrow> config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3404
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3405
  "wadjust_stage rs (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3406
           (if st \<ge> 2 \<and> st \<le> 7 then 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3407
                  rs - length (takeWhile (\<lambda> a. a = Oc) 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3408
                          (tl (dropWhile (\<lambda> a. a = Oc) (rev l @ r))))
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3409
            else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3410
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3411
fun wadjust_state :: "nat \<Rightarrow> config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3412
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3413
  "wadjust_state rs (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3414
       (if st \<ge> 2 \<and> st \<le> 7 then 8 - st
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3415
        else if st \<ge> 8 \<and> st \<le> 11 then 12 - st
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3416
        else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3417
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3418
fun wadjust_step :: "nat \<Rightarrow> config \<Rightarrow> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3419
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3420
  "wadjust_step rs (st, l, r) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3421
       (if st = 1 then (if hd r = Bk then 1
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3422
                        else 0) 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3423
        else if st = 3 then length r
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3424
        else if st = 5 then (if hd r = Oc then 1
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3425
                             else 0)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3426
        else if st = 6 then length l
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3427
        else if st = 8 then (if hd r = Oc then 1
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3428
                             else 0)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3429
        else if st = 9 then length l
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3430
        else if st = 10 then length l
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3431
        else if st = 11 then (if hd r = Bk then 0
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3432
                              else Suc (length l))
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3433
        else 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3434
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3435
fun wadjust_measure :: "(nat \<times> config) \<Rightarrow> nat \<times> nat \<times> nat \<times> nat"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3436
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3437
  "wadjust_measure (rs, (st, l, r)) = 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3438
     (wadjust_phase rs (st, l, r), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3439
      wadjust_stage rs (st, l, r),
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3440
      wadjust_state rs (st, l, r), 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3441
      wadjust_step rs (st, l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3442
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3443
definition wadjust_le :: "((nat \<times> config) \<times> nat \<times> config) set"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3444
  where "wadjust_le \<equiv> (inv_image lex_square wadjust_measure)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3445
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: 285
diff changeset
  3446
lemma wf_lex_square[intro]: "wf lex_square"
163
67063c5365e1 changed theory names to uppercase
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  3447
by(auto intro:wf_lex_prod simp: Abacus.lex_pair_def lex_square_def 
67063c5365e1 changed theory names to uppercase
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  3448
  Abacus.lex_triple_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3449
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3450
lemma wf_wadjust_le[intro]: "wf wadjust_le"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3451
by(auto intro:wf_inv_image simp: wadjust_le_def
163
67063c5365e1 changed theory names to uppercase
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  3452
           Abacus.lex_triple_def Abacus.lex_pair_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3453
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: 285
diff changeset
  3454
lemma wadjust_start_snd_nonempty[simp]: "wadjust_start m rs (c, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3455
apply(auto simp: wadjust_start.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3456
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3457
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: 285
diff changeset
  3458
lemma wadjust_loop_right_move_fst_nonempty[simp]: "wadjust_loop_right_move m rs (c, []) \<Longrightarrow> c \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3459
apply(auto simp: wadjust_loop_right_move.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3460
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3461
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: 285
diff changeset
  3462
lemma wadjust_loop_check_fst_nonempty[simp]: "wadjust_loop_check m rs (c, []) \<Longrightarrow> c \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3463
apply(simp only: wadjust_loop_check.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3464
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3465
 
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: 285
diff changeset
  3466
lemma wadjust_loop_start_snd_nonempty[simp]: "wadjust_loop_start m rs (c, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3467
apply(simp add: wadjust_loop_start.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3468
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3469
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: 285
diff changeset
  3470
lemma wadjust_erase2_singleton[simp]: "wadjust_loop_check m rs (c, []) \<Longrightarrow> wadjust_erase2 m rs (tl c, [hd c])"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3471
apply(simp only: wadjust_loop_check.simps wadjust_erase2.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3472
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3473
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: 285
diff changeset
  3474
lemma wadjust_loop_on_left_moving_snd_nonempty[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3475
  "wadjust_loop_on_left_moving m rs (c, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3476
"wadjust_loop_right_move2 m rs (c, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3477
"wadjust_erase2 m rs ([], []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3478
  by(auto simp: wadjust_loop_on_left_moving.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3479
        wadjust_loop_right_move2.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3480
        wadjust_erase2.simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3481
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3482
lemma wadjust_on_left_moving_B_Bk1[simp]: "wadjust_on_left_moving_B m rs 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3483
                 (Oc # Oc # Oc\<up>(rs) @ Bk # Oc # Oc\<up>(m), [Bk])"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3484
apply(simp add: wadjust_on_left_moving_B.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3485
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3486
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: 285
diff changeset
  3487
lemma wadjust_on_left_moving_B_Bk2[simp]: "wadjust_on_left_moving_B m rs 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3488
                 (Bk\<up>(n) @ Bk # Oc # Oc # Oc\<up>(rs) @ Bk # Oc # Oc\<up>(m), [Bk])"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3489
apply(simp add: wadjust_on_left_moving_B.simps , auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3490
apply(rule_tac x = "Suc n" in exI, simp add: exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3491
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3492
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: 285
diff changeset
  3493
lemma wadjust_on_left_moving_singleton[simp]: "\<lbrakk>wadjust_erase2 m rs (c, []); c \<noteq> []\<rbrakk> \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3494
            wadjust_on_left_moving m rs (tl c, [hd c])"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3495
apply(simp only: wadjust_erase2.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3496
apply(erule_tac exE)+
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3497
apply(case_tac ln, simp_all add:  wadjust_on_left_moving.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3498
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3499
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: 285
diff changeset
  3500
lemma wadjust_erase2_cases[simp]: "wadjust_erase2 m rs (c, [])
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3501
    \<Longrightarrow> (c = [] \<longrightarrow> wadjust_on_left_moving m rs ([], [Bk])) \<and> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3502
       (c \<noteq> [] \<longrightarrow> wadjust_on_left_moving m rs (tl c, [hd c]))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3503
apply(auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3504
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3505
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: 285
diff changeset
  3506
lemma wadjust_on_left_moving_nonempty[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3507
   "wadjust_on_left_moving m rs ([], []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3508
   "wadjust_on_left_moving_O m rs (c, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3509
apply(auto simp: wadjust_on_left_moving.simps 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3510
  wadjust_on_left_moving_O.simps wadjust_on_left_moving_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3511
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3512
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: 285
diff changeset
  3513
lemma wadjust_on_left_moving_B_singleton_Bk[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3514
  " \<lbrakk>wadjust_on_left_moving_B m rs (c, []); c \<noteq> []; hd c = Bk\<rbrakk> \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3515
                                      wadjust_on_left_moving_B m rs (tl c, [Bk])"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3516
apply(simp add: wadjust_on_left_moving_B.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3517
apply(case_tac [!] ln, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3518
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3519
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: 285
diff changeset
  3520
lemma wadjust_on_left_moving_B_singleton_Oc[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3521
 "\<lbrakk>wadjust_on_left_moving_B m rs (c, []); c \<noteq> []; hd c = Oc\<rbrakk> \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3522
                                  wadjust_on_left_moving_O m rs (tl c, [Oc])"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3523
apply(simp add: wadjust_on_left_moving_B.simps wadjust_on_left_moving_O.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3524
apply(case_tac [!] ln, simp_all add: )
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: 285
diff changeset
  3525
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3526
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3527
lemma wadjust_on_left_moving_singleton2[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3528
 "\<lbrakk>wadjust_on_left_moving m rs (c, []); c \<noteq> []\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3529
  wadjust_on_left_moving m rs (tl c, [hd c])"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3530
apply(simp add: wadjust_on_left_moving.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3531
apply(case_tac "hd c", simp_all)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3532
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3533
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: 285
diff changeset
  3534
lemma wadjust_nonempty[simp]: "wadjust_goon_left_moving m rs (c, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3535
"wadjust_backto_standard_pos m rs (c, []) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3536
  by(auto simp: wadjust_goon_left_moving.simps wadjust_goon_left_moving_B.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3537
                 wadjust_goon_left_moving_O.simps wadjust_backto_standard_pos.simps
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3538
 wadjust_backto_standard_pos_B.simps wadjust_backto_standard_pos_O.simps)
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: 285
diff changeset
  3539
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3540
lemma wadjust_loop_start_no_Bk[simp]: "wadjust_loop_start m rs (c, Bk # list) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3541
apply(auto simp: wadjust_loop_start.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3542
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3543
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: 285
diff changeset
  3544
lemma wadjust_loop_right_move_Bk[simp]: "wadjust_loop_right_move m rs (c, Bk # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3545
    \<Longrightarrow> wadjust_loop_right_move m rs (Bk # c, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3546
apply(simp only: wadjust_loop_right_move.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3547
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3548
apply(rule_tac x = ml in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3549
apply(rule_tac x = mr in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3550
apply(rule_tac x = "Suc nl" in exI, simp add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3551
apply(case_tac nr, simp, case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3552
apply(rule_tac x = nat in exI, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3553
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3554
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: 285
diff changeset
  3555
lemma wadjust_loop_check_nonempty[simp]: "wadjust_loop_check m rs (c, b) \<Longrightarrow> c \<noteq> []"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3556
apply(simp only: wadjust_loop_check.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3557
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3558
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: 285
diff changeset
  3559
lemma wadjust_erase2_via_loop_check_Bk[simp]: "wadjust_loop_check m rs (c, Bk # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3560
              \<Longrightarrow>  wadjust_erase2 m rs (tl c, hd c # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3561
apply(auto simp: wadjust_loop_check.simps wadjust_erase2.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3562
apply(case_tac [!] mr, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3563
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3564
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3565
declare wadjust_loop_on_left_moving_O.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3566
        wadjust_loop_on_left_moving_B.simps[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3567
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: 285
diff changeset
  3568
lemma wadjust_loop_on_left_moving_B_via_erase[simp]: "\<lbrakk>wadjust_loop_erase m rs (c, Bk # list); hd c = Bk\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3569
    \<Longrightarrow> wadjust_loop_on_left_moving_B m rs (tl c, Bk # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3570
apply(simp only: wadjust_loop_erase.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3571
  wadjust_loop_on_left_moving_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3572
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3573
apply(rule_tac x = ml in exI, rule_tac x = mr in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3574
      rule_tac x = ln in exI, rule_tac x = 0 in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3575
apply(case_tac ln, simp_all add: , auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3576
apply(simp add: exp_ind [THEN sym])
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3577
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3578
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: 285
diff changeset
  3579
lemma wadjust_loop_on_left_moving_O_Bk_via_erase[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3580
 "\<lbrakk>wadjust_loop_erase m rs (c, Bk # list); c \<noteq> []; hd c = Oc\<rbrakk> \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3581
             wadjust_loop_on_left_moving_O m rs (tl c, Oc # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3582
apply(simp only: wadjust_loop_erase.simps wadjust_loop_on_left_moving_O.simps,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3583
       auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3584
apply(case_tac [!] ln, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3585
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3586
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: 285
diff changeset
  3587
lemma wadjust_loop_on_left_moving_Bk_via_erase[simp]: "\<lbrakk>wadjust_loop_erase m rs (c, Bk # list); c \<noteq> []\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3588
                wadjust_loop_on_left_moving m rs (tl c, hd c # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3589
apply(case_tac "hd c", simp_all add:wadjust_loop_on_left_moving.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3590
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3591
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: 285
diff changeset
  3592
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3593
lemma wadjust_loop_on_left_moving_B_Bk_move[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3594
 "\<lbrakk>wadjust_loop_on_left_moving_B m rs (c, Bk # list); hd c = Bk\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3595
    \<Longrightarrow>  wadjust_loop_on_left_moving_B m rs (tl c, Bk # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3596
apply(simp only: wadjust_loop_on_left_moving_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3597
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3598
apply(rule_tac x = ml in exI, rule_tac x = mr in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3599
apply(case_tac nl, simp_all add: , auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3600
apply(rule_tac x = "Suc nr" in exI, auto simp: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3601
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3602
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: 285
diff changeset
  3603
lemma wadjust_loop_on_left_moving_O_Oc_move[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3604
 "\<lbrakk>wadjust_loop_on_left_moving_B m rs (c, Bk # list); hd c = Oc\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3605
    \<Longrightarrow> wadjust_loop_on_left_moving_O m rs (tl c, Oc # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3606
apply(simp only: wadjust_loop_on_left_moving_O.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3607
                 wadjust_loop_on_left_moving_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3608
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3609
apply(rule_tac x = ml in exI, rule_tac x = mr in exI)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3610
apply(case_tac nl, simp_all add: , auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3611
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3612
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: 285
diff changeset
  3613
lemma wadjust_loop_on_left_moving_O_noBk[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3614
 "wadjust_loop_on_left_moving_O m rs (c, Bk # list) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3615
apply(simp add: wadjust_loop_on_left_moving_O.simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3616
done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3617
lemma wadjust_loop_on_left_moving_Bk_move[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3618
 "wadjust_loop_on_left_moving m rs (c, Bk # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3619
            \<Longrightarrow> wadjust_loop_on_left_moving m rs (tl c, hd c # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3620
apply(simp add: wadjust_loop_on_left_moving.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3621
apply(case_tac "hd c", simp_all)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3622
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3623
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: 285
diff changeset
  3624
lemma wadjust_loop_erase_nonempty[simp]: "wadjust_loop_erase m rs (c, b) \<Longrightarrow> c \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3625
"wadjust_loop_on_left_moving m rs (c, b) \<Longrightarrow> c \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3626
"wadjust_loop_right_move2 m rs (c, b) \<Longrightarrow> c \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3627
"wadjust_erase2 m rs (c, Bk # list) \<Longrightarrow> c \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3628
"wadjust_on_left_moving m rs (c,b) \<Longrightarrow> c \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3629
"wadjust_on_left_moving_O m rs (c, Bk # list) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3630
"wadjust_goon_left_moving m rs (c, b) \<Longrightarrow> c \<noteq> []"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3631
  by(auto simp: wadjust_loop_erase.simps wadjust_loop_on_left_moving.simps 
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3632
    wadjust_loop_on_left_moving_O.simps wadjust_loop_on_left_moving_B.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3633
    wadjust_loop_right_move2.simps wadjust_erase2.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3634
    wadjust_on_left_moving.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3635
    wadjust_on_left_moving_O.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3636
    wadjust_on_left_moving_B.simps wadjust_goon_left_moving.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3637
                wadjust_goon_left_moving_B.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3638
                wadjust_goon_left_moving_O.simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3639
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3640
lemma wadjust_loop_start_Oc_via_Bk_move[simp]: 
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3641
"wadjust_loop_right_move2 m rs (c, Bk # list) \<Longrightarrow>  wadjust_loop_start m rs (c, Oc # list)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3642
apply(auto simp: wadjust_loop_right_move2.simps wadjust_loop_start.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3643
apply(case_tac ln, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3644
apply(rule_tac x = 0 in exI, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3645
apply(rule_tac x = rn in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3646
apply(rule_tac x = "Suc ml" in exI, simp add: , auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3647
apply(rule_tac x = "Suc nat" in exI, simp add: exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3648
apply(rule_tac x = rn in exI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3649
apply(rule_tac x = "Suc ml" in exI, 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: 285
diff changeset
  3650
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3651
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3652
lemma wadjust_on_left_moving_Bk_via_erase[simp]: "wadjust_erase2 m rs (c, Bk # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3653
                 wadjust_on_left_moving m rs (tl c, hd c # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3654
apply(auto simp: wadjust_erase2.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3655
apply(case_tac ln, simp_all add:  wadjust_on_left_moving.simps 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3656
        wadjust_on_left_moving_O.simps wadjust_on_left_moving_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3657
apply(auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3658
apply(rule_tac x = "(Suc (Suc rn))" in exI, simp add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3659
apply(rule_tac x = "Suc nat" in exI, simp add: exp_ind del: replicate_Suc)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3660
apply(rule_tac x = "(Suc (Suc rn))" in exI, simp add: )
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: 285
diff changeset
  3661
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3662
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3663
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3664
lemma wadjust_on_left_moving_B_Bk_drop_one: "\<lbrakk>wadjust_on_left_moving_B m rs (c, Bk # list); hd c = Bk\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3665
    \<Longrightarrow> wadjust_on_left_moving_B m rs (tl c, Bk # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3666
apply(auto simp: wadjust_on_left_moving_B.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3667
apply(case_tac ln, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3668
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3669
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: 285
diff changeset
  3670
lemma wadjust_on_left_moving_B_Bk_drop_Oc: "\<lbrakk>wadjust_on_left_moving_B m rs (c, Bk # list); hd c = Oc\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3671
    \<Longrightarrow> wadjust_on_left_moving_O m rs (tl c, Oc # Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3672
apply(auto simp: wadjust_on_left_moving_O.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3673
                 wadjust_on_left_moving_B.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3674
apply(case_tac ln, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3675
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3676
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: 285
diff changeset
  3677
lemma wadjust_on_left_moving_B_drop[simp]: "wadjust_on_left_moving  m rs (c, Bk # list) \<Longrightarrow>  
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3678
                  wadjust_on_left_moving m rs (tl c, hd c # Bk # list)"
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: 285
diff changeset
  3679
  by(cases "hd c", auto simp:wadjust_on_left_moving.simps wadjust_on_left_moving_B_Bk_drop_one
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3680
      wadjust_on_left_moving_B_Bk_drop_Oc)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3681
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3682
lemma wadjust_goon_left_moving_O_no_Bk[simp]: "wadjust_goon_left_moving_O m rs (c, Bk # list) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3683
apply(simp add: wadjust_goon_left_moving_O.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3684
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3685
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3686
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: 285
diff changeset
  3687
lemma wadjust_backto_standard_pos_via_left_Bk[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3688
 "wadjust_goon_left_moving m rs (c, Bk # list) \<Longrightarrow>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3689
  wadjust_backto_standard_pos m rs (tl c, hd c # Bk # list)"
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: 285
diff changeset
  3690
by(case_tac "hd c", simp_all add: wadjust_backto_standard_pos.simps wadjust_goon_left_moving.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3691
                    wadjust_goon_left_moving_B.simps wadjust_backto_standard_pos_O.simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3692
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3693
lemma wadjust_loop_right_move_Oc[simp]: "wadjust_loop_start m rs (c, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3694
              \<Longrightarrow> wadjust_loop_right_move m rs (Oc # c, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3695
apply(simp add: wadjust_loop_start.simps wadjust_loop_right_move.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3696
apply(rule_tac x = ml in exI, rule_tac x = mr in exI, 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3697
      rule_tac x = 0 in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3698
apply(rule_tac x = "Suc ln" in exI, simp add: exp_ind del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3699
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3700
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: 285
diff changeset
  3701
lemma wadjust_loop_check_Oc[simp]: "wadjust_loop_right_move m rs (c, Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3702
                       wadjust_loop_check m rs (Oc # c, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3703
apply(simp add: wadjust_loop_right_move.simps  
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3704
                 wadjust_loop_check.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3705
apply(rule_tac [!] x = ml in exI, simp_all add: exp_ind del: replicate_Suc, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3706
apply(case_tac nl, simp_all add: exp_ind del: replicate_Suc)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3707
apply(rule_tac x = "mr - 1" in exI, case_tac mr, simp_all add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3708
apply(case_tac [!] nr, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3709
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3710
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: 285
diff changeset
  3711
lemma wadjust_loop_erase_move_Oc[simp]: "wadjust_loop_check m rs (c, Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3712
               wadjust_loop_erase m rs (tl c, hd c # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3713
apply(simp only: wadjust_loop_check.simps wadjust_loop_erase.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3714
apply(erule_tac exE)+
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3715
apply(rule_tac x = ml in exI, rule_tac x = mr in exI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3716
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3717
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3718
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: 285
diff changeset
  3719
lemma wadjust_loop_erase_Bk_via_Oc[simp]: "wadjust_loop_erase m rs (c, Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3720
                wadjust_loop_erase m rs (c, Bk # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3721
apply(auto simp: wadjust_loop_erase.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3722
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3723
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: 285
diff changeset
  3724
lemma wadjust_loop_on_left_moving_B_no_Oc[simp]: "wadjust_loop_on_left_moving_B m rs (c, Oc # list) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3725
apply(auto simp: wadjust_loop_on_left_moving_B.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3726
apply(case_tac nr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3727
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3728
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: 285
diff changeset
  3729
lemma wadjust_loop_right_move2_via_left_moving[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3730
 "wadjust_loop_on_left_moving m rs (c, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3731
           \<Longrightarrow> wadjust_loop_right_move2 m rs (Oc # c, list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3732
apply(simp add:wadjust_loop_on_left_moving.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3733
apply(auto simp: wadjust_loop_on_left_moving_O.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3734
                 wadjust_loop_right_move2.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3735
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3736
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: 285
diff changeset
  3737
lemma wadjust_loop_right_move2_no_Oc[simp]: "wadjust_loop_right_move2 m rs (c, Oc # list) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3738
apply(auto simp: wadjust_loop_right_move2.simps )
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3739
apply(case_tac ln, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3740
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3741
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: 285
diff changeset
  3742
lemma wadjust_on_left_moving_B_no_Oc[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3743
 "wadjust_on_left_moving_B m rs (c, Oc # list) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3744
apply(auto simp: wadjust_on_left_moving_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3745
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3746
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: 285
diff changeset
  3747
lemma wadjust_goon_left_moving_B_Bk_Oc: "\<lbrakk>wadjust_on_left_moving_O m rs (c, Oc # list); hd c = Bk\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3748
         wadjust_goon_left_moving_B m rs (tl c, Bk # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3749
apply(auto simp: wadjust_on_left_moving_O.simps 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3750
     wadjust_goon_left_moving_B.simps )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3751
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3752
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: 285
diff changeset
  3753
lemma wadjust_goon_left_moving_O_Oc_Oc: "\<lbrakk>wadjust_on_left_moving_O m rs (c, Oc # list); hd c = Oc\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3754
    \<Longrightarrow> wadjust_goon_left_moving_O m rs (tl c, Oc # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3755
apply(auto simp: wadjust_on_left_moving_O.simps 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3756
                 wadjust_goon_left_moving_O.simps )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3757
apply(auto simp:  numeral_2_eq_2)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3758
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3759
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3760
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: 285
diff changeset
  3761
lemma wadjust_goon_left_moving_Oc[simp]: "wadjust_on_left_moving m rs (c, Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3762
              wadjust_goon_left_moving m rs (tl c, hd c # Oc # list)"
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: 285
diff changeset
  3763
  by(cases "hd c"; force simp: wadjust_on_left_moving.simps wadjust_goon_left_moving.simps
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3764
     wadjust_goon_left_moving_B_Bk_Oc wadjust_goon_left_moving_O_Oc_Oc)+
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3765
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3766
lemma left_moving_Bk_Oc[simp]: "\<lbrakk>wadjust_goon_left_moving_O m rs (c, Oc # list); hd c = Bk\<rbrakk> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3767
               \<Longrightarrow> wadjust_goon_left_moving_B m rs (tl c, Bk # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3768
apply(auto simp: wadjust_goon_left_moving_O.simps wadjust_goon_left_moving_B.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3769
apply(case_tac [!] ml, auto simp: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3770
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3771
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: 285
diff changeset
  3772
lemma  left_moving_Oc_Oc[simp]: "\<lbrakk>wadjust_goon_left_moving_O m rs (c, Oc # list); hd c = Oc\<rbrakk> \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3773
  wadjust_goon_left_moving_O m rs (tl c, Oc # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3774
apply(auto simp: wadjust_goon_left_moving_O.simps wadjust_goon_left_moving_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3775
apply(rule_tac x = "ml - 1" in exI, simp)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3776
apply(case_tac ml, simp_all add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3777
apply(rule_tac x = "Suc mr" in exI, auto simp: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3778
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3779
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: 285
diff changeset
  3780
lemma wadjust_goon_left_moving_B_no_Oc[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3781
  "wadjust_goon_left_moving_B m rs (c, Oc # list) = False"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3782
apply(auto simp: wadjust_goon_left_moving_B.simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3783
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3784
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3785
lemma wadjust_goon_left_moving_Oc_move[simp]: "wadjust_goon_left_moving m rs (c, Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3786
  wadjust_goon_left_moving m rs (tl c, hd c # Oc # list)"
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: 285
diff changeset
  3787
by(cases "hd c",auto simp: wadjust_goon_left_moving.simps)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3788
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3789
lemma wadjust_backto_standard_pos_B_no_Oc[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3790
  "wadjust_backto_standard_pos_B m rs (c, Oc # list) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3791
apply(simp add: wadjust_backto_standard_pos_B.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3792
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3793
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: 285
diff changeset
  3794
lemma wadjust_backto_standard_pos_O_no_Bk[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3795
  "wadjust_backto_standard_pos_O m rs (c, Bk # xs) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3796
apply(simp add: wadjust_backto_standard_pos_O.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3797
apply(case_tac mr, simp_all add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3798
done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3799
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: 285
diff changeset
  3800
lemma wadjust_backto_standard_pos_B_Bk_Oc[simp]:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3801
 "wadjust_backto_standard_pos_O m rs ([], Oc # list) \<Longrightarrow> 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3802
  wadjust_backto_standard_pos_B m rs ([], Bk # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3803
apply(auto simp: wadjust_backto_standard_pos_O.simps
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3804
                 wadjust_backto_standard_pos_B.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3805
done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3806
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: 285
diff changeset
  3807
lemma wadjust_backto_standard_pos_B_Bk_Oc_via_O[simp]: 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3808
  "\<lbrakk>wadjust_backto_standard_pos_O m rs (c, Oc # list); c \<noteq> []; hd c = Bk\<rbrakk>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3809
  \<Longrightarrow> wadjust_backto_standard_pos_B m rs (tl c, Bk # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3810
apply(simp add:wadjust_backto_standard_pos_O.simps 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3811
        wadjust_backto_standard_pos_B.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3812
done 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3813
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: 285
diff changeset
  3814
lemma wadjust_backto_standard_pos_B_Oc_Oc_via_O[simp]: "\<lbrakk>wadjust_backto_standard_pos_O m rs (c, Oc # list); c \<noteq> []; hd c = Oc\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3815
          \<Longrightarrow>  wadjust_backto_standard_pos_O m rs (tl c, Oc # Oc # list)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3816
apply(simp add: wadjust_backto_standard_pos_O.simps, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3817
apply(case_tac ml, simp_all add: , auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3818
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3819
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: 285
diff changeset
  3820
lemma wadjust_backto_standard_pos_cases[simp]: "wadjust_backto_standard_pos m rs (c, Oc # list)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3821
  \<Longrightarrow> (c = [] \<longrightarrow> wadjust_backto_standard_pos m rs ([], Bk # Oc # list)) \<and> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3822
 (c \<noteq> [] \<longrightarrow> wadjust_backto_standard_pos m rs (tl c, hd c # Oc # list))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3823
apply(auto simp: wadjust_backto_standard_pos.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3824
apply(case_tac "hd c", simp_all)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3825
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3826
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: 285
diff changeset
  3827
lemma wadjust_loop_right_move_nonempty_snd[simp]: "wadjust_loop_right_move m rs (c, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3828
apply(simp only: wadjust_loop_right_move.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3829
apply(rule_tac iffI)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3830
apply(erule_tac exE)+
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3831
apply(case_tac nr, simp_all add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3832
apply(case_tac mr, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3833
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3834
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: 285
diff changeset
  3835
lemma wadjust_loop_erase_nonempty_snd[simp]: "wadjust_loop_erase m rs (c, []) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3836
apply(simp only: wadjust_loop_erase.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3837
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3838
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: 285
diff changeset
  3839
lemma wadjust_loop_erase_cases2[simp]: "\<lbrakk>Suc (Suc rs) = a;  wadjust_loop_erase m rs (c, Bk # list)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3840
  \<Longrightarrow> a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev (tl c) @ hd c # Bk # list))))
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3841
  < a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Bk # list)))) \<or>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3842
  a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev (tl c) @ hd c # Bk # list)))) =
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3843
  a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Bk # list))))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3844
apply(simp only: wadjust_loop_erase.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3845
apply(rule_tac disjI2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3846
apply(case_tac c, simp, simp)
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: 285
diff changeset
  3847
  done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3848
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3849
lemma dropWhile_exp1: "dropWhile (\<lambda>a. a = Oc) (Oc\<up>(n) @ xs) = dropWhile (\<lambda>a. a = Oc) xs"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3850
apply(induct n, simp_all add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3851
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3852
lemma takeWhile_exp1: "takeWhile (\<lambda>a. a = Oc) (Oc\<up>(n) @ xs) = Oc\<up>(n) @ takeWhile (\<lambda>a. a = Oc) xs"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3853
apply(induct n, simp_all add: )
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3854
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3855
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: 285
diff changeset
  3856
lemma wadjust_correctness_helper_1:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3857
  assumes "Suc (Suc rs) = a" " wadjust_loop_right_move2 m rs (c, Bk # list)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3858
  shows "a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Oc # list))))
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3859
                 < a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Bk # list))))"
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: 285
diff changeset
  3860
proof -
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3861
  have "ml + mr = Suc rs \<Longrightarrow> 0 < mr \<Longrightarrow>
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3862
       rs - (ml + length (takeWhile (\<lambda>a. a = Oc) list))
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3863
       < Suc rs -
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3864
         (ml +
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3865
          length
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3866
           (takeWhile (\<lambda>a. a = Oc)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3867
             (Bk \<up> ln @ Bk # Bk # Oc \<up> mr @ Bk \<up> rn))) "
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3868
    for ml mr ln rn
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3869
  by(cases ln, auto)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3870
  thus ?thesis using assms
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3871
    by (auto simp: wadjust_loop_right_move2.simps dropWhile_exp1 takeWhile_exp1)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3872
qed
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3873
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3874
lemma wadjust_correctness_helper_2:
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3875
  "\<lbrakk>Suc (Suc rs) = a;  wadjust_loop_on_left_moving m rs (c, Bk # list)\<rbrakk>
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3876
  \<Longrightarrow> a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev (tl c) @ hd c # Bk # list))))
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3877
  < a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Bk # list)))) \<or>
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3878
  a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev (tl c) @ hd c # Bk # list)))) =
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3879
  a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Bk # list))))"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3880
  apply(subgoal_tac "c \<noteq> []")
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3881
  apply(case_tac c, simp_all)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3882
  done
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3883
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3884
lemma wadjust_loop_check_empty_false[simp]: "wadjust_loop_check m rs ([], b) = False"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3885
apply(simp add: wadjust_loop_check.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3886
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3887
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: 285
diff changeset
  3888
lemma wadjust_loop_check_cases: "\<lbrakk>Suc (Suc rs) = a;  wadjust_loop_check m rs (c, Oc # list)\<rbrakk>
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3889
  \<Longrightarrow> a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev (tl c) @ hd c # Oc # list))))
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3890
  < a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Oc # list)))) \<or>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3891
  a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev (tl c) @ hd c # Oc # list)))) =
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3892
  a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Oc # list))))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3893
apply(case_tac "c", simp_all)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3894
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3895
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: 285
diff changeset
  3896
lemma wadjust_loop_erase_cases_or: 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3897
  "\<lbrakk>Suc (Suc rs) = a;  wadjust_loop_erase m rs (c, Oc # list)\<rbrakk>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3898
  \<Longrightarrow> a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Bk # list))))
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3899
  < a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Oc # list)))) \<or>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3900
  a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Bk # list)))) =
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3901
  a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Oc # list))))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3902
apply(simp add: wadjust_loop_erase.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3903
apply(rule_tac disjI2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3904
apply(auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3905
apply(simp add: dropWhile_exp1 takeWhile_exp1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3906
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3907
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: 285
diff changeset
  3908
lemmas wadjust_correctness_helpers = wadjust_correctness_helper_2 wadjust_correctness_helper_1 wadjust_loop_erase_cases_or wadjust_loop_check_cases
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3909
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3910
declare numeral_2_eq_2[simp del]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3911
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: 285
diff changeset
  3912
lemma wadjust_start_Oc[simp]: "wadjust_start m rs (c, Bk # list)
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3913
       \<Longrightarrow> wadjust_start m rs (c, Oc # list)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3914
apply(auto simp: wadjust_start.simps)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3915
done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3916
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: 285
diff changeset
  3917
lemma wadjust_stop_Bk[simp]: "wadjust_backto_standard_pos m rs (c, Bk # list)
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3918
       \<Longrightarrow> wadjust_stop m rs (Bk # c, list)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3919
apply(auto simp: wadjust_backto_standard_pos.simps 
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3920
wadjust_stop.simps wadjust_backto_standard_pos_B.simps)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3921
done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3922
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: 285
diff changeset
  3923
lemma wadjust_loop_start_Oc[simp]: "wadjust_start m rs (c, Oc # list)
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3924
       \<Longrightarrow> wadjust_loop_start m rs (Oc # c, list)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3925
apply(auto simp: wadjust_start.simps wadjust_loop_start.simps)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3926
apply(rule_tac x = ln in exI, simp)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3927
apply(rule_tac x = "rn" in exI, simp)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3928
apply(rule_tac x = 1 in exI, simp)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3929
done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3930
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: 285
diff changeset
  3931
lemma erase2_Bk_if_Oc[simp]:" wadjust_erase2 m rs (c, Oc # list)
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3932
       \<Longrightarrow> wadjust_erase2 m rs (c, Bk # list)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3933
apply(auto simp: wadjust_erase2.simps)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3934
done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3935
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3936
lemma wadjust_correctness:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3937
  shows "let P = (\<lambda> (len, st, l, r). st = 0) in 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3938
  let Q = (\<lambda> (len, st, l, r). wadjust_inv st m rs (l, r)) in 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3939
  let f = (\<lambda> stp. (Suc (Suc rs),  steps0 (Suc 0, Bk # Oc\<up>(Suc m), 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3940
                Bk # Oc # Bk\<up>(ln) @ Bk #  Oc\<up>(Suc rs) @ Bk\<up>(rn)) t_wcode_adjust stp)) in
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3941
    \<exists> n .P (f n) \<and> Q (f n)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3942
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3943
  let ?P = "(\<lambda> (len, st, l, r). st = 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3944
  let ?Q = "\<lambda> (len, st, l, r). wadjust_inv st m rs (l, r)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3945
  let ?f = "\<lambda> stp. (Suc (Suc rs),  steps0 (Suc 0, Bk # Oc\<up>(Suc m), 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3946
                Bk # Oc # Bk\<up>(ln) @ Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn)) t_wcode_adjust stp)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3947
  have "\<exists> n. ?P (?f n) \<and> ?Q (?f n)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3948
  proof(rule_tac halt_lemma2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3949
    show "wf wadjust_le" by auto
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3950
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3951
    show "\<forall> n. \<not> ?P (?f n) \<and> ?Q (?f n) \<longrightarrow> 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3952
                 ?Q (?f (Suc n)) \<and> (?f (Suc n), ?f n) \<in> wadjust_le"
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: 285
diff changeset
  3953
      apply(rule_tac allI, rule_tac impI, case_tac "?f 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: 285
diff changeset
  3954
      apply((case_tac d, case_tac [2] aa); simp add: step.simps)
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3955
      apply(simp_all only: wadjust_inv.simps split: if_splits)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  3956
      apply(simp_all)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3957
      apply(simp_all add: wadjust_inv.simps wadjust_le_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: 285
diff changeset
  3958
            wadjust_correctness_helpers
163
67063c5365e1 changed theory names to uppercase
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
  3959
            Abacus.lex_triple_def Abacus.lex_pair_def lex_square_def  split: if_splits)
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: 285
diff changeset
  3960
      
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3961
      done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3962
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3963
    show "?Q (?f 0)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3964
      apply(simp add: steps.simps wadjust_inv.simps wadjust_start.simps, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3965
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3966
  next
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3967
    show "\<not> ?P (?f 0)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3968
      apply(simp add: steps.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3969
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3970
  qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3971
  thus"?thesis"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3972
    apply(simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3973
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3974
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3975
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: 285
diff changeset
  3976
lemma tm_wf_t_wcode_adjust[intro]: "tm_wf (t_wcode_adjust, 0)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3977
apply(auto simp: t_wcode_adjust_def tm_wf.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3978
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3979
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: 285
diff changeset
  3980
lemma bl_bin_nonzero[simp]: "args \<noteq> [] \<Longrightarrow> bl_bin (<args::nat list>) > 0"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3981
  by(cases args)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  3982
    (auto simp: tape_of_nl_cons bl_bin.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3983
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3984
lemma wcode_lemma_pre':
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3985
  "args \<noteq> [] \<Longrightarrow> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3986
  \<exists> stp rn. steps0 (Suc 0, [], <m # args>) 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3987
              ((t_wcode_prepare |+| t_wcode_main) |+| t_wcode_adjust) stp
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3988
  = (0,  [Bk],  Oc\<up>(Suc m) @ Bk # Oc\<up>(Suc (bl_bin (<args>))) @ Bk\<up>(rn))" 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3989
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3990
  let ?P1 = "\<lambda> (l, r). l = [] \<and> r = <m # args>"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3991
  let ?Q1 = "\<lambda>(l, r). l = Bk # Oc\<up>(Suc m) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3992
    (\<exists>ln rn. r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<args>)) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3993
  let ?P2 = ?Q1
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3994
  let ?Q2 = "\<lambda> (l, r). (wadjust_stop m (bl_bin (<args>) - 1) (l, r))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3995
  let ?P3 = "\<lambda> tp. False"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  3996
  assume h: "args \<noteq> []"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3997
  hence a: "bl_bin (<args>) > 0"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3998
    using h by simp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  3999
  hence "{?P1} (t_wcode_prepare |+| t_wcode_main) |+| t_wcode_adjust {?Q2}"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4000
  proof(rule_tac Hoare_plus_halt)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4001
  next
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4002
    show "tm_wf (t_wcode_prepare |+| t_wcode_main, 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4003
      apply(rule_tac tm_wf_comp, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4004
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4005
  next
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4006
    show "{?P1} t_wcode_prepare |+| t_wcode_main {?Q1}"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  4007
    proof(rule_tac Hoare_haltI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4008
      show 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4009
        "\<exists>n. is_final (steps0 (Suc 0, [], <m # args>) (t_wcode_prepare |+| t_wcode_main) n) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4010
        (\<lambda>(l, r). l = Bk # Oc # Oc \<up> m \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4011
        (\<exists>ln rn. r = Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> bl_bin (<args>) @ Bk \<up> rn))
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4012
        holds_for steps0 (Suc 0, [], <m # args>) (t_wcode_prepare |+| t_wcode_main) n"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4013
        using h prepare_mainpart_lemma[of args m]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4014
        apply(auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4015
        apply(rule_tac x = stp in exI, simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4016
        apply(rule_tac x = ln in exI, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4017
        done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4018
    qed
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4019
  next
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4020
    show "{?P2} t_wcode_adjust {?Q2}"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  4021
    proof(rule_tac Hoare_haltI, auto del: replicate_Suc)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4022
      fix ln rn
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4023
      show "\<exists>n. is_final (steps0 (Suc 0, Bk # Oc # Oc \<up> m, 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4024
        Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> bl_bin (<args>) @ Bk \<up> rn) t_wcode_adjust n) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4025
        wadjust_stop m (bl_bin (<args>) - Suc 0) holds_for steps0
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4026
        (Suc 0, Bk # Oc # Oc \<up> m, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> bl_bin (<args>) @ Bk \<up> rn) t_wcode_adjust n"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4027
        using wadjust_correctness[of m "bl_bin (<args>) - 1" "Suc ln" rn]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4028
        apply(simp del: replicate_Suc add: replicate_Suc[THEN sym] exp_ind, auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4029
        apply(rule_tac x = n in exI)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4030
        using a
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4031
        apply(case_tac "bl_bin (<args>)", simp, simp del: replicate_Suc add: exp_ind wadjust_inv.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4032
        done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4033
    qed
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4034
  qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4035
  thus "?thesis"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  4036
    apply(simp add: Hoare_halt_def, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4037
    apply(case_tac "(steps0 (Suc 0, [], <(m::nat) # args>) 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4038
      ((t_wcode_prepare |+| t_wcode_main) |+| t_wcode_adjust) n)")
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4039
    apply(rule_tac x = n in exI, auto simp: wadjust_stop.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4040
    using a
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4041
    apply(case_tac "bl_bin (<args>)", simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4042
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4043
qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4044
    
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4045
text {*
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4046
  The initialization TM @{text "t_wcode"}.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4047
  *}
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4048
definition t_wcode :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4049
  where
190
f1ecb4a68a54 renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 170
diff changeset
  4050
  "t_wcode = (t_wcode_prepare |+| t_wcode_main) |+| t_wcode_adjust        "
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4051
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4052
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4053
text {*
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4054
  The correctness of @{text "t_wcode"}.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4055
  *}
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4056
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4057
lemma wcode_lemma_1:
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4058
  "args \<noteq> [] \<Longrightarrow> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4059
  \<exists> stp ln rn. steps0 (Suc 0, [], <m # args>)  (t_wcode) stp = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4060
              (0,  [Bk],  Oc\<up>(Suc m) @ Bk # Oc\<up>(Suc (bl_bin (<args>))) @ Bk\<up>(rn))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4061
apply(simp add: wcode_lemma_pre' t_wcode_def del: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4062
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4063
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4064
lemma wcode_lemma: 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4065
  "args \<noteq> [] \<Longrightarrow> 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4066
  \<exists> stp ln rn. steps0 (Suc 0, [], <m # args>)  (t_wcode) stp = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4067
              (0,  [Bk],  <[m ,bl_bin (<args>)]> @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4068
using wcode_lemma_1[of args m]
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: 285
diff changeset
  4069
apply(simp add: t_wcode_def tape_of_list_def tape_of_nat_list.simps tape_of_nat_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4070
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4071
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4072
section {* The universal TM *}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4073
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4074
text {*
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4075
  This section gives the explicit construction of {\em Universal Turing Machine}, defined as @{text "UTM"} and proves its 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4076
  correctness. It is pretty easy by composing the partial results we have got so far.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4077
  *}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4078
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4079
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4080
definition UTM :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4081
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4082
  "UTM = (let (aprog, rs_pos, a_md) = rec_ci rec_F in 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4083
          let abc_F = aprog [+] dummy_abc (Suc (Suc 0)) in 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4084
          (t_wcode |+| (tm_of abc_F @ shift (mopup (Suc (Suc 0))) (length (tm_of abc_F) div 2))))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4085
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4086
definition F_aprog :: "abc_prog"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4087
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4088
  "F_aprog \<equiv> (let (aprog, rs_pos, a_md) = rec_ci rec_F in 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4089
                       aprog [+] dummy_abc (Suc (Suc 0)))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4090
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4091
definition F_tprog :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4092
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4093
  "F_tprog = tm_of (F_aprog)"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4094
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4095
definition t_utm :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4096
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4097
  "t_utm \<equiv>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4098
     F_tprog @ shift (mopup (Suc (Suc 0))) (length F_tprog div 2)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4099
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4100
definition UTM_pre :: "instr list"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4101
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4102
  "UTM_pre = t_wcode |+| t_utm"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4103
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4104
lemma tinres_step1: 
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: 285
diff changeset
  4105
  assumes "tinres l l'" "step (ss, l, r) (t, 0) = (sa, la, ra)" 
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4106
          "step (ss, l', r) (t, 0) = (sb, lb, rb)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4107
  shows "tinres la lb \<and> ra = rb \<and> sa = sb"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4108
proof(cases "r")
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4109
  case Nil
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4110
  then show ?thesis using assms
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4111
    by (cases "(fetch t ss Bk)";cases "fst (fetch t ss Bk)";auto simp:step.simps split:if_splits)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4112
next
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4113
  case (Cons a list)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4114
  then show ?thesis using assms
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4115
    by (cases "(fetch t ss a)";cases "fst (fetch t ss a)";auto simp:step.simps split:if_splits)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4116
qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4117
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4118
lemma tinres_steps1: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4119
  "\<lbrakk>tinres l l'; steps (ss, l, r) (t, 0) stp = (sa, la, ra); 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4120
                 steps (ss, l', r) (t, 0) stp = (sb, lb, rb)\<rbrakk>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4121
    \<Longrightarrow> tinres la lb \<and> ra = rb \<and> sa = sb"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4122
apply(induct stp arbitrary: sa la ra sb lb rb, simp add: steps.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4123
apply(simp add: step_red)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4124
apply(case_tac "(steps (ss, l, r) (t, 0) stp)")
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4125
apply(case_tac "(steps (ss, l', r) (t, 0) stp)")
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4126
proof -
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4127
  fix stp sa la ra sb lb rb a b c aa ba ca
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4128
  assume ind: "\<And>sa la ra sb lb rb. \<lbrakk>steps (ss, l, r) (t, 0) stp = (sa, (la::cell list), ra); 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4129
          steps (ss, l', r) (t, 0) stp = (sb, lb, rb)\<rbrakk> \<Longrightarrow> tinres la lb \<and> ra = rb \<and> sa = sb"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4130
  and h: " tinres l l'" "step (steps (ss, l, r) (t, 0) stp) (t, 0) = (sa, la, ra)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4131
         "step (steps (ss, l', r) (t, 0) stp) (t, 0) = (sb, lb, rb)" "steps (ss, l, r) (t, 0) stp = (a, b, c)" 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4132
         "steps (ss, l', r) (t, 0) stp = (aa, ba, ca)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4133
  have "tinres b ba \<and> c = ca \<and> a = aa"
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: 285
diff changeset
  4134
    using ind h by metis
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4135
  thus "tinres la lb \<and> ra = rb \<and> sa = sb"
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: 285
diff changeset
  4136
    using tinres_step1 h by metis
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4137
qed
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4138
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: 285
diff changeset
  4139
lemma tinres_some_exp[simp]: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4140
  "tinres (Bk \<up> m @ [Bk, Bk]) la \<Longrightarrow> \<exists>m. la = Bk \<up> m"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4141
apply(auto simp: tinres_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4142
apply(case_tac n, simp add: exp_ind)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4143
apply(rule_tac  x ="Suc (Suc m)" in exI, simp only: exp_ind, simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4144
apply(simp add: exp_ind del: replicate_Suc)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4145
apply(case_tac nat, simp add: exp_ind)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4146
apply(rule_tac x = "Suc m" in exI, simp only: exp_ind)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4147
apply(simp only: exp_ind, simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4148
apply(subgoal_tac "m = length la + nata")
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4149
apply(rule_tac x = "m - nata" in exI, simp add: replicate_add)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4150
apply(drule_tac length_equal, simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4151
apply(simp only: exp_ind[THEN sym] replicate_Suc[THEN sym] replicate_add[THEN sym])
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4152
apply(rule_tac x = "m + Suc (Suc n)" in exI, simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4153
done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4154
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4155
lemma t_utm_halt_eq: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4156
  assumes tm_wf: "tm_wf (tp, 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4157
  and exec: "steps0 (Suc 0, Bk\<up>(l), <lm::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(n))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4158
  and resutl: "0 < rs"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4159
  shows "\<exists>stp m n. steps0 (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>(i)) t_utm stp = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4160
                                                (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4161
proof -
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4162
  obtain ap arity fp where a: "rec_ci rec_F = (ap, arity, fp)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4163
    by (metis prod_cases3) 
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4164
  moreover have b: "rec_exec rec_F [code tp, (bl2wc (<lm>))] = (rs - Suc 0)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4165
    using assms
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4166
    apply(rule_tac F_correct, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4167
    done 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4168
  have "\<exists> stp m l. steps0 (Suc 0, Bk # Bk # [], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4169
    (F_tprog @ shift (mopup (length [code tp, bl2wc (<lm>)])) (length F_tprog div 2)) stp
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4170
    = (0, Bk\<up>m @ Bk # Bk # [], Oc\<up>Suc (rec_exec rec_F [code tp, (bl2wc (<lm>))]) @ Bk\<up>l)"  
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4171
  proof(rule_tac recursive_compile_to_tm_correct1)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4172
    show "rec_ci rec_F = (ap, arity, fp)" using a by simp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4173
  next
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4174
    show "terminate rec_F [code tp, bl2wc (<lm>)]"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4175
      using assms
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4176
      by(rule_tac terminate_F, simp_all)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4177
  next
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4178
    show "F_tprog = tm_of (ap [+] dummy_abc (length [code tp, bl2wc (<lm>)]))"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4179
      using a
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4180
      apply(simp add: F_tprog_def F_aprog_def numeral_2_eq_2)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4181
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4182
  qed
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4183
  then obtain stp m l where 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4184
    "steps0 (Suc 0, Bk # Bk # [], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4185
    (F_tprog @ shift (mopup (length [code tp, (bl2wc (<lm>))])) (length F_tprog div 2)) stp
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4186
    = (0, Bk\<up>m @ Bk # Bk # [], Oc\<up>Suc (rec_exec rec_F [code tp, (bl2wc (<lm>))]) @ Bk\<up>l)" by blast
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4187
  hence "\<exists> m. steps0 (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4188
    (F_tprog @ shift (mopup 2) (length F_tprog div 2)) stp
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4189
    = (0, Bk\<up>m, Oc\<up>Suc (rs - 1) @ Bk\<up>l)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4190
  proof -
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4191
    assume g: "steps0 (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk \<up> i)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4192
      (F_tprog @ shift (mopup (length [code tp, bl2wc (<lm>)])) (length F_tprog div 2)) stp =
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4193
      (0, Bk \<up> m @ [Bk, Bk], Oc \<up> Suc ((rec_exec rec_F [code tp, bl2wc (<lm>)])) @ Bk \<up> l)"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4194
   moreover have "tinres [Bk, Bk] [Bk]"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4195
     apply(auto simp: tinres_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4196
     done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4197
    moreover obtain sa la ra where "steps0 (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4198
    (F_tprog @ shift (mopup 2) (length F_tprog div 2)) stp = (sa, la, ra)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4199
      apply(case_tac "steps0 (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4200
    (F_tprog @ shift (mopup 2) (length F_tprog div 2)) stp", auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4201
      done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4202
    ultimately show "?thesis"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4203
      using b
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4204
      apply(drule_tac la = "Bk\<up>m @ [Bk, Bk]" in tinres_steps1, auto simp: numeral_2_eq_2)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4205
      done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4206
  qed
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4207
  thus "?thesis"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4208
    apply(auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4209
    apply(rule_tac x = stp in exI, simp add: t_utm_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4210
    using assms
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4211
    apply(case_tac rs, simp_all add: numeral_2_eq_2)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4212
    done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4213
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4214
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: 285
diff changeset
  4215
lemma tm_wf_t_wcode[intro]: "tm_wf (t_wcode, 0)"
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4216
  apply(simp add: t_wcode_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: 285
diff changeset
  4217
  apply(rule_tac tm_wf_comp)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4218
  apply(rule_tac tm_wf_comp, auto)
a9003e6d0463 Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents: 285
diff changeset
  4219
  done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4220
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4221
lemma UTM_halt_lemma_pre: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4222
  assumes wf_tm: "tm_wf (tp, 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4223
  and result: "0 < rs"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4224
  and args: "args \<noteq> []"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4225
  and exec: "steps0 (Suc 0, Bk\<up>(i), <args::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(k))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4226
  shows "\<exists>stp m n. steps0 (Suc 0, [], <code tp # args>) UTM_pre stp = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4227
                                                (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4228
proof -
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4229
  let ?Q2 = "\<lambda> (l, r). (\<exists> ln rn. l = Bk\<up>(ln) \<and> r = Oc\<up>(rs) @ Bk\<up>(rn))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4230
  let ?P1 = "\<lambda> (l, r). l = [] \<and> r = <code tp # args>"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4231
  let ?Q1 = "\<lambda> (l, r). (l = [Bk] \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4232
    (\<exists> rn. r = Oc\<up>(Suc (code tp)) @ Bk # Oc\<up>(Suc (bl_bin (<args>))) @ Bk\<up>(rn)))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4233
  let ?P2 = ?Q1
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4234
  let ?P3 = "\<lambda> (l, r). False"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4235
  have "{?P1} (t_wcode |+| t_utm) {?Q2}"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4236
  proof(rule_tac Hoare_plus_halt)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4237
    show "tm_wf (t_wcode, 0)" by auto
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4238
  next
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4239
    show "{?P1} t_wcode {?Q1}"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  4240
      apply(rule_tac Hoare_haltI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4241
      using wcode_lemma_1[of args "code tp"] args
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4242
      apply(auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4243
      apply(rule_tac x = stp in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4244
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4245
  next
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4246
    show "{?P2} t_utm {?Q2}"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  4247
    proof(rule_tac Hoare_haltI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4248
      fix rn
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4249
      show "\<exists>n. is_final (steps0 (Suc 0, [Bk], Oc # Oc \<up> code tp @ Bk # Oc # Oc \<up> bl_bin (<args>) @ Bk \<up> rn) t_utm n) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4250
        (\<lambda>(l, r). (\<exists>ln. l = Bk \<up> ln) \<and>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4251
        (\<exists>rn. r = Oc \<up> rs @ Bk \<up> rn)) holds_for steps0 (Suc 0, [Bk],
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4252
        Oc # Oc \<up> code tp @ Bk # Oc # Oc \<up> bl_bin (<args>) @ Bk \<up> rn) t_utm n"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4253
        using t_utm_halt_eq[of tp i "args" stp m rs k rn] assms
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4254
      apply(auto simp: bin_wc_eq)
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: 285
diff changeset
  4255
      apply(rule_tac x = stpa in exI, simp add: tape_of_list_def tape_of_nat_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4256
      done
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4257
    qed
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4258
  qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4259
  thus "?thesis"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  4260
    apply(auto simp: Hoare_halt_def UTM_pre_def)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4261
    apply(case_tac "steps0 (Suc 0, [], <code tp # args>) (t_wcode |+| t_utm) n")
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4262
    apply(rule_tac x = n in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4263
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4264
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4265
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4266
text {*
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4267
  The correctness of @{text "UTM"}, the halt case.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4268
*}
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4269
lemma UTM_halt_lemma': 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4270
  assumes tm_wf: "tm_wf (tp, 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4271
  and result: "0 < rs"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4272
  and args: "args \<noteq> []"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4273
  and exec: "steps0 (Suc 0, Bk\<up>(i), <args::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(k))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4274
  shows "\<exists>stp m n. steps0 (Suc 0, [], <code tp # args>) UTM stp = 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4275
                                                (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4276
using UTM_halt_lemma_pre[of tp rs args i stp m k] assms
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4277
apply(simp add: UTM_pre_def t_utm_def UTM_def F_aprog_def F_tprog_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4278
apply(case_tac "rec_ci rec_F", simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4279
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4280
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4281
definition TSTD:: "config \<Rightarrow> bool"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4282
  where
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4283
  "TSTD c = (let (st, l, r) = c in 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4284
             st = 0 \<and> (\<exists> m. l = Bk\<up>(m)) \<and> (\<exists> rs n. r = Oc\<up>(Suc rs) @ Bk\<up>(n)))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4285
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4286
lemma nstd_case1: "0 < a \<Longrightarrow> NSTD (trpl_code (a, b, c))"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4287
apply(simp add: NSTD.simps trpl_code.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4288
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4289
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: 285
diff changeset
  4290
lemma nonzero_bl2wc[simp]: "\<forall>m. b \<noteq> Bk\<up>(m) \<Longrightarrow> 0 < bl2wc b"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4291
apply(rule classical, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4292
apply(induct b, erule_tac x = 0 in allE, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4293
apply(simp add: bl2wc.simps, case_tac a, simp_all 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4294
  add: bl2nat.simps bl2nat_double)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4295
apply(case_tac "\<exists> m. b = Bk\<up>(m)",  erule exE)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4296
apply(erule_tac x = "Suc m" in allE, simp add: , simp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4297
done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4298
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4299
lemma nstd_case2: "\<forall>m. b \<noteq> Bk\<up>(m) \<Longrightarrow> NSTD (trpl_code (a, b, c))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4300
apply(simp add: NSTD.simps trpl_code.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4301
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4302
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: 285
diff changeset
  4303
lemma even_not_odd[elim]: "Suc (2 * x) = 2 * y \<Longrightarrow> RR"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4304
apply(induct x arbitrary: y, simp, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4305
apply(case_tac y, simp, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4306
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4307
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4308
declare replicate_Suc[simp del]
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4309
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4310
lemma bl2nat_zero_eq[simp]: "(bl2nat c 0 = 0) = (\<exists>n. c = Bk\<up>(n))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4311
apply(auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4312
apply(induct c, simp_all add: bl2nat.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4313
apply(case_tac a, auto simp: bl2nat.simps bl2nat_double)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4314
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4315
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4316
lemma bl2wc_exp_ex: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4317
  "\<lbrakk>Suc (bl2wc c) = 2 ^  m\<rbrakk> \<Longrightarrow> \<exists> rs n. c = Oc\<up>(rs) @ Bk\<up>(n)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4318
apply(induct c arbitrary: m, simp add: bl2wc.simps bl2nat.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4319
apply(case_tac a, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4320
apply(case_tac m, simp_all add: bl2wc.simps, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4321
apply(rule_tac x = 0 in exI, rule_tac x = "Suc n" in exI, 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4322
  simp add: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4323
apply(simp add: bl2wc.simps bl2nat.simps bl2nat_double)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4324
apply(case_tac m, simp, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4325
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4326
  fix c m nat
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4327
  assume ind: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4328
    "\<And>m. Suc (bl2nat c 0) = 2 ^ m \<Longrightarrow> \<exists>rs n. c = Oc\<up>(rs) @ Bk\<up>(n)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4329
  and h: 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4330
    "Suc (Suc (2 * bl2nat c 0)) = 2 * 2 ^ nat"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4331
  have "\<exists>rs n. c = Oc\<up>(rs) @ Bk\<up>(n)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4332
    apply(rule_tac m = nat in ind)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4333
    using h
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4334
    apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4335
    done
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4336
  from this obtain rs n where " c = Oc\<up>(rs) @ Bk\<up>(n)" by blast 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4337
  thus "\<exists>rs n. Oc # c = Oc\<up>(rs) @ Bk\<up>(n)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4338
    apply(rule_tac x = "Suc rs" in exI, simp add: )
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4339
    apply(rule_tac x = n in exI, simp add: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4340
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4341
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4342
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4343
lemma lg_bin: 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4344
  "\<lbrakk>\<forall>rs n. c \<noteq> Oc\<up>(Suc rs) @ Bk\<up>(n); 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4345
  bl2wc c = 2 ^ lg (Suc (bl2wc c)) 2 - Suc 0\<rbrakk> \<Longrightarrow> bl2wc c = 0"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4346
apply(subgoal_tac "\<exists> m. Suc (bl2wc c) = 2^m", erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4347
apply(drule_tac bl2wc_exp_ex, simp, erule_tac exE, erule_tac exE)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4348
apply(case_tac rs, simp, simp, erule_tac x = nat in allE,
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4349
  erule_tac x = n in allE, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4350
using bl2wc_exp_ex[of c "lg (Suc (bl2wc c)) 2"]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4351
apply(case_tac "(2::nat) ^ lg (Suc (bl2wc c)) 2", 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4352
  simp, simp, erule_tac exE, erule_tac exE, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4353
apply(simp add: bl2wc.simps)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4354
apply(rule_tac x = rs in exI)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4355
apply(case_tac "(2::nat)^rs", simp, simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4356
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4357
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4358
lemma nstd_case3: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4359
  "\<forall>rs n. c \<noteq> Oc\<up>(Suc rs) @ Bk\<up>(n) \<Longrightarrow>  NSTD (trpl_code (a, b, c))"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4360
apply(simp add: NSTD.simps trpl_code.simps)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4361
apply(auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4362
apply(drule_tac lg_bin, simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4363
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4364
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4365
lemma NSTD_1: "\<not> TSTD (a, b, c)
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4366
    \<Longrightarrow> rec_exec rec_NSTD [trpl_code (a, b, c)] = Suc 0"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4367
  using NSTD_lemma1[of "trpl_code (a, b, c)"]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4368
       NSTD_lemma2[of "trpl_code (a, b, c)"]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4369
  apply(simp add: TSTD_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4370
  apply(erule_tac disjE, erule_tac nstd_case1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4371
  apply(erule_tac disjE, erule_tac nstd_case2)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4372
  apply(erule_tac nstd_case3)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4373
  done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4374
 
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4375
lemma nonstop_t_uhalt_eq:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4376
  "\<lbrakk>tm_wf (tp, 0);
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4377
  steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp = (a, b, c);
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4378
  \<not> TSTD (a, b, c)\<rbrakk>
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4379
  \<Longrightarrow> rec_exec rec_nonstop [code tp, bl2wc (<lm>), stp] = Suc 0"
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4380
apply(simp add: rec_nonstop_def rec_exec.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4381
apply(subgoal_tac 
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4382
  "rec_exec rec_conf [code tp, bl2wc (<lm>), stp] =
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4383
  trpl_code (a, b, c)", simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4384
apply(erule_tac NSTD_1)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4385
using rec_t_eq_steps[of tp l lm stp]
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4386
apply(simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4387
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4388
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4389
lemma nonstop_true:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4390
  "\<lbrakk>tm_wf (tp, 0);
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4391
  \<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp))\<rbrakk>
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4392
  \<Longrightarrow> \<forall>y. rec_exec rec_nonstop ([code tp, bl2wc (<lm>), y]) =  (Suc 0)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4393
apply(rule_tac allI, erule_tac x = y in allE)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4394
apply(case_tac "steps0 (Suc 0, Bk\<up>(l), <lm>) tp y", simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4395
apply(rule_tac nonstop_t_uhalt_eq, simp_all)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4396
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4397
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4398
lemma cn_arity:  "rec_ci (Cn n f gs) = (a, b, c) \<Longrightarrow> b = n"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4399
by(case_tac "rec_ci f", simp add: rec_ci.simps)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4400
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4401
lemma mn_arity: "rec_ci (Mn n f) = (a, b, c) \<Longrightarrow> b = n"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4402
by(case_tac "rec_ci f", simp add: rec_ci.simps)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4403
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4404
lemma F_aprog_uhalt: 
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4405
  assumes wf_tm: "tm_wf (tp,0)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4406
   and unhalt:  "\<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp))"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4407
   and compile: "rec_ci rec_F = (F_ap, rs_pos, a_md)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4408
 shows "{\<lambda> nl. nl = [code tp, bl2wc (<lm>)] @ 0\<up>(a_md - rs_pos ) @ suflm} (F_ap) \<up>"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4409
  using compile
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4410
proof(simp only: rec_F_def)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4411
  assume h: "rec_ci (Cn (Suc (Suc 0)) rec_valu [Cn (Suc (Suc 0)) rec_right [Cn (Suc (Suc 0)) 
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4412
    rec_conf [recf.id (Suc (Suc 0)) 0, recf.id (Suc (Suc 0)) (Suc 0), rec_halt]]]) =
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4413
    (F_ap, rs_pos, a_md)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4414
  moreover hence "rs_pos = Suc (Suc 0)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4415
    using cn_arity 
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4416
    by simp
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4417
  moreover obtain ap1 ar1 ft1 where a: "rec_ci 
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4418
    (Cn (Suc (Suc 0)) rec_right 
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4419
    [Cn (Suc (Suc 0)) rec_conf [recf.id (Suc (Suc 0)) 0, recf.id (Suc (Suc 0)) (Suc 0), rec_halt]]) = (ap1, ar1, ft1)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4420
    by(case_tac "rec_ci (Cn (Suc (Suc 0)) rec_right [Cn (Suc (Suc 0)) 
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4421
      rec_conf [recf.id (Suc (Suc 0)) 0, recf.id (Suc (Suc 0)) (Suc 0), rec_halt]])", auto)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4422
  moreover hence b: "ar1 = Suc (Suc 0)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4423
    using cn_arity by simp
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4424
  ultimately show "?thesis"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4425
  proof(rule_tac i = 0 in cn_unhalt_case, auto)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4426
    fix anything
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4427
    obtain ap2 ar2 ft2 where c: 
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4428
      "rec_ci (Cn (Suc (Suc 0)) rec_conf [recf.id (Suc (Suc 0)) 0, recf.id (Suc (Suc 0)) (Suc 0), rec_halt])
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4429
      = (ap2, ar2, ft2)" 
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4430
      by(case_tac "rec_ci (Cn (Suc (Suc 0)) rec_conf
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4431
        [recf.id (Suc (Suc 0)) 0, recf.id (Suc (Suc 0)) (Suc 0), rec_halt])", auto)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4432
    moreover hence d:"ar2 = Suc (Suc 0)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4433
      using cn_arity by simp
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4434
    ultimately have "{\<lambda>nl. nl = [code tp, bl2wc (<lm>)] @ 0 \<up> (ft1 - Suc (Suc 0)) @ anything} ap1 \<up>"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4435
      using a b c d
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4436
    proof(rule_tac i = 0 in cn_unhalt_case, auto)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4437
      fix anything
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4438
      obtain ap3 ar3 ft3 where e: "rec_ci rec_halt = (ap3, ar3, ft3)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4439
        by(case_tac "rec_ci rec_halt", auto)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4440
      hence f: "ar3 = Suc (Suc 0)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4441
        using mn_arity
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4442
        by(simp add: rec_halt_def)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4443
      have "{\<lambda>nl. nl = [code tp, bl2wc (<lm>)] @ 0 \<up> (ft2 - Suc (Suc 0)) @ anything} ap2 \<up>"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4444
        using c d e f
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4445
      proof(rule_tac i = 2 in cn_unhalt_case, auto simp: rec_halt_def)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4446
        fix anything
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4447
        have "{\<lambda>nl. nl = [code tp, bl2wc (<lm>)] @ 0 \<up> (ft3 - Suc (Suc 0)) @ anything} ap3 \<up>"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4448
          using e f
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4449
        proof(rule_tac mn_unhalt_case, auto simp: rec_halt_def)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4450
          fix i
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4451
          show "terminate rec_nonstop [code tp, bl2wc (<lm>), i]"
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4452
            by(rule_tac primerec_terminate, auto)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4453
        next
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4454
          fix i
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4455
          show "0 < rec_exec rec_nonstop [code tp, bl2wc (<lm>), i]"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4456
            using assms
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4457
            by(drule_tac nonstop_true, auto)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4458
        qed
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4459
        thus "{\<lambda>nl. nl = code tp # bl2wc (<lm>) # 0 \<up> (ft3 - Suc (Suc 0)) @ anything} ap3 \<up>" by simp
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4460
      next
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4461
        fix apj arj ftj j  anything
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4462
        assume "j<2" "rec_ci ([recf.id (Suc (Suc 0)) 0, recf.id (Suc (Suc 0)) (Suc 0), Mn (Suc (Suc 0)) rec_nonstop] ! j) = (apj, arj, ftj)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4463
        hence "{\<lambda>nl. nl = [code tp, bl2wc (<lm>)] @ 0 \<up> (ftj - arj) @ anything} apj
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4464
          {\<lambda>nl. nl = [code tp, bl2wc (<lm>)] @
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4465
            rec_exec ([recf.id (Suc (Suc 0)) 0, recf.id (Suc (Suc 0)) (Suc 0), Mn (Suc (Suc 0)) rec_nonstop] ! j) [code tp, bl2wc (<lm>)] # 
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4466
               0 \<up> (ftj - Suc arj) @ anything}"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4467
          apply(rule_tac recursive_compile_correct)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4468
          apply(case_tac j, auto)
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4469
          apply(rule_tac [!] primerec_terminate)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4470
          by(auto)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4471
        thus "{\<lambda>nl. nl = code tp # bl2wc (<lm>) # 0 \<up> (ftj - arj) @ anything} apj
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4472
          {\<lambda>nl. nl = code tp # bl2wc (<lm>) # rec_exec ([recf.id (Suc (Suc 0)) 0, recf.id (Suc (Suc 0))
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4473
          (Suc 0), Mn (Suc (Suc 0)) rec_nonstop] ! j) [code tp, bl2wc (<lm>)] # 0 \<up> (ftj - Suc arj) @ anything}"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4474
          by simp
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4475
      next
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4476
        fix j
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4477
        assume "(j::nat) < 2"
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4478
        thus "terminate ([recf.id (Suc (Suc 0)) 0, recf.id (Suc (Suc 0)) (Suc 0), Mn (Suc (Suc 0)) rec_nonstop] ! j)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4479
          [code tp, bl2wc (<lm>)]"
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 240
diff changeset
  4480
          by(case_tac j, auto intro!: primerec_terminate)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4481
      qed
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4482
      thus "{\<lambda>nl. nl = code tp # bl2wc (<lm>) # 0 \<up> (ft2 - Suc (Suc 0)) @ anything} ap2 \<up>"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4483
        by simp
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4484
    qed
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4485
    thus "{\<lambda>nl. nl = code tp # bl2wc (<lm>) # 0 \<up> (ft1 - Suc (Suc 0)) @ anything} ap1 \<up>" by simp
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4486
  qed
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4487
qed
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4488
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4489
lemma uabc_uhalt': 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4490
  "\<lbrakk>tm_wf (tp, 0);
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4491
  \<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp));
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4492
  rec_ci rec_F = (ap, pos, md)\<rbrakk>
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4493
  \<Longrightarrow> {\<lambda> nl. nl = [code tp, bl2wc (<lm>)]} ap \<up>"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4494
proof(frule_tac F_ap = ap and rs_pos = pos and a_md = md
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4495
    and suflm = "[]" in F_aprog_uhalt, auto simp: abc_Hoare_unhalt_def, 
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4496
     case_tac "abc_steps_l (0, [code tp, bl2wc (<lm>)]) ap n", simp)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4497
  fix n a b
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4498
  assume h: 
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4499
    "\<forall>n. abc_notfinal (abc_steps_l (0, code tp # bl2wc (<lm>) # 0 \<up> (md - pos)) ap n) ap"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4500
    "abc_steps_l (0, [code tp, bl2wc (<lm>)]) ap n = (a, b)" 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4501
    "tm_wf (tp, 0)" 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4502
    "rec_ci rec_F = (ap, pos, md)"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4503
  moreover have a: "ap \<noteq> []"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4504
    using h rec_ci_not_null[of "rec_F" pos md] by auto
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4505
  ultimately show "a < length ap"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4506
  proof(erule_tac x = n in allE)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4507
    assume g: "abc_notfinal (abc_steps_l (0, code tp # bl2wc (<lm>) # 0 \<up> (md - pos)) ap n) ap"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4508
    obtain ss nl where b : "abc_steps_l (0, code tp # bl2wc (<lm>) # 0 \<up> (md - pos)) ap n = (ss, nl)"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4509
      by (metis prod.exhaust)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4510
    then have c: "ss < length ap"
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4511
      using g by simp
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4512
    thus "?thesis"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4513
      using a b c
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4514
      using abc_list_crsp_steps[of "[code tp, bl2wc (<lm>)]"
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4515
                                   "md - pos" ap n ss nl] h
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4516
      by(simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4517
  qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4518
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4519
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4520
lemma uabc_uhalt: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4521
  "\<lbrakk>tm_wf (tp, 0); 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4522
  \<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp))\<rbrakk>
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4523
  \<Longrightarrow> {\<lambda> nl. nl = [code tp, bl2wc (<lm>)]} F_aprog \<up> "
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4524
apply(case_tac "rec_ci rec_F", simp add: F_aprog_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4525
apply(drule_tac ap = a and pos = b and md = c in uabc_uhalt', simp_all)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4526
apply(rule_tac abc_Hoare_plus_unhalt1, simp)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4527
done
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4528
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4529
lemma tutm_uhalt': 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4530
assumes tm_wf:  "tm_wf (tp,0)"
170
eccd79a974ae updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
  4531
  and unhalt: "\<forall> stp. (\<not> TSTD (steps0 (1, Bk\<up>(l), <lm>) tp stp))"
eccd79a974ae updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
  4532
  shows "\<forall> stp. \<not> is_final (steps0 (1, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp)"
eccd79a974ae updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
  4533
unfolding t_utm_def
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4534
proof(rule_tac compile_correct_unhalt, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4535
  show "F_tprog = tm_of F_aprog"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4536
    by(simp add:  F_tprog_def)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4537
next
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4538
  show "crsp (layout_of F_aprog) (0, [code tp, bl2wc (<lm>)]) (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>)  []"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4539
    by(auto simp: crsp.simps start_of.simps)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4540
next
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4541
  fix stp a b
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4542
  show "abc_steps_l (0, [code tp, bl2wc (<lm>)]) F_aprog stp = (a, b) \<Longrightarrow> a < length F_aprog"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4543
    using assms
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4544
    apply(drule_tac uabc_uhalt, auto simp: abc_Hoare_unhalt_def)
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4545
    by(erule_tac x = stp in allE, erule_tac x = stp in allE, simp) 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4546
qed
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4547
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4548
lemma tinres_commute: "tinres r r' \<Longrightarrow> tinres r' r"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4549
apply(auto simp: tinres_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4550
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4551
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4552
lemma inres_tape:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4553
  "\<lbrakk>steps0 (st, l, r) tp stp = (a, b, c); steps0 (st, l', r') tp stp = (a', b', c'); 
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4554
  tinres l l'; tinres r r'\<rbrakk>
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4555
  \<Longrightarrow> a = a' \<and> tinres b b' \<and> tinres c c'"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4556
proof(case_tac "steps0 (st, l', r) tp stp")
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4557
  fix aa ba ca
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4558
  assume h: "steps0 (st, l, r) tp stp = (a, b, c)" 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4559
            "steps0 (st, l', r') tp stp = (a', b', c')"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4560
            "tinres l l'" "tinres r r'"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4561
            "steps0 (st, l', r) tp stp = (aa, ba, ca)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4562
  have "tinres b ba \<and> c = ca \<and> a = aa"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4563
    using h
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4564
    apply(rule_tac tinres_steps1, auto)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4565
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4566
  moreover have "b' = ba \<and> tinres c' ca \<and> a' =  aa"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4567
    using h
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4568
    apply(rule_tac tinres_steps2, auto intro: tinres_commute)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4569
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4570
  ultimately show "?thesis"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4571
    apply(auto intro: tinres_commute)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4572
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4573
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4574
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4575
lemma tape_normalize: "\<forall> stp. \<not> is_final(steps0 (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4576
      \<Longrightarrow> \<forall> stp. \<not> is_final (steps0 (Suc 0, Bk\<up>(m), <[code tp, bl2wc (<lm>)]> @ Bk\<up>(n)) t_utm stp)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4577
apply(rule_tac allI, case_tac "(steps0 (Suc 0, Bk\<up>(m), 
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4578
               <[code tp, bl2wc (<lm>)]> @ Bk\<up>(n)) t_utm stp)", simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4579
apply(erule_tac x = stp in allE)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4580
apply(case_tac "steps0 (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp", simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4581
apply(drule_tac inres_tape, auto)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4582
apply(auto simp: tinres_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4583
apply(case_tac "m > Suc (Suc 0)")
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4584
apply(rule_tac x = "m - Suc (Suc 0)" in exI) 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4585
apply(case_tac m, simp_all add: , case_tac nat, simp_all add: replicate_Suc)
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4586
apply(rule_tac x = "2 - m" in exI, simp add: replicate_add[THEN sym])
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4587
apply(simp only: numeral_2_eq_2, simp add: replicate_Suc)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4588
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4589
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4590
lemma tutm_uhalt: 
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4591
  "\<lbrakk>tm_wf (tp,0);
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4592
    \<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <args>) tp stp))\<rbrakk>
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4593
  \<Longrightarrow> \<forall> stp. \<not> is_final (steps0 (Suc 0, Bk\<up>(m), <[code tp, bl2wc (<args>)]> @ Bk\<up>(n)) t_utm stp)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4594
apply(rule_tac tape_normalize)
170
eccd79a974ae updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 169
diff changeset
  4595
apply(rule_tac tutm_uhalt'[simplified], simp_all)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4596
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4597
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4598
lemma UTM_uhalt_lemma_pre:
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4599
  assumes tm_wf: "tm_wf (tp, 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4600
  and exec: "\<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <args>) tp stp))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4601
  and args: "args \<noteq> []"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4602
  shows "\<forall> stp. \<not> is_final (steps0 (Suc 0, [], <code tp # args>)  UTM_pre stp)"
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4603
proof -
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4604
  let ?P1 = "\<lambda> (l, r). l = [] \<and> r = <code tp # args>"
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4605
  let ?Q1 = "\<lambda> (l, r). (l = [Bk] \<and>
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4606
             (\<exists> rn. r = Oc\<up>(Suc (code tp)) @ Bk # Oc\<up>(Suc (bl_bin (<args>))) @ Bk\<up>(rn)))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4607
  let ?P2 = ?Q1
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4608
  have "{?P1} (t_wcode |+| t_utm) \<up>"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4609
  proof(rule_tac Hoare_plus_unhalt)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4610
    show "tm_wf (t_wcode, 0)" by auto
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4611
  next
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4612
    show "{?P1} t_wcode {?Q1}"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  4613
      apply(rule_tac Hoare_haltI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4614
      using wcode_lemma_1[of args "code tp"] args
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4615
      apply(auto)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4616
      apply(rule_tac x = stp in exI, simp)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4617
      done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4618
  next
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4619
    show "{?P2} t_utm \<up>"
139
7cb94089324e updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 133
diff changeset
  4620
    proof(rule_tac Hoare_unhaltI, auto)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4621
      fix n rn
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4622
      assume h: "is_final (steps0 (Suc 0, [Bk], Oc \<up> Suc (code tp) @ Bk # Oc \<up> Suc (bl_bin (<args>)) @ Bk \<up> rn) t_utm n)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4623
      have "\<forall> stp. \<not> is_final (steps0 (Suc 0, Bk\<up>(Suc 0), <[code tp, bl2wc (<args>)]> @ Bk\<up>(rn)) t_utm stp)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4624
        using assms
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4625
        apply(rule_tac tutm_uhalt, simp_all)
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4626
        done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4627
      thus "False"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4628
        using h
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4629
        apply(erule_tac x = n in allE)
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: 285
diff changeset
  4630
        apply(simp add: tape_of_list_def bin_wc_eq tape_of_nat_def)
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4631
        done
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4632
    qed
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4633
  qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4634
  thus "?thesis"
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4635
    apply(simp add: Hoare_unhalt_def UTM_pre_def)
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4636
    done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4637
qed
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4638
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4639
text {*
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4640
  The correctness of @{text "UTM"}, the unhalt case.
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4641
  *}
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4642
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4643
lemma UTM_uhalt_lemma':
131
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4644
  assumes tm_wf: "tm_wf (tp, 0)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4645
  and unhalt: "\<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <args>) tp stp))"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4646
  and args: "args \<noteq> []"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4647
  shows " \<forall> stp. \<not> is_final (steps0 (Suc 0, [], <code tp # args>)  UTM stp)"
e995ae949731 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 130
diff changeset
  4648
  using UTM_uhalt_lemma_pre[of tp l args] assms
130
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4649
apply(simp add: UTM_pre_def t_utm_def UTM_def F_aprog_def F_tprog_def)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4650
apply(case_tac "rec_ci rec_F", simp)
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4651
done
1e89c65f844b added UTM
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  4652
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4653
lemma UTM_halt_lemma:
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4654
  assumes tm_wf: "tm_wf (p, 0)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4655
  and resut: "rs > 0"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4656
  and args: "(args::nat list) \<noteq> []"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4657
  and exec: "{(\<lambda>tp. tp = (Bk\<up>i, <args>))} p {(\<lambda>tp. tp = (Bk\<up>m, Oc\<up>rs @ Bk\<up>k))}" 
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4658
  shows "{(\<lambda>tp. tp = ([], <code p # args>))} UTM {(\<lambda>tp. (\<exists> m n. tp = (Bk\<up>m, Oc\<up>rs @ Bk\<up>n)))}"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4659
proof -
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4660
  have "{(\<lambda> (l, r). l = [] \<and> r = <code p # args>)} (t_wcode |+| t_utm)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4661
          {(\<lambda> (l, r). (\<exists> m. l = Bk\<up>m) \<and> (\<exists> n. r = Oc\<up>rs @ Bk\<up>n))}"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4662
  proof(rule_tac Hoare_plus_halt)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4663
    show "{\<lambda>(l, r). l = [] \<and> r = <code p # args>} t_wcode {\<lambda> (l, r). (l = [Bk] \<and>
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4664
    (\<exists> rn. r = Oc\<up>(Suc (code p)) @ Bk # Oc\<up>(Suc (bl_bin (<args>))) @ Bk\<up>(rn)))}"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4665
      apply(rule_tac Hoare_haltI, auto)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4666
      using wcode_lemma_1[of args "code p"] args
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4667
      apply(auto)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4668
      apply(rule_tac x = stp in exI, simp)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4669
      done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4670
  next
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4671
    have "\<exists> stp. steps0 (Suc 0, Bk\<up>i, <args>) p stp = (0, Bk\<up>m, Oc\<up>rs @ Bk\<up>k)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4672
      using exec
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4673
      apply(simp add: Hoare_halt_def, auto)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4674
      apply(case_tac "steps0 (Suc 0, Bk \<up> i, <args>) p n", simp)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4675
      apply(rule_tac x = n in exI, simp)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4676
      done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4677
    then obtain stp where k: "steps0 (Suc 0, Bk\<up>i, <args>) p stp = (0, Bk\<up>m, Oc\<up>rs @ Bk\<up>k)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4678
      ..
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4679
    thus "{\<lambda>(l, r). l = [Bk] \<and> (\<exists>rn. r = Oc \<up> Suc (code p) @ Bk # Oc \<up> Suc (bl_bin (<args>)) @ Bk \<up> rn)}
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4680
      t_utm {\<lambda>(l, r). (\<exists>m. l = Bk \<up> m) \<and> (\<exists>n. r = Oc \<up> rs @ Bk \<up> n)}"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4681
    proof(rule_tac Hoare_haltI, auto)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4682
      fix rn
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4683
      show "\<exists>n. is_final (steps0 (Suc 0, [Bk], Oc \<up> Suc (code p) @ Bk # Oc \<up> Suc (bl_bin (<args>)) @ Bk \<up> rn) t_utm n) \<and>
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4684
             (\<lambda>(l, r). (\<exists>m. l = Bk \<up> m) \<and> (\<exists>n. r = Oc \<up> rs @ Bk \<up> n)) holds_for steps0 
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4685
         (Suc 0, [Bk], Oc \<up> Suc (code p) @ Bk # Oc \<up> Suc (bl_bin (<args>)) @ Bk \<up> rn) t_utm n"      
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4686
        using t_utm_halt_eq[of p i "args" stp m rs k rn] assms k
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4687
        apply(auto simp: bin_wc_eq, 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: 285
diff changeset
  4688
        apply(rule_tac x = stpa in exI, simp add: tape_of_list_def tape_of_nat_def)
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4689
        done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4690
    qed
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4691
  next
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4692
    show "tm_wf0 t_wcode" by auto
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4693
  qed
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4694
  thus "?thesis"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4695
    apply(case_tac "rec_ci rec_F")
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4696
    apply(simp add: UTM_def t_utm_def F_aprog_def F_tprog_def)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4697
    apply(auto simp add: Hoare_halt_def)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4698
    apply(rule_tac x="n" in exI)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4699
    apply(auto)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4700
    apply(case_tac "(steps0 (Suc 0, [], <code p # args>)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4701
           (t_wcode |+| ((tm_of (a [+] dummy_abc (Suc (Suc 0)))) @
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4702
                        shift (mopup (Suc (Suc 0)))
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4703
                         (length (tm_of (a [+] dummy_abc (Suc (Suc 0)))) div
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4704
                          2))) n)")
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4705
    apply(simp)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4706
    done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4707
qed
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4708
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4709
lemma UTM_halt_lemma2:
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4710
  assumes tm_wf: "tm_wf (p, 0)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4711
  and args: "(args::nat list) \<noteq> []"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4712
  and exec: "{(\<lambda>tp. tp = ([], <args>))} p {(\<lambda>tp. tp = (Bk\<up>m, <(n::nat)> @ Bk\<up>k))}" 
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4713
  shows "{(\<lambda>tp. tp = ([], <code p # args>))} UTM {(\<lambda>tp. (\<exists> m k. tp = (Bk\<up>m, <n> @ Bk\<up>k)))}"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4714
using UTM_halt_lemma[OF assms(1) _ assms(2), where i="0"]
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4715
using assms(3)
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: 285
diff changeset
  4716
apply(simp add: tape_of_nat_def)
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4717
done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4718
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4719
    
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4720
lemma UTM_unhalt_lemma: 
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4721
  assumes tm_wf: "tm_wf (p, 0)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4722
  and unhalt: "{(\<lambda>tp. tp = (Bk\<up>i, <args>))} p \<up>"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4723
  and args: "args \<noteq> []"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4724
  shows "{(\<lambda>tp. tp = ([], <code p # args>))} UTM \<up>"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4725
proof -
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4726
  have "\<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(i), <args>) p stp))"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4727
    using unhalt
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4728
    apply(auto simp: Hoare_unhalt_def)    
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4729
    apply(case_tac "steps0 (Suc 0, Bk \<up> i, <args>) p stp", simp)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4730
    apply(erule_tac x = stp in allE, simp add: TSTD_def)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4731
    done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4732
  then have "\<forall> stp. \<not> is_final (steps0 (Suc 0, [], <code p # args>)  UTM stp)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4733
    using assms
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4734
    apply(rule_tac  UTM_uhalt_lemma', simp_all)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4735
    done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4736
  thus "?thesis"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4737
    apply(simp add: Hoare_unhalt_def)
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4738
    done
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4739
qed
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4740
    
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4741
lemma UTM_unhalt_lemma2: 
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4742
  assumes tm_wf: "tm_wf (p, 0)"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4743
  and unhalt: "{(\<lambda>tp. tp = ([], <args>))} p \<up>"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4744
  and args: "args \<noteq> []"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4745
  shows "{(\<lambda>tp. tp = ([], <code p # args>))} UTM \<up>"
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4746
using UTM_unhalt_lemma[OF assms(1), where i="0"]
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4747
using assms(2-3)
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: 285
diff changeset
  4748
apply(simp add: tape_of_nat_def)
145
38d8e0e37b7d updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 139
diff changeset
  4749
done
229
d8e6f0798e23 much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 190
diff changeset
  4750
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: 285
diff changeset
  4751
end