thys2/UF_Rec.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 17 Jul 2013 10:33:19 +0100
changeset 271 4457185b22ef
parent 269 fa40fd8abb54
child 284 a21fb87bb0bd
permissions -rwxr-xr-x
added slides
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
theory UF_Rec
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
     2
imports Recs Turing2
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
begin
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
     5
section {* Coding of Turing Machines and Tapes*}
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
     7
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
     8
fun actnum :: "action \<Rightarrow> nat"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
     9
  where
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    10
  "actnum W0 = 0"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    11
| "actnum W1 = 1"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    12
| "actnum L  = 2"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    13
| "actnum R  = 3"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    14
| "actnum Nop = 4"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    15
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    16
fun cellnum :: "cell \<Rightarrow> nat" where
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    17
  "cellnum Bk = 0"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    18
| "cellnum Oc = 1"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    19
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    20
text {* Coding tapes *}
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    21
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    22
fun code_tp :: "cell list \<Rightarrow> nat list"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    23
  where
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    24
  "code_tp [] = []"
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    25
| "code_tp (c # tp) = (cellnum c) # code_tp tp"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    26
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    27
fun Code_tp where
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    28
  "Code_tp tp = lenc (code_tp tp)"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    29
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
    30
lemma code_tp_append [simp]:
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
    31
  "code_tp (tp1 @ tp2) = code_tp tp1 @ code_tp tp2"
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
    32
by(induct tp1) (simp_all)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
    33
260
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    34
lemma code_tp_length [simp]:
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    35
  "length (code_tp tp) = length tp"
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    36
by (induct tp) (simp_all)
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    37
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    38
lemma code_tp_nth [simp]:
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    39
  "n < length tp \<Longrightarrow> (code_tp tp) ! n = cellnum (tp ! n)"
260
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    40
apply(induct n arbitrary: tp) 
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    41
apply(simp_all)
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    42
apply(case_tac [!] tp)
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    43
apply(simp_all)
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    44
done
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
    45
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
    46
lemma code_tp_replicate [simp]:
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    47
  "code_tp (c \<up> n) = (cellnum c) \<up> n"
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
    48
by(induct n) (simp_all)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
    49
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    50
text {* Coding Configurations and TMs *}
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
    51
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    52
fun Code_conf where
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    53
  "Code_conf (s, l, r) = (s, Code_tp l, Code_tp r)"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    54
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    55
fun code_instr :: "instr \<Rightarrow> nat" where
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    56
  "code_instr i = penc (actnum (fst i)) (snd i)"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    57
  
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    58
fun Code_instr :: "instr \<times> instr \<Rightarrow> nat" where
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    59
  "Code_instr i = penc (code_instr (fst i)) (code_instr (snd i))"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    60
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    61
fun code_tprog :: "tprog \<Rightarrow> nat list"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    62
  where
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    63
  "code_tprog [] =  []"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    64
| "code_tprog (i # tm) = Code_instr i # code_tprog tm"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    65
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    66
lemma code_tprog_length [simp]:
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    67
  "length (code_tprog tp) = length tp"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    68
by (induct tp) (simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    69
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    70
lemma code_tprog_nth [simp]:
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    71
  "n < length tp \<Longrightarrow> (code_tprog tp) ! n = Code_instr (tp ! n)"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    72
by (induct tp arbitrary: n) (simp_all add: nth_Cons')
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    73
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    74
fun Code_tprog :: "tprog \<Rightarrow> nat"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    75
  where 
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    76
  "Code_tprog tm = lenc (code_tprog tm)"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    79
section {* An Universal Function in HOL *}
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    80
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    81
text {* Reading and writing the encoded tape *}
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    83
fun Read where
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    84
  "Read tp = ldec tp 0"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
    85
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    86
fun Write where
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    87
  "Write n tp = penc (Suc n) (pdec2 tp)"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    89
text {* 
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    90
  The @{text Newleft} and @{text Newright} functions on page 91 of B book. 
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    91
  They calculate the new left and right tape (@{text p} and @{text r}) 
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
    92
  according to an action @{text a}. Adapted to our encoding functions.
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
    93
*}
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
fun Newleft :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat"
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
  where
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    97
  "Newleft l r a = (if a = 0 then l else 
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    98
                    if a = 1 then l else 
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
    99
                    if a = 2 then pdec2 l else 
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   100
                    if a = 3 then penc (Suc (Read r)) l
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   101
                    else l)"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
fun Newright :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat"
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
  where
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   105
  "Newright l r a  = (if a = 0 then Write 0 r
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   106
                      else if a = 1 then Write 1 r
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   107
                      else if a = 2 then penc (Suc (Read l)) r
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   108
                      else if a = 3 then pdec2 r
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
                      else r)"
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
text {*
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   112
  The @{text "Action"} function given on page 92 of B book, which is used to 
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   113
  fetch Turing Machine intructions. In @{text "Action m q r"}, @{text "m"} is 
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   114
  the code of the Turing Machine, @{text "q"} is the current state of 
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   115
  Turing Machine, and @{text "r"} is the scanned cell of is the right tape. 
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   116
*}
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   117
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   118
fun Actn :: "nat \<Rightarrow> nat \<Rightarrow> nat" where
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   119
  "Actn n 0 = pdec1 (pdec1 n)"
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   120
| "Actn n _ = pdec1 (pdec2 n)"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   121
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   122
fun Action :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
  where
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   124
  "Action m q c = (if q \<noteq> 0 \<and> within m (q - 1) then Actn (ldec m (q - 1)) c else 4)"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   125
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   126
fun Newstat :: "nat \<Rightarrow> nat \<Rightarrow> nat" where
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   127
  "Newstat n 0 = pdec2 (pdec1 n)"
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   128
| "Newstat n _ = pdec2 (pdec2 n)"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   130
fun Newstate :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
  where
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   132
  "Newstate m q r = (if q \<noteq> 0 then Newstat (ldec m (q - 1)) r else 0)"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   133
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   134
fun Conf :: "nat \<times> (nat \<times> nat) \<Rightarrow> nat"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   135
  where
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   136
  "Conf (q, l, r) = lenc [q, l, r]"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   137
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   138
fun State where
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   139
  "State cf = ldec cf 0"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   140
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
fun Left where
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   142
  "Left cf = ldec cf 1"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
fun Right where
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   145
  "Right cf = ldec cf 2"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   147
text {*
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   148
  @{text "Steps cf m k"} computes the TM configuration after @{text "k"} steps of 
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   149
  execution of TM coded as @{text "m"}. @{text Step} is a single step of the TM.
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   150
*}
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   151
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   152
fun Step :: "nat \<Rightarrow> nat \<Rightarrow> nat"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
  where
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   154
  "Step cf m = Conf (Newstate m (State cf) (Read (Right cf)), 
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   155
                     Newleft (Left cf) (Right cf) (Action m (State cf) (Read (Right cf))),
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   156
                     Newright (Left cf) (Right cf) (Action m (State cf) (Read (Right cf))))"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   157
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   158
fun Steps :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
  where
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   160
  "Steps cf p 0  = cf"
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   161
| "Steps cf p (Suc n) = Steps (Step cf p) p n"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   162
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   163
lemma Step_Steps_comm:
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   164
  "Step (Steps cf p n) p = Steps (Step cf p) p n"
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   165
by (induct n arbitrary: cf) (simp_all only: Steps.simps)
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   166
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   167
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   168
text {* Decoding tapes back into numbers. *}
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   169
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   170
definition Stknum :: "nat \<Rightarrow> nat"
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   171
  where
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   172
  "Stknum z \<equiv> (\<Sum>i < enclen z. ldec z i)"
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   173
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   174
lemma Stknum_append:
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   175
  "Stknum (Code_tp (tp1 @ tp2)) = Stknum (Code_tp tp1) + Stknum (Code_tp tp2)"
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   176
apply(simp only: Code_tp.simps)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   177
apply(simp only: code_tp_append)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   178
apply(simp only: Stknum_def)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   179
apply(simp only: enclen_length length_append code_tp_length)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   180
apply(simp only: list_encode_inverse)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   181
apply(simp only: enclen_length length_append code_tp_length)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   182
apply(simp)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   183
apply(subgoal_tac "{..<length tp1 + length tp2} = {..<length tp1} \<union> {length tp1 ..<length tp1 + length tp2}")
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   184
prefer 2
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   185
apply(auto)[1]
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   186
apply(simp only:)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   187
apply(subst setsum_Un_disjoint)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   188
apply(auto)[2]
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   189
apply (metis ivl_disj_int_one(2))
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   190
apply(simp add: nth_append)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   191
apply(subgoal_tac "{length tp1..<length tp1 + length tp2} = (\<lambda>x. x + length tp1) ` {0..<length tp2}")
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   192
prefer 2
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   193
apply(simp only: image_add_atLeastLessThan)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   194
apply (metis comm_monoid_add_class.add.left_neutral nat_add_commute)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   195
apply(simp only:)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   196
apply(subst setsum_reindex)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   197
prefer 2
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   198
apply(simp add: comp_def)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   199
apply (metis atLeast0LessThan)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   200
apply(simp add: inj_on_def)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   201
done
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   202
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   203
lemma Stknum_up:
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   204
  "Stknum (lenc (a \<up> n)) = n * a"
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   205
apply(induct n)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   206
apply(simp_all add: Stknum_def list_encode_inverse del: replicate.simps)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   207
done
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   208
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   209
lemma result:
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   210
  "Stknum (Code_tp (<n> @ Bk \<up> l)) - 1 = n"
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   211
apply(simp only: Stknum_append)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   212
apply(simp only: tape_of_nat.simps)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   213
apply(simp only: Code_tp.simps)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   214
apply(simp only: code_tp_replicate)
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   215
apply(simp only: cellnum.simps)
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   216
apply(simp only: Stknum_up)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   217
apply(simp)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   218
done
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   219
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   220
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   221
section  {* Standard Tapes *}
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   222
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   223
definition
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   224
  "right_std z \<equiv> (\<exists>i \<le> enclen z. 1 \<le> i \<and> (\<forall>j < i. ldec z j = 1) \<and> (\<forall>j < enclen z - i. ldec z (i + j) = 0))"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   225
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   226
definition
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   227
  "left_std z \<equiv> (\<forall>j < enclen z. ldec z j = 0)"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   228
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   229
lemma ww:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   230
 "(\<exists>k l. 1 \<le> k \<and> tp = Oc \<up> k @ Bk \<up> l) \<longleftrightarrow> 
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   231
  (\<exists>i\<le>length tp. 1 \<le> i \<and> (\<forall>j < i. tp ! j = Oc) \<and> (\<forall>j < length tp - i. tp ! (i + j) = Bk))"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   232
apply(rule iffI)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   233
apply(erule exE)+
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   234
apply(simp)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   235
apply(rule_tac x="k" in exI)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   236
apply(auto)[1]
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   237
apply(simp add: nth_append)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   238
apply(simp add: nth_append)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   239
apply(erule exE)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   240
apply(rule_tac x="i" in exI)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   241
apply(rule_tac x="length tp - i" in exI)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   242
apply(auto)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   243
apply(rule sym)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   244
apply(subst append_eq_conv_conj)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   245
apply(simp)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   246
apply(rule conjI)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   247
apply (smt length_replicate length_take nth_equalityI nth_replicate nth_take)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   248
by (smt length_drop length_replicate nth_drop nth_equalityI nth_replicate)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   249
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   250
lemma right_std:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   251
  "(\<exists>k l. 1 \<le> k \<and> tp = Oc \<up> k @ Bk \<up> l) \<longleftrightarrow> right_std (Code_tp tp)"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   252
apply(simp only: ww)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   253
apply(simp add: right_std_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   254
apply(simp only: list_encode_inverse)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   255
apply(simp)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   256
apply(auto)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   257
apply(rule_tac x="i" in exI)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   258
apply(simp)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   259
apply(rule conjI)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   260
apply (metis Suc_eq_plus1 Suc_neq_Zero cellnum.cases cellnum.simps(1) leD less_trans linorder_neqE_nat)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   261
apply(auto)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   262
by (metis One_nat_def cellnum.cases cellnum.simps(2) less_diff_conv n_not_Suc_n nat_add_commute)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   263
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   264
lemma left_std:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   265
  "(\<exists>k. tp = Bk \<up> k) \<longleftrightarrow> left_std (Code_tp tp)"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   266
apply(simp add: left_std_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   267
apply(simp only: list_encode_inverse)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   268
apply(simp)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   269
apply(auto)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   270
apply(rule_tac x="length tp" in exI)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   271
apply(induct tp)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   272
apply(simp)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   273
apply(simp)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   274
apply(auto)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   275
apply(case_tac a)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   276
apply(auto)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   277
apply(case_tac a)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   278
apply(auto)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   279
by (metis Suc_less_eq nth_Cons_Suc)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   280
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   281
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   282
section {* Standard- and Final Configurations, the Universal Function *}
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   283
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   284
text {*
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   285
  @{text "Std cf"} returns true, if the  configuration  @{text "cf"} 
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   286
  is a stardard tape. 
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   287
*}
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   288
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   289
fun Std :: "nat \<Rightarrow> bool"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
  where
260
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
   291
  "Std cf = (left_std (Left cf) \<and> right_std (Right cf))"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   292
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
text{* 
266
b1b47d28c295 polished Recs theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 265
diff changeset
   294
  @{text "Stop m cf k"} means that afer @{text k} steps of 
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   295
  execution the TM coded by @{text m} and started in configuration
266
b1b47d28c295 polished Recs theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 265
diff changeset
   296
  @{text cf} is in a stardard final configuration. *}
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   297
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   298
fun Final :: "nat \<Rightarrow> bool"
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   299
  where
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   300
    "Final cf = (State cf = 0)"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   301
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   302
fun Stop :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> bool"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   303
  where
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   304
  "Stop m cf k = (Final (Steps cf m k) \<and> Std (Steps cf m k))"
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   305
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   306
text{*
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   307
  @{text "Halt"} is the function calculating the steps a TM needs to 
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   308
  execute before reaching a stardard final configuration. This recursive 
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   309
  function is the only one that uses unbounded minimization. So it is the 
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   310
  only non-primitive recursive function needs to be used in the construction 
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   311
  of the universal function @{text "UF"}. 
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   312
*}
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   313
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   314
fun Halt :: "nat \<Rightarrow> nat \<Rightarrow> nat"
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   315
  where
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   316
  "Halt m cf = (LEAST k. Stop m cf k)"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   317
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   318
fun UF :: "nat \<Rightarrow> nat \<Rightarrow> nat"
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   319
  where
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   320
  "UF m cf = Stknum (Right (Steps cf m (Halt m cf))) - 1"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   321
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   322
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   323
section {* The UF simulates Turing machines *}
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   324
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   325
lemma Update_left_simulate:
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   326
  shows "Newleft (Code_tp l) (Code_tp r) (actnum a) = Code_tp (fst (update a (l, r)))"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   327
apply(induct a)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   328
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   329
apply(case_tac l)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   330
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   331
apply(case_tac r)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   332
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   333
done
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   334
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   335
lemma Update_right_simulate:
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   336
  shows "Newright (Code_tp l) (Code_tp r) (actnum a) = Code_tp (snd (update a (l, r)))"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   337
apply(induct a)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   338
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   339
apply(case_tac r)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   340
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   341
apply(case_tac r)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   342
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   343
apply(case_tac l)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   344
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   345
apply(case_tac r)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   346
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   347
done
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   348
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   349
lemma Fetch_state_simulate:
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   350
  "tm_wf tp \<Longrightarrow> Newstate (Code_tprog tp) st (cellnum c) = snd (fetch tp st c)"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   351
apply(induct tp st c rule: fetch.induct)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   352
apply(simp_all add: list_encode_inverse split: cell.split)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   353
done
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   354
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   355
lemma Fetch_action_simulate:
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   356
  "tm_wf tp \<Longrightarrow> Action (Code_tprog tp) st (cellnum c) = actnum (fst (fetch tp st c))"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   357
apply(induct tp st c rule: fetch.induct)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   358
apply(simp_all add: list_encode_inverse split: cell.split)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   359
done
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   360
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   361
lemma Read_simulate:
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   362
  "Read (Code_tp tp) = cellnum (read tp)"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   363
apply(case_tac tp)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   364
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   365
done
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   366
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   367
lemma misc:
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   368
  "2 < (3::nat)"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   369
  "1 < (3::nat)"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   370
  "0 < (3::nat)" 
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   371
  "length [x] = 1"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   372
  "length [x, y] = 2"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   373
  "length [x, y , z] = 3"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   374
  "[x, y, z] ! 0 = x"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   375
  "[x, y, z] ! 1 = y"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   376
  "[x, y, z] ! 2 = z"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   377
apply(simp_all)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   378
done
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   379
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   380
lemma Step_simulate:
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   381
  assumes "tm_wf tp"
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   382
  shows "Step (Conf (Code_conf (st, l, r))) (Code_tprog tp) = Conf (Code_conf (step (st, l, r) tp))"
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   383
apply(subst step.simps) 
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   384
apply(simp only: Let_def)
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   385
apply(subst Step.simps)
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   386
apply(simp only: Conf.simps Code_conf.simps Right.simps Left.simps)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   387
apply(simp only: list_encode_inverse)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   388
apply(simp only: misc if_True Code_tp.simps)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   389
apply(simp only: prod_case_beta) 
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   390
apply(subst Fetch_state_simulate[OF assms, symmetric])
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   391
apply(simp only: State.simps)
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   392
apply(simp only: list_encode_inverse)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   393
apply(simp only: misc if_True)
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   394
apply(simp only: Read_simulate[simplified Code_tp.simps])
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   395
apply(simp only: Fetch_action_simulate[OF assms])
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   396
apply(simp only: Update_left_simulate[simplified Code_tp.simps])
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   397
apply(simp only: Update_right_simulate[simplified Code_tp.simps])
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   398
apply(case_tac "update (fst (fetch tp st (read r))) (l, r)")
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   399
apply(simp only: Code_conf.simps)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   400
apply(simp only: Conf.simps)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   401
apply(simp)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   402
done
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   403
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   404
lemma Steps_simulate:
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   405
  assumes "tm_wf tp" 
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   406
  shows "Steps (Conf (Code_conf cf)) (Code_tprog tp) n = Conf (Code_conf (steps cf tp n))"
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   407
apply(induct n arbitrary: cf) 
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   408
apply(simp)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   409
apply(simp only: Steps.simps steps.simps)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   410
apply(case_tac cf)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   411
apply(simp only: )
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   412
apply(subst Step_simulate)
258
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   413
apply(rule assms)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   414
apply(drule_tac x="step (a, b, c) tp" in meta_spec)
32c5e8d1f6ff added more about UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 256
diff changeset
   415
apply(simp)
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   416
done
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   417
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   418
lemma Final_simulate:
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   419
  "Final (Conf (Code_conf cf)) = is_final cf"
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   420
by (case_tac cf) (simp)
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   421
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   422
lemma Std_simulate:
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   423
  "Std (Conf (Code_conf cf)) = std_tape cf" 
259
4524c5edcafb moved new theries into a separate directory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 258
diff changeset
   424
apply(case_tac cf)
260
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
   425
apply(simp only: std_tape_def)
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
   426
apply(simp only: Code_conf.simps)
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
   427
apply(simp only: Conf.simps)
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   428
apply(simp only: Std.simps)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   429
apply(simp only: Left.simps Right.simps)
260
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
   430
apply(simp only: list_encode_inverse)
1e45b5b6482a added definitions and proofs for right-std and left-std tapes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 259
diff changeset
   431
apply(simp only: misc if_True)
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   432
apply(simp only: left_std[symmetric] right_std[symmetric])
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   433
apply(simp)
271
4457185b22ef added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 269
diff changeset
   434
by (metis Suc_le_D Suc_neq_Zero append_Cons nat.exhaust not_less_eq_eq replicate_Suc)
4457185b22ef added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 269
diff changeset
   435
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   436
261
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   437
lemma UF_simulate:
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   438
  assumes "tm_wf tm"
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   439
  shows "UF (Code_tprog tm) (Conf (Code_conf cf)) = 
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   440
  Stknum (Right (Conf 
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   441
  (Code_conf (steps cf tm (LEAST n. is_final (steps cf tm n) \<and> std_tape (steps cf tm n)))))) - 1" 
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   442
apply(simp only: UF.simps)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   443
apply(subst Steps_simulate[symmetric, OF assms])
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   444
apply(subst Final_simulate[symmetric])
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   445
apply(subst Std_simulate[symmetric])
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   446
apply(simp only: Halt.simps)
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   447
apply(simp only: Steps_simulate[symmetric, OF assms])
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   448
apply(simp only: Stop.simps[symmetric])
ca1fe315cb0a completed the UF-simulation lemmas
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 260
diff changeset
   449
done
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   450
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   451
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   452
section {* Universal Function as Recursive Functions *}
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   453
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   454
definition 
262
5704925ad138 started with the definitions of the recursive functions for the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 261
diff changeset
   455
  "rec_read = CN rec_ldec [Id 1 0, constn 0]"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   456
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   457
definition 
269
fa40fd8abb54 implemented new UF in scala; made some small adjustments to the definitions in the theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
   458
  "rec_write = CN rec_penc [CN S [Id 2 0], CN rec_pdec2 [Id 2 1]]"
262
5704925ad138 started with the definitions of the recursive functions for the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 261
diff changeset
   459
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   460
definition
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   461
    "rec_newleft =
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   462
       (let cond0 = CN rec_eq [Id 3 2, constn 0] in 
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   463
        let cond1 = CN rec_eq [Id 3 2, constn 1] in
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   464
        let cond2 = CN rec_eq [Id 3 2, constn 2] in
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   465
        let cond3 = CN rec_eq [Id 3 2, constn 3] in
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   466
        let case3 = CN rec_penc [CN S [CN rec_read [Id 3 1]], Id 3 0] in
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   467
        CN rec_if [cond0, Id 3 0,
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   468
          CN rec_if [cond1, Id 3 0,  
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   469
            CN rec_if [cond2, CN rec_pdec2 [Id 3 0],
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   470
              CN rec_if [cond3, case3, Id 3 0]]]])"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   471
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   472
definition
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   473
    "rec_newright =
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   474
       (let cond0 = CN rec_eq [Id 3 2, constn 0] in
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   475
        let cond1 = CN rec_eq [Id 3 2, constn 1] in
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   476
        let cond2 = CN rec_eq [Id 3 2, constn 2] in
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   477
        let cond3 = CN rec_eq [Id 3 2, constn 3] in
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   478
        let case2 = CN rec_penc [CN S [CN rec_read [Id 3 0]], Id 3 1] in
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   479
        CN rec_if [cond0, CN rec_write [constn 0, Id 3 1], 
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   480
          CN rec_if [cond1, CN rec_write [constn 1, Id 3 1],
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   481
            CN rec_if [cond2, case2,
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   482
              CN rec_if [cond3, CN rec_pdec2 [Id 3 1], Id 3 1]]]])"
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   483
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   484
definition
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   485
  "rec_actn = rec_swap (PR (CN rec_pdec1 [CN rec_pdec1 [Id 1 0]])
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   486
                           (CN rec_pdec1 [CN rec_pdec2 [Id 3 2]]))"
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   487
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   488
definition 
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   489
  "rec_action = (let cond1 = CN rec_noteq [Id 3 1, Z] in 
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   490
                 let cond2 = CN rec_within [Id 3 0, CN rec_pred [Id 3 1]] in
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   491
                 let if_branch = CN rec_actn [CN rec_ldec [Id 3 0, CN rec_pred [Id 3 1]], Id 3 2]
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   492
                 in CN rec_if [CN rec_conj [cond1, cond2], if_branch, constn 4])"
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   493
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   494
definition
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   495
  "rec_newstat = rec_swap (PR (CN rec_pdec2 [CN rec_pdec1 [Id 1 0]])
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   496
                              (CN rec_pdec2 [CN rec_pdec2 [Id 3 2]]))"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   497
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   498
definition
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   499
  "rec_newstate = (let cond = CN rec_noteq [Id 3 1, Z] in
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   500
                   let if_branch = CN rec_newstat [CN rec_ldec [Id 3 0, CN rec_pred [Id 3 1]], Id 3 2]
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   501
                   in CN rec_if [cond, if_branch, Z])"
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   502
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   503
definition
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   504
  "rec_conf = rec_lenc [Id 3 0, Id 3 1, Id 3 2]"
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   505
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   506
definition 
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   507
  "rec_state = CN rec_ldec [Id 1 0, Z]"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   508
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   509
definition
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   510
  "rec_left = CN rec_ldec [Id 1 0, constn 1]"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   511
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   512
definition 
263
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   513
  "rec_right = CN rec_ldec [Id 1 0, constn 2]"
aa102c182132 more rec-funs definitions
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 262
diff changeset
   514
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   515
definition 
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   516
  "rec_step = (let left = CN rec_left [Id 2 0] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   517
               let right = CN rec_right [Id 2 0] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   518
               let state = CN rec_state [Id 2 0] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   519
               let read = CN rec_read [right] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   520
               let action = CN rec_action [Id 2 1, state, read] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   521
               let newstate = CN rec_newstate [Id 2 1, state, read] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   522
               let newleft = CN rec_newleft [left, right, action] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   523
               let newright = CN rec_newright [left, right, action] 
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   524
               in CN rec_conf [newstate, newleft, newright])" 
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   525
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   526
definition 
269
fa40fd8abb54 implemented new UF in scala; made some small adjustments to the definitions in the theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
   527
  "rec_steps = PR (Id 2 0) (CN rec_step [Id 4 1, Id 4 3])"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   528
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   529
definition
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   530
  "rec_stknum = CN rec_minus 
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   531
                  [CN (rec_sigma1 (CN rec_ldec [Id 2 1, Id 2 0])) [CN rec_enclen [Id 1 0], Id 1 0],
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   532
                   CN rec_ldec [Id 1 0, CN rec_enclen [Id 1 0]]]"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   533
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   534
definition
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   535
  "rec_right_std = (let bound = CN rec_enclen [Id 1 0] in
269
fa40fd8abb54 implemented new UF in scala; made some small adjustments to the definitions in the theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 267
diff changeset
   536
                    let cond1 = CN rec_le [CN (constn 1) [Id 2 0], Id 2 0] in
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   537
                    let cond2 = rec_all1_less (CN rec_eq [CN rec_ldec [Id 2 1, Id 2 0], constn 1]) in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   538
                    let bound2 = CN rec_minus [CN rec_enclen [Id 2 1], Id 2 0] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   539
                    let cond3 = CN (rec_all2_less 
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   540
                                     (CN rec_eq [CN rec_ldec [Id 3 2, CN rec_add [Id 3 1, Id 3 0]], Z])) 
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   541
                                [bound2, Id 2 0, Id 2 1] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   542
                    CN (rec_ex1 (CN rec_conj [CN rec_conj [cond1, cond2], cond3])) [bound, Id 1 0])"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   543
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   544
definition
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   545
  "rec_left_std = (let cond = CN rec_eq [CN rec_ldec [Id 2 1, Id 2 0], Z]
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   546
                   in CN (rec_all1_less cond) [CN rec_enclen [Id 1 0], Id 1 0])"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   547
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   548
definition
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   549
  "rec_std = CN rec_conj [CN rec_left_std [CN rec_left [Id 1 0]],
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   550
                          CN rec_right_std [CN rec_right [Id 1 0]]]"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   551
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   552
definition 
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   553
  "rec_final = CN rec_eq [CN rec_state [Id 1 0], Z]"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   554
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   555
definition 
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   556
  "rec_stop = (let steps = CN rec_steps [Id 3 2, Id 3 1, Id 3 0] in
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   557
               CN rec_conj [CN rec_final [steps], CN rec_std [steps]])"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   558
267
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   559
definition
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   560
  "rec_halt = MN (CN rec_not [CN rec_stop [Id 3 1, Id 3 2, Id 3 0]])"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   561
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   562
definition 
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   563
  "rec_uf = CN rec_pred 
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   564
              [CN rec_stknum 
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   565
                  [CN rec_right 
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   566
                     [CN rec_steps [CN rec_halt [Id 2 0, Id 2 1], Id 2 1, Id 2 0]]]]"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   567
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   568
lemma read_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   569
  "rec_eval rec_read [x] = Read x"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   570
by (simp add: rec_read_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   571
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   572
lemma write_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   573
  "rec_eval rec_write [x, y] = Write x y"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   574
by (simp add: rec_write_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   575
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   576
lemma newleft_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   577
  "rec_eval rec_newleft [p, r, a] = Newleft p r a"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   578
by (simp add: rec_newleft_def Let_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   579
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   580
lemma newright_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   581
  "rec_eval rec_newright [p, r, a] = Newright p r a"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   582
by (simp add: rec_newright_def Let_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   583
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   584
lemma act_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   585
  "rec_eval rec_actn [n, c] = Actn n c"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   586
apply(simp add: rec_actn_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   587
apply(case_tac c)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   588
apply(simp_all)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   589
done
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   590
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   591
lemma action_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   592
  "rec_eval rec_action [m, q, c] = Action m q c"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   593
by (simp add: rec_action_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   594
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   595
lemma newstat_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   596
  "rec_eval rec_newstat [n, c] = Newstat n c"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   597
apply(simp add: rec_newstat_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   598
apply(case_tac c)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   599
apply(simp_all)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   600
done
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   601
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   602
lemma newstate_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   603
  "rec_eval rec_newstate [m, q, r] = Newstate m q r"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   604
by (simp add: rec_newstate_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   605
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   606
lemma conf_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   607
  "rec_eval rec_conf [q, l, r] = Conf (q, l, r)"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   608
by(simp add: rec_conf_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   609
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   610
lemma state_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   611
  "rec_eval rec_state [cf] = State cf"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   612
by (simp add: rec_state_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   613
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   614
lemma left_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   615
  "rec_eval rec_left [cf] = Left cf"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   616
by (simp add: rec_left_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   617
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   618
lemma right_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   619
  "rec_eval rec_right [cf] = Right cf"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   620
by (simp add: rec_right_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   621
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   622
lemma step_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   623
  "rec_eval rec_step [cf, m] = Step cf m"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   624
by (simp add: Let_def rec_step_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   625
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   626
lemma steps_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   627
  "rec_eval rec_steps [n, cf, p] = Steps cf p n"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   628
by (induct n) (simp_all add: rec_steps_def Step_Steps_comm del: Step.simps)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   629
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   630
lemma stknum_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   631
  "rec_eval rec_stknum [z] = Stknum z"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   632
by (simp add: rec_stknum_def Stknum_def lessThan_Suc_atMost[symmetric])
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   633
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   634
lemma left_std_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   635
  "rec_eval rec_left_std [z] = (if left_std z then 1 else 0)"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   636
by (simp add: Let_def rec_left_std_def left_std_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   637
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   638
lemma right_std_lemma [simp]:
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   639
  "rec_eval rec_right_std [z] = (if right_std z then 1 else 0)"
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   640
by (simp add: Let_def rec_right_std_def right_std_def)
28d85e8ff391 more cleaning
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 266
diff changeset
   641
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   642
lemma std_lemma [simp]:
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   643
  "rec_eval rec_std [cf] = (if Std cf then 1 else 0)"
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   644
by (simp add: rec_std_def)
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   645
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   646
lemma final_lemma [simp]:
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   647
  "rec_eval rec_final [cf] = (if Final cf then 1 else 0)"
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   648
by (simp add: rec_final_def)
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   649
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   650
lemma stop_lemma [simp]:
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   651
  "rec_eval rec_stop [m, cf, k] = (if Stop m cf k then 1 else 0)"
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   652
by (simp add: Let_def rec_stop_def)
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   653
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   654
lemma halt_lemma [simp]:
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   655
  "rec_eval rec_halt [m, cf] = Halt m cf"
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   656
by (simp add: rec_halt_def del: Stop.simps)
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   657
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   658
lemma uf_lemma [simp]:
265
fa3c214559b0 finished recusive version of the UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 264
diff changeset
   659
  "rec_eval rec_uf [m, cf] = UF m cf"
250
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   660
by (simp add: rec_uf_def)
745547bdc1c7 added lemmas about a pairing function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 249
diff changeset
   661
271
4457185b22ef added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 269
diff changeset
   662
value "size rec_uf"
248
aea02b5a58d2 repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 246
diff changeset
   663
end
246
e113420a2fce separated recursive functions and UF
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   664