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