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