src/HOL/Nominal/Examples/LocalWeakening.thy
author boehmes
Wed, 02 Sep 2009 21:31:58 +0200
changeset 32498 1132c7c13f36
parent 29097 68245155eb58
child 35416 d8d7d1b785af
permissions -rw-r--r--
Mirabelle: actions are responsible for handling exceptions, Mirabelle core logs only structural information, measuring running times for sledgehammer and subsequent metis invocation, Mirabelle produces reports for every theory (only for sledgehammer at the moment)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
     1
(* Formalisation of weakening using locally nameless    *)
25867
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
     2
(* terms; the nominal infrastructure can also derive    *)
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
     3
(* strong induction principles for such representations *)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
     4
(*                                                      *)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
     5
(* Authors: Christian Urban and Randy Pollack           *)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
     6
theory LocalWeakening
25867
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
     7
  imports "../Nominal"
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
     8
begin
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
     9
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    10
atom_decl name
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    11
25867
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
    12
text {* 
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
    13
  Curry-style lambda terms in locally nameless 
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
    14
  representation without any binders           
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
    15
*}
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    16
nominal_datatype llam = 
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    17
    lPar "name"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    18
  | lVar "nat"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    19
  | lApp "llam" "llam"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    20
  | lLam "llam"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    21
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
    22
text {* definition of vsub - at the moment a bit cumbersome *}
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
    23
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    24
lemma llam_cases:
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    25
  "(\<exists>a. t = lPar a) \<or> (\<exists>n. t = lVar n) \<or> (\<exists>t1 t2. t = lApp t1 t2) \<or> 
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    26
   (\<exists>t1. t = lLam t1)"
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 25867
diff changeset
    27
by (induct t rule: llam.induct)
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    28
   (auto simp add: llam.inject)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    29
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    30
nominal_primrec
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28042
diff changeset
    31
  llam_size :: "llam \<Rightarrow> nat"
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28042
diff changeset
    32
where
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28042
diff changeset
    33
  "llam_size (lPar a) = 1"
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28042
diff changeset
    34
| "llam_size (lVar n) = 1"
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28042
diff changeset
    35
| "llam_size (lApp t1 t2) = 1 + (llam_size t1) + (llam_size t2)"
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 28042
diff changeset
    36
| "llam_size (lLam t) = 1 + (llam_size t)"
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    37
by (rule TrueI)+
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    38
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    39
function  
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    40
  vsub :: "llam \<Rightarrow> nat \<Rightarrow> llam \<Rightarrow> llam"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    41
where
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    42
   vsub_lPar: "vsub (lPar p) x s = lPar p"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    43
 | vsub_lVar: "vsub (lVar n) x s = (if n < x then (lVar n)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    44
                      else (if n = x then s else (lVar (n - 1))))"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    45
 | vsub_lApp: "vsub (lApp t u) x s = (lApp (vsub t x s) (vsub u x s))"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    46
 | vsub_lLam: "vsub (lLam t) x s = (lLam (vsub t (x + 1) s))"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    47
using llam_cases
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    48
apply(auto simp add: llam.inject)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    49
apply(rotate_tac 4)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    50
apply(drule_tac x="a" in meta_spec)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    51
apply(blast)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    52
done
28042
1471f2974eb1 more function -> fun
krauss
parents: 26966
diff changeset
    53
termination by (relation "measure (llam_size \<circ> fst)") auto
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    54
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    55
lemma vsub_eqvt[eqvt]:
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    56
  fixes pi::"name prm" 
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    57
  shows "pi\<bullet>(vsub t n s) = vsub (pi\<bullet>t) (pi\<bullet>n) (pi\<bullet>s)"
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 25867
diff changeset
    58
by (induct t arbitrary: n rule: llam.induct)
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    59
   (simp_all add: perm_nat_def)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    60
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    61
constdefs
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    62
  freshen :: "llam \<Rightarrow> name \<Rightarrow> llam"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    63
  "freshen t p \<equiv> vsub t 0 (lPar p)"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    64
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    65
lemma freshen_eqvt[eqvt]:
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    66
  fixes pi::"name prm" 
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    67
  shows "pi\<bullet>(freshen t p) = freshen (pi\<bullet>t) (pi\<bullet>p)"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    68
by (simp add: vsub_eqvt freshen_def perm_nat_def)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    69
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
    70
text {* types *}
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
    71
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    72
nominal_datatype ty =
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    73
    TVar "nat"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    74
  | TArr "ty" "ty" (infix "\<rightarrow>" 200)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    75
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    76
lemma ty_fresh[simp]:
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    77
  fixes x::"name"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    78
  and   T::"ty"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    79
  shows "x\<sharp>T"
26966
071f40487734 made the naming of the induction principles consistent: weak_induct is
urbanc
parents: 25867
diff changeset
    80
by (induct T rule: ty.induct) 
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    81
   (simp_all add: fresh_nat)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    82
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    83
text {* valid contexts *}
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
    84
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    85
types cxt = "(name\<times>ty) list"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    86
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23467
diff changeset
    87
inductive
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    88
  valid :: "cxt \<Rightarrow> bool"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    89
where
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    90
  v1[intro]: "valid []"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    91
| v2[intro]: "\<lbrakk>valid \<Gamma>;a\<sharp>\<Gamma>\<rbrakk>\<Longrightarrow> valid ((a,T)#\<Gamma>)"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    92
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    93
equivariance valid
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    94
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    95
lemma v2_elim:
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    96
  assumes a: "valid ((a,T)#\<Gamma>)"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    97
  shows   "a\<sharp>\<Gamma> \<and> valid \<Gamma>"
25867
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
    98
using a by (cases) (auto)
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
    99
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   100
text {* "weak" typing relation *}
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   101
23760
aca2c7f80e2f Renamed inductive2 to inductive.
berghofe
parents: 23467
diff changeset
   102
inductive
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   103
  typing :: "cxt\<Rightarrow>llam\<Rightarrow>ty\<Rightarrow>bool" (" _ \<turnstile> _ : _ " [60,60,60] 60)
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   104
where
25867
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   105
  t_lPar[intro]: "\<lbrakk>valid \<Gamma>; (x,T)\<in>set \<Gamma>\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> lPar x : T"
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   106
| t_lApp[intro]: "\<lbrakk>\<Gamma> \<turnstile> t1 : T1\<rightarrow>T2; \<Gamma> \<turnstile> t2 : T1\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> lApp t1 t2 : T2"
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   107
| t_lLam[intro]: "\<lbrakk>x\<sharp>t; (x,T1)#\<Gamma> \<turnstile> freshen t x : T2\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> lLam t : T1\<rightarrow>T2"
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   108
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   109
equivariance typing
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   110
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   111
lemma typing_implies_valid:
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   112
  assumes a: "\<Gamma> \<turnstile> t : T"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   113
  shows "valid \<Gamma>"
25867
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   114
using a by (induct) (auto dest: v2_elim)
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   115
25867
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   116
text {* 
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   117
  we have to explicitly state that nominal_inductive should strengthen 
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   118
  over the variable x (since x is not a binder)
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   119
*}
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   120
nominal_inductive typing
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   121
  avoids t_lLam: x
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   122
  by (auto simp add: fresh_prod dest: v2_elim typing_implies_valid)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   123
  
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   124
text {* strong induction principle for typing *}
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   125
thm typing.strong_induct
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   126
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   127
text {* sub-contexts *}
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   128
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   129
abbreviation
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   130
  "sub_context" :: "cxt \<Rightarrow> cxt \<Rightarrow> bool" ("_ \<subseteq> _" [60,60] 60) 
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   131
where
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   132
  "\<Gamma>1 \<subseteq> \<Gamma>2 \<equiv> \<forall>x T. (x,T)\<in>set \<Gamma>1 \<longrightarrow> (x,T)\<in>set \<Gamma>2"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   133
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   134
lemma weakening_almost_automatic:
24231
85fb973a8207 added type constraints to resolve syntax ambiguities;
wenzelm
parents: 23760
diff changeset
   135
  fixes \<Gamma>1 \<Gamma>2 :: cxt
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   136
  assumes a: "\<Gamma>1 \<turnstile> t : T"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   137
  and     b: "\<Gamma>1 \<subseteq> \<Gamma>2"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   138
  and     c: "valid \<Gamma>2"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   139
shows "\<Gamma>2 \<turnstile> t : T"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   140
using a b c
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   141
apply(nominal_induct \<Gamma>1 t T avoiding: \<Gamma>2 rule: typing.strong_induct)
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   142
apply(auto)
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   143
apply(drule_tac x="(x,T1)#\<Gamma>2" in meta_spec)
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   144
apply(auto intro!: t_lLam)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   145
done
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   146
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   147
lemma weakening_in_more_detail:
24231
85fb973a8207 added type constraints to resolve syntax ambiguities;
wenzelm
parents: 23760
diff changeset
   148
  fixes \<Gamma>1 \<Gamma>2 :: cxt
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   149
  assumes a: "\<Gamma>1 \<turnstile> t : T"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   150
  and     b: "\<Gamma>1 \<subseteq> \<Gamma>2"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   151
  and     c: "valid \<Gamma>2"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   152
shows "\<Gamma>2 \<turnstile> t : T"
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   153
using a b c
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   154
proof(nominal_induct \<Gamma>1 t T avoiding: \<Gamma>2 rule: typing.strong_induct)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   155
  case (t_lPar \<Gamma>1 x T \<Gamma>2)  (* variable case *)
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   156
  have "\<Gamma>1 \<subseteq> \<Gamma>2" by fact 
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   157
  moreover  
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   158
  have "valid \<Gamma>2" by fact 
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   159
  moreover 
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   160
  have "(x,T)\<in> set \<Gamma>1" by fact
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   161
  ultimately show "\<Gamma>2 \<turnstile> lPar x : T" by auto
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   162
next
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   163
  case (t_lLam x t T1 \<Gamma>1 T2 \<Gamma>2) (* lambda case *)
23467
d1b97708d5eb tuned proofs -- avoid implicit prems;
wenzelm
parents: 23315
diff changeset
   164
  have vc: "x\<sharp>\<Gamma>2" "x\<sharp>t" by fact+  (* variable convention *)
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   165
  have ih: "\<lbrakk>(x,T1)#\<Gamma>1 \<subseteq> (x,T1)#\<Gamma>2; valid ((x,T1)#\<Gamma>2)\<rbrakk> \<Longrightarrow> (x,T1)#\<Gamma>2 \<turnstile> freshen t x : T2" by fact
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   166
  have "\<Gamma>1 \<subseteq> \<Gamma>2" by fact
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   167
  then have "(x,T1)#\<Gamma>1 \<subseteq> (x,T1)#\<Gamma>2" by simp
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   168
  moreover
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   169
  have "valid \<Gamma>2" by fact
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   170
  then have "valid ((x,T1)#\<Gamma>2)" using vc by (simp add: v2)
23233
76462538f349 added a few comments to the proofs
urbanc
parents: 23143
diff changeset
   171
  ultimately have "(x,T1)#\<Gamma>2 \<turnstile> freshen t x : T2" using ih by simp
23315
df3a7e9ebadb tuned Proof
chaieb
parents: 23233
diff changeset
   172
  with vc show "\<Gamma>2 \<turnstile> lLam t : T1\<rightarrow>T2" by auto
df3a7e9ebadb tuned Proof
chaieb
parents: 23233
diff changeset
   173
next 
25867
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   174
  case (t_lApp \<Gamma>1 t1 T1 T2 t2 \<Gamma>2)
c24395ea4e71 tuned proofs
urbanc
parents: 24231
diff changeset
   175
  then show "\<Gamma>2 \<turnstile> lApp t1 t2 : T2" by auto
23315
df3a7e9ebadb tuned Proof
chaieb
parents: 23233
diff changeset
   176
qed
23143
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   177
f72bc42882ea a theory using locally nameless terms and strong induction principles
urbanc
parents:
diff changeset
   178
end