src/HOL/Nominal/Examples/Weakening.thy
author urbanc
Mon, 07 Nov 2005 15:12:13 +0100
changeset 18105 4c9c081a416b
child 18269 3f36e2165e51
permissions -rw-r--r--
Initial commit of the theory "Weakening".
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18105
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
     1
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
     2
theory lam_public 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
     3
imports "../nominal" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
     4
begin
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
     5
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
     6
(* WEAKENING EXAMPLE*)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
     7
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
     8
section {* Simply-Typed Lambda-Calculus *}
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
     9
(*======================================*)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    10
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    11
atom_decl name 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    12
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    13
nominal_datatype lam = Var "name"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    14
                     | App "lam" "lam"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    15
                     | Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._" [100,100] 100)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    16
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    17
datatype ty =
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    18
    TVar "string"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    19
  | TArr "ty" "ty" (infix "\<rightarrow>" 200)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    20
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    21
primrec
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    22
 "pi\<bullet>(TVar s) = TVar s"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    23
 "pi\<bullet>(\<tau> \<rightarrow> \<sigma>) = (\<tau> \<rightarrow> \<sigma>)"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    24
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    25
lemma perm_ty[simp]:
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    26
  fixes pi ::"name prm"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    27
  and   \<tau>  ::"ty"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    28
  shows "pi\<bullet>\<tau> = \<tau>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    29
  by (cases \<tau>, simp_all)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    30
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    31
instance ty :: pt_name
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    32
apply(intro_classes)   
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    33
apply(simp_all)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    34
done
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    35
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    36
instance ty :: fs_name
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    37
apply(intro_classes)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    38
apply(simp add: supp_def)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    39
done
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    40
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    41
(* valid contexts *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    42
consts
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    43
  ctxts :: "((name\<times>ty) list) set" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    44
  valid :: "(name\<times>ty) list \<Rightarrow> bool"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    45
translations
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    46
  "valid \<Gamma>" \<rightleftharpoons> "\<Gamma> \<in> ctxts"  
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    47
inductive ctxts
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    48
intros
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    49
v1[intro]: "valid []"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    50
v2[intro]: "\<lbrakk>valid \<Gamma>;a\<sharp>\<Gamma>\<rbrakk>\<Longrightarrow> valid ((a,\<sigma>)#\<Gamma>)"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    51
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    52
lemma eqvt_valid:
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    53
  fixes   pi:: "name prm"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    54
  assumes a: "valid \<Gamma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    55
  shows   "valid (pi\<bullet>\<Gamma>)"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    56
using a
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    57
apply(induct)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    58
apply(auto simp add: pt_fresh_bij[OF pt_name_inst, OF at_name_inst])
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    59
done
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    60
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    61
(* typing judgements *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    62
consts
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    63
  typing :: "(((name\<times>ty) list)\<times>lam\<times>ty) set" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    64
syntax
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    65
  "_typing_judge" :: "(name\<times>ty) list\<Rightarrow>lam\<Rightarrow>ty\<Rightarrow>bool" (" _ \<turnstile> _ : _ " [80,80,80] 80) 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    66
translations
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    67
  "\<Gamma> \<turnstile> t : \<tau>" \<rightleftharpoons> "(\<Gamma>,t,\<tau>) \<in> typing"  
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    68
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    69
inductive typing
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    70
intros
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    71
t1[intro]: "\<lbrakk>valid \<Gamma>; (a,\<tau>)\<in>set \<Gamma>\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> Var a : \<tau>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    72
t2[intro]: "\<lbrakk>\<Gamma> \<turnstile> t1 : \<tau>\<rightarrow>\<sigma>; \<Gamma> \<turnstile> t2 : \<tau>\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> App t1 t2 : \<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    73
t3[intro]: "\<lbrakk>a\<sharp>\<Gamma>;((a,\<tau>)#\<Gamma>) \<turnstile> t : \<sigma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [a].t : \<tau>\<rightarrow>\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    74
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    75
lemma eqvt_typing: 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    76
  fixes  \<Gamma> :: "(name\<times>ty) list"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    77
  and    t :: "lam"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    78
  and    \<tau> :: "ty"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    79
  and    pi:: "name prm"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    80
  assumes a: "\<Gamma> \<turnstile> t : \<tau>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    81
  shows "(pi\<bullet>\<Gamma>) \<turnstile> (pi\<bullet>t) : \<tau>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    82
using a
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    83
proof (induct)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    84
  case (t1 \<Gamma> \<tau> a)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    85
  have "valid (pi\<bullet>\<Gamma>)" by (rule eqvt_valid)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    86
  moreover
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    87
  have "(pi\<bullet>(a,\<tau>))\<in>((pi::name prm)\<bullet>set \<Gamma>)" by (rule pt_set_bij2[OF pt_name_inst, OF at_name_inst])
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    88
  ultimately show "(pi\<bullet>\<Gamma>) \<turnstile> ((pi::name prm)\<bullet>Var a) : \<tau>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    89
    using typing.intros by (force simp add: pt_list_set_pi[OF pt_name_inst, symmetric])
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    90
next 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    91
  case (t3 \<Gamma> \<sigma> \<tau> a t)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    92
  moreover have "(pi\<bullet>a)\<sharp>(pi\<bullet>\<Gamma>)" by (rule pt_fresh_bij1[OF pt_name_inst, OF at_name_inst])
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    93
  ultimately show "(pi\<bullet>\<Gamma>) \<turnstile> (pi\<bullet>Lam [a].t) :\<tau>\<rightarrow>\<sigma>" by force 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    94
qed (auto)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    95
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    96
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    97
lemma typing_induct_weak[THEN spec, case_names t1 t2 t3]:
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    98
  fixes  P :: "(name\<times>ty) list \<Rightarrow> lam \<Rightarrow> ty \<Rightarrow>'a\<Rightarrow>bool"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
    99
  and    \<Gamma> :: "(name\<times>ty) list"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   100
  and    t :: "lam"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   101
  and    \<tau> :: "ty"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   102
  assumes a: "\<Gamma> \<turnstile> t : \<tau>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   103
  and a1:    "\<And>x \<Gamma> (a::name) \<tau>. valid \<Gamma> \<Longrightarrow> (a,\<tau>) \<in> set \<Gamma> \<Longrightarrow> P \<Gamma> (Var a) \<tau> x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   104
  and a2:    "\<And>x \<Gamma> \<tau> \<sigma> t1 t2. 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   105
              \<Gamma> \<turnstile> t1 : \<tau>\<rightarrow>\<sigma> \<Longrightarrow> (\<forall>z. P \<Gamma> t1 (\<tau>\<rightarrow>\<sigma>) z) \<Longrightarrow> \<Gamma> \<turnstile> t2 : \<tau> \<Longrightarrow> (\<forall>z. P \<Gamma> t2 \<tau> z)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   106
              \<Longrightarrow> P \<Gamma> (App t1 t2) \<sigma> x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   107
  and a3:    "\<And>x (a::name) \<Gamma> \<tau> \<sigma> t. 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   108
              a\<sharp>\<Gamma> \<Longrightarrow> ((a,\<tau>) # \<Gamma>) \<turnstile> t : \<sigma> \<Longrightarrow> (\<forall>z. P ((a,\<tau>)#\<Gamma>) t \<sigma> z)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   109
              \<Longrightarrow> P \<Gamma> (Lam [a].t) (\<tau>\<rightarrow>\<sigma>) x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   110
  shows "\<forall>x. P \<Gamma> t \<tau> x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   111
using a by (induct, simp_all add: a1 a2 a3)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   112
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   113
lemma typing_induct_aux[rule_format]:
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   114
  fixes  P :: "(name\<times>ty) list \<Rightarrow> lam \<Rightarrow> ty \<Rightarrow>'a::fs_name\<Rightarrow>bool"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   115
  and    \<Gamma> :: "(name\<times>ty) list"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   116
  and    t :: "lam"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   117
  and    \<tau> :: "ty"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   118
  assumes a: "\<Gamma> \<turnstile> t : \<tau>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   119
  and a1:    "\<And>x \<Gamma> (a::name) \<tau>. valid \<Gamma> \<Longrightarrow> (a,\<tau>) \<in> set \<Gamma> \<Longrightarrow> P \<Gamma> (Var a) \<tau> x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   120
  and a2:    "\<And>x \<Gamma> \<tau> \<sigma> t1 t2. 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   121
              \<Gamma> \<turnstile> t1 : \<tau>\<rightarrow>\<sigma> \<Longrightarrow> (\<And>z. P \<Gamma> t1 (\<tau>\<rightarrow>\<sigma>) z) \<Longrightarrow> \<Gamma> \<turnstile> t2 : \<tau> \<Longrightarrow> (\<And>z. P \<Gamma> t2 \<tau> z)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   122
              \<Longrightarrow> P \<Gamma> (App t1 t2) \<sigma> x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   123
  and a3:    "\<And>x (a::name) \<Gamma> \<tau> \<sigma> t. 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   124
              a\<sharp>x \<Longrightarrow> a\<sharp>\<Gamma> \<Longrightarrow> ((a,\<tau>) # \<Gamma>) \<turnstile> t : \<sigma> \<Longrightarrow> (\<forall>z. P ((a,\<tau>)#\<Gamma>) t \<sigma> z)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   125
              \<Longrightarrow> P \<Gamma> (Lam [a].t) (\<tau>\<rightarrow>\<sigma>) x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   126
  shows "\<forall>(pi::name prm) (x::'a::fs_name). P (pi\<bullet>\<Gamma>) (pi\<bullet>t) \<tau> x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   127
using a
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   128
proof (induct)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   129
  case (t1 \<Gamma> \<tau> a)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   130
  have j1: "valid \<Gamma>" by fact
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   131
  have j2: "(a,\<tau>)\<in>set \<Gamma>" by fact
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   132
  show ?case
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   133
  proof (intro strip, simp)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   134
    fix pi::"name prm" and x::"'a::fs_name"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   135
    from j1 have j3: "valid (pi\<bullet>\<Gamma>)" by (rule eqvt_valid)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   136
    from j2 have "pi\<bullet>(a,\<tau>)\<in>pi\<bullet>(set \<Gamma>)" by (simp only: pt_set_bij[OF pt_name_inst, OF at_name_inst])  
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   137
    hence j4: "(pi\<bullet>a,\<tau>)\<in>set (pi\<bullet>\<Gamma>)" by (simp add: pt_list_set_pi[OF pt_name_inst])
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   138
    show "P (pi\<bullet>\<Gamma>) (Var (pi\<bullet>a)) \<tau> x" using a1 j3 j4 by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   139
  qed
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   140
next
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   141
  case (t2 \<Gamma> \<sigma> \<tau> t1 t2)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   142
  thus ?case using a2 by (simp, blast intro: eqvt_typing)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   143
next
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   144
  case (t3 \<Gamma> \<sigma> \<tau> a t)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   145
  have k1: "a\<sharp>\<Gamma>" by fact
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   146
  have k2: "((a,\<tau>)#\<Gamma>)\<turnstile>t:\<sigma>" by fact
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   147
  have k3: "\<forall>(pi::name prm) (x::'a::fs_name). P (pi \<bullet> ((a,\<tau>)#\<Gamma>)) (pi\<bullet>t) \<sigma> x" by fact
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   148
  show ?case
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   149
  proof (intro strip, simp)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   150
    fix pi::"name prm" and x::"'a::fs_name"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   151
    have f: "\<exists>c::name. c\<sharp>(pi\<bullet>a,pi\<bullet>t,pi\<bullet>\<Gamma>,x)"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   152
      by (rule at_exists_fresh[OF at_name_inst], simp add: fs_name1)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   153
    then obtain c::"name" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   154
      where f1: "c\<noteq>(pi\<bullet>a)" and f2: "c\<sharp>x" and f3: "c\<sharp>(pi\<bullet>t)" and f4: "c\<sharp>(pi\<bullet>\<Gamma>)"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   155
      by (force simp add: fresh_prod at_fresh[OF at_name_inst])
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   156
    from k1 have k1a: "(pi\<bullet>a)\<sharp>(pi\<bullet>\<Gamma>)" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   157
      by (simp add: pt_fresh_left[OF pt_name_inst, OF at_name_inst] 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   158
                    pt_rev_pi[OF pt_name_inst, OF at_name_inst])
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   159
    have l1: "(([(c,pi\<bullet>a)]@pi)\<bullet>\<Gamma>) = (pi\<bullet>\<Gamma>)" using f4 k1a 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   160
      by (simp only: pt2[OF pt_name_inst], rule pt_fresh_fresh[OF pt_name_inst, OF at_name_inst])
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   161
    have "\<forall>x. P (([(c,pi\<bullet>a)]@pi)\<bullet>((a,\<tau>)#\<Gamma>)) (([(c,pi\<bullet>a)]@pi)\<bullet>t) \<sigma> x" using k3 by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   162
    hence l2: "\<forall>x. P ((c, \<tau>)#(pi\<bullet>\<Gamma>)) (([(c,pi\<bullet>a)]@pi)\<bullet>t) \<sigma> x" using f1 l1
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   163
      by (force simp add: pt2[OF pt_name_inst]  at_calc[OF at_name_inst] split: if_splits)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   164
    have "(([(c,pi\<bullet>a)]@pi)\<bullet>((a,\<tau>)#\<Gamma>)) \<turnstile> (([(c,pi\<bullet>a)]@pi)\<bullet>t) : \<sigma>" using k2 by (rule eqvt_typing)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   165
    hence l3: "((c, \<tau>)#(pi\<bullet>\<Gamma>)) \<turnstile> (([(c,pi\<bullet>a)]@pi)\<bullet>t) : \<sigma>" using l1 f1 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   166
      by (force simp add: pt2[OF pt_name_inst]  at_calc[OF at_name_inst] split: if_splits)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   167
    have l4: "P (pi\<bullet>\<Gamma>) (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>t)) (\<tau> \<rightarrow> \<sigma>) x" using f2 f4 l2 l3 a3 by auto
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   168
    have alpha: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>t))) = (Lam [(pi\<bullet>a)].(pi\<bullet>t))" using f1 f3
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   169
      by (simp add: lam.inject alpha)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   170
    show "P (pi\<bullet>\<Gamma>) (Lam [(pi\<bullet>a)].(pi\<bullet>t)) (\<tau> \<rightarrow> \<sigma>) x" using l4 alpha 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   171
      by (simp only: pt2[OF pt_name_inst])
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   172
  qed
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   173
qed
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   174
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   175
lemma typing_induct[case_names t1 t2 t3]:
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   176
  fixes  P :: "(name\<times>ty) list \<Rightarrow> lam \<Rightarrow> ty \<Rightarrow>'a::fs_name\<Rightarrow>bool"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   177
  and    \<Gamma> :: "(name\<times>ty) list"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   178
  and    t :: "lam"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   179
  and    \<tau> :: "ty"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   180
  and    x :: "'a::fs_name"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   181
  assumes a: "\<Gamma> \<turnstile> t : \<tau>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   182
  and a1:    "\<And>x \<Gamma> (a::name) \<tau>. valid \<Gamma> \<Longrightarrow> (a,\<tau>) \<in> set \<Gamma> \<Longrightarrow> P \<Gamma> (Var a) \<tau> x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   183
  and a2:    "\<And>x \<Gamma> \<tau> \<sigma> t1 t2. 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   184
              \<Gamma> \<turnstile> t1 : \<tau>\<rightarrow>\<sigma> \<Longrightarrow> (\<forall>z. P \<Gamma> t1 (\<tau>\<rightarrow>\<sigma>) z) \<Longrightarrow> \<Gamma> \<turnstile> t2 : \<tau> \<Longrightarrow> (\<forall>z. P \<Gamma> t2 \<tau> z)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   185
              \<Longrightarrow> P \<Gamma> (App t1 t2) \<sigma> x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   186
  and a3:    "\<And>x (a::name) \<Gamma> \<tau> \<sigma> t. 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   187
              a\<sharp>x \<Longrightarrow> a\<sharp>\<Gamma> \<Longrightarrow> ((a,\<tau>) # \<Gamma>) \<turnstile> t : \<sigma> \<Longrightarrow> (\<forall>z. P ((a,\<tau>)#\<Gamma>) t \<sigma> z)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   188
              \<Longrightarrow> P \<Gamma> (Lam [a].t) (\<tau>\<rightarrow>\<sigma>) x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   189
  shows "P \<Gamma> t \<tau> x"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   190
using a a1 a2 a3 typing_induct_aux[of "\<Gamma>" "t" "\<tau>" "P" "[]" "x", simplified] by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   191
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   192
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   193
(* Now it comes: The Weakening Lemma *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   194
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   195
constdefs
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   196
  "sub" :: "(name\<times>ty) list \<Rightarrow> (name\<times>ty) list \<Rightarrow> bool" (" _ \<lless> _ " [80,80] 80)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   197
  "\<Gamma>1 \<lless> \<Gamma>2 \<equiv> \<forall>a \<sigma>. (a,\<sigma>)\<in>set \<Gamma>1 \<longrightarrow>  (a,\<sigma>)\<in>set \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   198
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   199
lemma weakening_version1[rule_format]: 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   200
  assumes a: "\<Gamma>1 \<turnstile> t : \<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   201
  shows "valid \<Gamma>2 \<longrightarrow> \<Gamma>1 \<lless> \<Gamma>2 \<longrightarrow> \<Gamma>2 \<turnstile> t:\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   202
using a
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   203
apply(nominal_induct \<Gamma>1 t \<sigma> rule: typing_induct)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   204
apply(auto simp add: sub_def)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   205
done
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   206
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   207
lemma weakening_version2[rule_format]: 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   208
  fixes \<Gamma>1::"(name\<times>ty) list"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   209
  and   t ::"lam"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   210
  and   \<tau> ::"ty"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   211
  assumes a: "\<Gamma>1 \<turnstile> t:\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   212
  shows "valid \<Gamma>2 \<longrightarrow> \<Gamma>1 \<lless> \<Gamma>2 \<longrightarrow> \<Gamma>2 \<turnstile> t:\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   213
using a
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   214
proof (nominal_induct \<Gamma>1 t \<sigma> rule: typing_induct, auto)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   215
  case (t1 \<Gamma>2 \<Gamma>1 a \<tau>)  (* variable case *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   216
  assume "\<Gamma>1 \<lless> \<Gamma>2" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   217
  and    "valid \<Gamma>2" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   218
  and    "(a,\<tau>)\<in> set \<Gamma>1" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   219
  thus  "\<Gamma>2 \<turnstile> Var a : \<tau>" by (force simp add: sub_def)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   220
next
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   221
  case (t3 \<Gamma>2 a \<Gamma>1 \<tau> \<sigma> t) (* lambda case *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   222
  assume a1: "\<Gamma>1 \<lless> \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   223
  and    a2: "valid \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   224
  and    a3: "a\<sharp>\<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   225
  have i: "\<forall>\<Gamma>3. valid \<Gamma>3 \<longrightarrow> ((a,\<tau>)#\<Gamma>1) \<lless> \<Gamma>3 \<longrightarrow>  \<Gamma>3 \<turnstile> t:\<sigma>" by fact
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   226
  have "((a,\<tau>)#\<Gamma>1) \<lless> ((a,\<tau>)#\<Gamma>2)" using a1 by (simp add: sub_def)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   227
  moreover
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   228
  have "valid ((a,\<tau>)#\<Gamma>2)" using a2 a3 v2 by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   229
  ultimately have "((a,\<tau>)#\<Gamma>2) \<turnstile> t:\<sigma>" using i by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   230
  with a3 show "\<Gamma>2 \<turnstile> (Lam [a].t) : \<tau> \<rightarrow> \<sigma>" by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   231
qed
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   232
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   233
lemma weakening_version3[rule_format]: 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   234
  fixes \<Gamma>1::"(name\<times>ty) list"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   235
  and   t ::"lam"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   236
  and   \<tau> ::"ty"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   237
  assumes a: "\<Gamma>1 \<turnstile> t:\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   238
  shows "valid \<Gamma>2 \<longrightarrow> \<Gamma>1 \<lless> \<Gamma>2 \<longrightarrow> \<Gamma>2 \<turnstile> t:\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   239
using a
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   240
proof (nominal_induct \<Gamma>1 t \<sigma> rule: typing_induct)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   241
  case (t1 \<Gamma>2 \<Gamma>1 a \<tau>)  (* variable case *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   242
  thus "valid \<Gamma>2 \<longrightarrow> \<Gamma>1 \<lless> \<Gamma>2 \<longrightarrow> \<Gamma>2 \<turnstile> Var a : \<tau>" by (force simp add: sub_def)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   243
next 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   244
  case (t2 \<Gamma>2 \<Gamma>1 \<tau> \<sigma> t1 t2)  (* variable case *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   245
  thus "valid \<Gamma>2 \<longrightarrow> \<Gamma>1 \<lless> \<Gamma>2 \<longrightarrow> \<Gamma>2 \<turnstile> App t1 t2 : \<sigma>" by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   246
next
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   247
  case (t3 \<Gamma>2 a \<Gamma>1 \<tau> \<sigma> t) (* lambda case *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   248
  have a3: "a\<sharp>\<Gamma>2" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   249
  and  i: "\<forall>\<Gamma>3. valid \<Gamma>3 \<longrightarrow> ((a,\<tau>)#\<Gamma>1) \<lless> \<Gamma>3 \<longrightarrow>  \<Gamma>3 \<turnstile> t:\<sigma>" by fact
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   250
  show "valid \<Gamma>2 \<longrightarrow> \<Gamma>1 \<lless> \<Gamma>2 \<longrightarrow> \<Gamma>2 \<turnstile> (Lam [a].t) : \<tau> \<rightarrow> \<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   251
    proof (intro strip)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   252
      assume a1: "\<Gamma>1 \<lless> \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   253
      and    a2: "valid \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   254
      have "((a,\<tau>)#\<Gamma>1) \<lless> ((a,\<tau>)#\<Gamma>2)" using a1 by (simp add: sub_def)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   255
      moreover
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   256
      have "valid ((a,\<tau>)#\<Gamma>2)" using a2 a3 v2 by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   257
      ultimately have "((a,\<tau>)#\<Gamma>2) \<turnstile> t:\<sigma>" using i by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   258
      with a3 show "\<Gamma>2 \<turnstile> (Lam [a].t) : \<tau> \<rightarrow> \<sigma>" by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   259
    qed
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   260
qed
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   261
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   262
lemma weakening_version4[rule_format]: 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   263
  assumes a: "\<Gamma>1 \<turnstile> t:\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   264
  shows "valid \<Gamma>2 \<longrightarrow> \<Gamma>1 \<lless> \<Gamma>2 \<longrightarrow> \<Gamma>2 \<turnstile> t:\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   265
using a
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   266
proof (nominal_induct \<Gamma>1 t \<sigma> rule: typing_induct)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   267
  case (t3 \<Gamma>2 a \<Gamma>1 \<tau> \<sigma> t) (* lambda case *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   268
  have fc: "a\<sharp>\<Gamma>2" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   269
  and ih: "\<forall>\<Gamma>3. valid \<Gamma>3 \<longrightarrow> ((a,\<tau>)#\<Gamma>1) \<lless> \<Gamma>3  \<longrightarrow>  \<Gamma>3 \<turnstile> t:\<sigma>" by fact 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   270
  show "valid \<Gamma>2 \<longrightarrow> \<Gamma>1 \<lless> \<Gamma>2 \<longrightarrow> \<Gamma>2 \<turnstile> (Lam [a].t) : \<tau> \<rightarrow> \<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   271
  proof (intro strip)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   272
    assume a1: "\<Gamma>1 \<lless> \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   273
    and    a2: "valid \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   274
    have "((a,\<tau>)#\<Gamma>1) \<lless> ((a,\<tau>)#\<Gamma>2)" using a1 sub_def by simp 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   275
    moreover
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   276
    have "valid ((a,\<tau>)#\<Gamma>2)" using a2 fc by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   277
    ultimately have "((a,\<tau>)#\<Gamma>2) \<turnstile> t:\<sigma>" using ih by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   278
    with fc show "\<Gamma>2 \<turnstile> (Lam [a].t) : \<tau> \<rightarrow> \<sigma>" by force
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   279
  qed
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   280
qed (auto simp add: sub_def) (* lam and var case *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   281
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   282
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   283
(* original induction principle is not strong *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   284
(* enough - so the simple proof fails         *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   285
lemma weakening_too_weak[rule_format]: 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   286
  assumes a: "\<Gamma>1 \<turnstile> t:\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   287
  shows "valid \<Gamma>2 \<longrightarrow> \<Gamma>1 \<lless> \<Gamma>2 \<longrightarrow> \<Gamma>2 \<turnstile> t:\<sigma>"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   288
using a
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   289
proof (nominal_induct \<Gamma>1 t \<sigma> rule: typing_induct_weak, auto)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   290
  case (t1 \<Gamma>2 \<Gamma>1 a \<tau>)  (* variable case *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   291
  assume "\<Gamma>1 \<lless> \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   292
  and    "valid \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   293
  and    "(a,\<tau>)\<in> set \<Gamma>1" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   294
  thus "\<Gamma>2 \<turnstile> Var a : \<tau>" by (force simp add: sub_def)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   295
next
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   296
  case (t3 \<Gamma>2 a \<Gamma>1 \<tau> \<sigma> t) (* lambda case *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   297
  assume a1: "\<Gamma>1 \<lless> \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   298
  and    a2: "valid \<Gamma>2"
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   299
  and    i: "\<forall>\<Gamma>3. valid \<Gamma>3 \<longrightarrow> ((a,\<tau>)#\<Gamma>1) \<lless> \<Gamma>3  \<longrightarrow>  \<Gamma>3 \<turnstile> t:\<sigma>" 
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   300
  have "((a,\<tau>)#\<Gamma>1) \<lless> ((a,\<tau>)#\<Gamma>2)" using a1 by (simp add: sub_def)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   301
  moreover
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   302
  have "valid ((a,\<tau>)#\<Gamma>2)" using v2 (* fails *)
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   303
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   304
4c9c081a416b Initial commit of the theory "Weakening".
urbanc
parents:
diff changeset
   305