src/HOL/Nominal/Examples/SOS.thy
author urbanc
Tue, 27 Mar 2007 19:13:28 +0200
changeset 22534 bd4b954e85ee
parent 22531 1cbfb4066e47
child 22541 c33b542394f3
permissions -rw-r--r--
adapted to nominal_inductive
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
     1
(* "$Id$" *)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
     2
(*                                                   *)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
     3
(* Formalisation of some typical SOS-proofs          *)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
     4
(*                                                   *) 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
     5
(* This work arose from challenge suggested by Adam  *)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
     6
(* Chlipala suggested on the POPLmark mailing list.  *)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
     7
(*                                                   *) 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
     8
(* We thank Nick Benton for helping us with the      *) 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
     9
(* termination-proof for evaluation.                 *)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    10
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    11
theory SOS
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
    12
  imports "../Nominal"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    13
begin
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    14
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    15
atom_decl name 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    16
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    17
nominal_datatype data = 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    18
    DNat
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    19
  | DProd "data" "data"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    20
  | DSum "data" "data"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    21
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    22
nominal_datatype ty = 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    23
    Data "data"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    24
  | Arrow "ty" "ty" ("_\<rightarrow>_" [100,100] 100)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    25
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    26
nominal_datatype trm = 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    27
    Var "name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    28
  | Lam "\<guillemotleft>name\<guillemotright>trm" ("Lam [_]._" [100,100] 100)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    29
  | App "trm" "trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    30
  | Const "nat"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    31
  | Pr "trm" "trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    32
  | Fst "trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    33
  | Snd "trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    34
  | InL "trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    35
  | InR "trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    36
  | Case "trm" "\<guillemotleft>name\<guillemotright>trm" "\<guillemotleft>name\<guillemotright>trm" ("Case _ of inl _ \<rightarrow> _ | inr _ \<rightarrow> _" [100,100,100,100,100] 100)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    37
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    38
lemma in_eqvt[eqvt]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    39
  fixes pi::"name prm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    40
  and   x::"'a::pt_name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    41
  assumes "x\<in>X"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    42
  shows "pi\<bullet>x \<in> pi\<bullet>X"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    43
  using assms by (perm_simp add: pt_set_bij1a[OF pt_name_inst, OF at_name_inst])
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    44
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    45
lemma perm_data[simp]: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    46
  fixes D::"data"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    47
  and   pi::"name prm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    48
  shows "pi\<bullet>D = D"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    49
  by (induct D rule: data.induct_weak) (simp_all)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    50
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    51
lemma perm_ty[simp]: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    52
  fixes T::"ty"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    53
  and   pi::"name prm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    54
  shows "pi\<bullet>T = T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    55
  by (induct T rule: ty.induct_weak) (simp_all)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    56
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    57
lemma fresh_ty[simp]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    58
  fixes x::"name" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    59
  and   T::"ty"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    60
  shows "x\<sharp>T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    61
  by (simp add: fresh_def supp_def)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    62
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    63
text {* substitution *}
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    64
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    65
fun
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    66
  lookup :: "(name\<times>trm) list \<Rightarrow> name \<Rightarrow> trm"   
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    67
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    68
  "lookup [] x        = Var x"
22502
baee64dbe8ea fixed function syntax
krauss
parents: 22472
diff changeset
    69
| "lookup ((y,e)#\<theta>) x = (if x=y then e else lookup \<theta> x)"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    70
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    71
lemma lookup_eqvt:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    72
  fixes pi::"name prm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    73
  and   \<theta>::"(name\<times>trm) list"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    74
  and   X::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    75
  shows "pi\<bullet>(lookup \<theta> X) = lookup (pi\<bullet>\<theta>) (pi\<bullet>X)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    76
by (induct \<theta>, auto simp add: perm_bij)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    77
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    78
lemma lookup_fresh:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    79
  fixes z::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    80
  assumes "z\<sharp>\<theta>" and "z\<sharp>x"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    81
  shows "z \<sharp>lookup \<theta> x"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    82
using assms 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    83
by (induct rule: lookup.induct) (auto simp add: fresh_list_cons)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    84
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    85
lemma lookup_fresh':
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    86
  assumes "z\<sharp>\<theta>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    87
  shows "lookup \<theta> z = Var z"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    88
using assms 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    89
by (induct rule: lookup.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    90
   (auto simp add: fresh_list_cons fresh_prod fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    91
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
    92
text {* Parallel Substitution *}
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
    93
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    94
consts
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    95
  psubst :: "(name\<times>trm) list \<Rightarrow> trm \<Rightarrow> trm"  ("_<_>" [95,95] 105)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    96
 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    97
nominal_primrec
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    98
  "\<theta><(Var x)> = (lookup \<theta> x)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    99
  "\<theta><(App e\<^isub>1 e\<^isub>2)> = App (\<theta><e\<^isub>1>) (\<theta><e\<^isub>2>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   100
  "x\<sharp>\<theta> \<Longrightarrow> \<theta><(Lam [x].e)> = Lam [x].(\<theta><e>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   101
  "\<theta><(Const n)> = Const n"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   102
  "\<theta><(Pr e\<^isub>1 e\<^isub>2)> = Pr (\<theta><e\<^isub>1>) (\<theta><e\<^isub>2>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   103
  "\<theta><(Fst e)> = Fst (\<theta><e>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   104
  "\<theta><(Snd e)> = Snd (\<theta><e>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   105
  "\<theta><(InL e)> = InL (\<theta><e>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   106
  "\<theta><(InR e)> = InR (\<theta><e>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   107
  "\<lbrakk>y\<noteq>x; x\<sharp>(e,e\<^isub>2,\<theta>); y\<sharp>(e,e\<^isub>1,\<theta>)\<rbrakk> 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   108
   \<Longrightarrow> \<theta><Case e of inl x \<rightarrow> e\<^isub>1 | inr y \<rightarrow> e\<^isub>2> = (Case (\<theta><e>) of inl x \<rightarrow> (\<theta><e\<^isub>1>) | inr y \<rightarrow> (\<theta><e\<^isub>2>))"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   109
apply(finite_guess add: lookup_eqvt)+
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   110
apply(rule TrueI)+
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   111
apply(simp add: abs_fresh)+
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   112
apply(fresh_guess add: fs_name1 lookup_eqvt)+
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   113
done
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   114
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   115
lemma psubst_eqvt[eqvt]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   116
  fixes pi::"name prm" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   117
  and   t::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   118
  shows "pi\<bullet>(\<theta><t>) = (pi\<bullet>\<theta>)<(pi\<bullet>t)>"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   119
by (nominal_induct t avoiding: \<theta> rule: trm.induct)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   120
   (perm_simp add: fresh_bij lookup_eqvt)+
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   121
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   122
lemma fresh_psubst: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   123
  fixes z::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   124
  and   t::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   125
  assumes "z\<sharp>t" and "z\<sharp>\<theta>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   126
  shows "z\<sharp>(\<theta><t>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   127
using assms
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   128
by (nominal_induct t avoiding: z \<theta> t rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   129
   (auto simp add: abs_fresh lookup_fresh)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   130
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   131
abbreviation 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   132
 subst :: "trm \<Rightarrow> name \<Rightarrow> trm \<Rightarrow> trm" ("_[_::=_]" [100,100,100] 100)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   133
  where "t[x::=t']  \<equiv> ([(x,t')])<t>" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   134
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   135
lemma subst[simp]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   136
  shows "(Var x)[y::=t'] = (if x=y then t' else (Var x))"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   137
  and   "(App t\<^isub>1 t\<^isub>2)[y::=t'] = App (t\<^isub>1[y::=t']) (t\<^isub>2[y::=t'])"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   138
  and   "x\<sharp>(y,t') \<Longrightarrow> (Lam [x].t)[y::=t'] = Lam [x].(t[y::=t'])"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   139
  and   "(Const n)[y::=t'] = Const n"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   140
  and   "(Pr e\<^isub>1 e\<^isub>2)[y::=t'] = Pr (e\<^isub>1[y::=t']) (e\<^isub>2[y::=t'])"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   141
  and   "(Fst e)[y::=t'] = Fst (e[y::=t'])"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   142
  and   "(Snd e)[y::=t'] = Snd (e[y::=t'])"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   143
  and   "(InL e)[y::=t'] = InL (e[y::=t'])"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   144
  and   "(InR e)[y::=t'] = InR (e[y::=t'])"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   145
  and   "\<lbrakk>z\<noteq>x; x\<sharp>(y,e,e\<^isub>2,t'); z\<sharp>(y,e,e\<^isub>1,t')\<rbrakk> 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   146
         \<Longrightarrow> (Case e of inl x \<rightarrow> e\<^isub>1 | inr z \<rightarrow> e\<^isub>2)[y::=t'] =
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   147
                   (Case (e[y::=t']) of inl x \<rightarrow> (e\<^isub>1[y::=t']) | inr z \<rightarrow> (e\<^isub>2[y::=t']))"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   148
by (simp_all add: fresh_list_cons fresh_list_nil)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   149
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   150
lemma subst_eqvt[eqvt]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   151
  fixes pi::"name prm" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   152
  and   t::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   153
  shows "pi\<bullet>(t[x::=t']) = (pi\<bullet>t)[(pi\<bullet>x)::=(pi\<bullet>t')]"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   154
  by (nominal_induct t avoiding: x t' rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   155
     (perm_simp add: fresh_bij)+
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   156
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   157
lemma fresh_subst:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   158
  fixes z::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   159
  and   t\<^isub>1::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   160
  and   t2::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   161
  assumes "z\<sharp>t\<^isub>1" and "z\<sharp>t\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   162
  shows "z\<sharp>t\<^isub>1[y::=t\<^isub>2]"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   163
using assms 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   164
by (nominal_induct t\<^isub>1 avoiding: z y t\<^isub>2 rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   165
   (auto simp add: abs_fresh fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   166
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   167
lemma fresh_subst':
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   168
  fixes z::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   169
  and   t\<^isub>1::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   170
  and   t2::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   171
  assumes "z\<sharp>[y].t\<^isub>1" and "z\<sharp>t\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   172
  shows "z\<sharp>t\<^isub>1[y::=t\<^isub>2]"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   173
using assms 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   174
by (nominal_induct t\<^isub>1 avoiding: y t\<^isub>2 z  rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   175
   (auto simp add: abs_fresh fresh_nat fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   176
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   177
lemma forget: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   178
  fixes x::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   179
  and   L::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   180
  assumes "x\<sharp>L" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   181
  shows "L[x::=P] = L"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   182
  using assms
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   183
  by (nominal_induct L avoiding: x P rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   184
     (auto simp add: fresh_atm abs_fresh)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   185
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   186
lemma psubst_empty[simp]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   187
  shows "[]<t> = t"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   188
  by (nominal_induct t rule: trm.induct, auto simp add:fresh_list_nil)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   189
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   190
lemma psubst_subst_psubst:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   191
assumes h:"x\<sharp>\<theta>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   192
shows "\<theta><e>[x::=e'] = ((x,e')#\<theta>)<e>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   193
using h
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   194
apply(nominal_induct e avoiding: \<theta> x e' rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   195
apply(auto simp add: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh' fresh_psubst)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   196
done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   197
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   198
lemma fresh_subst_fresh:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   199
    assumes "a\<sharp>e"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   200
    shows "a\<sharp>t[a::=e]"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   201
using assms 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   202
by (nominal_induct t avoiding: a e rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   203
   (auto simp add: fresh_atm abs_fresh fresh_nat) 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   204
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   205
text {* Typing-Judgements *}
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   206
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   207
inductive2
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   208
  valid :: "(name \<times> 'a::pt_name) list \<Rightarrow> bool"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   209
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   210
    v_nil[intro]:  "valid []"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   211
  | v_cons[intro]: "\<lbrakk>valid \<Gamma>;x\<sharp>\<Gamma>\<rbrakk> \<Longrightarrow> valid ((x,T)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   212
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   213
equivariance valid 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   214
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   215
inductive_cases2  
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   216
  valid_cons_inv_auto[elim]:"valid ((x,T)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   217
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   218
abbreviation
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   219
  "sub" :: "(name\<times>ty) list \<Rightarrow> (name\<times>ty) list \<Rightarrow> bool" ("_ \<lless> _" [55,55] 55)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   220
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   221
  "\<Gamma>\<^isub>1 \<lless> \<Gamma>\<^isub>2 \<equiv> \<forall>x T. (x,T)\<in>set \<Gamma>\<^isub>1 \<longrightarrow> (x,T)\<in>set \<Gamma>\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   222
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   223
lemma type_unicity_in_context:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   224
  assumes asm1: "(x,t\<^isub>2) \<in> set ((x,t\<^isub>1)#\<Gamma>)" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   225
  and     asm2: "valid ((x,t\<^isub>1)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   226
  shows "t\<^isub>1=t\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   227
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   228
  from asm2 have "x\<sharp>\<Gamma>" by (cases, auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   229
  then have "(x,t\<^isub>2) \<notin> set \<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   230
    by (induct \<Gamma>) (auto simp add: fresh_list_cons fresh_prod fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   231
  then have "(x,t\<^isub>2) = (x,t\<^isub>1)" using asm1 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   232
  then show "t\<^isub>1 = t\<^isub>2" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   233
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   234
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   235
lemma case_distinction_on_context:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   236
  fixes \<Gamma>::"(name \<times> ty) list"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   237
  assumes asm1: "valid ((m,t)#\<Gamma>)" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   238
  and     asm2: "(n,U) \<in> set ((m,T)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   239
  shows "(n,U) = (m,T) \<or> ((n,U) \<in> set \<Gamma> \<and> n \<noteq> m)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   240
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   241
from asm2 have "(n,U) \<in> set [(m,T)] \<or> (n,U) \<in> set \<Gamma>" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   242
moreover
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   243
{ assume eq: "m=n"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   244
  assume "(n,U) \<in> set \<Gamma>" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   245
  then have "\<not> n\<sharp>\<Gamma>" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   246
    by (induct \<Gamma>) (auto simp add: fresh_list_cons fresh_prod fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   247
  moreover have "m\<sharp>\<Gamma>" using asm1 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   248
  ultimately have False using eq by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   249
}
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   250
ultimately show ?thesis by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   251
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   252
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   253
inductive2
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   254
  typing :: "(name\<times>ty) list\<Rightarrow>trm\<Rightarrow>ty\<Rightarrow>bool" ("_ \<turnstile> _ : _" [60,60,60] 60) 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   255
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   256
  t_Var[intro]:   "\<lbrakk>valid \<Gamma>; (x,T)\<in>set \<Gamma>\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> Var x : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   257
| t_App[intro]:   "\<lbrakk>\<Gamma> \<turnstile> e\<^isub>1 : T\<^isub>1\<rightarrow>T\<^isub>2; \<Gamma> \<turnstile> e\<^isub>2 : T\<^isub>1\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> App e\<^isub>1 e\<^isub>2 : T\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   258
| t_Lam[intro]:   "\<lbrakk>x\<sharp>\<Gamma>; (x,T\<^isub>1)#\<Gamma> \<turnstile> e : T\<^isub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].e : T\<^isub>1\<rightarrow>T\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   259
| t_Const[intro]: "valid \<Gamma> \<Longrightarrow> \<Gamma> \<turnstile> Const n : Data(DNat)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   260
| t_Pr[intro]:    "\<lbrakk>\<Gamma> \<turnstile> e\<^isub>1 : Data(S\<^isub>1); \<Gamma> \<turnstile> e\<^isub>2 : Data(S\<^isub>2)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Pr e\<^isub>1 e\<^isub>2 : Data (DProd S\<^isub>1 S\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   261
| t_Fst[intro]:   "\<lbrakk>\<Gamma> \<turnstile> e : Data(DProd S\<^isub>1 S\<^isub>2)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Fst e : Data(S\<^isub>1)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   262
| t_Snd[intro]:   "\<lbrakk>\<Gamma> \<turnstile> e : Data(DProd S\<^isub>1 S\<^isub>2)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Snd e : Data(S\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   263
| t_InL[intro]:   "\<lbrakk>\<Gamma> \<turnstile> e : Data(S\<^isub>1)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> InL e : Data(DSum S\<^isub>1 S\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   264
| t_InR[intro]:   "\<lbrakk>\<Gamma> \<turnstile> e : Data(S\<^isub>2)\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> InR e : Data(DSum S\<^isub>1 S\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   265
| t_Case[intro]:  "\<lbrakk>x\<^isub>1\<sharp>(\<Gamma>,e,e\<^isub>2,x\<^isub>2); x\<^isub>2\<sharp>(\<Gamma>,e,e\<^isub>1,x\<^isub>1); \<Gamma> \<turnstile> e: Data(DSum S\<^isub>1 S\<^isub>2); 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   266
                   (x\<^isub>1,Data(S\<^isub>1))#\<Gamma> \<turnstile> e\<^isub>1 : T; (x\<^isub>2,Data(S\<^isub>2))#\<Gamma> \<turnstile> e\<^isub>2 : T\<rbrakk> 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   267
                   \<Longrightarrow> \<Gamma> \<turnstile> (Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2) : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   268
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   269
nominal_inductive typing
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   270
  by (simp_all add: abs_fresh fresh_prod fresh_atm)
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   271
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   272
lemmas typing_eqvt' = typing_eqvt[simplified]
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   273
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   274
lemma typing_implies_valid:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   275
  assumes "\<Gamma> \<turnstile> t : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   276
  shows "valid \<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   277
  using assms
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   278
  by (induct) (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   279
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   280
declare trm.inject [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   281
declare ty.inject  [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   282
declare data.inject [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   283
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   284
inductive_cases2 t_Lam_inv_auto[elim]: "\<Gamma> \<turnstile> Lam [x].t : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   285
inductive_cases2 t_Var_inv_auto[elim]: "\<Gamma> \<turnstile> Var x : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   286
inductive_cases2 t_App_inv_auto[elim]: "\<Gamma> \<turnstile> App x y : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   287
inductive_cases2 t_Const_inv_auto[elim]: "\<Gamma> \<turnstile> Const n : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   288
inductive_cases2 t_Fst_inv_auto[elim]: "\<Gamma> \<turnstile> Fst x : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   289
inductive_cases2 t_Snd_inv_auto[elim]: "\<Gamma> \<turnstile> Snd x : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   290
inductive_cases2 t_InL_inv_auto[elim]: "\<Gamma> \<turnstile> InL x : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   291
inductive_cases2 t_InL_inv_auto'[elim]: "\<Gamma> \<turnstile> InL x : Data (DSum T\<^isub>1 T2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   292
inductive_cases2 t_InR_inv_auto[elim]: "\<Gamma> \<turnstile> InR x : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   293
inductive_cases2 t_InR_inv_auto'[elim]: "\<Gamma> \<turnstile> InR x : Data (DSum T\<^isub>1 T2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   294
inductive_cases2 t_Pr_inv_auto[elim]:  "\<Gamma> \<turnstile> Pr x y : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   295
inductive_cases2 t_Pr_inv_auto'[elim]: "\<Gamma> \<turnstile> Pr e\<^isub>1 e\<^isub>2 : Data (DProd \<sigma>1 \<sigma>\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   296
inductive_cases2 t_Case_inv_auto[elim]: "\<Gamma> \<turnstile> Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   297
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   298
declare trm.inject [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   299
declare ty.inject [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   300
declare data.inject [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   301
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   302
lemma t_Lam_elim[elim]: 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   303
  assumes a1:"\<Gamma> \<turnstile> Lam [x].t : T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   304
  and     a2: "x\<sharp>\<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   305
  obtains T\<^isub>1 and T\<^isub>2 where "(x,T\<^isub>1)#\<Gamma> \<turnstile> t : T\<^isub>2" and "T=T\<^isub>1\<rightarrow>T\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   306
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   307
  from a1 obtain x' t' T\<^isub>1 T\<^isub>2 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   308
    where b1: "x'\<sharp>\<Gamma>" and b2: "(x',T\<^isub>1)#\<Gamma> \<turnstile> t' : T\<^isub>2" and b3: "[x'].t' = [x].t" and b4: "T=T\<^isub>1\<rightarrow>T\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   309
    by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   310
  obtain c::"name" where "c\<sharp>(\<Gamma>,x,x',t,t')" by (erule exists_fresh[OF fs_name1])
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   311
  then have fs: "c\<sharp>\<Gamma>" "c\<noteq>x" "c\<noteq>x'" "c\<sharp>t" "c\<sharp>t'" by (simp_all add: fresh_atm[symmetric]) 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   312
  then have b5: "[(x',c)]\<bullet>t'=[(x,c)]\<bullet>t" using b3 fs by (simp add: alpha')
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   313
  have "([(x,c)]\<bullet>[(x',c)]\<bullet>((x',T\<^isub>1)#\<Gamma>)) \<turnstile> ([(x,c)]\<bullet>[(x',c)]\<bullet>t') : T\<^isub>2" using b2
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   314
    by (simp only: typing_eqvt[simplified perm_ty])
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   315
  then have "(x,T\<^isub>1)#\<Gamma> \<turnstile> t : T\<^isub>2" using fs b1 a2 b5 by (perm_simp add: calc_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   316
  then show ?thesis using prems b4 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   317
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   318
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   319
lemma t_Case_elim[elim]: 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   320
  assumes "\<Gamma> \<turnstile> Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 : T" and "x\<^isub>1\<sharp>\<Gamma>" and "x\<^isub>2\<sharp>\<Gamma>" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   321
  obtains \<sigma>\<^isub>1 \<sigma>\<^isub>2 where "\<Gamma> \<turnstile> e : Data (DSum \<sigma>\<^isub>1 \<sigma>\<^isub>2)" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   322
                  and "(x\<^isub>1, Data \<sigma>\<^isub>1)#\<Gamma> \<turnstile> e\<^isub>1 : T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   323
                  and "(x\<^isub>2, Data \<sigma>\<^isub>2)#\<Gamma> \<turnstile> e\<^isub>2 : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   324
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   325
  have f:"x\<^isub>1\<sharp>\<Gamma>" "x\<^isub>2\<sharp>\<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   326
  have "\<Gamma> \<turnstile> Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   327
  then obtain \<sigma>\<^isub>1 \<sigma>\<^isub>2 x\<^isub>1' x\<^isub>2' e\<^isub>1' e\<^isub>2' where 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   328
    h:"\<Gamma> \<turnstile> e : Data (DSum \<sigma>\<^isub>1 \<sigma>\<^isub>2)" and 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   329
    h1:"(x\<^isub>1',Data \<sigma>\<^isub>1)#\<Gamma> \<turnstile> e\<^isub>1' : T" and 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   330
    h2:"(x\<^isub>2',Data \<sigma>\<^isub>2)#\<Gamma> \<turnstile> e\<^isub>2' : T" and
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   331
    e1:"[x\<^isub>1].e\<^isub>1=[x\<^isub>1'].e\<^isub>1'" and e2:"[x\<^isub>2].e\<^isub>2=[x\<^isub>2'].e\<^isub>2'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   332
    by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   333
  obtain c::name where f':"c \<sharp> (x\<^isub>1,x\<^isub>1',e\<^isub>1,e\<^isub>1',\<Gamma>)" by (erule exists_fresh[OF fs_name1])
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   334
  have e1':"[(x\<^isub>1,c)]\<bullet>e\<^isub>1 = [(x\<^isub>1',c)]\<bullet>e\<^isub>1'" using e1 f' by (auto simp add: alpha' fresh_prod fresh_atm)
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   335
  have "[(x\<^isub>1',c)]\<bullet>((x\<^isub>1',Data \<sigma>\<^isub>1)# \<Gamma>) \<turnstile> [(x\<^isub>1',c)]\<bullet>e\<^isub>1' : T" using h1 typing_eqvt' by blast
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   336
  then have x:"(c,Data \<sigma>\<^isub>1)#( [(x\<^isub>1',c)]\<bullet>\<Gamma>) \<turnstile> [(x\<^isub>1',c)]\<bullet>e\<^isub>1': T" using f' 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   337
    by (auto simp add: fresh_atm calc_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   338
  have "x\<^isub>1' \<sharp> \<Gamma>" using h1 typing_implies_valid by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   339
  then have "(c,Data \<sigma>\<^isub>1)#\<Gamma> \<turnstile> [(x\<^isub>1 ,c)]\<bullet>e\<^isub>1 : T" using f' x e1' by (auto simp add: perm_fresh_fresh)
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   340
  then have "[(x\<^isub>1,c)]\<bullet>((c,Data \<sigma>\<^isub>1)#\<Gamma>) \<turnstile> [(x\<^isub>1,c)]\<bullet>[(x\<^isub>1 ,c)]\<bullet>e\<^isub>1 : T" using typing_eqvt' by blast 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   341
  then have "([(x\<^isub>1,c)]\<bullet>(c,Data \<sigma>\<^isub>1)) #\<Gamma> \<turnstile> [(x\<^isub>1,c)]\<bullet>[(x\<^isub>1 ,c)]\<bullet>e\<^isub>1 : T" using f f' 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   342
    by (auto simp add: perm_fresh_fresh)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   343
  then have "([(x\<^isub>1,c)]\<bullet>(c,Data \<sigma>\<^isub>1)) #\<Gamma> \<turnstile> e\<^isub>1 : T" by perm_simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   344
  then have g1:"(x\<^isub>1, Data \<sigma>\<^isub>1)#\<Gamma> \<turnstile> e\<^isub>1 : T"  using f' by (auto simp add: fresh_atm calc_atm fresh_prod)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   345
    (* The second part of the proof is the same *)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   346
  obtain c::name where f':"c \<sharp> (x\<^isub>2,x\<^isub>2',e\<^isub>2,e\<^isub>2',\<Gamma>)" by (erule exists_fresh[OF fs_name1])
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   347
  have e2':"[(x\<^isub>2,c)]\<bullet>e\<^isub>2 = [(x\<^isub>2',c)]\<bullet>e\<^isub>2'" using e2 f' by (auto simp add: alpha' fresh_prod fresh_atm)
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   348
  have "[(x\<^isub>2',c)]\<bullet>((x\<^isub>2',Data \<sigma>\<^isub>2)# \<Gamma>) \<turnstile> [(x\<^isub>2',c)]\<bullet>e\<^isub>2' : T" using h2 typing_eqvt' by blast
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   349
  then have x:"(c,Data \<sigma>\<^isub>2)#([(x\<^isub>2',c)]\<bullet>\<Gamma>) \<turnstile> [(x\<^isub>2',c)]\<bullet>e\<^isub>2': T" using f' 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   350
    by (auto simp add: fresh_atm calc_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   351
  have "x\<^isub>2' \<sharp> \<Gamma>" using h2 typing_implies_valid by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   352
  then have "(c,Data \<sigma>\<^isub>2)#\<Gamma> \<turnstile> [(x\<^isub>2 ,c)]\<bullet>e\<^isub>2 : T" using f' x e2' by (auto simp add: perm_fresh_fresh)
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   353
  then have "[(x\<^isub>2,c)]\<bullet>((c,Data \<sigma>\<^isub>2)#\<Gamma>) \<turnstile> [(x\<^isub>2,c)]\<bullet>[(x\<^isub>2 ,c)]\<bullet>e\<^isub>2 : T" using typing_eqvt' by blast 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   354
  then have "([(x\<^isub>2,c)]\<bullet>(c,Data \<sigma>\<^isub>2))#\<Gamma> \<turnstile> [(x\<^isub>2,c)]\<bullet>[(x\<^isub>2 ,c)]\<bullet>e\<^isub>2 : T" using f f' 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   355
    by (auto simp add: perm_fresh_fresh)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   356
  then have "([(x\<^isub>2,c)]\<bullet>(c,Data \<sigma>\<^isub>2)) #\<Gamma> \<turnstile> e\<^isub>2 : T" by perm_simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   357
  then have g2:"(x\<^isub>2,Data \<sigma>\<^isub>2)#\<Gamma> \<turnstile> e\<^isub>2 : T"  using f' by (auto simp add: fresh_atm calc_atm fresh_prod)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   358
  show ?thesis using g1 g2 prems by auto 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   359
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   360
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   361
lemma weakening: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   362
  assumes "\<Gamma>\<^isub>1 \<turnstile> e: T" and "valid \<Gamma>\<^isub>2" and "\<Gamma>\<^isub>1 \<lless> \<Gamma>\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   363
  shows "\<Gamma>\<^isub>2 \<turnstile> e: T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   364
  using assms
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   365
proof(nominal_induct \<Gamma>\<^isub>1 e T avoiding: \<Gamma>\<^isub>2 rule: typing.strong_induct)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   366
  case (t_Lam x \<Gamma>\<^isub>1 T\<^isub>1 t T\<^isub>2 \<Gamma>\<^isub>2)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   367
  have ih: "\<lbrakk>valid ((x,T\<^isub>1)#\<Gamma>\<^isub>2); (x,T\<^isub>1)#\<Gamma>\<^isub>1 \<lless> (x,T\<^isub>1)#\<Gamma>\<^isub>2\<rbrakk> \<Longrightarrow> (x,T\<^isub>1)#\<Gamma>\<^isub>2 \<turnstile> t : T\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   368
  have H1: "valid \<Gamma>\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   369
  have H2: "\<Gamma>\<^isub>1 \<lless> \<Gamma>\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   370
  have fs: "x\<sharp>\<Gamma>\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   371
  then have "valid ((x,T\<^isub>1)#\<Gamma>\<^isub>2)" using H1 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   372
  moreover have "(x,T\<^isub>1)#\<Gamma>\<^isub>1 \<lless> (x,T\<^isub>1)#\<Gamma>\<^isub>2" using H2 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   373
  ultimately have "(x,T\<^isub>1)#\<Gamma>\<^isub>2 \<turnstile> t : T\<^isub>2" using ih by simp 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   374
  thus "\<Gamma>\<^isub>2 \<turnstile> Lam [x].t : T\<^isub>1\<rightarrow>T\<^isub>2" using fs by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   375
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   376
  case (t_Case x\<^isub>1 \<Gamma>\<^isub>1 e e\<^isub>2 x\<^isub>2 e\<^isub>1 S\<^isub>1 S\<^isub>2 T \<Gamma>\<^isub>2)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   377
  then have ih\<^isub>1: "valid ((x\<^isub>1,Data S\<^isub>1)#\<Gamma>\<^isub>2) \<Longrightarrow> (x\<^isub>1,Data S\<^isub>1)#\<Gamma>\<^isub>2 \<turnstile> e\<^isub>1 : T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   378
       and  ih\<^isub>2: "valid ((x\<^isub>2,Data S\<^isub>2)#\<Gamma>\<^isub>2) \<Longrightarrow> (x\<^isub>2,Data S\<^isub>2)#\<Gamma>\<^isub>2 \<turnstile> e\<^isub>2 : T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   379
       and  ih\<^isub>3: "\<Gamma>\<^isub>2 \<turnstile> e : Data (DSum S\<^isub>1 S\<^isub>2)" by auto 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   380
  have fs\<^isub>1: "x\<^isub>1\<sharp>\<Gamma>\<^isub>2" "x\<^isub>1\<sharp>e" "x\<^isub>1\<sharp>e\<^isub>2" "x\<^isub>1\<sharp>x\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   381
  have fs\<^isub>2: "x\<^isub>2\<sharp>\<Gamma>\<^isub>2" "x\<^isub>2\<sharp>e" "x\<^isub>2\<sharp>e\<^isub>1" "x\<^isub>2\<sharp>x\<^isub>1" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   382
  have "valid \<Gamma>\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   383
  then have "valid ((x\<^isub>1,Data S\<^isub>1)#\<Gamma>\<^isub>2)" and "valid ((x\<^isub>2,Data S\<^isub>2)#\<Gamma>\<^isub>2)" using fs\<^isub>1 fs\<^isub>2 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   384
  then have "(x\<^isub>1, Data S\<^isub>1)#\<Gamma>\<^isub>2 \<turnstile> e\<^isub>1 : T" and "(x\<^isub>2, Data S\<^isub>2)#\<Gamma>\<^isub>2 \<turnstile> e\<^isub>2 : T" using ih\<^isub>1 ih\<^isub>2 by simp_all
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   385
  with ih\<^isub>3 show "\<Gamma>\<^isub>2 \<turnstile> Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 : T" using fs\<^isub>1 fs\<^isub>2 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   386
qed (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   387
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   388
lemma context_exchange:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   389
  assumes a: "(x\<^isub>1,T\<^isub>1)#(x\<^isub>2,T\<^isub>2)#\<Gamma> \<turnstile> e : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   390
  shows "(x\<^isub>2,T\<^isub>2)#(x\<^isub>1,T\<^isub>1)#\<Gamma> \<turnstile> e : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   391
proof -
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   392
  from  a have "valid ((x\<^isub>1,T\<^isub>1)#(x\<^isub>2,T\<^isub>2)#\<Gamma>)" by (simp add: typing_implies_valid)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   393
  then have "x\<^isub>1\<noteq>x\<^isub>2" "x\<^isub>1\<sharp>\<Gamma>" "x\<^isub>2\<sharp>\<Gamma>" "valid \<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   394
    by (auto simp: fresh_list_cons fresh_atm[symmetric])
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   395
  then have "valid ((x\<^isub>2,T\<^isub>2)#(x\<^isub>1,T\<^isub>1)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   396
    by (auto simp: fresh_list_cons fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   397
  moreover 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   398
  have "(x\<^isub>1,T\<^isub>1)#(x\<^isub>2,T\<^isub>2)#\<Gamma> \<lless> (x\<^isub>2,T\<^isub>2)#(x\<^isub>1,T\<^isub>1)#\<Gamma>" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   399
  ultimately show "(x\<^isub>2,T\<^isub>2)#(x\<^isub>1,T\<^isub>1)#\<Gamma> \<turnstile> e : T" using a by (auto intro: weakening)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   400
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   401
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   402
lemma typing_var_unicity: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   403
  assumes "(x,t\<^isub>1)#\<Gamma> \<turnstile> Var x : t\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   404
  shows "t\<^isub>1=t\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   405
proof - 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   406
  have "(x,t\<^isub>2) \<in> set ((x,t\<^isub>1)#\<Gamma>)" and "valid ((x,t\<^isub>1)#\<Gamma>)" using assms by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   407
  thus "t\<^isub>1=t\<^isub>2" by (simp only: type_unicity_in_context)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   408
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   409
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   410
lemma typing_substitution: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   411
  fixes \<Gamma>::"(name \<times> ty) list"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   412
  assumes "(x,T')#\<Gamma> \<turnstile> e : T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   413
  and     "\<Gamma> \<turnstile> e': T'" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   414
  shows "\<Gamma> \<turnstile> e[x::=e'] : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   415
  using assms
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   416
proof (nominal_induct e avoiding: \<Gamma> e' x arbitrary: T rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   417
  case (Var y \<Gamma> e' x T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   418
  have h1: "(x,T')#\<Gamma> \<turnstile> Var y : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   419
  have h2: "\<Gamma> \<turnstile> e' : T'" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   420
  show "\<Gamma> \<turnstile> (Var y)[x::=e'] : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   421
  proof (cases "x=y")
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   422
    case True
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   423
    assume as: "x=y"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   424
    then have "T=T'" using h1 typing_var_unicity by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   425
    then show "\<Gamma> \<turnstile> (Var y)[x::=e'] : T" using as h2 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   426
  next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   427
    case False
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   428
    assume as: "x\<noteq>y" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   429
    have "(y,T) \<in> set ((x,T')#\<Gamma>)" using h1 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   430
    then have "(y,T) \<in> set \<Gamma>" using as by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   431
    moreover 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   432
    have "valid \<Gamma>" using h2 by (simp only: typing_implies_valid)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   433
    ultimately show "\<Gamma> \<turnstile> (Var y)[x::=e'] : T" using as by (simp add: t_Var)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   434
  qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   435
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   436
  case (Lam y t \<Gamma> e' x T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   437
  have vc: "y\<sharp>\<Gamma>" "y\<sharp>x" "y\<sharp>e'"  by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   438
  have pr1: "\<Gamma> \<turnstile> e' : T'" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   439
  have pr2: "(x,T')#\<Gamma> \<turnstile> Lam [y].t : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   440
  then obtain T\<^isub>1 T\<^isub>2 where pr2': "(y,T\<^isub>1)#(x,T')#\<Gamma> \<turnstile> t : T\<^isub>2" and eq: "T = T\<^isub>1\<rightarrow>T\<^isub>2" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   441
    using vc by (auto simp add: fresh_list_cons)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   442
  then have pr2'':"(x,T')#(y,T\<^isub>1)#\<Gamma> \<turnstile> t : T\<^isub>2" by (simp add: context_exchange)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   443
  have ih: "\<lbrakk>(x,T')#(y,T\<^isub>1)#\<Gamma> \<turnstile> t : T\<^isub>2; (y,T\<^isub>1)#\<Gamma> \<turnstile> e' : T'\<rbrakk> \<Longrightarrow> (y,T\<^isub>1)#\<Gamma> \<turnstile> t[x::=e'] : T\<^isub>2" by fact
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   444
  have "valid \<Gamma>" using pr1 by (simp add: typing_implies_valid)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   445
  then have "valid ((y,T\<^isub>1)#\<Gamma>)" using vc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   446
  then have "(y,T\<^isub>1)#\<Gamma> \<turnstile> e' : T'" using pr1 by (auto intro: weakening)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   447
  then have "(y,T\<^isub>1)#\<Gamma> \<turnstile> t[x::=e'] : T\<^isub>2" using ih pr2'' by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   448
  then have "\<Gamma> \<turnstile> Lam [y].(t[x::=e']) : T\<^isub>1\<rightarrow>T\<^isub>2" using vc by (auto intro: t_Lam)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   449
  thus "\<Gamma> \<turnstile> (Lam [y].t)[x::=e'] : T" using vc eq by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   450
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   451
  case (Case t\<^isub>1 x\<^isub>1 t\<^isub>2 x\<^isub>2 t3 \<Gamma> e' x T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   452
  have vc: "x\<^isub>1\<sharp>\<Gamma>" "x\<^isub>1\<sharp>e'" "x\<^isub>1\<sharp>x""x\<^isub>1\<sharp>t\<^isub>1" "x\<^isub>1\<sharp>t3" "x\<^isub>2\<sharp>\<Gamma>" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   453
           "x\<^isub>2\<sharp>e'" "x\<^isub>2\<sharp>x"  "x\<^isub>2\<sharp>t\<^isub>1" "x\<^isub>2\<sharp>t\<^isub>2" "x\<^isub>2\<noteq>x\<^isub>1" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   454
  have as1: "\<Gamma> \<turnstile> e' : T'" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   455
  have as2: "(x,T')#\<Gamma> \<turnstile> Case t\<^isub>1 of inl x\<^isub>1 \<rightarrow> t\<^isub>2 | inr x\<^isub>2 \<rightarrow> t3 : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   456
  then obtain S\<^isub>1 S\<^isub>2 where 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   457
    h1:"(x,T')#\<Gamma> \<turnstile> t\<^isub>1 : Data (DSum S\<^isub>1 S\<^isub>2)" and
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   458
    h2:"(x\<^isub>1,Data S\<^isub>1)#(x,T')#\<Gamma> \<turnstile> t\<^isub>2 : T" and
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   459
    h3:"(x\<^isub>2,Data S\<^isub>2)#(x,T')#\<Gamma> \<turnstile> t3 : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   460
    using vc by (auto simp add: fresh_list_cons)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   461
  have ih1: "\<lbrakk>(x,T')#\<Gamma> \<turnstile> t\<^isub>1 : T; \<Gamma> \<turnstile> e' : T'\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> t\<^isub>1[x::=e'] : T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   462
  and  ih2: "\<lbrakk>(x,T')#(x\<^isub>1,Data S\<^isub>1)#\<Gamma> \<turnstile> t\<^isub>2:T; (x\<^isub>1,Data S\<^isub>1)#\<Gamma> \<turnstile> e':T'\<rbrakk> \<Longrightarrow> (x\<^isub>1,Data S\<^isub>1)#\<Gamma> \<turnstile> t\<^isub>2[x::=e']:T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   463
  and  ih3: "\<lbrakk>(x,T')#(x\<^isub>2,Data S\<^isub>2)#\<Gamma> \<turnstile> t3:T; (x\<^isub>2,Data S\<^isub>2)#\<Gamma> \<turnstile> e':T'\<rbrakk> \<Longrightarrow> (x\<^isub>2,Data S\<^isub>2)#\<Gamma> \<turnstile> t3[x::=e']:T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   464
    by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   465
  from h2 have h2': "(x,T')#(x\<^isub>1,Data S\<^isub>1)#\<Gamma> \<turnstile> t\<^isub>2 : T" by (rule context_exchange)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   466
  from h3 have h3': "(x,T')#(x\<^isub>2,Data S\<^isub>2)#\<Gamma> \<turnstile> t3 : T" by (rule context_exchange)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   467
  have "\<Gamma> \<turnstile> t\<^isub>1[x::=e'] : Data (DSum S\<^isub>1 S\<^isub>2)" using h1 ih1 as1 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   468
  moreover
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   469
  have "valid ((x\<^isub>1,Data S\<^isub>1)#\<Gamma>)" using h2' by (auto dest: typing_implies_valid)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   470
  then have "(x\<^isub>1,Data S\<^isub>1)#\<Gamma> \<turnstile> e' : T'" using as1 by (auto simp add: weakening)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   471
  then have "(x\<^isub>1,Data S\<^isub>1)#\<Gamma> \<turnstile> t\<^isub>2[x::=e'] : T" using ih2 h2' by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   472
  moreover 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   473
  have "valid ((x\<^isub>2,Data S\<^isub>2)#\<Gamma>)" using h3' by (auto dest: typing_implies_valid)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   474
  then have "(x\<^isub>2,Data S\<^isub>2)#\<Gamma> \<turnstile> e' : T'" using as1 by (auto simp add: weakening)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   475
  then have "(x\<^isub>2,Data S\<^isub>2)#\<Gamma> \<turnstile> t3[x::=e'] : T" using ih3 h3' by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   476
  ultimately have "\<Gamma> \<turnstile> Case (t\<^isub>1[x::=e']) of inl x\<^isub>1 \<rightarrow> (t\<^isub>2[x::=e']) | inr x\<^isub>2 \<rightarrow> (t3[x::=e']) : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   477
    using vc by (auto simp add: fresh_atm fresh_subst)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   478
  thus "\<Gamma> \<turnstile> (Case t\<^isub>1 of inl x\<^isub>1 \<rightarrow> t\<^isub>2 | inr x\<^isub>2 \<rightarrow> t3)[x::=e'] : T" using vc by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   479
qed (simp, fast)+
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   480
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   481
text {* Big-Step Evaluation *}
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   482
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   483
inductive2
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   484
  big :: "trm\<Rightarrow>trm\<Rightarrow>bool" ("_ \<Down> _" [80,80] 80) 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   485
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   486
  b_Lam[intro]:   "Lam [x].e \<Down> Lam [x].e"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   487
| b_App[intro]:   "\<lbrakk>x\<sharp>(e\<^isub>1,e\<^isub>2,e'); e\<^isub>1\<Down>Lam [x].e; e\<^isub>2\<Down>e\<^isub>2'; e[x::=e\<^isub>2']\<Down>e'\<rbrakk> \<Longrightarrow> App e\<^isub>1 e\<^isub>2 \<Down> e'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   488
| b_Const[intro]: "Const n \<Down> Const n"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   489
| b_Pr[intro]:    "\<lbrakk>e\<^isub>1\<Down>e\<^isub>1'; e\<^isub>2\<Down>e\<^isub>2'\<rbrakk> \<Longrightarrow> Pr e\<^isub>1 e\<^isub>2 \<Down> Pr e\<^isub>1' e\<^isub>2'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   490
| b_Fst[intro]:   "e\<Down>Pr e\<^isub>1 e\<^isub>2 \<Longrightarrow> Fst e\<Down>e\<^isub>1"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   491
| b_Snd[intro]:   "e\<Down>Pr e\<^isub>1 e\<^isub>2 \<Longrightarrow> Snd e\<Down>e\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   492
| b_InL[intro]:   "e\<Down>e' \<Longrightarrow> InL e \<Down> InL e'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   493
| b_InR[intro]:   "e\<Down>e' \<Longrightarrow> InR e \<Down> InR e'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   494
| b_CaseL[intro]: "\<lbrakk>x\<^isub>1\<sharp>(e,e\<^isub>2,e'',x\<^isub>2); x\<^isub>2\<sharp>(e,e\<^isub>1,e'',x\<^isub>1) ; e\<Down>InL e'; e\<^isub>1[x\<^isub>1::=e']\<Down>e''\<rbrakk> 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   495
                   \<Longrightarrow> Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 \<Down> e''"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   496
| b_CaseR[intro]: "\<lbrakk>x\<^isub>1\<sharp>(e,e\<^isub>2,e'',x\<^isub>2); x\<^isub>2\<sharp>(e,e\<^isub>1,e'',x\<^isub>1) ; e\<Down>InR e'; e\<^isub>2[x\<^isub>2::=e']\<Down>e''\<rbrakk> 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   497
                   \<Longrightarrow> Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 \<Down> e''"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   498
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   499
nominal_inductive big
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   500
  by (simp_all add: abs_fresh fresh_prod fresh_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   501
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   502
lemma big_eqvt':
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   503
  fixes pi::"name prm"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   504
  assumes a: "(pi\<bullet>t) \<Down> (pi\<bullet>t')"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   505
  shows "t \<Down> t'"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   506
using a
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   507
apply -
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   508
apply(drule_tac pi="rev pi" in big_eqvt)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   509
apply(perm_simp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   510
done
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   511
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   512
lemma fresh_preserved:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   513
  fixes x::name
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   514
  fixes t::trm
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   515
  fixes t'::trm
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   516
  assumes "e \<Down> e'" and "x\<sharp>e" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   517
  shows "x\<sharp>e'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   518
  using assms by (induct) (auto simp add:fresh_subst')
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   519
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   520
declare trm.inject  [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   521
declare ty.inject  [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   522
declare data.inject [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   523
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   524
inductive_cases2 b_App_inv_auto[elim]: "App e\<^isub>1 e\<^isub>2 \<Down> t" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   525
inductive_cases2 b_Case_inv_auto[elim]: "Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 \<Down> t"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   526
inductive_cases2 b_Lam_inv_auto[elim]: "Lam[x].t \<Down> t"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   527
inductive_cases2 b_Const_inv_auto[elim]: "Const n \<Down> t"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   528
inductive_cases2 b_Fst_inv_auto[elim]: "Fst e \<Down> t"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   529
inductive_cases2 b_Snd_inv_auto[elim]: "Snd e \<Down> t"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   530
inductive_cases2 b_InL_inv_auto[elim]: "InL e \<Down> t"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   531
inductive_cases2 b_InR_inv_auto[elim]: "InR e \<Down> t"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   532
inductive_cases2 b_Pr_inv_auto[elim]: "Pr e\<^isub>1 e\<^isub>2 \<Down> t"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   533
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   534
declare trm.inject  [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   535
declare ty.inject  [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   536
declare data.inject [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   537
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   538
lemma b_App_elim[elim]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   539
  assumes "App e\<^isub>1 e\<^isub>2 \<Down> e'" and "x\<sharp>(e\<^isub>1,e\<^isub>2,e')"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   540
  obtains f\<^isub>1 and f\<^isub>2 where "e\<^isub>1 \<Down> Lam [x]. f\<^isub>1" "e\<^isub>2 \<Down> f\<^isub>2" "f\<^isub>1[x::=f\<^isub>2] \<Down> e'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   541
  using assms
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   542
  apply -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   543
  apply(erule b_App_inv_auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   544
  apply(drule_tac pi="[(xa,x)]" in big_eqvt)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   545
  apply(drule_tac pi="[(xa,x)]" in big_eqvt)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   546
  apply(drule_tac pi="[(xa,x)]" in big_eqvt)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   547
  apply(perm_simp add: calc_atm eqvt)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   548
  done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   549
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   550
lemma  b_CaseL_elim[elim]: 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   551
  assumes "Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 \<Down> e''" 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   552
  and     "\<And> t. \<not>  e \<Down> InR t"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   553
  and     "x\<^isub>1\<sharp>e''" "x\<^isub>1\<sharp>e" "x\<^isub>2\<sharp>e''" "x\<^isub>1\<sharp>e"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   554
  obtains e' where "e \<Down> InL e'" and "e\<^isub>1[x\<^isub>1::=e'] \<Down> e''"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   555
  using assms 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   556
  apply -
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   557
  apply(rule b_Case_inv_auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   558
  apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   559
  apply(simp add: alpha)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   560
  apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   561
  apply(drule_tac x="[(x\<^isub>1,x\<^isub>1')]\<bullet>e'" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   562
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   563
  apply(rule_tac pi="[(x\<^isub>1,x\<^isub>1')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   564
  apply(perm_simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   565
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   566
  apply(rule_tac pi="[(x\<^isub>1,x\<^isub>1')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   567
  apply(perm_simp add: eqvt calc_atm)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   568
  apply(assumption)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   569
  apply(drule_tac x="[(x\<^isub>1,x\<^isub>1')]\<bullet>e'" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   570
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   571
  apply(rule_tac pi="[(x\<^isub>1,x\<^isub>1')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   572
  apply(perm_simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   573
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   574
  apply(rule_tac pi="[(x\<^isub>1,x\<^isub>1')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   575
  apply(perm_simp add: eqvt calc_atm)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   576
  apply(assumption)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   577
done
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   578
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   579
lemma b_CaseR_elim[elim]: 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   580
  assumes "Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 \<Down> e''" 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   581
  and     "\<And> t. \<not> e \<Down> InL t"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   582
  and     "x\<^isub>1\<sharp>e''" "x\<^isub>1\<sharp>e" "x\<^isub>2\<sharp>e''" "x\<^isub>2\<sharp>e"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   583
  obtains e' where "e \<Down> InR e'" and "e\<^isub>2[x\<^isub>2::=e'] \<Down> e''"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   584
  using assms 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   585
  apply -
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   586
  apply(rule b_Case_inv_auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   587
  apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   588
  apply(simp add: alpha)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   589
  apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   590
  apply(drule_tac x="[(x\<^isub>2,x\<^isub>2')]\<bullet>e'" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   591
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   592
  apply(rule_tac pi="[(x\<^isub>2,x\<^isub>2')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   593
  apply(perm_simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   594
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   595
  apply(rule_tac pi="[(x\<^isub>2,x\<^isub>2')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   596
  apply(perm_simp add: eqvt calc_atm)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   597
  apply(assumption)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   598
  apply(drule_tac x="[(x\<^isub>2,x\<^isub>2')]\<bullet>e'" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   599
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   600
  apply(rule_tac pi="[(x\<^isub>2,x\<^isub>2')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   601
  apply(perm_simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   602
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   603
  apply(rule_tac pi="[(x\<^isub>2,x\<^isub>2')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   604
  apply(perm_simp add: eqvt calc_atm)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   605
  apply(assumption)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   606
done
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   607
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   608
inductive2
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   609
  val :: "trm\<Rightarrow>bool" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   610
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   611
  v_Lam[intro]:   "val (Lam [x].e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   612
| v_Const[intro]: "val (Const n)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   613
| v_Pr[intro]:    "\<lbrakk>val e\<^isub>1; val e\<^isub>2\<rbrakk> \<Longrightarrow> val (Pr e\<^isub>1 e\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   614
| v_InL[intro]:   "val e \<Longrightarrow> val (InL e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   615
| v_InR[intro]:   "val e \<Longrightarrow> val (InR e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   616
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   617
declare trm.inject  [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   618
declare ty.inject  [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   619
declare data.inject [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   620
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   621
inductive_cases2 v_Const_inv_auto[elim]: "val (Const n)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   622
inductive_cases2 v_Pr_inv_auto[elim]: "val (Pr e\<^isub>1 e\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   623
inductive_cases2 v_InL_inv_auto[elim]: "val (InL e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   624
inductive_cases2 v_InR_inv_auto[elim]: "val (InR e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   625
inductive_cases2 v_Fst_inv_auto[elim]: "val (Fst e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   626
inductive_cases2 v_Snd_inv_auto[elim]: "val (Snd e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   627
inductive_cases2 v_Case_inv_auto[elim]: "val (Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   628
inductive_cases2 v_Var_inv_auto[elim]: "val (Var x)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   629
inductive_cases2 v_Lam_inv_auto[elim]: "val (Lam [x].e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   630
inductive_cases2 v_App_inv_auto[elim]: "val (App e\<^isub>1 e\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   631
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   632
declare trm.inject  [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   633
declare ty.inject  [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   634
declare data.inject [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   635
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   636
lemma subject_reduction:
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   637
  assumes a: "e \<Down> e'" 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   638
  and     b: "\<Gamma> \<turnstile> e : T"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   639
  shows "\<Gamma> \<turnstile> e' : T"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   640
  using a b
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   641
proof (nominal_induct avoiding: \<Gamma> arbitrary: T rule: big.strong_induct) 
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   642
  case (b_App x e\<^isub>1 e\<^isub>2 e' e e\<^isub>2' \<Gamma> T)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   643
  have vc: "x\<sharp>\<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   644
  have "\<Gamma> \<turnstile> App e\<^isub>1 e\<^isub>2 : T" by fact
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   645
  then obtain T' where 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   646
    a1: "\<Gamma> \<turnstile> e\<^isub>1 : T'\<rightarrow>T" and  
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   647
    a2: "\<Gamma> \<turnstile> e\<^isub>2 : T'" by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   648
  have ih1: "\<Gamma> \<turnstile> e\<^isub>1 : T' \<rightarrow> T \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].e : T' \<rightarrow> T" by fact
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   649
  have ih2: "\<Gamma> \<turnstile> e\<^isub>2 : T' \<Longrightarrow> \<Gamma> \<turnstile> e\<^isub>2' : T'" by fact 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   650
  have ih3: "\<Gamma> \<turnstile> e[x::=e\<^isub>2'] : T \<Longrightarrow> \<Gamma> \<turnstile> e' : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   651
  have "\<Gamma> \<turnstile> Lam [x].e : T'\<rightarrow>T" using ih1 a1 by simp 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   652
  then have "((x,T')#\<Gamma>) \<turnstile> e : T" using vc by (auto simp add: ty.inject)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   653
  moreover
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   654
  have "\<Gamma> \<turnstile> e\<^isub>2': T'" using ih2 a2 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   655
  ultimately have "\<Gamma> \<turnstile> e[x::=e\<^isub>2'] : T" by (simp add: typing_substitution)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   656
  thus "\<Gamma> \<turnstile> e' : T" using ih3 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   657
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   658
  case (b_CaseL x\<^isub>1 e e\<^isub>2 e'' x\<^isub>2 e\<^isub>1 e' \<Gamma>)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   659
  have vc: "x\<^isub>1\<sharp>\<Gamma>" "x\<^isub>2\<sharp>\<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   660
  have "\<Gamma> \<turnstile> Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 : T" by fact 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   661
  then obtain S\<^isub>1 S\<^isub>2 e\<^isub>1' e\<^isub>2' where 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   662
    a1: "\<Gamma> \<turnstile> e : Data (DSum S\<^isub>1 S\<^isub>2)" and 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   663
    a2: "((x\<^isub>1,Data S\<^isub>1)#\<Gamma>) \<turnstile> e\<^isub>1 : T" using vc by auto 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   664
  have ih1:"\<Gamma> \<turnstile> e : Data (DSum S\<^isub>1 S\<^isub>2) \<Longrightarrow> \<Gamma> \<turnstile> InL e' : Data (DSum S\<^isub>1 S\<^isub>2)" by fact 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   665
  have ih2:"\<Gamma> \<turnstile> e\<^isub>1[x\<^isub>1::=e'] : T \<Longrightarrow> \<Gamma> \<turnstile> e'' : T " by fact 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   666
  have "\<Gamma> \<turnstile> InL e' : Data (DSum S\<^isub>1 S\<^isub>2)" using ih1 a1 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   667
  then have "\<Gamma> \<turnstile> e' : Data S\<^isub>1" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   668
  then have "\<Gamma> \<turnstile> e\<^isub>1[x\<^isub>1::=e'] : T" using a2 by (simp add: typing_substitution)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   669
  then show "\<Gamma> \<turnstile> e'' : T" using ih2 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   670
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   671
 case (b_CaseR x\<^isub>1 e e\<^isub>2 e'' x\<^isub>2 e\<^isub>1 e' \<Gamma> T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   672
 then show "\<Gamma> \<turnstile> e'' : T" by (blast intro: typing_substitution)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   673
qed (blast)+
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   674
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   675
lemma unicity_of_evaluation:
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   676
  assumes a: "e \<Down> e\<^isub>1" 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   677
  and     b: "e \<Down> e\<^isub>2"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   678
  shows "e\<^isub>1 = e\<^isub>2"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   679
  using a b
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   680
proof (nominal_induct e e\<^isub>1 avoiding: e\<^isub>2 rule: big.strong_induct)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   681
  case (b_Lam x e t\<^isub>2)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   682
  have "Lam [x].e \<Down> t\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   683
  thus "Lam [x].e = t\<^isub>2" by (cases, simp_all add: trm.inject)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   684
next
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   685
  case (b_App x e\<^isub>1 e\<^isub>2 e' e\<^isub>1' e\<^isub>2' t\<^isub>2)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   686
  have ih1: "\<And>t. e\<^isub>1 \<Down> t \<Longrightarrow> Lam [x].e\<^isub>1' = t" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   687
  have ih2:"\<And>t. e\<^isub>2 \<Down> t \<Longrightarrow> e\<^isub>2' = t" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   688
  have ih3: "\<And>t. e\<^isub>1'[x::=e\<^isub>2'] \<Down> t \<Longrightarrow> e' = t" by fact
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   689
  have app: "App e\<^isub>1 e\<^isub>2 \<Down> t\<^isub>2" by fact
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   690
  have vc: "x\<sharp>e\<^isub>1" "x\<sharp>e\<^isub>2" by fact
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   691
  then have "x \<sharp> App e\<^isub>1 e\<^isub>2" by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   692
  then have vc': "x\<sharp>t\<^isub>2" using fresh_preserved app by blast
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   693
  from vc vc' obtain f\<^isub>1 f\<^isub>2 where x1: "e\<^isub>1 \<Down> Lam [x]. f\<^isub>1" and x2: "e\<^isub>2 \<Down> f\<^isub>2" and x3: "f\<^isub>1[x::=f\<^isub>2] \<Down> t\<^isub>2"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   694
    using app by (auto simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   695
  then have "Lam [x]. f\<^isub>1 = Lam [x]. e\<^isub>1'" using ih1 by simp
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   696
  then 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   697
  have "f\<^isub>1 = e\<^isub>1'" by (auto simp add: trm.inject alpha) 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   698
  moreover 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   699
  have "f\<^isub>2 = e\<^isub>2'" using x2 ih2 by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   700
  ultimately have "e\<^isub>1'[x::=e\<^isub>2'] \<Down> t\<^isub>2" using x3 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   701
  thus ?case using ih3 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   702
next
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   703
  case (b_CaseL  x\<^isub>1 e e\<^isub>2 e'' x\<^isub>2 e\<^isub>1 e' t\<^isub>2)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   704
  have fs: "x\<^isub>1\<sharp>e" "x\<^isub>1\<sharp>t\<^isub>2" "x\<^isub>2\<sharp>e" "x\<^isub>2\<sharp>t\<^isub>2" by fact 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   705
  have ih1:"\<And>t. e \<Down> t \<Longrightarrow> InL e' = t" by fact 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   706
  have ih2:"\<And>t. e\<^isub>1[x\<^isub>1::=e'] \<Down> t \<Longrightarrow> e'' = t" by fact
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   707
  have ha: "\<not>(\<exists>t. e \<Down> InR t)" using ih1 by force
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   708
  have "Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 \<Down> t\<^isub>2" by fact
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   709
  then obtain f' where "e \<Down> InL f'" and h: "e\<^isub>1[x\<^isub>1::=f']\<Down>t\<^isub>2" using ha fs by auto
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   710
  then have "InL f' = InL e'" using ih1 by simp
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   711
  then have "f' = e'" by (simp add: trm.inject)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   712
  then have "e\<^isub>1[x\<^isub>1::=e'] \<Down> t\<^isub>2" using h by simp
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   713
  then show "e'' = t\<^isub>2" using ih2 by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   714
next 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   715
  case (b_CaseR x\<^isub>1 e e\<^isub>2 e'' x\<^isub>2 e\<^isub>1 e' t\<^isub>2 )
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   716
  have fs: "x\<^isub>1\<sharp>e" "x\<^isub>1\<sharp>t\<^isub>2" "x\<^isub>2\<sharp>e" "x\<^isub>2\<sharp>t\<^isub>2" by fact 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   717
  have ih1: "\<And>t. e \<Down> t \<Longrightarrow> InR e' = t" by fact
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   718
  have ih2: "\<And>t. e\<^isub>2[x\<^isub>2::=e'] \<Down> t \<Longrightarrow> e'' = t" by fact
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   719
  have ha: "\<not>(\<exists>t. e \<Down> InL t)" using ih1 by force
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   720
  have "Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 \<Down> t\<^isub>2" by fact
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   721
  then obtain f' where "e \<Down> InR f'" and h: "e\<^isub>2[x\<^isub>2::=f']\<Down>t\<^isub>2"  using ha fs by auto
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   722
  then have "InR f' = InR e'" using ih1 by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   723
  then have "e\<^isub>2[x\<^isub>2::=e'] \<Down> t\<^isub>2" using h by (simp add: trm.inject)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   724
  thus "e'' = t\<^isub>2" using ih2 by simp
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   725
next
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   726
  case b_Const
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   727
  then show ?case by force
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   728
next
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   729
  case b_Pr
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   730
  then show ?case by blast
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   731
next
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   732
  case b_Fst
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   733
  then show ?case by (force simp add: trm.inject)
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   734
next
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   735
  case b_Snd
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   736
  then show ?case by (force simp add: trm.inject)
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   737
next
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   738
  case b_InL 
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   739
  then show ?case by blast 
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   740
next
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   741
  case b_InR 
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   742
  then show ?case by blast
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   743
qed 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   744
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   745
lemma not_val_App[simp]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   746
  shows 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   747
  "\<not> val (App e\<^isub>1 e\<^isub>2)" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   748
  "\<not> val (Fst e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   749
  "\<not> val (Snd e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   750
  "\<not> val (Var x)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   751
  "\<not> val (Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   752
by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   753
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   754
lemma reduces_evaluates_to_values:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   755
  assumes h:"t \<Down> t'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   756
  shows "val t'"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   757
  using h by (induct) (auto)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   758
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   759
lemma type_prod_evaluates_to_pairs:
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   760
  assumes a: "\<Gamma> \<turnstile> t : Data (DProd S\<^isub>1 S\<^isub>2)" 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   761
  and     b: "t \<Down> t'"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   762
  obtains t\<^isub>1 t\<^isub>2 where "t' = Pr t\<^isub>1 t\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   763
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   764
   have "\<Gamma> \<turnstile> t' : Data (DProd S\<^isub>1 S\<^isub>2)" using assms subject_reduction by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   765
   moreover
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   766
   have "val t'" using reduces_evaluates_to_values assms by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   767
   ultimately obtain t\<^isub>1 t\<^isub>2 where "t' = Pr t\<^isub>1 t\<^isub>2" by (cases, auto simp add:ty.inject data.inject)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   768
   thus ?thesis using prems by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   769
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   770
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   771
lemma type_sum_evaluates_to_ins:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   772
  assumes "\<Gamma> \<turnstile> t : Data (DSum \<sigma>\<^isub>1 \<sigma>\<^isub>2)" and "t \<Down> t'"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   773
  shows "(\<exists>t''. t' = InL t'') \<or> (\<exists>t''. t' = InR t'')"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   774
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   775
  have "\<Gamma> \<turnstile> t' : Data (DSum \<sigma>\<^isub>1 \<sigma>\<^isub>2)" using assms subject_reduction by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   776
  moreover
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   777
  have "val t'" using reduces_evaluates_to_values assms by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   778
  ultimately obtain t'' where "t' = InL t'' \<or>  t' = InR t''"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   779
    by (cases, auto simp add:ty.inject data.inject)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   780
  thus ?thesis by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   781
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   782
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   783
lemma type_arrow_evaluates_to_lams:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   784
  assumes "\<Gamma> \<turnstile> t : \<sigma> \<rightarrow> \<tau>" and "t \<Down> t'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   785
  obtains  x t'' where "t' = Lam [x]. t''"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   786
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   787
  have "\<Gamma> \<turnstile> t' : \<sigma> \<rightarrow> \<tau>" using assms subject_reduction by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   788
  moreover
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   789
  have "val t'" using reduces_evaluates_to_values assms by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   790
  ultimately obtain x t'' where "t' = Lam [x]. t''" by (cases, auto simp add:ty.inject data.inject)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   791
  thus ?thesis using prems by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   792
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   793
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   794
lemma type_nat_evaluates_to_consts:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   795
  assumes "\<Gamma> \<turnstile> t : Data DNat" and "t \<Down> t'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   796
  obtains n where "t' = Const n"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   797
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   798
  have "\<Gamma> \<turnstile> t' : Data DNat " using assms subject_reduction by simp
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   799
  moreover have "val t'" using reduces_evaluates_to_values assms by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   800
  ultimately obtain n where "t' = Const n" by (cases, auto simp add:ty.inject data.inject)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   801
  thus ?thesis using prems by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   802
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   803
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   804
consts
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   805
  V' :: "data \<Rightarrow> trm set" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   806
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   807
nominal_primrec    
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   808
  "V' (DNat) = {Const n | n. n \<in> (UNIV::nat set)}"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   809
  "V' (DProd S\<^isub>1 S\<^isub>2) = {Pr x y | x y. x \<in> V' S\<^isub>1 \<and> y \<in> V' S\<^isub>2}"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   810
  "V' (DSum S\<^isub>1 S\<^isub>2) = {InL x | x. x \<in> V' S\<^isub>1} \<union> {InR y | y. y \<in> V' S\<^isub>2}"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   811
apply(rule TrueI)+
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   812
done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   813
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   814
lemma Vprimes_are_values :
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   815
  fixes S::"data"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   816
  assumes h: "e \<in> V' S"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   817
  shows "val e"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   818
using h 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   819
by (nominal_induct S arbitrary: e rule:data.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   820
   (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   821
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   822
lemma V'_eqvt:
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   823
  fixes pi::"name prm"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   824
  assumes a: "v \<in> V' S"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   825
  shows "(pi\<bullet>v) \<in> V' S"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   826
using a
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   827
by (nominal_induct S arbitrary: v rule: data.induct)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   828
   (auto simp add: trm.inject)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   829
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   830
consts
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   831
  V :: "ty \<Rightarrow> trm set" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   832
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   833
nominal_primrec
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   834
  "V (Data S) = V' S"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   835
  "V (T\<^isub>1 \<rightarrow> T\<^isub>2) = {Lam [x].e | x e. \<forall> v \<in> (V T\<^isub>1). \<exists> v'. e[x::=v] \<Down> v' \<and> v' \<in> V T\<^isub>2}"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   836
apply(rule TrueI)+ 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   837
done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   838
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   839
lemma V_eqvt:
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   840
  fixes pi::"name prm"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   841
  assumes a: "x\<in>V T"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   842
  shows "(pi\<bullet>x)\<in>V T"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   843
using a
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   844
apply(nominal_induct T arbitrary: pi x rule: ty.induct)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   845
apply(auto simp add: trm.inject perm_set_def)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   846
apply(perm_simp add: V'_eqvt)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   847
apply(rule_tac x="pi\<bullet>xa" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   848
apply(rule_tac x="pi\<bullet>e" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   849
apply(simp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   850
apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   851
apply(drule_tac x="(rev pi)\<bullet>v" in bspec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   852
apply(force)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   853
apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   854
apply(rule_tac x="pi\<bullet>v'" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   855
apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   856
apply(drule_tac pi="pi" in big_eqvt)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   857
apply(perm_simp add: eqvt)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   858
done
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   859
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   860
lemma V_arrow_elim_weak[elim] :
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   861
  assumes h:"u \<in> (V (T\<^isub>1 \<rightarrow> T\<^isub>2))"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   862
  obtains a t where "u = Lam[a].t" and "\<forall> v \<in> (V T\<^isub>1). \<exists> v'. t[a::=v] \<Down> v' \<and> v' \<in> V T\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   863
using h by (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   864
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   865
lemma V_arrow_elim_strong[elim]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   866
  fixes c::"'a::fs_name"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   867
  assumes h: "u \<in> V (T\<^isub>1 \<rightarrow> T\<^isub>2)"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   868
  obtains a t where "a\<sharp>c" "u = Lam[a].t" "\<forall>v \<in> (V T\<^isub>1). \<exists> v'. t[a::=v] \<Down> v' \<and> v' \<in> V T\<^isub>2"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   869
using h
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   870
apply -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   871
apply(erule V_arrow_elim_weak)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   872
apply(subgoal_tac "\<exists>a'::name. a'\<sharp>(a,t,c)") (*A*)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   873
apply(erule exE)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   874
apply(drule_tac x="a'" in meta_spec)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   875
apply(drule_tac x="[(a,a')]\<bullet>t" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   876
apply(drule meta_mp)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   877
apply(simp)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   878
apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   879
apply(simp add: trm.inject alpha fresh_left fresh_prod calc_atm fresh_atm)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   880
apply(perm_simp)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   881
apply(force)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   882
apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   883
apply(rule ballI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   884
apply(drule_tac x="[(a,a')]\<bullet>v" in bspec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   885
apply(simp add: V_eqvt)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   886
apply(auto)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   887
apply(rule_tac x="[(a,a')]\<bullet>v'" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   888
apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   889
apply(drule_tac pi="[(a,a')]" in big_eqvt)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   890
apply(perm_simp add: eqvt calc_atm)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   891
apply(simp add: V_eqvt)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   892
(*A*)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   893
apply(rule exists_fresh')
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   894
apply(simp add: fin_supp)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   895
done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   896
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   897
lemma V_are_values :
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   898
  fixes T::"ty"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   899
  assumes h:"e \<in> V T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   900
  shows "val e"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   901
using h by (nominal_induct T arbitrary: e rule:ty.induct, auto simp add: Vprimes_are_values)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   902
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   903
lemma values_reduce_to_themselves:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   904
  assumes h:"val v"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   905
  shows "v \<Down> v"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   906
using h by (induct,auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   907
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   908
lemma Vs_reduce_to_themselves[simp]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   909
  assumes h:"v \<in> V T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   910
  shows "v \<Down> v"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   911
using h by (simp add: values_reduce_to_themselves V_are_values)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   912
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   913
lemma V_sum:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   914
  assumes h:"x \<in> V (Data (DSum S\<^isub>1 S\<^isub>2))"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   915
  shows "(\<exists> y. x= InL y \<and>  y \<in> V' S\<^isub>1) \<or> (\<exists> y. x= InR y \<and> y \<in> V' S\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   916
using h by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   917
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   918
abbreviation 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   919
 mapsto :: "(name\<times>trm) list \<Rightarrow> name \<Rightarrow> trm \<Rightarrow> bool" ("_ maps _ to _" [55,55,55] 55) 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   920
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   921
 "\<theta> maps x to e\<equiv> (lookup \<theta> x) = e"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   922
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   923
abbreviation 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   924
  v_closes :: "(name\<times>trm) list \<Rightarrow> (name\<times>ty) list \<Rightarrow> bool" ("_ Vcloses _" [55,55] 55) 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   925
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   926
  "\<theta> Vcloses \<Gamma> \<equiv> \<forall>x T. ((x,T) \<in> set \<Gamma> \<longrightarrow> (\<exists>v. \<theta> maps x to v \<and> v \<in> (V T)))"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   927
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   928
lemma monotonicity:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   929
  fixes m::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   930
  fixes \<theta>::"(name \<times> trm) list" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   931
  assumes h1: "\<theta> Vcloses \<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   932
  and     h2: "e \<in> V T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   933
  and     h3: "valid ((x,T)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   934
  shows "(x,e)#\<theta> Vcloses (x,T)#\<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   935
proof(intro strip)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   936
  fix x' T'
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   937
  assume "(x',T') \<in> set ((x,T)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   938
  then have "((x',T')=(x,T)) \<or> ((x',T')\<in>set \<Gamma> \<and> x'\<noteq>x)" using h3 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   939
    by (rule_tac case_distinction_on_context)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   940
  moreover
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   941
  { (* first case *)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   942
    assume "(x',T') = (x,T)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   943
    then have "\<exists>e'. ((x,e)#\<theta>) maps x to e' \<and> e' \<in> V T'" using h2 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   944
  }
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   945
  moreover
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   946
  { (* second case *)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   947
    assume "(x',T') \<in> set \<Gamma>" and neq:"x' \<noteq> x"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   948
      then have "\<exists>e'. \<theta> maps x' to e' \<and> e' \<in> V T'" using h1 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   949
      then have "\<exists>e'. ((x,e)#\<theta>) maps x' to e' \<and> e' \<in> V T'" using neq by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   950
  }
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   951
  ultimately show "\<exists>e'.  ((x,e)#\<theta>) maps x' to e'  \<and> e' \<in> V T'" by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   952
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   953
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   954
lemma termination_aux:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   955
  fixes T :: "ty"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   956
  fixes \<Gamma> :: "(name \<times> ty) list"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   957
  fixes \<theta> :: "(name \<times> trm) list"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   958
  fixes e :: "trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   959
  assumes h1: "\<Gamma> \<turnstile> e : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   960
  and     h2: "\<theta> Vcloses \<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   961
  shows "\<exists>v. \<theta><e> \<Down> v \<and> v \<in> V T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   962
using h2 h1
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   963
proof(nominal_induct e avoiding: \<Gamma> \<theta> arbitrary: T rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   964
  case (App e\<^isub>1 e\<^isub>2 \<Gamma> \<theta> T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   965
  have ih\<^isub>1:"\<And>\<theta> \<Gamma> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> e\<^isub>1 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><e\<^isub>1> \<Down> v \<and> v \<in> V T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   966
  have ih\<^isub>2:"\<And>\<theta> \<Gamma> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> e\<^isub>2 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><e\<^isub>2> \<Down> v \<and> v \<in> V T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   967
  have as\<^isub>1:"\<theta> Vcloses \<Gamma>" by fact 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   968
  have as\<^isub>2: "\<Gamma> \<turnstile> App e\<^isub>1 e\<^isub>2 : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   969
  from as\<^isub>2 obtain T' where "\<Gamma> \<turnstile> e\<^isub>1 : T' \<rightarrow> T" and "\<Gamma> \<turnstile> e\<^isub>2 : T'" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   970
  then obtain v\<^isub>1 v\<^isub>2 where "(i)": "\<theta><e\<^isub>1> \<Down> v\<^isub>1" "v\<^isub>1 \<in> V (T' \<rightarrow> T)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   971
                      and "(ii)":"\<theta><e\<^isub>2> \<Down> v\<^isub>2" "v\<^isub>2 \<in> V T'" using ih\<^isub>1 ih\<^isub>2 as\<^isub>1 by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   972
  from "(i)" obtain x e' 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   973
            where "v\<^isub>1 = Lam[x].e'" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   974
            and "(iii)": "(\<forall>v \<in> (V T').\<exists> v'. e'[x::=v] \<Down> v' \<and> v' \<in> V T)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   975
            and "(iv)":  "\<theta><e\<^isub>1> \<Down> Lam [x].e'" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   976
            and fr: "x\<sharp>(\<theta>,e\<^isub>1,e\<^isub>2)" by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   977
  from fr have fr\<^isub>1: "x\<sharp>\<theta><e\<^isub>1>" and fr\<^isub>2: "x\<sharp>\<theta><e\<^isub>2>" by (simp_all add: fresh_psubst)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   978
  from "(ii)" "(iii)" obtain v\<^isub>3 where "(v)": "e'[x::=v\<^isub>2] \<Down> v\<^isub>3" "v\<^isub>3 \<in> V T" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   979
  from fr\<^isub>2 "(ii)" have "x\<sharp>v\<^isub>2" by (simp add: fresh_preserved)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   980
  then have "x\<sharp>e'[x::=v\<^isub>2]" by (simp add: fresh_subst_fresh)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   981
  then have fr\<^isub>3: "x\<sharp>v\<^isub>3" using "(v)" by (simp add: fresh_preserved)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   982
  from fr\<^isub>1 fr\<^isub>2 fr\<^isub>3 have "x\<sharp>(\<theta><e\<^isub>1>,\<theta><e\<^isub>2>,v\<^isub>3)" by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   983
  with "(iv)" "(ii)" "(v)" have "App (\<theta><e\<^isub>1>) (\<theta><e\<^isub>2>) \<Down> v\<^isub>3" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   984
  then show "\<exists>v. \<theta><App e\<^isub>1 e\<^isub>2> \<Down> v \<and> v \<in> V T" using "(v)" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   985
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   986
  case (Pr t\<^isub>1 t\<^isub>2 \<Gamma> \<theta> T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   987
  have "\<Gamma> \<turnstile> Pr t\<^isub>1 t\<^isub>2 : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   988
  then obtain T\<^isub>a T\<^isub>b where ta:"\<Gamma> \<turnstile> t\<^isub>1 : Data T\<^isub>a" and "\<Gamma> \<turnstile> t\<^isub>2 : Data T\<^isub>b" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   989
                      and eq:"T=Data (DProd T\<^isub>a T\<^isub>b)" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   990
  have h:"\<theta> Vcloses \<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   991
  then obtain v\<^isub>1 v\<^isub>2 where "\<theta><t\<^isub>1> \<Down> v\<^isub>1 \<and> v\<^isub>1 \<in> V (Data T\<^isub>a)" "\<theta><t\<^isub>2> \<Down> v\<^isub>2 \<and> v\<^isub>2 \<in> V (Data T\<^isub>b)" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   992
    using prems by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   993
  thus "\<exists>v. \<theta><Pr t\<^isub>1 t\<^isub>2> \<Down> v \<and> v \<in> V T" using eq by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   994
next 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   995
  case (Lam x e \<Gamma> \<theta> T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   996
  have ih:"\<And>\<theta> \<Gamma> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> e : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><e> \<Down> v \<and> v \<in> V T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   997
  have as\<^isub>1: "\<theta> Vcloses \<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   998
  have as\<^isub>2: "\<Gamma> \<turnstile> Lam [x].e : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   999
  have fs: "x\<sharp>\<Gamma>" "x\<sharp>\<theta>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1000
  from as\<^isub>2 fs obtain T\<^isub>1 T\<^isub>2 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1001
    where "(i)": "(x,T\<^isub>1)#\<Gamma> \<turnstile> e:T\<^isub>2" and "(ii)": "T = T\<^isub>1 \<rightarrow> T\<^isub>2" by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1002
  from "(i)" have "(iii)": "valid ((x,T\<^isub>1)#\<Gamma>)" by (simp add: typing_implies_valid)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1003
  have "\<forall>v \<in> (V T\<^isub>1). \<exists>v'. (\<theta><e>)[x::=v] \<Down> v' \<and> v' \<in> V T\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1004
  proof
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1005
    fix v
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1006
    assume "v \<in> (V T\<^isub>1)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1007
    with "(iii)" as\<^isub>1 have "(x,v)#\<theta> Vcloses (x,T\<^isub>1)#\<Gamma>" using monotonicity by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1008
    with ih "(i)" obtain v' where "((x,v)#\<theta>)<e> \<Down> v' \<and> v' \<in> V T\<^isub>2" by blast
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1009
    then have "\<theta><e>[x::=v] \<Down> v' \<and> v' \<in> V T\<^isub>2" using fs by (simp add: psubst_subst_psubst)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1010
    then show "\<exists>v'. \<theta><e>[x::=v] \<Down> v' \<and> v' \<in> V T\<^isub>2" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1011
  qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1012
  then have "Lam[x].\<theta><e> \<in> V (T\<^isub>1 \<rightarrow> T\<^isub>2)" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1013
  then have "\<theta><Lam [x].e> \<Down> Lam[x].\<theta><e> \<and> Lam[x].\<theta><e> \<in> V (T\<^isub>1\<rightarrow>T\<^isub>2)" using fs by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1014
  thus "\<exists>v. \<theta><Lam [x].e> \<Down> v \<and> v \<in> V T" using "(ii)" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1015
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1016
  case (Case t' n\<^isub>1 t\<^isub>1 n\<^isub>2 t\<^isub>2 \<Gamma> \<theta> T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1017
  have f: "n\<^isub>1\<sharp>\<Gamma>" "n\<^isub>1\<sharp>\<theta>" "n\<^isub>2\<sharp>\<Gamma>" "n\<^isub>2\<sharp>\<theta>" "n\<^isub>2\<noteq>n\<^isub>1" "n\<^isub>1\<sharp>t'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1018
  "n\<^isub>1\<sharp>t\<^isub>2" "n\<^isub>2\<sharp>t'" "n\<^isub>2\<sharp>t\<^isub>1" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1019
  have h:"\<theta> Vcloses \<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1020
  have th:"\<Gamma> \<turnstile> Case t' of inl n\<^isub>1 \<rightarrow> t\<^isub>1 | inr n\<^isub>2 \<rightarrow> t\<^isub>2 : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1021
  then obtain S\<^isub>1 S\<^isub>2 where 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1022
    hm:"\<Gamma> \<turnstile> t' : Data (DSum S\<^isub>1 S\<^isub>2)" and
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1023
    hl:"(n\<^isub>1,Data S\<^isub>1)#\<Gamma> \<turnstile> t\<^isub>1 : T" and
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1024
    hr:"(n\<^isub>2,Data S\<^isub>2)#\<Gamma> \<turnstile> t\<^isub>2 : T" using f by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1025
  then obtain v\<^isub>0 where ht':"\<theta><t'> \<Down> v\<^isub>0" and hS:"v\<^isub>0 \<in> V (Data (DSum S\<^isub>1 S\<^isub>2))" using prems h by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1026
  (* We distinguish between the cases InL and InR *)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1027
  { fix v\<^isub>0'
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1028
    assume eqc:"v\<^isub>0 = InL v\<^isub>0'" and "v\<^isub>0' \<in> V' S\<^isub>1"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1029
    then have inc: "v\<^isub>0' \<in> V (Data S\<^isub>1)" by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1030
    have "valid \<Gamma>" using th typing_implies_valid by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1031
    then moreover have "valid ((n\<^isub>1,Data S\<^isub>1)#\<Gamma>)" using f by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1032
    then moreover have "(n\<^isub>1,v\<^isub>0')#\<theta> Vcloses (n\<^isub>1,Data S\<^isub>1)#\<Gamma>" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1033
      using inc h monotonicity by blast
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1034
    moreover 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1035
    have ih:"\<And>\<Gamma> \<theta> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> t\<^isub>1 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><t\<^isub>1> \<Down> v \<and> v \<in> V T" by fact
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1036
    ultimately obtain v\<^isub>1 where ho: "((n\<^isub>1,v\<^isub>0')#\<theta>)<t\<^isub>1> \<Down> v\<^isub>1 \<and> v\<^isub>1 \<in> V T" using hl by blast
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1037
    then have r:"\<theta><t\<^isub>1>[n\<^isub>1::=v\<^isub>0'] \<Down> v\<^isub>1 \<and> v\<^isub>1 \<in> V T" using psubst_subst_psubst f by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1038
    then moreover have "n\<^isub>1\<sharp>(\<theta><t'>,\<theta><t\<^isub>2>,v\<^isub>1,n\<^isub>2)" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1039
      proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1040
	have "n\<^isub>1\<sharp>v\<^isub>0" using ht' fresh_preserved fresh_psubst f by auto 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1041
	then have "n\<^isub>1\<sharp>v\<^isub>0'" using eqc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1042
	then have "n\<^isub>1\<sharp>v\<^isub>1" using f r fresh_preserved fresh_subst_fresh by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1043
	thus "n\<^isub>1\<sharp>(\<theta><t'>,\<theta><t\<^isub>2>,v\<^isub>1,n\<^isub>2)" using f by (simp add: fresh_atm fresh_psubst)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1044
      qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1045
    moreover have "n\<^isub>2\<sharp>(\<theta><t'>,\<theta><t\<^isub>1>,v\<^isub>1,n\<^isub>1)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1046
      proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1047
	have "n\<^isub>2\<sharp>v\<^isub>0" using ht' fresh_preserved fresh_psubst f by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1048
	then have "n\<^isub>2\<sharp>v\<^isub>0'" using eqc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1049
	then have "n\<^isub>2\<sharp>((n\<^isub>1,v\<^isub>0')#\<theta>)" using f fresh_list_cons fresh_atm by force 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1050
	then have "n\<^isub>2\<sharp>((n\<^isub>1,v\<^isub>0')#\<theta>)<t\<^isub>1>" using f fresh_psubst by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1051
	moreover then have "n\<^isub>2 \<sharp> v\<^isub>1" using fresh_preserved ho by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1052
	ultimately show  "n\<^isub>2\<sharp>(\<theta><t'>,\<theta><t\<^isub>1>,v\<^isub>1,n\<^isub>1)" using f by (simp add: fresh_psubst fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1053
      qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1054
    ultimately have "Case \<theta><t'> of inl n\<^isub>1 \<rightarrow> \<theta><t\<^isub>1> | inr n\<^isub>2 \<rightarrow> \<theta><t\<^isub>2> \<Down> v\<^isub>1 \<and> v\<^isub>1 \<in> V T" using ht' eqc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1055
    moreover 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1056
      have "Case \<theta><t'> of inl n\<^isub>1 \<rightarrow> \<theta><t\<^isub>1> | inr n\<^isub>2 \<rightarrow> \<theta><t\<^isub>2> = \<theta><Case t' of inl n\<^isub>1 \<rightarrow> t\<^isub>1 | inr n\<^isub>2 \<rightarrow> t\<^isub>2>" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1057
      using f by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1058
    ultimately have "\<exists>v. \<theta><Case t' of inl n\<^isub>1 \<rightarrow> t\<^isub>1 | inr n\<^isub>2 \<rightarrow> t\<^isub>2> \<Down> v \<and> v \<in> V T" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1059
  }
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1060
  moreover 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1061
  { fix v\<^isub>0'
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1062
    assume eqc:"v\<^isub>0 = InR v\<^isub>0'" and "v\<^isub>0' \<in> V' S\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1063
    then have inc:"v\<^isub>0' \<in> V (Data S\<^isub>2)" by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1064
    have "valid \<Gamma>" using th typing_implies_valid by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1065
    then moreover have "valid ((n\<^isub>2,Data S\<^isub>2)#\<Gamma>)" using f by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1066
    then moreover have "(n\<^isub>2,v\<^isub>0')#\<theta> Vcloses (n\<^isub>2,Data S\<^isub>2)#\<Gamma>" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1067
      using inc h monotonicity by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1068
    moreover have ih:"\<And>\<Gamma> \<theta> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> t\<^isub>2 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><t\<^isub>2> \<Down> v \<and> v \<in> V T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1069
    ultimately obtain v\<^isub>2 where ho:"((n\<^isub>2,v\<^isub>0')#\<theta>)<t\<^isub>2> \<Down> v\<^isub>2 \<and> v\<^isub>2 \<in> V T" using hr by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1070
    then have r:"\<theta><t\<^isub>2>[n\<^isub>2::=v\<^isub>0'] \<Down> v\<^isub>2 \<and> v\<^isub>2 \<in> V T" using psubst_subst_psubst f by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1071
    moreover have "n\<^isub>1\<sharp>(\<theta><t'>,\<theta><t\<^isub>2>,v\<^isub>2,n\<^isub>2)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1072
    proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1073
      have "n\<^isub>1\<sharp>\<theta><t'>" using fresh_psubst f by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1074
      then have "n\<^isub>1\<sharp>v\<^isub>0" using ht' fresh_preserved by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1075
      then have "n\<^isub>1\<sharp>v\<^isub>0'" using eqc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1076
      then have "n\<^isub>1\<sharp>((n\<^isub>2,v\<^isub>0')#\<theta>)" using f fresh_list_cons fresh_atm by force 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1077
      then have "n\<^isub>1\<sharp>((n\<^isub>2,v\<^isub>0')#\<theta>)<t\<^isub>2>" using f fresh_psubst by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1078
      moreover then have "n\<^isub>1\<sharp>v\<^isub>2" using fresh_preserved ho by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1079
      ultimately show  "n\<^isub>1 \<sharp> (\<theta><t'>,\<theta><t\<^isub>2>,v\<^isub>2,n\<^isub>2)" using f by (simp add: fresh_psubst fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1080
    qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1081
    moreover have "n\<^isub>2 \<sharp> (\<theta><t'>,\<theta><t\<^isub>1>,v\<^isub>2,n\<^isub>1)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1082
      proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1083
	have "n\<^isub>2\<sharp>\<theta><t'>" using fresh_psubst f by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1084
	then have "n\<^isub>2\<sharp>v\<^isub>0" using ht' fresh_preserved by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1085
	then have "n\<^isub>2\<sharp>v\<^isub>0'" using eqc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1086
	then have "n\<^isub>2\<sharp>\<theta><t\<^isub>2>[n\<^isub>2::=v\<^isub>0']" using f fresh_subst_fresh by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1087
	then have "n\<^isub>2\<sharp>v\<^isub>2" using f fresh_preserved r by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1088
	then show "n\<^isub>2\<sharp>(\<theta><t'>,\<theta><t\<^isub>1>,v\<^isub>2,n\<^isub>1)" using f by (simp add: fresh_atm fresh_psubst)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1089
      qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1090
    ultimately have "Case \<theta><t'> of inl n\<^isub>1 \<rightarrow> \<theta><t\<^isub>1> | inr n\<^isub>2 \<rightarrow> \<theta><t\<^isub>2> \<Down> v\<^isub>2 \<and> v\<^isub>2 \<in> V T" using ht' eqc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1091
    then have "\<exists>v. \<theta><Case t' of inl n\<^isub>1 \<rightarrow> t\<^isub>1 | inr n\<^isub>2 \<rightarrow> t\<^isub>2> \<Down> v \<and> v \<in> V T" using f by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1092
  }
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1093
  ultimately show "\<exists>v. \<theta><Case t' of inl n\<^isub>1 \<rightarrow> t\<^isub>1 | inr n\<^isub>2 \<rightarrow> t\<^isub>2> \<Down> v \<and> v \<in> V T" using hS V_sum by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1094
qed (force)+
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1095
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1096
theorem termination_of_evaluation:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1097
  assumes a: "[] \<turnstile> e : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1098
  shows "\<exists>v. e \<Down> v \<and> val v"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1099
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1100
  from a have "\<exists>v. (([]::(name \<times> trm) list)<e>) \<Down> v \<and> v \<in> V T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1101
    by (rule termination_aux) (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1102
  thus "\<exists>v. e \<Down> v \<and> val v" using V_are_values by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1103
qed 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1104
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1105
end