src/HOL/Nominal/Examples/SOS.thy
author wenzelm
Tue, 13 Aug 2013 16:25:47 +0200
changeset 53015 a1119cf551e8
parent 49171 3d7a695385f1
child 58238 a701907d621e
permissions -rw-r--r--
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
     1
(*                                                        *)
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
     2
(* Formalisation of some typical SOS-proofs.              *)
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
     3
(*                                                        *) 
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
     4
(* This work was inspired by challenge suggested by Adam  *)
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
     5
(* Chlipala on the POPLmark mailing list.                 *)
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
     6
(*                                                        *) 
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
     7
(* We thank Nick Benton for helping us with the           *) 
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
     8
(* termination-proof for evaluation.                      *)
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
     9
(*                                                        *)
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
    10
(* The formalisation was done by Julien Narboux and       *)
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
    11
(* Christian Urban.                                       *)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    12
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    13
theory SOS
28568
urbanc
parents: 26966
diff changeset
    14
  imports "Nominal"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    15
begin
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    16
23158
749b6870b1a1 introduced symmetric variants of the lemmas for alpha-equivalence
urbanc
parents: 22730
diff changeset
    17
atom_decl name
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    18
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    19
text {* types and terms *}
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    20
nominal_datatype ty = 
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    21
    TVar "nat"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    22
  | Arrow "ty" "ty" ("_\<rightarrow>_" [100,100] 100)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    23
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    24
nominal_datatype trm = 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    25
    Var "name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    26
  | Lam "\<guillemotleft>name\<guillemotright>trm" ("Lam [_]._" [100,100] 100)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    27
  | App "trm" "trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    28
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    29
lemma fresh_ty:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    30
  fixes x::"name" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    31
  and   T::"ty"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    32
  shows "x\<sharp>T"
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 26806
diff changeset
    33
by (induct T rule: ty.induct)
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    34
   (auto simp add: fresh_nat)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    35
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    36
text {* Parallel and single substitution. *}
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    37
fun
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    38
  lookup :: "(name\<times>trm) list \<Rightarrow> name \<Rightarrow> trm"   
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    39
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    40
  "lookup [] x        = Var x"
22502
baee64dbe8ea fixed function syntax
krauss
parents: 22472
diff changeset
    41
| "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
    42
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    43
lemma lookup_eqvt[eqvt]:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    44
  fixes pi::"name prm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    45
  shows "pi\<bullet>(lookup \<theta> X) = lookup (pi\<bullet>\<theta>) (pi\<bullet>X)"
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    46
by (induct \<theta>) (auto simp add: eqvts)
22447
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 lookup_fresh:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    49
  fixes z::"name"
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    50
  assumes a: "z\<sharp>\<theta>" and b: "z\<sharp>x"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    51
  shows "z \<sharp>lookup \<theta> x"
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    52
using a b
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    53
by (induct rule: lookup.induct) (auto simp add: fresh_list_cons)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    54
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    55
lemma lookup_fresh':
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    56
  assumes "z\<sharp>\<theta>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    57
  shows "lookup \<theta> z = Var z"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    58
using assms 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    59
by (induct rule: lookup.induct)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    60
   (auto simp add: fresh_list_cons fresh_prod fresh_atm)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    61
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    62
(* parallel substitution *)
28568
urbanc
parents: 26966
diff changeset
    63
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28568
diff changeset
    64
nominal_primrec
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    65
  psubst :: "(name\<times>trm) list \<Rightarrow> trm \<Rightarrow> trm"  ("_<_>" [95,95] 105)
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28568
diff changeset
    66
where
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    67
  "\<theta><(Var x)> = (lookup \<theta> x)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
    68
| "\<theta><(App e\<^sub>1 e\<^sub>2)> = App (\<theta><e\<^sub>1>) (\<theta><e\<^sub>2>)"
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28568
diff changeset
    69
| "x\<sharp>\<theta> \<Longrightarrow> \<theta><(Lam [x].e)> = Lam [x].(\<theta><e>)"
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    70
apply(finite_guess)+
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
    71
apply(rule TrueI)+
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
    72
apply(simp add: abs_fresh)+
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    73
apply(fresh_guess)+
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
    74
done
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    75
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    76
lemma psubst_eqvt[eqvt]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    77
  fixes pi::"name prm" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    78
  and   t::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    79
  shows "pi\<bullet>(\<theta><t>) = (pi\<bullet>\<theta>)<(pi\<bullet>t)>"
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 26806
diff changeset
    80
by (nominal_induct t avoiding: \<theta> rule: trm.strong_induct)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
    81
   (perm_simp add: fresh_bij lookup_eqvt)+
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    82
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    83
lemma fresh_psubst: 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    84
  fixes z::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    85
  and   t::"trm"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    86
  assumes "z\<sharp>t" and "z\<sharp>\<theta>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    87
  shows "z\<sharp>(\<theta><t>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    88
using assms
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 26806
diff changeset
    89
by (nominal_induct t avoiding: z \<theta> t rule: trm.strong_induct)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    90
   (auto simp add: abs_fresh lookup_fresh)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    91
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    92
lemma psubst_empty[simp]:
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    93
  shows "[]<t> = t"
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 26806
diff changeset
    94
  by (nominal_induct t rule: trm.strong_induct) 
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    95
     (auto simp add: fresh_list_nil)
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    96
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
    97
text {* Single substitution *}
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
    98
abbreviation 
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
    99
  subst :: "trm \<Rightarrow> name \<Rightarrow> trm \<Rightarrow> trm" ("_[_::=_]" [100,100,100] 100)
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   100
where 
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   101
  "t[x::=t']  \<equiv> ([(x,t')])<t>" 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   102
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   103
lemma subst[simp]:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   104
  shows "(Var x)[y::=t'] = (if x=y then t' else (Var x))"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   105
  and   "(App t\<^sub>1 t\<^sub>2)[y::=t'] = App (t\<^sub>1[y::=t']) (t\<^sub>2[y::=t'])"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   106
  and   "x\<sharp>(y,t') \<Longrightarrow> (Lam [x].t)[y::=t'] = Lam [x].(t[y::=t'])"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   107
by (simp_all add: fresh_list_cons fresh_list_nil)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   108
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   109
lemma fresh_subst:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   110
  fixes z::"name"
28568
urbanc
parents: 26966
diff changeset
   111
  shows "\<lbrakk>z\<sharp>s; (z=y \<or> z\<sharp>t)\<rbrakk> \<Longrightarrow> z\<sharp>t[y::=s]"
urbanc
parents: 26966
diff changeset
   112
by (nominal_induct t avoiding: z y s rule: trm.strong_induct)
urbanc
parents: 26966
diff changeset
   113
   (auto simp add: abs_fresh fresh_prod fresh_atm)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   114
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   115
lemma forget: 
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
   116
  assumes a: "x\<sharp>e" 
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   117
  shows "e[x::=e'] = e"
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
   118
using a
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 26806
diff changeset
   119
by (nominal_induct e avoiding: x e' rule: trm.strong_induct)
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
   120
   (auto simp add: fresh_atm abs_fresh)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   121
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   122
lemma psubst_subst_psubst:
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
   123
  assumes h: "x\<sharp>\<theta>"
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   124
  shows "\<theta><e>[x::=e'] = ((x,e')#\<theta>)<e>"
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   125
  using h
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 26806
diff changeset
   126
by (nominal_induct e avoiding: \<theta> x e' rule: trm.strong_induct)
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
   127
   (auto simp add: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh')
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   128
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   129
text {* Typing Judgements *}
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   130
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   131
inductive
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   132
  valid :: "(name\<times>ty) list \<Rightarrow> bool"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   133
where
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   134
  v_nil[intro]:  "valid []"
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   135
| v_cons[intro]: "\<lbrakk>valid \<Gamma>;x\<sharp>\<Gamma>\<rbrakk> \<Longrightarrow> valid ((x,T)#\<Gamma>)"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   136
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   137
equivariance valid 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   138
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   139
inductive_cases
28568
urbanc
parents: 26966
diff changeset
   140
  valid_elim[elim]: "valid ((x,T)#\<Gamma>)"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   141
28568
urbanc
parents: 26966
diff changeset
   142
lemma valid_insert:
urbanc
parents: 26966
diff changeset
   143
  assumes a: "valid (\<Delta>@[(x,T)]@\<Gamma>)"
urbanc
parents: 26966
diff changeset
   144
  shows "valid (\<Delta> @ \<Gamma>)" 
urbanc
parents: 26966
diff changeset
   145
using a
urbanc
parents: 26966
diff changeset
   146
by (induct \<Delta>)
urbanc
parents: 26966
diff changeset
   147
   (auto simp add:  fresh_list_append fresh_list_cons elim!: valid_elim)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   148
28568
urbanc
parents: 26966
diff changeset
   149
lemma fresh_set: 
urbanc
parents: 26966
diff changeset
   150
  shows "y\<sharp>xs = (\<forall>x\<in>set xs. y\<sharp>x)"
urbanc
parents: 26966
diff changeset
   151
by (induct xs) (simp_all add: fresh_list_nil fresh_list_cons)
urbanc
parents: 26966
diff changeset
   152
urbanc
parents: 26966
diff changeset
   153
lemma context_unique:
urbanc
parents: 26966
diff changeset
   154
  assumes a1: "valid \<Gamma>"
urbanc
parents: 26966
diff changeset
   155
  and     a2: "(x,T) \<in> set \<Gamma>"
urbanc
parents: 26966
diff changeset
   156
  and     a3: "(x,U) \<in> set \<Gamma>"
urbanc
parents: 26966
diff changeset
   157
  shows "T = U" 
urbanc
parents: 26966
diff changeset
   158
using a1 a2 a3
urbanc
parents: 26966
diff changeset
   159
by (induct) (auto simp add: fresh_set fresh_prod fresh_atm)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   160
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
   161
text {* Typing Relation *}
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
   162
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   163
inductive
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   164
  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
   165
where
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   166
  t_Var[intro]:   "\<lbrakk>valid \<Gamma>; (x,T)\<in>set \<Gamma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Var x : T"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   167
| t_App[intro]:   "\<lbrakk>\<Gamma> \<turnstile> e\<^sub>1 : T\<^sub>1\<rightarrow>T\<^sub>2; \<Gamma> \<turnstile> e\<^sub>2 : T\<^sub>1\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> App e\<^sub>1 e\<^sub>2 : T\<^sub>2"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   168
| t_Lam[intro]:   "\<lbrakk>x\<sharp>\<Gamma>; (x,T\<^sub>1)#\<Gamma> \<turnstile> e : T\<^sub>2\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].e : T\<^sub>1\<rightarrow>T\<^sub>2"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   169
22730
8bcc8809ed3b nominal_inductive no longer proves equivariance.
berghofe
parents: 22650
diff changeset
   170
equivariance typing
8bcc8809ed3b nominal_inductive no longer proves equivariance.
berghofe
parents: 22650
diff changeset
   171
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   172
nominal_inductive typing
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   173
  by (simp_all add: abs_fresh fresh_ty)
22531
1cbfb4066e47 Adapted to changes in nominal_inductive.
berghofe
parents: 22502
diff changeset
   174
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   175
lemma typing_implies_valid:
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   176
  assumes a: "\<Gamma> \<turnstile> t : T"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   177
  shows "valid \<Gamma>"
28568
urbanc
parents: 26966
diff changeset
   178
using a by (induct) (auto)
urbanc
parents: 26966
diff changeset
   179
urbanc
parents: 26966
diff changeset
   180
urbanc
parents: 26966
diff changeset
   181
lemma t_App_elim:
urbanc
parents: 26966
diff changeset
   182
  assumes a: "\<Gamma> \<turnstile> App t1 t2 : T"
urbanc
parents: 26966
diff changeset
   183
  obtains T' where "\<Gamma> \<turnstile> t1 : T' \<rightarrow> T" and "\<Gamma> \<turnstile> t2 : T'"
urbanc
parents: 26966
diff changeset
   184
using a
urbanc
parents: 26966
diff changeset
   185
by (cases) (auto simp add: trm.inject)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   186
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   187
lemma t_Lam_elim: 
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
   188
  assumes a: "\<Gamma> \<turnstile> Lam [x].t : T" "x\<sharp>\<Gamma>"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   189
  obtains T\<^sub>1 and T\<^sub>2 where "(x,T\<^sub>1)#\<Gamma> \<turnstile> t : T\<^sub>2" and "T=T\<^sub>1\<rightarrow>T\<^sub>2"
25867
c24395ea4e71 tuned proofs
urbanc
parents: 25832
diff changeset
   190
using a
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   191
by (cases rule: typing.strong_cases [where x="x"])
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   192
   (auto simp add: abs_fresh fresh_ty alpha trm.inject)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   193
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   194
abbreviation
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   195
  "sub_context" :: "(name\<times>ty) list \<Rightarrow> (name\<times>ty) list \<Rightarrow> bool" ("_ \<subseteq> _" [55,55] 55)
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   196
where
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   197
  "\<Gamma>\<^sub>1 \<subseteq> \<Gamma>\<^sub>2 \<equiv> \<forall>x T. (x,T)\<in>set \<Gamma>\<^sub>1 \<longrightarrow> (x,T)\<in>set \<Gamma>\<^sub>2"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   198
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   199
lemma weakening: 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   200
  fixes \<Gamma>\<^sub>1 \<Gamma>\<^sub>2::"(name\<times>ty) list"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   201
  assumes "\<Gamma>\<^sub>1 \<turnstile> e: T" and "valid \<Gamma>\<^sub>2" and "\<Gamma>\<^sub>1 \<subseteq> \<Gamma>\<^sub>2"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   202
  shows "\<Gamma>\<^sub>2 \<turnstile> e: T"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   203
  using assms
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   204
proof(nominal_induct \<Gamma>\<^sub>1 e T avoiding: \<Gamma>\<^sub>2 rule: typing.strong_induct)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   205
  case (t_Lam x \<Gamma>\<^sub>1 T\<^sub>1 t T\<^sub>2 \<Gamma>\<^sub>2)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   206
  have vc: "x\<sharp>\<Gamma>\<^sub>2" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   207
  have ih: "\<lbrakk>valid ((x,T\<^sub>1)#\<Gamma>\<^sub>2); (x,T\<^sub>1)#\<Gamma>\<^sub>1 \<subseteq> (x,T\<^sub>1)#\<Gamma>\<^sub>2\<rbrakk> \<Longrightarrow> (x,T\<^sub>1)#\<Gamma>\<^sub>2 \<turnstile> t : T\<^sub>2" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   208
  have "valid \<Gamma>\<^sub>2" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   209
  then have "valid ((x,T\<^sub>1)#\<Gamma>\<^sub>2)" using vc by auto
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   210
  moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   211
  have "\<Gamma>\<^sub>1 \<subseteq> \<Gamma>\<^sub>2" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   212
  then have "(x,T\<^sub>1)#\<Gamma>\<^sub>1 \<subseteq> (x,T\<^sub>1)#\<Gamma>\<^sub>2" by simp
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   213
  ultimately have "(x,T\<^sub>1)#\<Gamma>\<^sub>2 \<turnstile> t : T\<^sub>2" using ih by simp 
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   214
  with vc show "\<Gamma>\<^sub>2 \<turnstile> Lam [x].t : T\<^sub>1\<rightarrow>T\<^sub>2" by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   215
qed (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   216
28568
urbanc
parents: 26966
diff changeset
   217
lemma type_substitutivity_aux:
urbanc
parents: 26966
diff changeset
   218
  assumes a: "(\<Delta>@[(x,T')]@\<Gamma>) \<turnstile> e : T"
urbanc
parents: 26966
diff changeset
   219
  and     b: "\<Gamma> \<turnstile> e' : T'"
urbanc
parents: 26966
diff changeset
   220
  shows "(\<Delta>@\<Gamma>) \<turnstile> e[x::=e'] : T" 
urbanc
parents: 26966
diff changeset
   221
using a b 
urbanc
parents: 26966
diff changeset
   222
proof (nominal_induct \<Gamma>\<equiv>"\<Delta>@[(x,T')]@\<Gamma>" e T avoiding: e' \<Delta> rule: typing.strong_induct)
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 29300
diff changeset
   223
  case (t_Var y T e' \<Delta>)
28568
urbanc
parents: 26966
diff changeset
   224
  then have a1: "valid (\<Delta>@[(x,T')]@\<Gamma>)" 
urbanc
parents: 26966
diff changeset
   225
       and  a2: "(y,T) \<in> set (\<Delta>@[(x,T')]@\<Gamma>)" 
34915
7894c7dab132 Adapted to changes in induct method.
berghofe
parents: 29300
diff changeset
   226
       and  a3: "\<Gamma> \<turnstile> e' : T'" .
28568
urbanc
parents: 26966
diff changeset
   227
  from a1 have a4: "valid (\<Delta>@\<Gamma>)" by (rule valid_insert)
urbanc
parents: 26966
diff changeset
   228
  { assume eq: "x=y"
urbanc
parents: 26966
diff changeset
   229
    from a1 a2 have "T=T'" using eq by (auto intro: context_unique)
urbanc
parents: 26966
diff changeset
   230
    with a3 have "\<Delta>@\<Gamma> \<turnstile> Var y[x::=e'] : T" using eq a4 by (auto intro: weakening)
urbanc
parents: 26966
diff changeset
   231
  }
urbanc
parents: 26966
diff changeset
   232
  moreover
urbanc
parents: 26966
diff changeset
   233
  { assume ineq: "x\<noteq>y"
urbanc
parents: 26966
diff changeset
   234
    from a2 have "(y,T) \<in> set (\<Delta>@\<Gamma>)" using ineq by simp
urbanc
parents: 26966
diff changeset
   235
    then have "\<Delta>@\<Gamma> \<turnstile> Var y[x::=e'] : T" using ineq a4 by auto
urbanc
parents: 26966
diff changeset
   236
  }
urbanc
parents: 26966
diff changeset
   237
  ultimately show "\<Delta>@\<Gamma> \<turnstile> Var y[x::=e'] : T" by blast
urbanc
parents: 26966
diff changeset
   238
qed (force simp add: fresh_list_append fresh_list_cons)+
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   239
28568
urbanc
parents: 26966
diff changeset
   240
corollary type_substitutivity:
urbanc
parents: 26966
diff changeset
   241
  assumes a: "(x,T')#\<Gamma> \<turnstile> e : T"
urbanc
parents: 26966
diff changeset
   242
  and     b: "\<Gamma> \<turnstile> e' : T'"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   243
  shows "\<Gamma> \<turnstile> e[x::=e'] : T"
28568
urbanc
parents: 26966
diff changeset
   244
using a b type_substitutivity_aux[where \<Delta>="[]"]
urbanc
parents: 26966
diff changeset
   245
by (auto)
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   246
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   247
text {* Values *}
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   248
inductive
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   249
  val :: "trm\<Rightarrow>bool" 
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   250
where
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   251
  v_Lam[intro]:   "val (Lam [x].e)"
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   252
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   253
equivariance val 
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   254
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   255
lemma not_val_App[simp]:
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   256
  shows 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   257
  "\<not> val (App e\<^sub>1 e\<^sub>2)" 
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   258
  "\<not> val (Var x)"
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   259
  by (auto elim: val.cases)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   260
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   261
text {* Big-Step Evaluation *}
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   262
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23450
diff changeset
   263
inductive
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   264
  big :: "trm\<Rightarrow>trm\<Rightarrow>bool" ("_ \<Down> _" [80,80] 80) 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   265
where
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   266
  b_Lam[intro]:   "Lam [x].e \<Down> Lam [x].e"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   267
| b_App[intro]:   "\<lbrakk>x\<sharp>(e\<^sub>1,e\<^sub>2,e'); e\<^sub>1\<Down>Lam [x].e; e\<^sub>2\<Down>e\<^sub>2'; e[x::=e\<^sub>2']\<Down>e'\<rbrakk> \<Longrightarrow> App e\<^sub>1 e\<^sub>2 \<Down> e'"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   268
22730
8bcc8809ed3b nominal_inductive no longer proves equivariance.
berghofe
parents: 22650
diff changeset
   269
equivariance big
8bcc8809ed3b nominal_inductive no longer proves equivariance.
berghofe
parents: 22650
diff changeset
   270
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   271
nominal_inductive big
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   272
  by (simp_all add: abs_fresh)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   273
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   274
lemma big_preserves_fresh:
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   275
  fixes x::"name"
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   276
  assumes a: "e \<Down> e'" "x\<sharp>e" 
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   277
  shows "x\<sharp>e'"
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   278
  using a by (induct) (auto simp add: abs_fresh fresh_subst)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   279
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   280
lemma b_App_elim:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   281
  assumes a: "App e\<^sub>1 e\<^sub>2 \<Down> e'" "x\<sharp>(e\<^sub>1,e\<^sub>2,e')"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   282
  obtains f\<^sub>1 and f\<^sub>2 where "e\<^sub>1 \<Down> Lam [x]. f\<^sub>1" "e\<^sub>2 \<Down> f\<^sub>2" "f\<^sub>1[x::=f\<^sub>2] \<Down> e'"
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   283
  using a
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   284
by (cases rule: big.strong_cases[where x="x" and xa="x"])
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   285
   (auto simp add: trm.inject)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   286
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   287
lemma subject_reduction:
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   288
  assumes a: "e \<Down> e'" and b: "\<Gamma> \<turnstile> e : T"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   289
  shows "\<Gamma> \<turnstile> e' : T"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   290
  using a b
22534
bd4b954e85ee adapted to nominal_inductive
urbanc
parents: 22531
diff changeset
   291
proof (nominal_induct avoiding: \<Gamma> arbitrary: T rule: big.strong_induct) 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   292
  case (b_App x e\<^sub>1 e\<^sub>2 e' e e\<^sub>2' \<Gamma> T)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   293
  have vc: "x\<sharp>\<Gamma>" by fact
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   294
  have "\<Gamma> \<turnstile> App e\<^sub>1 e\<^sub>2 : T" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   295
  then obtain T' where a1: "\<Gamma> \<turnstile> e\<^sub>1 : T'\<rightarrow>T" and a2: "\<Gamma> \<turnstile> e\<^sub>2 : T'" 
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   296
    by (cases) (auto simp add: trm.inject)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   297
  have ih1: "\<Gamma> \<turnstile> e\<^sub>1 : T' \<rightarrow> T \<Longrightarrow> \<Gamma> \<turnstile> Lam [x].e : T' \<rightarrow> T" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   298
  have ih2: "\<Gamma> \<turnstile> e\<^sub>2 : T' \<Longrightarrow> \<Gamma> \<turnstile> e\<^sub>2' : T'" by fact 
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   299
  have ih3: "\<Gamma> \<turnstile> e[x::=e\<^sub>2'] : T \<Longrightarrow> \<Gamma> \<turnstile> e' : T" by fact
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   300
  have "\<Gamma> \<turnstile> Lam [x].e : T'\<rightarrow>T" using ih1 a1 by simp 
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   301
  then have "((x,T')#\<Gamma>) \<turnstile> e : T" using vc  
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   302
    by (auto elim: t_Lam_elim simp add: ty.inject)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   303
  moreover
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   304
  have "\<Gamma> \<turnstile> e\<^sub>2': T'" using ih2 a2 by simp
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   305
  ultimately have "\<Gamma> \<turnstile> e[x::=e\<^sub>2'] : T" by (simp add: type_substitutivity)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   306
  thus "\<Gamma> \<turnstile> e' : T" using ih3 by simp
28568
urbanc
parents: 26966
diff changeset
   307
qed (blast)
urbanc
parents: 26966
diff changeset
   308
urbanc
parents: 26966
diff changeset
   309
lemma subject_reduction2:
urbanc
parents: 26966
diff changeset
   310
  assumes a: "e \<Down> e'" and b: "\<Gamma> \<turnstile> e : T"
urbanc
parents: 26966
diff changeset
   311
  shows "\<Gamma> \<turnstile> e' : T"
urbanc
parents: 26966
diff changeset
   312
  using a b
urbanc
parents: 26966
diff changeset
   313
by (nominal_induct avoiding: \<Gamma> T rule: big.strong_induct)
urbanc
parents: 26966
diff changeset
   314
   (force elim: t_App_elim t_Lam_elim simp add: ty.inject type_substitutivity)+
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   315
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   316
lemma unicity_of_evaluation:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   317
  assumes a: "e \<Down> e\<^sub>1" 
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   318
  and     b: "e \<Down> e\<^sub>2"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   319
  shows "e\<^sub>1 = e\<^sub>2"
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   320
  using a b
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   321
proof (nominal_induct e e\<^sub>1 avoiding: e\<^sub>2 rule: big.strong_induct)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   322
  case (b_Lam x e t\<^sub>2)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   323
  have "Lam [x].e \<Down> t\<^sub>2" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   324
  thus "Lam [x].e = t\<^sub>2" by cases (simp_all add: trm.inject)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   325
next
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   326
  case (b_App x e\<^sub>1 e\<^sub>2 e' e\<^sub>1' e\<^sub>2' t\<^sub>2)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   327
  have ih1: "\<And>t. e\<^sub>1 \<Down> t \<Longrightarrow> Lam [x].e\<^sub>1' = t" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   328
  have ih2:"\<And>t. e\<^sub>2 \<Down> t \<Longrightarrow> e\<^sub>2' = t" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   329
  have ih3: "\<And>t. e\<^sub>1'[x::=e\<^sub>2'] \<Down> t \<Longrightarrow> e' = t" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   330
  have app: "App e\<^sub>1 e\<^sub>2 \<Down> t\<^sub>2" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   331
  have vc: "x\<sharp>e\<^sub>1" "x\<sharp>e\<^sub>2" "x\<sharp>t\<^sub>2" by fact+
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   332
  then have "x\<sharp>App e\<^sub>1 e\<^sub>2" by auto
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   333
  from app vc obtain f\<^sub>1 f\<^sub>2 where x1: "e\<^sub>1 \<Down> Lam [x]. f\<^sub>1" and x2: "e\<^sub>2 \<Down> f\<^sub>2" and x3: "f\<^sub>1[x::=f\<^sub>2] \<Down> t\<^sub>2"
28568
urbanc
parents: 26966
diff changeset
   334
    by (auto elim!: b_App_elim)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   335
  then have "Lam [x]. f\<^sub>1 = Lam [x]. e\<^sub>1'" using ih1 by simp
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   336
  then 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   337
  have "f\<^sub>1 = e\<^sub>1'" by (auto simp add: trm.inject alpha) 
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   338
  moreover 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   339
  have "f\<^sub>2 = e\<^sub>2'" using x2 ih2 by simp
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   340
  ultimately have "e\<^sub>1'[x::=e\<^sub>2'] \<Down> t\<^sub>2" using x3 by simp
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   341
  thus "e' = t\<^sub>2" using ih3 by simp
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   342
qed
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   343
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   344
lemma reduces_evaluates_to_values:
28568
urbanc
parents: 26966
diff changeset
   345
  assumes h: "t \<Down> t'"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   346
  shows "val t'"
28568
urbanc
parents: 26966
diff changeset
   347
using h by (induct) (auto)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   348
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   349
(* Valuation *)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   350
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   351
nominal_primrec
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28568
diff changeset
   352
  V :: "ty \<Rightarrow> trm set" 
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28568
diff changeset
   353
where
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   354
  "V (TVar x) = {e. val e}"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   355
| "V (T\<^sub>1 \<rightarrow> T\<^sub>2) = {Lam [x].e | x e. \<forall> v \<in> (V T\<^sub>1). \<exists> v'. e[x::=v] \<Down> v' \<and> v' \<in> V T\<^sub>2}"
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   356
  by (rule TrueI)+ 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   357
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   358
lemma V_eqvt:
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   359
  fixes pi::"name prm"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   360
  assumes a: "x\<in>V T"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   361
  shows "(pi\<bullet>x)\<in>V T"
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   362
using a
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 26806
diff changeset
   363
apply(nominal_induct T arbitrary: pi x rule: ty.strong_induct)
26806
40b411ec05aa Adapted to encoding of sets as predicates
berghofe
parents: 25867
diff changeset
   364
apply(auto simp add: trm.inject)
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   365
apply(simp add: eqvts)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   366
apply(rule_tac x="pi\<bullet>xa" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   367
apply(rule_tac x="pi\<bullet>e" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   368
apply(simp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   369
apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   370
apply(drule_tac x="(rev pi)\<bullet>v" in bspec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   371
apply(force)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   372
apply(auto)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   373
apply(rule_tac x="pi\<bullet>v'" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   374
apply(auto)
22542
8279a25ad0ae - Renamed <predicate>_eqvt to <predicate>.eqvt
berghofe
parents: 22541
diff changeset
   375
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
   376
apply(perm_simp add: eqvts)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   377
done
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   378
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   379
lemma V_arrow_elim_weak:
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   380
  assumes h:"u \<in> V (T\<^sub>1 \<rightarrow> T\<^sub>2)"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   381
  obtains a t where "u = Lam [a].t" and "\<forall> v \<in> (V T\<^sub>1). \<exists> v'. t[a::=v] \<Down> v' \<and> v' \<in> V T\<^sub>2"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   382
using h by (auto)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   383
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   384
lemma V_arrow_elim_strong:
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   385
  fixes c::"'a::fs_name"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   386
  assumes h: "u \<in> V (T\<^sub>1 \<rightarrow> T\<^sub>2)"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   387
  obtains a t where "a\<sharp>c" "u = Lam [a].t" "\<forall>v \<in> (V T\<^sub>1). \<exists> v'. t[a::=v] \<Down> v' \<and> v' \<in> V T\<^sub>2"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   388
using h
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   389
apply -
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   390
apply(erule V_arrow_elim_weak)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   391
apply(subgoal_tac "\<exists>a'::name. a'\<sharp>(a,t,c)") (*A*)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   392
apply(erule exE)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   393
apply(drule_tac x="a'" in meta_spec)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   394
apply(drule_tac x="[(a,a')]\<bullet>t" in meta_spec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   395
apply(drule meta_mp)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   396
apply(simp)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   397
apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   398
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
   399
apply(perm_simp)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   400
apply(force)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   401
apply(drule meta_mp)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   402
apply(rule ballI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   403
apply(drule_tac x="[(a,a')]\<bullet>v" in bspec)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   404
apply(simp add: V_eqvt)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   405
apply(auto)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   406
apply(rule_tac x="[(a,a')]\<bullet>v'" in exI)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   407
apply(auto)
22542
8279a25ad0ae - Renamed <predicate>_eqvt to <predicate>.eqvt
berghofe
parents: 22541
diff changeset
   408
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
   409
apply(perm_simp add: eqvts calc_atm)
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   410
apply(simp add: V_eqvt)
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   411
(*A*)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   412
apply(rule exists_fresh')
22472
bfd9c0fd70b1 tuned the proof
urbanc
parents: 22447
diff changeset
   413
apply(simp add: fin_supp)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   414
done
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   415
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   416
lemma Vs_are_values:
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   417
  assumes a: "e \<in> V T"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   418
  shows "val e"
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 26806
diff changeset
   419
using a by (nominal_induct T arbitrary: e rule: ty.strong_induct) (auto)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   420
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   421
lemma values_reduce_to_themselves:
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   422
  assumes a: "val v"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   423
  shows "v \<Down> v"
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   424
using a by (induct) (auto)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   425
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   426
lemma Vs_reduce_to_themselves:
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   427
  assumes a: "v \<in> V T"
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   428
  shows "v \<Down> v"
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   429
using a by (simp add: values_reduce_to_themselves Vs_are_values)
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   430
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   431
text {* '\<theta> maps x to e' asserts that \<theta> substitutes x with e *}
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   432
abbreviation 
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   433
  mapsto :: "(name\<times>trm) list \<Rightarrow> name \<Rightarrow> trm \<Rightarrow> bool" ("_ maps _ to _" [55,55,55] 55) 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   434
where
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   435
 "\<theta> maps x to e \<equiv> (lookup \<theta> x) = e"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   436
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   437
abbreviation 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   438
  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
   439
where
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   440
  "\<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)"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   441
28568
urbanc
parents: 26966
diff changeset
   442
lemma case_distinction_on_context:
urbanc
parents: 26966
diff changeset
   443
  fixes \<Gamma>::"(name\<times>ty) list"
urbanc
parents: 26966
diff changeset
   444
  assumes asm1: "valid ((m,t)#\<Gamma>)" 
urbanc
parents: 26966
diff changeset
   445
  and     asm2: "(n,U) \<in> set ((m,T)#\<Gamma>)"
urbanc
parents: 26966
diff changeset
   446
  shows "(n,U) = (m,T) \<or> ((n,U) \<in> set \<Gamma> \<and> n \<noteq> m)"
urbanc
parents: 26966
diff changeset
   447
proof -
urbanc
parents: 26966
diff changeset
   448
  from asm2 have "(n,U) \<in> set [(m,T)] \<or> (n,U) \<in> set \<Gamma>" by auto
urbanc
parents: 26966
diff changeset
   449
  moreover
urbanc
parents: 26966
diff changeset
   450
  { assume eq: "m=n"
urbanc
parents: 26966
diff changeset
   451
    assume "(n,U) \<in> set \<Gamma>" 
urbanc
parents: 26966
diff changeset
   452
    then have "\<not> n\<sharp>\<Gamma>" 
urbanc
parents: 26966
diff changeset
   453
      by (induct \<Gamma>) (auto simp add: fresh_list_cons fresh_prod fresh_atm)
urbanc
parents: 26966
diff changeset
   454
    moreover have "m\<sharp>\<Gamma>" using asm1 by auto
urbanc
parents: 26966
diff changeset
   455
    ultimately have False using eq by auto
urbanc
parents: 26966
diff changeset
   456
  }
urbanc
parents: 26966
diff changeset
   457
  ultimately show ?thesis by auto
urbanc
parents: 26966
diff changeset
   458
qed
urbanc
parents: 26966
diff changeset
   459
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   460
lemma monotonicity:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   461
  fixes m::"name"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   462
  fixes \<theta>::"(name \<times> trm) list" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   463
  assumes h1: "\<theta> Vcloses \<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   464
  and     h2: "e \<in> V T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   465
  and     h3: "valid ((x,T)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   466
  shows "(x,e)#\<theta> Vcloses (x,T)#\<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   467
proof(intro strip)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   468
  fix x' T'
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   469
  assume "(x',T') \<in> set ((x,T)#\<Gamma>)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   470
  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
   471
    by (rule_tac case_distinction_on_context)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   472
  moreover
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   473
  { (* first case *)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   474
    assume "(x',T') = (x,T)"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   475
    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
   476
  }
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   477
  moreover
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   478
  { (* second case *)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   479
    assume "(x',T') \<in> set \<Gamma>" and neq:"x' \<noteq> x"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   480
      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
   481
      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
   482
  }
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   483
  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
   484
qed
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   485
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   486
lemma termination_aux:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   487
  assumes h1: "\<Gamma> \<turnstile> e : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   488
  and     h2: "\<theta> Vcloses \<Gamma>"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   489
  shows "\<exists>v. \<theta><e> \<Down> v \<and> v \<in> V T" 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   490
using h2 h1
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 26806
diff changeset
   491
proof(nominal_induct e avoiding: \<Gamma> \<theta> arbitrary: T rule: trm.strong_induct)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   492
  case (App e\<^sub>1 e\<^sub>2 \<Gamma> \<theta> T)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   493
  have ih\<^sub>1: "\<And>\<theta> \<Gamma> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> e\<^sub>1 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><e\<^sub>1> \<Down> v \<and> v \<in> V T" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   494
  have ih\<^sub>2: "\<And>\<theta> \<Gamma> T. \<lbrakk>\<theta> Vcloses \<Gamma>; \<Gamma> \<turnstile> e\<^sub>2 : T\<rbrakk> \<Longrightarrow> \<exists>v. \<theta><e\<^sub>2> \<Down> v \<and> v \<in> V T" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   495
  have as\<^sub>1: "\<theta> Vcloses \<Gamma>" by fact 
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   496
  have as\<^sub>2: "\<Gamma> \<turnstile> App e\<^sub>1 e\<^sub>2 : T" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   497
  then obtain T' where "\<Gamma> \<turnstile> e\<^sub>1 : T' \<rightarrow> T" and "\<Gamma> \<turnstile> e\<^sub>2 : T'" by (auto elim: t_App_elim)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   498
  then obtain v\<^sub>1 v\<^sub>2 where "(i)": "\<theta><e\<^sub>1> \<Down> v\<^sub>1" "v\<^sub>1 \<in> V (T' \<rightarrow> T)"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   499
                      and "(ii)": "\<theta><e\<^sub>2> \<Down> v\<^sub>2" "v\<^sub>2 \<in> V T'" using ih\<^sub>1 ih\<^sub>2 as\<^sub>1 by blast
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   500
  from "(i)" obtain x e' 
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   501
            where "v\<^sub>1 = Lam [x].e'" 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   502
            and "(iii)": "(\<forall>v \<in> (V T').\<exists> v'. e'[x::=v] \<Down> v' \<and> v' \<in> V T)"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   503
            and "(iv)":  "\<theta><e\<^sub>1> \<Down> Lam [x].e'" 
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   504
            and fr: "x\<sharp>(\<theta>,e\<^sub>1,e\<^sub>2)" by (blast elim: V_arrow_elim_strong)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   505
  from fr have fr\<^sub>1: "x\<sharp>\<theta><e\<^sub>1>" and fr\<^sub>2: "x\<sharp>\<theta><e\<^sub>2>" by (simp_all add: fresh_psubst)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   506
  from "(ii)" "(iii)" obtain v\<^sub>3 where "(v)": "e'[x::=v\<^sub>2] \<Down> v\<^sub>3" "v\<^sub>3 \<in> V T" by auto
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   507
  from fr\<^sub>2 "(ii)" have "x\<sharp>v\<^sub>2" by (simp add: big_preserves_fresh)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   508
  then have "x\<sharp>e'[x::=v\<^sub>2]" by (simp add: fresh_subst)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   509
  then have fr\<^sub>3: "x\<sharp>v\<^sub>3" using "(v)" by (simp add: big_preserves_fresh)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   510
  from fr\<^sub>1 fr\<^sub>2 fr\<^sub>3 have "x\<sharp>(\<theta><e\<^sub>1>,\<theta><e\<^sub>2>,v\<^sub>3)" by simp
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   511
  with "(iv)" "(ii)" "(v)" have "App (\<theta><e\<^sub>1>) (\<theta><e\<^sub>2>) \<Down> v\<^sub>3" by auto
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   512
  then show "\<exists>v. \<theta><App e\<^sub>1 e\<^sub>2> \<Down> v \<and> v \<in> V T" using "(v)" by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   513
next
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   514
  case (Lam x e \<Gamma> \<theta> T)
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   515
  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
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   516
  have as\<^sub>1: "\<theta> Vcloses \<Gamma>" by fact
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   517
  have as\<^sub>2: "\<Gamma> \<turnstile> Lam [x].e : T" by fact
29300
e841a9de5445 avoid implicit use of prems;
wenzelm
parents: 29097
diff changeset
   518
  have fs: "x\<sharp>\<Gamma>" "x\<sharp>\<theta>" by fact+
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   519
  from as\<^sub>2 fs obtain T\<^sub>1 T\<^sub>2 
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   520
    where "(i)": "(x,T\<^sub>1)#\<Gamma> \<turnstile> e:T\<^sub>2" and "(ii)": "T = T\<^sub>1 \<rightarrow> T\<^sub>2" using fs
28568
urbanc
parents: 26966
diff changeset
   521
    by (auto elim: t_Lam_elim)
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   522
  from "(i)" have "(iii)": "valid ((x,T\<^sub>1)#\<Gamma>)" by (simp add: typing_implies_valid)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   523
  have "\<forall>v \<in> (V T\<^sub>1). \<exists>v'. (\<theta><e>)[x::=v] \<Down> v' \<and> v' \<in> V T\<^sub>2"
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   524
  proof
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   525
    fix v
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   526
    assume "v \<in> (V T\<^sub>1)"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   527
    with "(iii)" as\<^sub>1 have "(x,v)#\<theta> Vcloses (x,T\<^sub>1)#\<Gamma>" using monotonicity by auto
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   528
    with ih "(i)" obtain v' where "((x,v)#\<theta>)<e> \<Down> v' \<and> v' \<in> V T\<^sub>2" by blast
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   529
    then have "\<theta><e>[x::=v] \<Down> v' \<and> v' \<in> V T\<^sub>2" using fs by (simp add: psubst_subst_psubst)
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   530
    then show "\<exists>v'. \<theta><e>[x::=v] \<Down> v' \<and> v' \<in> V T\<^sub>2" by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   531
  qed
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   532
  then have "Lam[x].\<theta><e> \<in> V (T\<^sub>1 \<rightarrow> T\<^sub>2)" by auto
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 49171
diff changeset
   533
  then have "\<theta><Lam [x].e> \<Down> Lam [x].\<theta><e> \<and> Lam [x].\<theta><e> \<in> V (T\<^sub>1\<rightarrow>T\<^sub>2)" using fs by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   534
  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
   535
next
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   536
  case (Var x \<Gamma> \<theta> T)
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   537
  have "\<Gamma> \<turnstile> (Var x) : T" by fact
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   538
  then have "(x,T)\<in>set \<Gamma>" by (cases) (auto simp add: trm.inject)
41893
dde7df1176b7 eliminated prems;
wenzelm
parents: 34915
diff changeset
   539
  with Var have "\<theta><Var x> \<Down> \<theta><Var x> \<and> \<theta><Var x>\<in> V T" 
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   540
    by (auto intro!: Vs_reduce_to_themselves)
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   541
  then show "\<exists>v. \<theta><Var x> \<Down> v \<and> v \<in> V T" by auto
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   542
qed 
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   543
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   544
theorem termination_of_evaluation:
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   545
  assumes a: "[] \<turnstile> e : T"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   546
  shows "\<exists>v. e \<Down> v \<and> val v"
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   547
proof -
25832
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   548
  from a have "\<exists>v. []<e> \<Down> v \<and> v \<in> V T" by (rule termination_aux) (auto)
41a014cc44c0 partially adapted to new inversion rules
urbanc
parents: 24678
diff changeset
   549
  thus "\<exists>v. e \<Down> v \<and> val v" using Vs_are_values by auto
22447
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   550
qed 
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   551
013dbd8234f0 added formalisations of typical SOS-proofs
urbanc
parents:
diff changeset
   552
end