src/HOL/Nominal/Examples/SOS.thy
author urbanc
Sun, 23 Sep 2007 22:11:50 +0200
changeset 24678 232e71c2a6d9
parent 24231 85fb973a8207
child 25832 41a014cc44c0
permissions -rw-r--r--
tuned one proof so to not run in a loop with the new atom-representation
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
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   210
inductive
22447
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
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   218
inductive_cases  
22447
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
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   256
inductive
22447
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
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   290
inductive_cases typing_inv_auto[elim]: 
23450
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: 
24231
85fb973a8207 added type constraints to resolve syntax ambiguities;
wenzelm
parents: 23760
diff changeset
   369
  fixes \<Gamma>\<^isub>1 \<Gamma>\<^isub>2 :: "(name\<times>ty) list"
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
   370
  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
   371
  shows "\<Gamma>\<^isub>2 \<turnstile> e: T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   372
  using assms
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   373
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
   374
  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
   375
  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
   376
  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
   377
  have H2: "\<Gamma>\<^isub>1 \<subseteq> \<Gamma>\<^isub>2" by fact
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   378
  have fs: "x\<sharp>\<Gamma>\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   379
  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
   380
  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
   381
  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
   382
  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
   383
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   384
  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
   385
  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
   386
       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
   387
       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
   388
  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
   389
  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
   390
  have "valid \<Gamma>\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   391
  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
   392
  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
   393
  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
   394
qed (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   395
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   396
lemma context_exchange:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   397
  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
   398
  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
   399
proof -
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   400
  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
   401
  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
   402
    by (auto simp: fresh_list_cons fresh_atm[symmetric])
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   403
  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
   404
    by (auto simp: fresh_list_cons fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   405
  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
   406
  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
   407
  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
   408
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   409
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   410
lemma typing_var_unicity: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   411
  assumes "(x,t\<^isub>1)#\<Gamma> \<turnstile> Var x : t\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   412
  shows "t\<^isub>1=t\<^isub>2"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   413
proof - 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   414
  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
   415
  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
   416
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   417
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   418
lemma typing_substitution: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   419
  fixes \<Gamma>::"(name \<times> ty) list"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   420
  assumes "(x,T')#\<Gamma> \<turnstile> e : T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   421
  and     "\<Gamma> \<turnstile> e': T'" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   422
  shows "\<Gamma> \<turnstile> e[x::=e'] : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   423
  using assms
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   424
proof (nominal_induct e avoiding: \<Gamma> e' x arbitrary: T rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   425
  case (Var y \<Gamma> e' x T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   426
  have h1: "(x,T')#\<Gamma> \<turnstile> Var y : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   427
  have h2: "\<Gamma> \<turnstile> e' : T'" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   428
  show "\<Gamma> \<turnstile> (Var y)[x::=e'] : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   429
  proof (cases "x=y")
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   430
    case True
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   431
    assume as: "x=y"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   432
    then have "T=T'" using h1 typing_var_unicity by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   433
    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
   434
  next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   435
    case False
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   436
    assume as: "x\<noteq>y" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   437
    have "(y,T) \<in> set ((x,T')#\<Gamma>)" using h1 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   438
    then have "(y,T) \<in> set \<Gamma>" using as by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   439
    moreover 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   440
    have "valid \<Gamma>" using h2 by (simp only: typing_implies_valid)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   441
    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
   442
  qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   443
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   444
  case (Lam y t \<Gamma> e' x T)
23393
31781b2de73d tuned proofs: avoid implicit prems;
wenzelm
parents: 23158
diff changeset
   445
  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
   446
  have pr1: "\<Gamma> \<turnstile> e' : T'" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   447
  have pr2: "(x,T')#\<Gamma> \<turnstile> Lam [y].t : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   448
  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
   449
    using vc by (auto simp add: fresh_list_cons)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   450
  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
   451
  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
   452
  have "valid \<Gamma>" using pr1 by (simp add: typing_implies_valid)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   453
  then have "valid ((y,T\<^isub>1)#\<Gamma>)" using vc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   454
  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
   455
  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
   456
  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
   457
  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
   458
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   459
  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
   460
  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
   461
           "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
   462
  have as1: "\<Gamma> \<turnstile> e' : T'" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   463
  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
   464
  then obtain S\<^isub>1 S\<^isub>2 where 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   465
    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
   466
    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
   467
    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
   468
    using vc by (auto simp add: fresh_list_cons)
23393
31781b2de73d tuned proofs: avoid implicit prems;
wenzelm
parents: 23158
diff changeset
   469
  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
   470
  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
   471
  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
   472
    by fact+
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   473
  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
   474
  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
   475
  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
   476
  moreover
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   477
  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
   478
  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
   479
  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
   480
  moreover 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   481
  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
   482
  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
   483
  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
   484
  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
   485
    using vc by (auto simp add: fresh_atm fresh_subst)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   486
  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
   487
qed (simp, fast)+
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   488
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   489
text {* Big-Step Evaluation *}
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   490
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   491
inductive
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   492
  big :: "trm\<Rightarrow>trm\<Rightarrow>bool" ("_ \<Down> _" [80,80] 80) 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   493
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   494
  b_Lam[intro]:   "Lam [x].e \<Down> Lam [x].e"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   495
| 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
   496
| b_Const[intro]: "Const n \<Down> Const n"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   497
| 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
   498
| 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
   499
| 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
   500
| b_InL[intro]:   "e\<Down>e' \<Longrightarrow> InL e \<Down> InL e'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   501
| b_InR[intro]:   "e\<Down>e' \<Longrightarrow> InR e \<Down> InR e'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   502
| 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
   503
                   \<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
   504
| 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
   505
                   \<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
   506
22730
8bcc8809ed3b nominal_inductive no longer proves equivariance.
berghofe
parents: 22650
diff changeset
   507
equivariance big
8bcc8809ed3b nominal_inductive no longer proves equivariance.
berghofe
parents: 22650
diff changeset
   508
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   509
nominal_inductive big
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   510
  by (simp_all add: abs_fresh fresh_prod fresh_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   511
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   512
lemma big_eqvt':
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   513
  fixes pi::"name prm"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   514
  assumes a: "(pi\<bullet>t) \<Down> (pi\<bullet>t')"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   515
  shows "t \<Down> t'"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   516
using a
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   517
apply -
22542
8279a25ad0ae - Renamed <predicate>_eqvt to <predicate>.eqvt
berghofe
parents: 22541
diff changeset
   518
apply(drule_tac pi="rev pi" in big.eqvt)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   519
apply(perm_simp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   520
done
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   521
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   522
lemma fresh_preserved:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   523
  fixes x::name
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
  fixes t'::trm
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   526
  assumes "e \<Down> e'" and "x\<sharp>e" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   527
  shows "x\<sharp>e'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   528
  using assms by (induct) (auto simp add:fresh_subst')
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   529
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   530
declare trm.inject  [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   531
declare ty.inject  [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   532
declare data.inject [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   533
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   534
inductive_cases b_inv_auto[elim]: 
23450
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   535
  "App e\<^isub>1 e\<^isub>2 \<Down> t" 
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   536
  "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
   537
  "Lam[x].t \<Down> t"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   538
  "Const n \<Down> t"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   539
  "Fst e \<Down> t"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   540
  "Snd e \<Down> t"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   541
  "InL e \<Down> t"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   542
  "InR e \<Down> t"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   543
  "Pr e\<^isub>1 e\<^isub>2 \<Down> t"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   544
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   545
declare trm.inject  [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   546
declare ty.inject  [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   547
declare data.inject [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   548
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   549
lemma b_App_elim[elim]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   550
  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
   551
  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
   552
  using assms
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   553
  apply -
23450
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   554
  apply(erule b_inv_auto)
22542
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)
8279a25ad0ae - Renamed <predicate>_eqvt to <predicate>.eqvt
berghofe
parents: 22541
diff changeset
   557
  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
   558
  apply(perm_simp add: calc_atm eqvts)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   559
  done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   560
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   561
lemma  b_CaseL_elim[elim]: 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   562
  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
   563
  and     "\<And> t. \<not>  e \<Down> InR t"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   564
  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
   565
  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
   566
  using assms 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   567
  apply -
23450
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   568
  apply(rule b_inv_auto(2))
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   569
  apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   570
  apply(simp add: alpha)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   571
  apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   572
  apply(drule_tac x="[(x\<^isub>1,x\<^isub>1')]\<bullet>e'" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   573
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   574
  apply(rule_tac pi="[(x\<^isub>1,x\<^isub>1')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   575
  apply(perm_simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   576
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   577
  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
   578
  apply(perm_simp add: eqvts calc_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   579
  apply(assumption)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   580
  apply(drule_tac x="[(x\<^isub>1,x\<^isub>1')]\<bullet>e'" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   581
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   582
  apply(rule_tac pi="[(x\<^isub>1,x\<^isub>1')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   583
  apply(perm_simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   584
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   585
  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
   586
  apply(perm_simp add: eqvts calc_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   587
  apply(assumption)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   588
done
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   589
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   590
lemma b_CaseR_elim[elim]: 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   591
  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
   592
  and     "\<And> t. \<not> e \<Down> InL t"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   593
  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
   594
  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
   595
  using assms 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   596
  apply -
23450
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   597
  apply(rule b_inv_auto(2))
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   598
  apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   599
  apply(simp add: alpha)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   600
  apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   601
  apply(drule_tac x="[(x\<^isub>2,x\<^isub>2')]\<bullet>e'" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   602
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   603
  apply(rule_tac pi="[(x\<^isub>2,x\<^isub>2')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   604
  apply(perm_simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   605
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   606
  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
   607
  apply(perm_simp add: eqvts calc_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   608
  apply(assumption)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   609
  apply(drule_tac x="[(x\<^isub>2,x\<^isub>2')]\<bullet>e'" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   610
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   611
  apply(rule_tac pi="[(x\<^isub>2,x\<^isub>2')]" in big_eqvt')
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   612
  apply(perm_simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   613
  apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   614
  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
   615
  apply(perm_simp add: eqvts calc_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   616
  apply(assumption)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   617
done
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   618
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   619
inductive
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   620
  val :: "trm\<Rightarrow>bool" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   621
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   622
  v_Lam[intro]:   "val (Lam [x].e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   623
| v_Const[intro]: "val (Const n)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   624
| 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
   625
| v_InL[intro]:   "val e \<Longrightarrow> val (InL e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   626
| v_InR[intro]:   "val e \<Longrightarrow> val (InR e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   627
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   628
declare trm.inject  [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   629
declare ty.inject  [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   630
declare data.inject [simp add]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   631
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   632
inductive_cases v_inv_auto[elim]: 
23450
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   633
  "val (Const n)"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   634
  "val (Pr e\<^isub>1 e\<^isub>2)"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   635
  "val (InL e)"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   636
  "val (InR e)"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   637
  "val (Fst e)"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   638
  "val (Snd e)"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   639
  "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
   640
  "val (Var x)"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   641
  "val (Lam [x].e)"
f274975039b2 fine tune automatic generation of inversion lemmas
narboux
parents: 23393
diff changeset
   642
  "val (App e\<^isub>1 e\<^isub>2)"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   643
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   644
declare trm.inject  [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   645
declare ty.inject  [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   646
declare data.inject [simp del]
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   647
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   648
lemma subject_reduction:
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   649
  assumes a: "e \<Down> e'" 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   650
  and     b: "\<Gamma> \<turnstile> e : T"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   651
  shows "\<Gamma> \<turnstile> e' : T"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   652
  using a b
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   653
proof (nominal_induct avoiding: \<Gamma> arbitrary: T rule: big.strong_induct) 
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   654
  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
   655
  have vc: "x\<sharp>\<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   656
  have "\<Gamma> \<turnstile> App e\<^isub>1 e\<^isub>2 : T" by fact
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   657
  then obtain T' where 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   658
    a1: "\<Gamma> \<turnstile> e\<^isub>1 : T'\<rightarrow>T" and  
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   659
    a2: "\<Gamma> \<turnstile> e\<^isub>2 : T'" by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   660
  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
   661
  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
   662
  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
   663
  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
   664
  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
   665
  moreover
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   666
  have "\<Gamma> \<turnstile> e\<^isub>2': T'" using ih2 a2 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   667
  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
   668
  thus "\<Gamma> \<turnstile> e' : T" using ih3 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   669
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   670
  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
   671
  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
   672
  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
   673
  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
   674
    a1: "\<Gamma> \<turnstile> e : Data (DSum S\<^isub>1 S\<^isub>2)" and 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   675
    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
   676
  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
   677
  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
   678
  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
   679
  then have "\<Gamma> \<turnstile> e' : Data S\<^isub>1" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   680
  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
   681
  then show "\<Gamma> \<turnstile> e'' : T" using ih2 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   682
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   683
 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
   684
 then show "\<Gamma> \<turnstile> e'' : T" by (blast intro: typing_substitution)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   685
qed (blast)+
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   686
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   687
lemma unicity_of_evaluation:
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   688
  assumes a: "e \<Down> e\<^isub>1" 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   689
  and     b: "e \<Down> e\<^isub>2"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   690
  shows "e\<^isub>1 = e\<^isub>2"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   691
  using a b
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   692
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
   693
  case (b_Lam x e t\<^isub>2)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   694
  have "Lam [x].e \<Down> t\<^isub>2" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   695
  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
   696
next
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   697
  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
   698
  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
   699
  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
   700
  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
   701
  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
   702
  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
   703
  then have "x \<sharp> App e\<^isub>1 e\<^isub>2" by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   704
  then have vc': "x\<sharp>t\<^isub>2" using fresh_preserved app by blast
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   705
  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
   706
    using app by (auto simp add: fresh_prod)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   707
  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
   708
  then 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   709
  have "f\<^isub>1 = e\<^isub>1'" by (auto simp add: trm.inject alpha) 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   710
  moreover 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   711
  have "f\<^isub>2 = e\<^isub>2'" using x2 ih2 by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   712
  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
   713
  thus ?case using ih3 by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   714
next
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   715
  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
   716
  have fs: "x\<^isub>1\<sharp>e" "x\<^isub>1\<sharp>t\<^isub>2" "x\<^isub>2\<sharp>e" "x\<^isub>2\<sharp>t\<^isub>2" by fact+
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   717
  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
   718
  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
   719
  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
   720
  have "Case e of inl x\<^isub>1 \<rightarrow> e\<^isub>1 | inr x\<^isub>2 \<rightarrow> e\<^isub>2 \<Down> t\<^isub>2" by fact
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   721
  then obtain f' where "e \<Down> 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
   722
  then have "InL f' = InL e'" using ih1 by simp
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   723
  then have "f' = e'" by (simp add: trm.inject)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   724
  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
   725
  then show "e'' = t\<^isub>2" using ih2 by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   726
next 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   727
  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
   728
  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
   729
  have ih1: "\<And>t. e \<Down> t \<Longrightarrow> InR e' = t" by fact
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   730
  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
   731
  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
   732
  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
   733
  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
   734
  then have "InR f' = InR e'" using ih1 by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   735
  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
   736
  thus "e'' = t\<^isub>2" using ih2 by simp
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   737
next
22594
33a690455f88 add a few details in the Fst and Snd cases of unicity proof
narboux
parents: 22564
diff changeset
   738
  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
   739
  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
   740
  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
   741
  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
   742
  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
   743
next
22594
33a690455f88 add a few details in the Fst and Snd cases of unicity proof
narboux
parents: 22564
diff changeset
   744
  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
   745
  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
   746
  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
   747
  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
   748
  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
   749
qed (blast)+
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   750
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   751
lemma not_val_App[simp]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   752
  shows 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   753
  "\<not> val (App e\<^isub>1 e\<^isub>2)" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   754
  "\<not> val (Fst e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   755
  "\<not> val (Snd e)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   756
  "\<not> val (Var x)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   757
  "\<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
   758
by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   759
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   760
lemma reduces_evaluates_to_values:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   761
  assumes h:"t \<Down> t'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   762
  shows "val t'"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   763
  using h by (induct) (auto)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   764
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   765
lemma type_prod_evaluates_to_pairs:
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   766
  assumes a: "\<Gamma> \<turnstile> t : Data (DProd S\<^isub>1 S\<^isub>2)" 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   767
  and     b: "t \<Down> t'"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   768
  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
   769
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   770
   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
   771
   moreover
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   772
   have "val t'" using reduces_evaluates_to_values assms by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   773
   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
   774
   thus ?thesis using prems by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   775
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   776
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   777
lemma type_sum_evaluates_to_ins:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   778
  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
   779
  shows "(\<exists>t''. t' = InL t'') \<or> (\<exists>t''. t' = InR t'')"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   780
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   781
  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
   782
  moreover
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   783
  have "val t'" using reduces_evaluates_to_values assms by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   784
  ultimately obtain t'' where "t' = InL t'' \<or>  t' = InR t''"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   785
    by (cases, auto simp add:ty.inject data.inject)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   786
  thus ?thesis by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   787
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   788
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   789
lemma type_arrow_evaluates_to_lams:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   790
  assumes "\<Gamma> \<turnstile> t : \<sigma> \<rightarrow> \<tau>" and "t \<Down> t'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   791
  obtains  x t'' where "t' = Lam [x]. t''"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   792
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   793
  have "\<Gamma> \<turnstile> t' : \<sigma> \<rightarrow> \<tau>" using assms subject_reduction by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   794
  moreover
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   795
  have "val t'" using reduces_evaluates_to_values assms by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   796
  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
   797
  thus ?thesis using prems by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   798
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   799
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   800
lemma type_nat_evaluates_to_consts:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   801
  assumes "\<Gamma> \<turnstile> t : Data DNat" and "t \<Down> t'"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   802
  obtains n where "t' = Const n"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   803
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   804
  have "\<Gamma> \<turnstile> t' : Data DNat " using assms subject_reduction by simp
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   805
  moreover have "val t'" using reduces_evaluates_to_values assms by simp
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   806
  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
   807
  thus ?thesis using prems by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   808
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   809
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   810
consts
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   811
  V' :: "data \<Rightarrow> trm set" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   812
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   813
nominal_primrec    
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   814
  "V' (DNat) = {Const n | n. n \<in> (UNIV::nat set)}"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   815
  "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
   816
  "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
   817
apply(rule TrueI)+
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   818
done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   819
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   820
lemma Vprimes_are_values :
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   821
  fixes S::"data"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   822
  assumes h: "e \<in> V' S"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   823
  shows "val e"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   824
using h 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   825
by (nominal_induct S arbitrary: e rule:data.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   826
   (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   827
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   828
lemma V'_eqvt:
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   829
  fixes pi::"name prm"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   830
  assumes a: "v \<in> V' S"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   831
  shows "(pi\<bullet>v) \<in> V' S"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   832
using a
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   833
by (nominal_induct S arbitrary: v rule: data.induct)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   834
   (auto simp add: trm.inject)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   835
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   836
consts
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   837
  V :: "ty \<Rightarrow> trm set" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   838
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   839
nominal_primrec
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   840
  "V (Data S) = V' S"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   841
  "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
   842
apply(rule TrueI)+ 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   843
done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   844
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   845
lemma V_eqvt:
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   846
  fixes pi::"name prm"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   847
  assumes a: "x\<in>V T"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   848
  shows "(pi\<bullet>x)\<in>V T"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   849
using a
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   850
apply(nominal_induct T arbitrary: pi x rule: ty.induct)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   851
apply(auto simp add: trm.inject perm_set_def)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   852
apply(perm_simp add: V'_eqvt)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   853
apply(rule_tac x="pi\<bullet>xa" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   854
apply(rule_tac x="pi\<bullet>e" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   855
apply(simp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   856
apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   857
apply(drule_tac x="(rev pi)\<bullet>v" in bspec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   858
apply(force)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   859
apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   860
apply(rule_tac x="pi\<bullet>v'" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   861
apply(auto)
22542
8279a25ad0ae - Renamed <predicate>_eqvt to <predicate>.eqvt
berghofe
parents: 22541
diff changeset
   862
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
   863
apply(perm_simp add: eqvts)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   864
done
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   865
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   866
lemma V_arrow_elim_weak[elim] :
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   867
  assumes h:"u \<in> (V (T\<^isub>1 \<rightarrow> T\<^isub>2))"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   868
  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
   869
using h by (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   870
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   871
lemma V_arrow_elim_strong[elim]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   872
  fixes c::"'a::fs_name"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   873
  assumes h: "u \<in> V (T\<^isub>1 \<rightarrow> T\<^isub>2)"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   874
  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
   875
using h
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   876
apply -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   877
apply(erule V_arrow_elim_weak)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   878
apply(subgoal_tac "\<exists>a'::name. a'\<sharp>(a,t,c)") (*A*)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   879
apply(erule exE)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   880
apply(drule_tac x="a'" in meta_spec)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   881
apply(drule_tac x="[(a,a')]\<bullet>t" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   882
apply(drule meta_mp)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   883
apply(simp)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   884
apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   885
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
   886
apply(perm_simp)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   887
apply(force)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   888
apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   889
apply(rule ballI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   890
apply(drule_tac x="[(a,a')]\<bullet>v" in bspec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   891
apply(simp add: V_eqvt)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   892
apply(auto)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   893
apply(rule_tac x="[(a,a')]\<bullet>v'" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   894
apply(auto)
22542
8279a25ad0ae - Renamed <predicate>_eqvt to <predicate>.eqvt
berghofe
parents: 22541
diff changeset
   895
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
   896
apply(perm_simp add: eqvts calc_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   897
apply(simp add: V_eqvt)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   898
(*A*)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   899
apply(rule exists_fresh')
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   900
apply(simp add: fin_supp)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   901
done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   902
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   903
lemma V_are_values :
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   904
  fixes T::"ty"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   905
  assumes h:"e \<in> V T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   906
  shows "val e"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   907
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
   908
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   909
lemma values_reduce_to_themselves:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   910
  assumes h:"val v"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   911
  shows "v \<Down> v"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   912
using h by (induct,auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   913
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   914
lemma Vs_reduce_to_themselves[simp]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   915
  assumes h:"v \<in> V T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   916
  shows "v \<Down> v"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   917
using h by (simp add: values_reduce_to_themselves V_are_values)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   918
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   919
lemma V_sum:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   920
  assumes h:"x \<in> V (Data (DSum S\<^isub>1 S\<^isub>2))"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   921
  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
   922
using h by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   923
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   924
abbreviation 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   925
 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
   926
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   927
 "\<theta> maps x to e\<equiv> (lookup \<theta> x) = e"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   928
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   929
abbreviation 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   930
  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
   931
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   932
  "\<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
   933
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   934
lemma monotonicity:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   935
  fixes m::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   936
  fixes \<theta>::"(name \<times> trm) list" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   937
  assumes h1: "\<theta> Vcloses \<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   938
  and     h2: "e \<in> V T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   939
  and     h3: "valid ((x,T)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   940
  shows "(x,e)#\<theta> Vcloses (x,T)#\<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   941
proof(intro strip)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   942
  fix x' T'
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   943
  assume "(x',T') \<in> set ((x,T)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   944
  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
   945
    by (rule_tac case_distinction_on_context)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   946
  moreover
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   947
  { (* first case *)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   948
    assume "(x',T') = (x,T)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   949
    then have "\<exists>e'. ((x,e)#\<theta>) maps x to e' \<and> e' \<in> V T'" using h2 by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   950
  }
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   951
  moreover
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   952
  { (* second case *)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   953
    assume "(x',T') \<in> set \<Gamma>" and neq:"x' \<noteq> x"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   954
      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
   955
      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
   956
  }
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   957
  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
   958
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   959
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   960
lemma termination_aux:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   961
  fixes T :: "ty"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   962
  fixes \<Gamma> :: "(name \<times> ty) list"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   963
  fixes \<theta> :: "(name \<times> trm) list"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   964
  fixes e :: "trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   965
  assumes h1: "\<Gamma> \<turnstile> e : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   966
  and     h2: "\<theta> Vcloses \<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   967
  shows "\<exists>v. \<theta><e> \<Down> v \<and> v \<in> V T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   968
using h2 h1
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   969
proof(nominal_induct e avoiding: \<Gamma> \<theta> arbitrary: T rule: trm.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   970
  case (App e\<^isub>1 e\<^isub>2 \<Gamma> \<theta> T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   971
  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
   972
  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
   973
  have as\<^isub>1:"\<theta> Vcloses \<Gamma>" by fact 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   974
  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
   975
  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
   976
  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
   977
                      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
   978
  from "(i)" obtain x e' 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   979
            where "v\<^isub>1 = Lam[x].e'" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   980
            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
   981
            and "(iv)":  "\<theta><e\<^isub>1> \<Down> Lam [x].e'" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   982
            and fr: "x\<sharp>(\<theta>,e\<^isub>1,e\<^isub>2)" by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   983
  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
   984
  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
   985
  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
   986
  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
   987
  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
   988
  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
   989
  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
   990
  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
   991
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   992
  case (Pr t\<^isub>1 t\<^isub>2 \<Gamma> \<theta> T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   993
  have "\<Gamma> \<turnstile> Pr t\<^isub>1 t\<^isub>2 : T" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   994
  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
   995
                      and eq:"T=Data (DProd T\<^isub>a T\<^isub>b)" by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   996
  have h:"\<theta> Vcloses \<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   997
  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
   998
    using prems by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   999
  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
  1000
next 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1001
  case (Lam x e \<Gamma> \<theta> T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1002
  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
  1003
  have as\<^isub>1: "\<theta> Vcloses \<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1004
  have as\<^isub>2: "\<Gamma> \<turnstile> Lam [x].e : T" by fact
23393
31781b2de73d tuned proofs: avoid implicit prems;
wenzelm
parents: 23158
diff changeset
  1005
  have fs: "x\<sharp>\<Gamma>" "x\<sharp>\<theta>" by fact+
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1006
  from as\<^isub>2 fs obtain T\<^isub>1 T\<^isub>2 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1007
    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
  1008
  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
  1009
  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
  1010
  proof
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1011
    fix v
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1012
    assume "v \<in> (V T\<^isub>1)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1013
    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
  1014
    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
  1015
    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
  1016
    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
  1017
  qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1018
  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
  1019
  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
  1020
  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
  1021
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1022
  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
  1023
  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
  1024
  "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
  1025
  have h:"\<theta> Vcloses \<Gamma>" by fact
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1026
  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
  1027
  then obtain S\<^isub>1 S\<^isub>2 where 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1028
    hm:"\<Gamma> \<turnstile> t' : Data (DSum S\<^isub>1 S\<^isub>2)" and
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1029
    hl:"(n\<^isub>1,Data S\<^isub>1)#\<Gamma> \<turnstile> t\<^isub>1 : T" and
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1030
    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
  1031
  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
  1032
  (* We distinguish between the cases InL and InR *)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1033
  { fix v\<^isub>0'
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1034
    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
  1035
    then have inc: "v\<^isub>0' \<in> V (Data S\<^isub>1)" by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1036
    have "valid \<Gamma>" using th typing_implies_valid by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1037
    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
  1038
    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
  1039
      using inc h monotonicity by blast
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1040
    moreover 
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1041
    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
  1042
    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
  1043
    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
  1044
    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
  1045
      proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1046
	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
  1047
	then have "n\<^isub>1\<sharp>v\<^isub>0'" using eqc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1048
	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
  1049
	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
  1050
      qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1051
    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
  1052
      proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1053
	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
  1054
	then have "n\<^isub>2\<sharp>v\<^isub>0'" using eqc by auto
24678
232e71c2a6d9 tuned one proof so to not run in a loop with the new atom-representation
urbanc
parents: 24231
diff changeset
  1055
	then have "n\<^isub>2\<sharp>((n\<^isub>1,v\<^isub>0')#\<theta>)" using f by (simp add: fresh_list_cons fresh_prod fresh_atm)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1056
	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
  1057
	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
  1058
	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
  1059
      qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1060
    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
  1061
    moreover 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1062
      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
  1063
      using f by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1064
    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
  1065
  }
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1066
  moreover 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1067
  { fix v\<^isub>0'
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1068
    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
  1069
    then have inc:"v\<^isub>0' \<in> V (Data S\<^isub>2)" by auto
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
  1070
    have "valid \<Gamma>" using th typing_implies_valid by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1071
    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
  1072
    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
  1073
      using inc h monotonicity by blast
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1074
    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
  1075
    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
  1076
    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
  1077
    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
  1078
    proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1079
      have "n\<^isub>1\<sharp>\<theta><t'>" using fresh_psubst f by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1080
      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
  1081
      then have "n\<^isub>1\<sharp>v\<^isub>0'" using eqc by auto
24678
232e71c2a6d9 tuned one proof so to not run in a loop with the new atom-representation
urbanc
parents: 24231
diff changeset
  1082
      then have "n\<^isub>1\<sharp>((n\<^isub>2,v\<^isub>0')#\<theta>)" using f by (simp add: fresh_list_cons fresh_atm fresh_prod)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1083
      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
  1084
      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
  1085
      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
  1086
    qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1087
    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
  1088
      proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1089
	have "n\<^isub>2\<sharp>\<theta><t'>" using fresh_psubst f by simp
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1090
	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
  1091
	then have "n\<^isub>2\<sharp>v\<^isub>0'" using eqc by auto
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1092
	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
  1093
	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
  1094
	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
  1095
      qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1096
    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
  1097
    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
  1098
  }
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1099
  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
  1100
qed (force)+
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1101
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1102
theorem termination_of_evaluation:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1103
  assumes a: "[] \<turnstile> e : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1104
  shows "\<exists>v. e \<Down> v \<and> val v"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1105
proof -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1106
  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
  1107
    by (rule termination_aux) (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1108
  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
  1109
qed 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1110
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
  1111
end