Nominal/Ex/PaperTest.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 13 May 2011 14:50:17 +0100
changeset 2783 8412c7e503d4
child 2802 3b9ef98a03d2
permissions -rw-r--r--
misc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2783
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory PaperTest
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports "../Nominal2"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
atom_decl name 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
datatype trm = 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  Const "string"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
| Var "name"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
| App "trm" "trm"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
| Lam "name" "trm"  ("Lam [_]. _" [100, 100] 100)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
fun
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  subst :: "trm \<Rightarrow> name \<Rightarrow> name \<Rightarrow> trm"  ("_[_::=_]" [100,100,100] 100)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  "(Var x)[y::=p] = (if x=y then (App (App (Const ''unpermute'') (Var p)) (Var x)) else (Var x))"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
| "(App t\<^isub>1 t\<^isub>2)[y::=p] = App (t\<^isub>1[y::=p]) (t\<^isub>2[y::=p])"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
| "(Lam [x].t)[y::=p] = (if x=y then (Lam [x].t) else Lam [x].(t[y::=p]))"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
| "(Const n)[y::=p] = Const n"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
datatype utrm = 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
  UConst "string"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
| UnPermute "name" "name"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
| UVar "name"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
| UApp "utrm" "utrm"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
| ULam "name" "utrm"  ("ULam [_]. _" [100, 100] 100)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
fun
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  usubst :: "utrm \<Rightarrow> name \<Rightarrow> name \<Rightarrow> utrm"  ("_[_:::=_]" [100,100,100] 100)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
  "(UVar x)[y:::=p] = (if x=y then UnPermute x p else (UVar x))"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
| "(UApp t\<^isub>1 t\<^isub>2)[y:::=p] = UApp (t\<^isub>1[y:::=p]) (t\<^isub>2[y:::=p])"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
| "(ULam [x].t)[y:::=p] = (if x=y then (ULam [x].t) else ULam [x].(t[y:::=p]))"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
| "(UConst n)[y:::=p] = UConst n"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
| "(UnPermute x q)[y:::=p] = UnPermute x q"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
function
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
  ss :: "trm \<Rightarrow> nat"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  "ss (Var x) = 1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
| "ss (Const s) = 1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
| "ss (Lam [x].t) = 1 + ss t"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
| "ss (App (App (Const ''unpermute'') (Var p)) (Var x)) = 1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
| "\<not>(\<exists>p x. t1 = App (Const ''unpermute'') (Var p) \<and> t2 = (Var x)) \<Longrightarrow> ss (App t1 t2) = 1 + ss t1 + ss t2"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
defer
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
apply(case_tac x)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
apply(auto)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
apply(blast)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
termination
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  apply(relation "measure (\<lambda>t. size t)")
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
  done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
fun
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
  uss :: "utrm \<Rightarrow> nat"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
  "uss (UVar x) = 1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
| "uss (UConst s) = 1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
| "uss (ULam [x].t) = 1 + uss t"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
| "uss (UnPermute x y) = 1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
| "uss (UApp t1 t2) = 1 + uss t1 + uss t2"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
lemma trm_uss:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
  shows "uss (t[x:::=p]) = uss t"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
apply(induct rule: uss.induct)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
inductive
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
  ufree :: "utrm \<Rightarrow> bool"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
  "ufree (UVar x)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
| "s \<noteq> ''unpermute'' \<Longrightarrow> ufree (UConst s)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
| "ufree t \<Longrightarrow> ufree (ULam [x].t)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
| "ufree (UnPermute x y)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
| "\<lbrakk>ufree t1; ufree t2\<rbrakk> \<Longrightarrow> ufree (UApp t1 t2)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
fun
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
  trans :: "utrm \<Rightarrow> trm" ("\<parallel>_\<parallel>" [100] 100)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
  "\<parallel>(UVar x)\<parallel> = Var x"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
| "\<parallel>(UConst x)\<parallel> = Const x"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
| "\<parallel>(UnPermute p x)\<parallel> = (App (App (Const ''unpermute'') (Var p)) (Var x))"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
| "\<parallel>(ULam [x].t)\<parallel> = Lam [x].(\<parallel>t\<parallel>)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
| "\<parallel>(UApp t1 t2)\<parallel> = App (\<parallel>t1\<parallel>) (\<parallel>t2\<parallel>)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
lemma elim1:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
  "ufree t \<Longrightarrow> \<parallel>t\<parallel> \<noteq>(Const ''unpermute'')"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
apply(erule ufree.induct)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
apply(auto)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
lemma elim2:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
  "ufree t \<Longrightarrow> \<not>(\<exists>p. \<parallel>t\<parallel> = App (Const ''unpermute'') (Var p))"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
apply(erule ufree.induct)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
apply(auto dest: elim1)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
lemma
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
  "ufree t \<Longrightarrow> uss t = ss (\<parallel>t\<parallel>)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
apply(erule ufree.induct)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
apply(subst ss.simps)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
apply(auto)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
apply(drule elim2)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
apply(auto)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
fun
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
  fr :: "trm \<Rightarrow> name set"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
  "fr (Var x) = {x}"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
| "fr (Const s) = {}"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
| "fr (Lam [x].t) = fr t - {x}"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
| "fr (App t1 t2) = fr t1 \<union> fr t2"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
function
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
  sfr :: "trm \<Rightarrow> name set"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
  "sfr (Var x) = {}"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
| "sfr (Const s) = {}"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
| "sfr (Lam [x].t) = sfr t - {x}"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
| "sfr (App (App (Const ''unpermute'') (Var p)) (Var x)) = {p, x}"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
| "\<not>(\<exists>p x. t1 = App (Const ''unpermute'') (Var p) \<and> t2 = (Var x)) \<Longrightarrow> sfr (App t1 t2) = sfr t1 \<union> sfr t2"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
defer
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
apply(case_tac x)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
apply(auto)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
apply(blast)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
termination
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
  apply(relation "measure (\<lambda>t. size t)")
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
  apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
  done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
function
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
  ss :: "trm \<Rightarrow> nat"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
  "ss (Var x) = 1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
| "ss (Const s) = 1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
| "ss (Lam [x].t) = 1 + ss t"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
| "ss (App (App (Const ''unpermute'') (Var p)) (Var x)) = 1"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
| "\<not>(\<exists>p x. t1 = App (Const ''unpermute'') (Var p) \<and> t2 = (Var x)) \<Longrightarrow> ss (App t1 t2) = 1 + ss t1 + ss t2"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
defer
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
apply(case_tac x)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
apply(auto)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
apply(blast)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
done 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
termination
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
  apply(relation "measure (\<lambda>t. size t)")
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
  apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
  done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
inductive
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
  improper :: "trm \<Rightarrow> bool"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
  "improper (App (App (Const ''unpermute'') (Var p)) (Var x))"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
| "improper p x t \<Longrightarrow> improper p x (Lam [y].t)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
| "\<lbrakk>improper p x t1; improper p x t2\<rbrakk> \<Longrightarrow> improper p x (App t1 t2)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
lemma trm_ss:
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
  shows "\<not>improper p x t \<Longrightarrow> ss (t[x::= p]) = ss t"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
apply(induct rule: ss.induct)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   180
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   181
apply(case_tac "improper p x t")
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
apply(drule improper.intros(2))
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
apply(blast)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
using improper.intros(1)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
apply(blast)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
apply(erule contrapos_pn)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
thm contrapos_np
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   190
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
apply(erule disjE)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
apply(erule conjE)+
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
apply(subst ss.simps)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
apply(rule disjI1)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
apply(rule allI)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
apply(rule notI)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
apply(simp del: ss.simps)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
apply(erule disjE)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
apply(subst ss.simps)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
apply(simp only: subst.simps)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
apply(subst ss.simps)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
apply(simp del: ss.simps)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
apply(rule conjI)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
apply(rule impI)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
apply(erule conjE)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
apply(erule exE)+
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   211
apply(subst ss.simps)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
apply(simp)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   213
apply(auto)[1]
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
apply(simp add: if_splits)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
apply()
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
function
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   218
  simp :: "name \<Rightarrow> trm \<Rightarrow> trm"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   219
where
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   220
  "simp p (Const c) = (Const c)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   221
| "simp p (Var x) = App (App (Const ''permute'') (Var p)) (Var x)"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   222
| "simp p (App t1 t2) = (if ((\<exists>x. t1 = App (Const ''unpermute'') (Var p) \<and> t2 = (Var x))) 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
                         then t2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   224
                         else App (simp p t1) (simp p t2))"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   225
| "simp p (Lam [x].t) = Lam [x]. (simp p (t[x ::= p]))"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   226
apply(pat_completeness)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   227
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   228
apply(auto)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   229
done
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   230
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   231
termination
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   232
apply(relation "measure (\<lambda>(_, t). size t)")
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   233
apply(simp_all)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   234
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   235
end