src/HOL/Nominal/Examples/SN.thy
author urbanc
Tue, 06 Mar 2007 16:17:52 +0100
changeset 22420 4ccc8c1b08a3
parent 22418 49e2d9744ae1
child 22440 7e4f4f19002f
permissions -rw-r--r--
updated this file to the new infrastructure
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18263
7f75925498da cleaned up all examples so that they work with the
urbanc
parents: 18106
diff changeset
     1
(* $Id$ *)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     2
19496
79dbe35c6cba Capitalized theory names.
berghofe
parents: 19218
diff changeset
     3
theory SN
21107
e69c0e82955a new file for defining functions in the lambda-calculus
urbanc
parents: 19972
diff changeset
     4
imports Lam_Funs
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     5
begin
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     6
18269
3f36e2165e51 some small tuning
urbanc
parents: 18263
diff changeset
     7
text {* Strong Normalisation proof from the Proofs and Types book *}
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     8
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     9
section {* Beta Reduction *}
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    10
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    11
lemma subst_rename: 
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    12
  assumes a: "c\<sharp>t1"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    13
  shows "t1[a::=t2] = ([(c,a)]\<bullet>t1)[c::=t2]"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    14
using a
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    15
by (nominal_induct t1 avoiding: a c t2 rule: lam.induct)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    16
   (auto simp add: calc_atm fresh_atm abs_fresh)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    17
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    18
lemma forget: 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    19
  assumes a: "a\<sharp>t1"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    20
  shows "t1[a::=t2] = t1"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    21
  using a
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    22
by (nominal_induct t1 avoiding: a t2 rule: lam.induct)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    23
   (auto simp add: abs_fresh fresh_atm)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    24
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    25
lemma fresh_fact: 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    26
  fixes a::"name"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    27
  assumes a: "a\<sharp>t1"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    28
  and     b: "a\<sharp>t2"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    29
  shows "a\<sharp>(t1[b::=t2])"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    30
using a b
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    31
by (nominal_induct t1 avoiding: a b t2 rule: lam.induct)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    32
   (auto simp add: abs_fresh fresh_atm)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    33
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
    34
lemma subst_lemma:  
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    35
  assumes a: "x\<noteq>y"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    36
  and     b: "x\<sharp>L"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    37
  shows "M[x::=N][y::=L] = M[y::=L][x::=N[y::=L]]"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    38
using a b
18659
2ff0ae57431d changes to make use of the new induction principle proved by
urbanc
parents: 18654
diff changeset
    39
by (nominal_induct M avoiding: x y N L rule: lam.induct)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    40
   (auto simp add: fresh_fact forget)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    41
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    42
lemma id_subs: 
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    43
  shows "t[x::=Var x] = t"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    44
  by (nominal_induct t avoiding: x rule: lam.induct)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    45
     (simp_all add: fresh_atm)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    46
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    47
lemma subst_eqvt[eqvt]:
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    48
  fixes pi::"name prm" 
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    49
  and   t::"lam"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    50
  shows "pi\<bullet>(t[x::=t']) = (pi\<bullet>t)[(pi\<bullet>x)::=(pi\<bullet>t')]"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    51
by (nominal_induct t avoiding: x t' rule: lam.induct)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    52
   (perm_simp add: fresh_bij)+
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    53
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    54
inductive2 Beta :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta> _" [80,80] 80)
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    55
where
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    56
  b1[intro!]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (App s1 t)\<longrightarrow>\<^isub>\<beta>(App s2 t)"
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    57
| b2[intro!]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (App t s1)\<longrightarrow>\<^isub>\<beta>(App t s2)"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    58
| b3[intro!]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (Lam [a].s1)\<longrightarrow>\<^isub>\<beta> (Lam [(a::name)].s2)"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    59
| b4[intro!]: "(App (Lam [(a::name)].s1) s2)\<longrightarrow>\<^isub>\<beta>(s1[a::=s2])"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    60
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    61
abbreviation "Beta_star"  :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta>\<^sup>* _" [80,80] 80) where
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    62
  "t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t2 \<equiv> Beta\<^sup>*\<^sup>* t1 t2"
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    63
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    64
nominal_inductive Beta
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    65
 
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    66
lemma beta_induct[consumes 1, case_names b1 b2 b3 b4]:
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    67
  fixes  P :: "'a::fs_name\<Rightarrow>lam \<Rightarrow> lam \<Rightarrow>bool"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    68
  and    t :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    69
  and    s :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    70
  and    x :: "'a::fs_name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    71
  assumes a: "t\<longrightarrow>\<^isub>\<beta>s"
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    72
  and a1:    "\<And>t s1 s2 x. s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (\<And>z. P z s1 s2) \<Longrightarrow> P x (App s1 t) (App s2 t)"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    73
  and a2:    "\<And>t s1 s2 x. s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (\<And>z. P z s1 s2) \<Longrightarrow> P x (App t s1) (App t s2)"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    74
  and a3:    "\<And>a s1 s2 x. a\<sharp>x \<Longrightarrow> s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (\<And>z. P z s1 s2) \<Longrightarrow> P x (Lam [a].s1) (Lam [a].s2)"
19218
47b05ebe106b deleted some proofs "on comment"
urbanc
parents: 18659
diff changeset
    75
  and a4:    "\<And>a t1 s1 x. a\<sharp>x \<Longrightarrow> P x (App (Lam [a].t1) s1) (t1[a::=s1])"
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    76
  shows "P x t s"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    77
proof -
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    78
  from a have "\<And>(pi::name prm) x. P x (pi\<bullet>t) (pi\<bullet>s)"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    79
  proof (induct)
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    80
    case b1 thus ?case using a1 by (simp, blast intro: eqvt)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    81
  next
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    82
    case b2 thus ?case using a2 by (simp, blast intro: eqvt)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    83
  next
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    84
    case (b3 s1 s2 a)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    85
    have j1: "s1 \<longrightarrow>\<^isub>\<beta> s2" by fact
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    86
    have j2: "\<And>x (pi::name prm). P x (pi\<bullet>s1) (pi\<bullet>s2)" by fact
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    87
    show ?case 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    88
    proof (simp)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    89
      have f: "\<exists>c::name. c\<sharp>(pi\<bullet>a,pi\<bullet>s1,pi\<bullet>s2,x)"
21377
c29146dc14f1 replaced exists_fresh lemma with a version formulated with obtains;
urbanc
parents: 21107
diff changeset
    90
	by (rule exists_fresh', simp add: fs_name1)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    91
      then obtain c::"name" 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    92
	where f1: "c\<noteq>(pi\<bullet>a)" and f2: "c\<sharp>x" and f3: "c\<sharp>(pi\<bullet>s1)" and f4: "c\<sharp>(pi\<bullet>s2)"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    93
	by (force simp add: fresh_prod fresh_atm)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    94
      have x: "P x (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>s1)) (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>s2))"
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
    95
	using a3 f2 j1 j2 by (simp, blast intro: eqvt)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    96
      have alpha1: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>s1))) = (Lam [(pi\<bullet>a)].(pi\<bullet>s1))" using f1 f3
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    97
	by (simp add: lam.inject alpha)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    98
      have alpha2: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>s2))) = (Lam [(pi\<bullet>a)].(pi\<bullet>s2))" using f1 f3
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
    99
	by (simp add: lam.inject alpha)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   100
      show " P x (Lam [(pi\<bullet>a)].(pi\<bullet>s1)) (Lam [(pi\<bullet>a)].(pi\<bullet>s2))"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   101
	using x alpha1 alpha2 by (simp only: pt_name2)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   102
    qed
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   103
  next
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   104
    case (b4 a s1 s2)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   105
    show ?case
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   106
    proof (simp add: subst_eqvt)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   107
      have f: "\<exists>c::name. c\<sharp>(pi\<bullet>a,pi\<bullet>s1,pi\<bullet>s2,x)"
21377
c29146dc14f1 replaced exists_fresh lemma with a version formulated with obtains;
urbanc
parents: 21107
diff changeset
   108
	by (rule exists_fresh', simp add: fs_name1)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   109
      then obtain c::"name" 
19218
47b05ebe106b deleted some proofs "on comment"
urbanc
parents: 18659
diff changeset
   110
	where f1: "c\<noteq>(pi\<bullet>a)" and f2: "c\<sharp>x" and f3: "c\<sharp>(pi\<bullet>s1)" and f4: "c\<sharp>(pi\<bullet>s2)"
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   111
	by (force simp add: fresh_prod fresh_atm)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   112
      have x: "P x (App (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>s1)) (pi\<bullet>s2)) ((([(c,pi\<bullet>a)]@pi)\<bullet>s1)[c::=(pi\<bullet>s2)])"
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   113
	using a4 f2 by (blast intro!: eqvt)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   114
      have alpha1: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>s1))) = (Lam [(pi\<bullet>a)].(pi\<bullet>s1))" using f1 f3
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   115
	by (simp add: lam.inject alpha)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   116
      have alpha2: "(([(c,pi\<bullet>a)]@pi)\<bullet>s1)[c::=(pi\<bullet>s2)] = (pi\<bullet>s1)[(pi\<bullet>a)::=(pi\<bullet>s2)]"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   117
	using f3 by (simp only: subst_rename[symmetric] pt_name2)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   118
      show "P x (App (Lam [(pi\<bullet>a)].(pi\<bullet>s1)) (pi\<bullet>s2)) ((pi\<bullet>s1)[(pi\<bullet>a)::=(pi\<bullet>s2)])"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   119
	using x alpha1 alpha2 by (simp only: pt_name2)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   120
    qed
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   121
  qed
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   122
  hence "P x (([]::name prm)\<bullet>t) (([]::name prm)\<bullet>s)" by blast 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   123
  thus ?thesis by simp
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   124
qed
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   125
18378
urbanc
parents: 18348
diff changeset
   126
lemma supp_beta: 
urbanc
parents: 18348
diff changeset
   127
  assumes a: "t\<longrightarrow>\<^isub>\<beta> s"
urbanc
parents: 18348
diff changeset
   128
  shows "(supp s)\<subseteq>((supp t)::name set)"
urbanc
parents: 18348
diff changeset
   129
using a
urbanc
parents: 18348
diff changeset
   130
by (induct)
urbanc
parents: 18348
diff changeset
   131
   (auto intro!: simp add: abs_supp lam.supp subst_supp)
urbanc
parents: 18348
diff changeset
   132
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   133
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   134
lemma beta_abs: "Lam [a].t\<longrightarrow>\<^isub>\<beta> t'\<Longrightarrow>\<exists>t''. t'=Lam [a].t'' \<and> t\<longrightarrow>\<^isub>\<beta> t''"
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   135
apply(ind_cases2 "Lam [a].t  \<longrightarrow>\<^isub>\<beta> t'")
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   136
apply(auto simp add: lam.distinct lam.inject)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   137
apply(auto simp add: alpha)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   138
apply(rule_tac x="[(a,aa)]\<bullet>s2" in exI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   139
apply(rule conjI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   140
apply(rule sym)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   141
apply(rule pt_bij2[OF pt_name_inst, OF at_name_inst])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   142
apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   143
apply(rule pt_name3)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   144
apply(simp add: at_ds5[OF at_name_inst])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   145
apply(rule conjI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   146
apply(simp add: pt_fresh_left[OF pt_name_inst, OF at_name_inst] calc_atm)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   147
apply(force dest!: supp_beta simp add: fresh_def)
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   148
apply(force intro!: eqvt)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   149
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   150
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   151
lemma beta_subst: 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   152
  assumes a: "M \<longrightarrow>\<^isub>\<beta> M'"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   153
  shows "M[x::=N]\<longrightarrow>\<^isub>\<beta> M'[x::=N]" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   154
using a
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   155
apply(nominal_induct M M' avoiding: x N rule: beta_induct)
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   156
apply(auto simp add: fresh_atm subst_lemma)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   157
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   158
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   159
section {* types *}
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   160
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   161
nominal_datatype ty =
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   162
    TVar "nat"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   163
  | TArr "ty" "ty" (infix "\<rightarrow>" 200)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   164
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   165
lemma perm_ty[simp]:
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   166
  fixes pi ::"name prm"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   167
  and   \<tau>  ::"ty"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   168
  shows "pi\<bullet>\<tau> = \<tau>"
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   169
by (nominal_induct \<tau> rule: ty.induct) 
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   170
   (simp_all add: perm_nat_def)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   171
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   172
lemma fresh_ty:
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   173
  fixes a ::"name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   174
  and   \<tau>  ::"ty"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   175
  shows "a\<sharp>\<tau>"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   176
  by (simp add: fresh_def supp_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   177
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   178
(* valid contexts *)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   179
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   180
consts
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   181
  "dom_ty" :: "(name\<times>ty) list \<Rightarrow> (name list)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   182
primrec
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   183
  "dom_ty []    = []"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   184
  "dom_ty (x#\<Gamma>) = (fst x)#(dom_ty \<Gamma>)" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   185
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   186
inductive2 valid :: "(name\<times>ty) list \<Rightarrow> bool"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   187
where
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   188
  v1[intro]: "valid []"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   189
| v2[intro]: "\<lbrakk>valid \<Gamma>;a\<sharp>\<Gamma>\<rbrakk>\<Longrightarrow> valid ((a,\<sigma>)#\<Gamma>)"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   190
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   191
nominal_inductive valid
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   192
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   193
(* typing judgements *)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   194
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   195
lemma fresh_context: 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   196
  fixes  \<Gamma> :: "(name\<times>ty)list"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   197
  and    a :: "name"
18378
urbanc
parents: 18348
diff changeset
   198
  assumes a: "a\<sharp>\<Gamma>"
urbanc
parents: 18348
diff changeset
   199
  shows "\<not>(\<exists>\<tau>::ty. (a,\<tau>)\<in>set \<Gamma>)"
urbanc
parents: 18348
diff changeset
   200
using a
urbanc
parents: 18348
diff changeset
   201
apply(induct \<Gamma>)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   202
apply(auto simp add: fresh_prod fresh_list_cons fresh_atm)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   203
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   204
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   205
inductive_cases2 valid_elim[elim]: "valid ((a,\<tau>)#\<Gamma>)"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   206
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   207
lemma valid_unicity: 
18378
urbanc
parents: 18348
diff changeset
   208
  assumes a: "valid \<Gamma>"
urbanc
parents: 18348
diff changeset
   209
  and     b: "(c,\<sigma>)\<in>set \<Gamma>"
urbanc
parents: 18348
diff changeset
   210
  and     c: "(c,\<tau>)\<in>set \<Gamma>"
urbanc
parents: 18348
diff changeset
   211
  shows "\<sigma>=\<tau>" 
urbanc
parents: 18348
diff changeset
   212
using a b c
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   213
by (induct \<Gamma>) (auto dest!: fresh_context)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   214
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   215
inductive2 typing :: "(name\<times>ty) list\<Rightarrow>lam\<Rightarrow>ty\<Rightarrow>bool" (" _ \<turnstile> _ : _ " [80,80,80] 80)
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   216
where
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   217
  t1[intro]: "\<lbrakk>valid \<Gamma>; (a,\<tau>)\<in>set \<Gamma>\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> Var a : \<tau>"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   218
| t2[intro]: "\<lbrakk>\<Gamma> \<turnstile> t1 : \<tau>\<rightarrow>\<sigma>; \<Gamma> \<turnstile> t2 : \<tau>\<rbrakk>\<Longrightarrow> \<Gamma> \<turnstile> App t1 t2 : \<sigma>"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   219
| t3[intro]: "\<lbrakk>a\<sharp>\<Gamma>;((a,\<tau>)#\<Gamma>) \<turnstile> t : \<sigma>\<rbrakk> \<Longrightarrow> \<Gamma> \<turnstile> Lam [a].t : \<tau>\<rightarrow>\<sigma>"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   220
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   221
lemma eqvt_typing: 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   222
  fixes  \<Gamma> :: "(name\<times>ty) list"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   223
  and    t :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   224
  and    \<tau> :: "ty"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   225
  and    pi:: "name prm"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   226
  assumes a: "\<Gamma> \<turnstile> t : \<tau>"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   227
  shows "(pi\<bullet>\<Gamma>) \<turnstile> (pi\<bullet>t) : \<tau>"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   228
using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   229
proof (induct)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   230
  case (t1 \<Gamma> a \<tau>)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   231
  have "valid (pi\<bullet>\<Gamma>)" by (rule valid_eqvt)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   232
  moreover
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   233
  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])
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   234
  ultimately show "(pi\<bullet>\<Gamma>) \<turnstile> ((pi::name prm)\<bullet>Var a) : \<tau>"
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   235
    using typing.t1 by (force simp add: set_eqvt[symmetric])
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   236
next 
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   237
  case (t3 a \<Gamma> \<tau> t \<sigma>)
19972
89c5afe4139a added more infrastructure for the recursion combinator
urbanc
parents: 19687
diff changeset
   238
  moreover have "(pi\<bullet>a)\<sharp>(pi\<bullet>\<Gamma>)" by (simp add: fresh_bij)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   239
  ultimately show "(pi\<bullet>\<Gamma>) \<turnstile> (pi\<bullet>Lam [a].t) :\<tau>\<rightarrow>\<sigma>" by force 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   240
qed (auto)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   241
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   242
lemma typing_induct[consumes 1, case_names t1 t2 t3]:
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   243
  fixes  P :: "'a::fs_name\<Rightarrow>(name\<times>ty) list \<Rightarrow> lam \<Rightarrow> ty \<Rightarrow>bool"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   244
  and    \<Gamma> :: "(name\<times>ty) list"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   245
  and    t :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   246
  and    \<tau> :: "ty"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   247
  and    x :: "'a::fs_name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   248
  assumes a: "\<Gamma> \<turnstile> t : \<tau>"
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   249
  and a1:    "\<And>\<Gamma> (a::name) \<tau> x. valid \<Gamma> \<Longrightarrow> (a,\<tau>) \<in> set \<Gamma> \<Longrightarrow> P x \<Gamma> (Var a) \<tau>"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   250
  and a2:    "\<And>\<Gamma> \<tau> \<sigma> t1 t2 x. 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   251
              \<Gamma> \<turnstile> t1 : \<tau>\<rightarrow>\<sigma> \<Longrightarrow> (\<And>z. P z \<Gamma> t1 (\<tau>\<rightarrow>\<sigma>)) \<Longrightarrow> \<Gamma> \<turnstile> t2 : \<tau> \<Longrightarrow> (\<And>z. P z \<Gamma> t2 \<tau>)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   252
              \<Longrightarrow> P x \<Gamma> (App t1 t2) \<sigma>"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   253
  and a3:    "\<And>a \<Gamma> \<tau> \<sigma> t x. a\<sharp>x \<Longrightarrow> a\<sharp>\<Gamma> \<Longrightarrow> ((a,\<tau>) # \<Gamma>) \<turnstile> t : \<sigma> \<Longrightarrow> (\<And>z. P z ((a,\<tau>)#\<Gamma>) t \<sigma>)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   254
              \<Longrightarrow> P x \<Gamma> (Lam [a].t) (\<tau>\<rightarrow>\<sigma>)"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   255
  shows "P x \<Gamma> t \<tau>"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   256
proof -
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   257
  from a have "\<And>(pi::name prm) x. P x (pi\<bullet>\<Gamma>) (pi\<bullet>t) \<tau>"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   258
  proof (induct)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   259
    case (t1 \<Gamma> a \<tau>)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   260
    have j1: "valid \<Gamma>" by fact
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   261
    have j2: "(a,\<tau>)\<in>set \<Gamma>" by fact
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   262
    from j1 have j3: "valid (pi\<bullet>\<Gamma>)" by (rule valid_eqvt)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   263
    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])  
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   264
    hence j4: "(pi\<bullet>a,\<tau>)\<in>set (pi\<bullet>\<Gamma>)" by (simp add: eqvt)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   265
    show "P x (pi\<bullet>\<Gamma>) (pi\<bullet>(Var a)) \<tau>" using a1 j3 j4 by simp
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   266
  next
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   267
    case (t2 \<Gamma> t1 \<tau> \<sigma> t2)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   268
    thus ?case using a2 by (simp, blast intro: eqvt_typing)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   269
  next
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   270
    case (t3 a \<Gamma> \<tau> t \<sigma>)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   271
    have k1: "a\<sharp>\<Gamma>" by fact
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   272
    have k2: "((a,\<tau>)#\<Gamma>)\<turnstile>t:\<sigma>" by fact
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   273
    have k3: "\<And>(pi::name prm) (x::'a::fs_name). P x (pi \<bullet>((a,\<tau>)#\<Gamma>)) (pi\<bullet>t) \<sigma>" by fact
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   274
    have f: "\<exists>c::name. c\<sharp>(pi\<bullet>a,pi\<bullet>t,pi\<bullet>\<Gamma>,x)"
21377
c29146dc14f1 replaced exists_fresh lemma with a version formulated with obtains;
urbanc
parents: 21107
diff changeset
   275
      by (rule exists_fresh', simp add: fs_name1)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   276
    then obtain c::"name" 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   277
      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>)"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   278
      by (force simp add: fresh_prod at_fresh[OF at_name_inst])
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   279
    from k1 have k1a: "(pi\<bullet>a)\<sharp>(pi\<bullet>\<Gamma>)" 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   280
      by (simp add: pt_fresh_left[OF pt_name_inst, OF at_name_inst] 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   281
                    pt_rev_pi[OF pt_name_inst, OF at_name_inst])
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   282
    have l1: "(([(c,pi\<bullet>a)]@pi)\<bullet>\<Gamma>) = (pi\<bullet>\<Gamma>)" using f4 k1a 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   283
      by (simp only: pt2[OF pt_name_inst], rule pt_fresh_fresh[OF pt_name_inst, OF at_name_inst])
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   284
    have "\<And>x. P x (([(c,pi\<bullet>a)]@pi)\<bullet>((a,\<tau>)#\<Gamma>)) (([(c,pi\<bullet>a)]@pi)\<bullet>t) \<sigma>" using k3 by force
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   285
    hence l2: "\<And>x. P x ((c, \<tau>)#(pi\<bullet>\<Gamma>)) (([(c,pi\<bullet>a)]@pi)\<bullet>t) \<sigma>" using f1 l1
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   286
      by (force simp add: pt2[OF pt_name_inst]  at_calc[OF at_name_inst])
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   287
    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)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   288
    hence l3: "((c, \<tau>)#(pi\<bullet>\<Gamma>)) \<turnstile> (([(c,pi\<bullet>a)]@pi)\<bullet>t) : \<sigma>" using l1 f1 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   289
      by (force simp add: pt2[OF pt_name_inst]  at_calc[OF at_name_inst])
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   290
    have l4: "P x (pi\<bullet>\<Gamma>) (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>t)) (\<tau> \<rightarrow> \<sigma>)" using f2 f4 l2 l3 a3 by auto
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   291
    have alpha: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>t))) = (Lam [(pi\<bullet>a)].(pi\<bullet>t))" using f1 f3
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   292
      by (simp add: lam.inject alpha)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   293
    show "P x (pi\<bullet>\<Gamma>) (pi\<bullet>(Lam [a].t)) (\<tau> \<rightarrow> \<sigma>)" using l4 alpha 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   294
      by (simp only: pt2[OF pt_name_inst], simp)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   295
  qed
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   296
  hence "P x (([]::name prm)\<bullet>\<Gamma>) (([]::name prm)\<bullet>t) \<tau>" by blast
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   297
  thus "P x \<Gamma> t \<tau>" by simp
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   298
qed
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   299
21107
e69c0e82955a new file for defining functions in the lambda-calculus
urbanc
parents: 19972
diff changeset
   300
abbreviation
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21377
diff changeset
   301
  "sub" :: "(name\<times>ty) list \<Rightarrow> (name\<times>ty) list \<Rightarrow> bool" (" _ \<lless> _ " [80,80] 80) where
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   302
  "\<Gamma>1 \<lless> \<Gamma>2 \<equiv> \<forall>a \<sigma>. (a,\<sigma>)\<in>set \<Gamma>1 \<longrightarrow>  (a,\<sigma>)\<in>set \<Gamma>2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   303
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   304
lemma weakening: 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   305
  assumes a: "\<Gamma>1 \<turnstile> t : \<sigma>" 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   306
  and     b: "valid \<Gamma>2" 
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   307
  and     c: "\<Gamma>1 \<lless> \<Gamma>2"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   308
  shows "\<Gamma>2 \<turnstile> t:\<sigma>"
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   309
using a b c
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   310
apply(nominal_induct \<Gamma>1 t \<sigma> avoiding: \<Gamma>2 rule: typing_induct)
21107
e69c0e82955a new file for defining functions in the lambda-calculus
urbanc
parents: 19972
diff changeset
   311
apply(auto | atomize)+
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   312
(* FIXME: before using meta-connectives and the new induction *)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   313
(* method, this was completely automatic *)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   314
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   315
18378
urbanc
parents: 18348
diff changeset
   316
lemma in_ctxt: 
urbanc
parents: 18348
diff changeset
   317
  assumes a: "(a,\<tau>)\<in>set \<Gamma>"
urbanc
parents: 18348
diff changeset
   318
  shows "a\<in>set(dom_ty \<Gamma>)"
urbanc
parents: 18348
diff changeset
   319
using a
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   320
by (induct \<Gamma>) (auto)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   321
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   322
lemma free_vars: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   323
  assumes a: "\<Gamma> \<turnstile> t : \<tau>"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   324
  shows " (supp t)\<subseteq>set(dom_ty \<Gamma>)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   325
using a
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   326
by (nominal_induct \<Gamma> t \<tau> rule: typing_induct)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   327
   (auto simp add: lam.supp abs_supp supp_atm in_ctxt)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   328
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   329
lemma t1_elim: "\<Gamma> \<turnstile> Var a : \<tau> \<Longrightarrow> valid \<Gamma> \<and> (a,\<tau>) \<in> set \<Gamma>"
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   330
apply(ind_cases2 "\<Gamma> \<turnstile> Var a : \<tau>")
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   331
apply(auto simp add: lam.inject lam.distinct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   332
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   333
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   334
lemma t2_elim: "\<Gamma> \<turnstile> App t1 t2 : \<sigma> \<Longrightarrow> \<exists>\<tau>. (\<Gamma> \<turnstile> t1 : \<tau>\<rightarrow>\<sigma> \<and> \<Gamma> \<turnstile> t2 : \<tau>)"
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   335
apply(ind_cases2 "\<Gamma> \<turnstile> App t1 t2 : \<sigma>")
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   336
apply(auto simp add: lam.inject lam.distinct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   337
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   338
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   339
lemma t3_elim: "\<lbrakk>\<Gamma> \<turnstile> Lam [a].t : \<sigma>;a\<sharp>\<Gamma>\<rbrakk>\<Longrightarrow> \<exists>\<tau> \<tau>'. \<sigma>=\<tau>\<rightarrow>\<tau>' \<and> ((a,\<tau>)#\<Gamma>) \<turnstile> t : \<tau>'"
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   340
apply(ind_cases2 "\<Gamma> \<turnstile> Lam [a].t : \<sigma>")
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   341
apply(auto simp add: lam.distinct lam.inject alpha) 
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   342
apply(drule_tac pi="[(a,aa)]::name prm" in eqvt_typing)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   343
apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   344
apply(subgoal_tac "([(a,aa)]::name prm)\<bullet>\<Gamma> = \<Gamma>")(*A*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   345
apply(force simp add: calc_atm)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   346
(*A*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   347
apply(force intro!: pt_fresh_fresh[OF pt_name_inst, OF at_name_inst])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   348
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   349
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   350
lemma typing_valid: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   351
  assumes a: "\<Gamma> \<turnstile> t : \<tau>" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   352
  shows "valid \<Gamma>"
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   353
using a by (induct, auto)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   354
18378
urbanc
parents: 18348
diff changeset
   355
lemma ty_subs:
urbanc
parents: 18348
diff changeset
   356
  assumes a: "((c,\<sigma>)#\<Gamma>) \<turnstile> t1:\<tau>"
urbanc
parents: 18348
diff changeset
   357
  and     b: "\<Gamma>\<turnstile> t2:\<sigma>"
urbanc
parents: 18348
diff changeset
   358
  shows  "\<Gamma> \<turnstile> t1[c::=t2]:\<tau>"
urbanc
parents: 18348
diff changeset
   359
using a b
18659
2ff0ae57431d changes to make use of the new induction principle proved by
urbanc
parents: 18654
diff changeset
   360
proof(nominal_induct t1 avoiding: \<Gamma> \<sigma> \<tau> c t2 rule: lam.induct)
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   361
  case (Var a) 
18378
urbanc
parents: 18348
diff changeset
   362
  have a1: "\<Gamma> \<turnstile>t2:\<sigma>" by fact
urbanc
parents: 18348
diff changeset
   363
  have a2: "((c,\<sigma>)#\<Gamma>) \<turnstile> Var a:\<tau>" by fact
urbanc
parents: 18348
diff changeset
   364
  hence a21: "(a,\<tau>)\<in>set((c,\<sigma>)#\<Gamma>)" and a22: "valid((c,\<sigma>)#\<Gamma>)" by (auto dest: t1_elim)
urbanc
parents: 18348
diff changeset
   365
  from a22 have a23: "valid \<Gamma>" and a24: "c\<sharp>\<Gamma>" by (auto dest: valid_elim) 
urbanc
parents: 18348
diff changeset
   366
  from a24 have a25: "\<not>(\<exists>\<tau>. (c,\<tau>)\<in>set \<Gamma>)" by (rule fresh_context)
urbanc
parents: 18348
diff changeset
   367
  show "\<Gamma>\<turnstile>(Var a)[c::=t2] : \<tau>"
urbanc
parents: 18348
diff changeset
   368
  proof (cases "a=c", simp_all)
urbanc
parents: 18348
diff changeset
   369
    assume case1: "a=c"
urbanc
parents: 18348
diff changeset
   370
    show "\<Gamma> \<turnstile> t2:\<tau>" using a1
urbanc
parents: 18348
diff changeset
   371
    proof (cases "\<sigma>=\<tau>")
urbanc
parents: 18348
diff changeset
   372
      assume "\<sigma>=\<tau>" thus ?thesis using a1 by simp 
urbanc
parents: 18348
diff changeset
   373
    next
urbanc
parents: 18348
diff changeset
   374
      assume a3: "\<sigma>\<noteq>\<tau>"
urbanc
parents: 18348
diff changeset
   375
      show ?thesis
urbanc
parents: 18348
diff changeset
   376
      proof (rule ccontr)
urbanc
parents: 18348
diff changeset
   377
	from a3 a21 have "(a,\<tau>)\<in>set \<Gamma>" by force
urbanc
parents: 18348
diff changeset
   378
	with case1 a25 show False by force 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   379
      qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   380
    qed
18378
urbanc
parents: 18348
diff changeset
   381
  next
urbanc
parents: 18348
diff changeset
   382
    assume case2: "a\<noteq>c"
urbanc
parents: 18348
diff changeset
   383
    with a21 have a26: "(a,\<tau>)\<in>set \<Gamma>" by force 
urbanc
parents: 18348
diff changeset
   384
    from a23 a26 show "\<Gamma> \<turnstile> Var a:\<tau>" by force
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   385
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   386
next
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   387
  case (App s1 s2)
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   388
  have ih_s1: "\<And>c \<sigma> \<tau> t2 \<Gamma>. ((c,\<sigma>)#\<Gamma>) \<turnstile> s1:\<tau> \<Longrightarrow> \<Gamma>\<turnstile> t2: \<sigma> \<Longrightarrow> \<Gamma> \<turnstile> s1[c::=t2]:\<tau>" by fact
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   389
  have ih_s2: "\<And>c \<sigma> \<tau> t2 \<Gamma>. ((c,\<sigma>)#\<Gamma>) \<turnstile> s2:\<tau> \<Longrightarrow> \<Gamma>\<turnstile> t2: \<sigma> \<Longrightarrow> \<Gamma> \<turnstile> s2[c::=t2]:\<tau>" by fact
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   390
  have "((c,\<sigma>)#\<Gamma>)\<turnstile>App s1 s2 : \<tau>" by fact
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   391
  hence "\<exists>\<tau>'. ((c,\<sigma>)#\<Gamma>)\<turnstile>s1:\<tau>'\<rightarrow>\<tau> \<and> ((c,\<sigma>)#\<Gamma>)\<turnstile>s2:\<tau>'" by (rule t2_elim) 
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   392
  then obtain \<tau>' where "((c,\<sigma>)#\<Gamma>)\<turnstile>s1:\<tau>'\<rightarrow>\<tau>" and "((c,\<sigma>)#\<Gamma>)\<turnstile>s2:\<tau>'" by blast
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   393
  moreover
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   394
  have "\<Gamma> \<turnstile>t2:\<sigma>" by fact
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   395
  ultimately show "\<Gamma> \<turnstile>  (App s1 s2)[c::=t2] : \<tau>" using ih_s1 ih_s2 by (simp, blast)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   396
next
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   397
  case (Lam a s)
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   398
  have "a\<sharp>\<Gamma>" "a\<sharp>\<sigma>" "a\<sharp>\<tau>" "a\<sharp>c" "a\<sharp>t2" by fact 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   399
  hence f1: "a\<sharp>\<Gamma>" and f2: "a\<noteq>c" and f2': "c\<sharp>a" and f3: "a\<sharp>t2" and f4: "a\<sharp>((c,\<sigma>)#\<Gamma>)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   400
    by (auto simp add: fresh_atm fresh_prod fresh_list_cons)
18378
urbanc
parents: 18348
diff changeset
   401
  have c1: "((c,\<sigma>)#\<Gamma>)\<turnstile>Lam [a].s : \<tau>" by fact
urbanc
parents: 18348
diff changeset
   402
  hence "\<exists>\<tau>1 \<tau>2. \<tau>=\<tau>1\<rightarrow>\<tau>2 \<and> ((a,\<tau>1)#(c,\<sigma>)#\<Gamma>) \<turnstile> s : \<tau>2" using f4 by (auto dest: t3_elim) 
urbanc
parents: 18348
diff changeset
   403
  then obtain \<tau>1 \<tau>2 where c11: "\<tau>=\<tau>1\<rightarrow>\<tau>2" and c12: "((a,\<tau>1)#(c,\<sigma>)#\<Gamma>) \<turnstile> s : \<tau>2" by force
urbanc
parents: 18348
diff changeset
   404
  from c12 have "valid ((a,\<tau>1)#(c,\<sigma>)#\<Gamma>)" by (rule typing_valid)
urbanc
parents: 18348
diff changeset
   405
  hence ca: "valid \<Gamma>" and cb: "a\<sharp>\<Gamma>" and cc: "c\<sharp>\<Gamma>" 
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   406
    by (auto simp add: fresh_list_cons) 
18378
urbanc
parents: 18348
diff changeset
   407
  from c12 have c14: "((c,\<sigma>)#(a,\<tau>1)#\<Gamma>) \<turnstile> s : \<tau>2"
urbanc
parents: 18348
diff changeset
   408
  proof -
21107
e69c0e82955a new file for defining functions in the lambda-calculus
urbanc
parents: 19972
diff changeset
   409
    have c2: "((a,\<tau>1)#(c,\<sigma>)#\<Gamma>) \<lless> ((c,\<sigma>)#(a,\<tau>1)#\<Gamma>)" by force
18378
urbanc
parents: 18348
diff changeset
   410
    have c3: "valid ((c,\<sigma>)#(a,\<tau>1)#\<Gamma>)"
urbanc
parents: 18348
diff changeset
   411
      by (rule v2, rule v2, auto simp add: fresh_list_cons fresh_prod ca cb cc f2' fresh_ty)
urbanc
parents: 18348
diff changeset
   412
    from c12 c2 c3 show ?thesis by (force intro: weakening)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   413
  qed
18378
urbanc
parents: 18348
diff changeset
   414
  assume c8: "\<Gamma> \<turnstile> t2 : \<sigma>"
urbanc
parents: 18348
diff changeset
   415
  have c81: "((a,\<tau>1)#\<Gamma>)\<turnstile>t2 :\<sigma>"
urbanc
parents: 18348
diff changeset
   416
  proof -
21107
e69c0e82955a new file for defining functions in the lambda-calculus
urbanc
parents: 19972
diff changeset
   417
    have c82: "\<Gamma> \<lless> ((a,\<tau>1)#\<Gamma>)" by force
18378
urbanc
parents: 18348
diff changeset
   418
    have c83: "valid ((a,\<tau>1)#\<Gamma>)" using f1 ca by force
urbanc
parents: 18348
diff changeset
   419
    with c8 c82 c83 show ?thesis by (force intro: weakening)
urbanc
parents: 18348
diff changeset
   420
  qed
urbanc
parents: 18348
diff changeset
   421
  show "\<Gamma> \<turnstile> (Lam [a].s)[c::=t2] : \<tau>"
urbanc
parents: 18348
diff changeset
   422
    using c11 prems c14 c81 f1 by force
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   423
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   424
18378
urbanc
parents: 18348
diff changeset
   425
lemma subject: 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   426
  assumes a: "t1\<longrightarrow>\<^isub>\<beta>t2"
18378
urbanc
parents: 18348
diff changeset
   427
  and     b: "\<Gamma> \<turnstile> t1:\<tau>"
urbanc
parents: 18348
diff changeset
   428
  shows "\<Gamma> \<turnstile> t2:\<tau>"
urbanc
parents: 18348
diff changeset
   429
using a b
urbanc
parents: 18348
diff changeset
   430
proof (nominal_induct t1 t2 avoiding: \<Gamma> \<tau> rule: beta_induct)
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   431
  case (b1 t s1 s2) --"App-case left"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   432
  have ih: "\<And>\<Gamma> \<tau>. \<Gamma> \<turnstile> s1:\<tau> \<Longrightarrow> \<Gamma> \<turnstile> s2 : \<tau>" by fact
18378
urbanc
parents: 18348
diff changeset
   433
  have "\<Gamma> \<turnstile> App s1 t : \<tau>" by fact 
urbanc
parents: 18348
diff changeset
   434
  hence "\<exists>\<sigma>. \<Gamma> \<turnstile> s1 : \<sigma>\<rightarrow>\<tau> \<and> \<Gamma> \<turnstile> t : \<sigma>" by (rule t2_elim)
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   435
  then obtain \<sigma> where "\<Gamma> \<turnstile> s1 : \<sigma>\<rightarrow>\<tau>" and "\<Gamma> \<turnstile> t : \<sigma>" by blast
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   436
  with ih show "\<Gamma> \<turnstile> App s2 t : \<tau>" by blast
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   437
next
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   438
  case (b2 t s1 s2) --"App-case right"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   439
  have ih: "\<And>\<Gamma> \<tau>. \<Gamma> \<turnstile> s1 : \<tau> \<Longrightarrow> \<Gamma> \<turnstile> s2 : \<tau>" by fact 
18378
urbanc
parents: 18348
diff changeset
   440
  have "\<Gamma> \<turnstile> App t s1 : \<tau>" by fact
urbanc
parents: 18348
diff changeset
   441
  hence "\<exists>\<sigma>. \<Gamma> \<turnstile> t : \<sigma>\<rightarrow>\<tau> \<and> \<Gamma> \<turnstile> s1 : \<sigma>" by (rule t2_elim)
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   442
  then obtain \<sigma> where "\<Gamma> \<turnstile> t : \<sigma>\<rightarrow>\<tau>" and "\<Gamma> \<turnstile> s1 : \<sigma>" by blast
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   443
  with ih show "\<Gamma> \<turnstile> App t s2 : \<tau>" by blast
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   444
next
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   445
  case (b3 a s1 s2) --"Lam-case"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   446
  have fr: "a\<sharp>\<Gamma>" "a\<sharp>\<tau>" by fact
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   447
  have ih: "\<And>\<Gamma> \<tau>. \<Gamma> \<turnstile> s1 : \<tau> \<Longrightarrow> \<Gamma> \<turnstile> s2 : \<tau>" by fact
18378
urbanc
parents: 18348
diff changeset
   448
  have "\<Gamma> \<turnstile> Lam [a].s1 : \<tau>" by fact
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   449
  with fr have "\<exists>\<tau>1 \<tau>2. \<tau>=\<tau>1\<rightarrow>\<tau>2 \<and> ((a,\<tau>1)#\<Gamma>) \<turnstile> s1 : \<tau>2" by (simp add: t3_elim)
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   450
  then obtain \<tau>1 \<tau>2 where "\<tau>=\<tau>1\<rightarrow>\<tau>2" and "((a,\<tau>1)#\<Gamma>) \<turnstile> s1 : \<tau>2" by blast
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   451
  with ih show "\<Gamma> \<turnstile> Lam [a].s2 : \<tau>" using fr by blast
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   452
next
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   453
  case (b4 a s1 s2) --"Beta-redex"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   454
  have fr: "a\<sharp>\<Gamma>" by fact
18378
urbanc
parents: 18348
diff changeset
   455
  have "\<Gamma> \<turnstile> App (Lam [a].s1) s2 : \<tau>" by fact
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   456
  hence "\<exists>\<sigma>. (\<Gamma> \<turnstile> (Lam [a].s1) : \<sigma>\<rightarrow>\<tau> \<and> \<Gamma> \<turnstile> s2 : \<sigma>)" by (simp add: t2_elim)
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   457
  then obtain \<sigma> where a1: "\<Gamma> \<turnstile> (Lam [a].s1) : \<sigma>\<rightarrow>\<tau>" and a2: "\<Gamma> \<turnstile> s2 : \<sigma>" by blast
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   458
  from a1 have "((a,\<sigma>)#\<Gamma>) \<turnstile> s1 : \<tau>" using fr by (auto dest!: t3_elim simp add: ty.inject) 
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   459
  with a2 show "\<Gamma> \<turnstile> s1[a::=s2] : \<tau>" by (simp add: ty_subs)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   460
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   461
18378
urbanc
parents: 18348
diff changeset
   462
lemma subject_automatic: 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   463
  assumes a: "t1\<longrightarrow>\<^isub>\<beta>t2"
18378
urbanc
parents: 18348
diff changeset
   464
  and     b: "\<Gamma> \<turnstile> t1:\<tau>"
urbanc
parents: 18348
diff changeset
   465
  shows "\<Gamma> \<turnstile> t2:\<tau>"
urbanc
parents: 18348
diff changeset
   466
using a b
18313
e61d2424863d initial cleanup to use the new induction method
urbanc
parents: 18269
diff changeset
   467
apply(nominal_induct t1 t2 avoiding: \<Gamma> \<tau> rule: beta_induct)
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   468
apply(auto dest!: t2_elim t3_elim intro: ty_subs simp add: ty.inject)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   469
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   470
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   471
subsection {* some facts about beta *}
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   472
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   473
constdefs
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   474
  "NORMAL" :: "lam \<Rightarrow> bool"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   475
  "NORMAL t \<equiv> \<not>(\<exists>t'. t\<longrightarrow>\<^isub>\<beta> t')"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   476
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   477
lemma NORMAL_Var:
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   478
  shows "NORMAL (Var a)"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   479
proof -
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   480
  { assume "\<exists>t'. (Var a) \<longrightarrow>\<^isub>\<beta> t'"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   481
    then obtain t' where "(Var a) \<longrightarrow>\<^isub>\<beta> t'" by blast
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   482
    hence False by (cases, auto) 
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   483
  }
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   484
  thus "NORMAL (Var a)" by (force simp add: NORMAL_def)
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   485
qed
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   486
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   487
constdefs
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   488
  "SN" :: "lam \<Rightarrow> bool"
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   489
  "SN t \<equiv> termi Beta t"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   490
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   491
lemma SN_preserved: "\<lbrakk>SN(t1);t1\<longrightarrow>\<^isub>\<beta> t2\<rbrakk>\<Longrightarrow>SN(t2)"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   492
apply(simp add: SN_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   493
apply(drule_tac a="t2" in acc_downward)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   494
apply(auto)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   495
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   496
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   497
lemma SN_intro: "(\<forall>t2. t1\<longrightarrow>\<^isub>\<beta>t2 \<longrightarrow> SN(t2))\<Longrightarrow>SN(t1)"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   498
apply(simp add: SN_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   499
apply(rule accI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   500
apply(auto)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   501
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   502
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   503
section {* Candidates *}
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   504
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   505
lemma ty_cases:
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   506
  fixes x::ty
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   507
  shows "(\<exists>X. x= TVar X) \<or> (\<exists>T1 T2. x=T1\<rightarrow>T2)"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   508
by (induct x rule: ty.induct_weak) (auto)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   509
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   510
function
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   511
  RED :: "ty \<Rightarrow> lam set"
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   512
where
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   513
  "RED (TVar X) = {t. SN(t)}"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   514
| "RED (\<tau>\<rightarrow>\<sigma>) =   {t. \<forall>u. (u\<in>RED \<tau> \<longrightarrow> (App t u)\<in>RED \<sigma>)}"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   515
apply(auto simp add: ty.inject)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   516
apply(subgoal_tac "(\<exists>X. x= TVar X) \<or> (\<exists>T1 T2. x=T1\<rightarrow>T2)")
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   517
apply(blast)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   518
apply(rule ty_cases)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   519
done
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   520
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   521
instance ty :: size ..
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   522
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   523
nominal_primrec
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   524
  "size (TVar X) = 1"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   525
  "size (T\<^isub>1\<rightarrow>T\<^isub>2) = size T\<^isub>1 + size T\<^isub>2"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   526
by (rule TrueI)+
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   527
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   528
lemma ty_size_greater_zero[simp]:
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   529
  fixes T::"ty"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   530
  shows "size T > 0"
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   531
by (nominal_induct T rule: ty.induct) (simp_all)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   532
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   533
termination
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   534
apply(relation "measure size") 
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   535
apply(auto)
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   536
done
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   537
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   538
constdefs
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   539
  NEUT :: "lam \<Rightarrow> bool"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   540
  "NEUT t \<equiv> (\<exists>a. t=Var a)\<or>(\<exists>t1 t2. t=App t1 t2)" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   541
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   542
(* a slight hack to get the first element of applications *)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   543
inductive2 FST :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<guillemotright> _" [80,80] 80)
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   544
where
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   545
  fst[intro!]:  "(App t s) \<guillemotright> t"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   546
18378
urbanc
parents: 18348
diff changeset
   547
lemma fst_elim[elim!]: 
urbanc
parents: 18348
diff changeset
   548
  shows "(App t s) \<guillemotright> t' \<Longrightarrow> t=t'"
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   549
apply(ind_cases2 "App t s \<guillemotright> t'")
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   550
apply(simp add: lam.inject)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   551
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   552
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   553
lemma qq3: "SN(App t s)\<Longrightarrow>SN(t)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   554
apply(simp add: SN_def)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   555
apply(subgoal_tac "\<forall>z. (App t s \<guillemotright> z) \<longrightarrow> termi Beta z")(*A*)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   556
apply(force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   557
(*A*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   558
apply(erule acc_induct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   559
apply(clarify)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   560
apply(ind_cases2 "x \<guillemotright> z" for x z)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   561
apply(clarify)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   562
apply(rule accI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   563
apply(auto intro: b1)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   564
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   565
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   566
section {* Candidates *}
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   567
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   568
constdefs
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   569
  "CR1" :: "ty \<Rightarrow> bool"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   570
  "CR1 \<tau> \<equiv> \<forall> t. (t\<in>RED \<tau> \<longrightarrow> SN(t))"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   571
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   572
  "CR2" :: "ty \<Rightarrow> bool"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   573
  "CR2 \<tau> \<equiv> \<forall>t t'. (t\<in>RED \<tau> \<and> t \<longrightarrow>\<^isub>\<beta> t') \<longrightarrow> t'\<in>RED \<tau>"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   574
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   575
  "CR3_RED" :: "lam \<Rightarrow> ty \<Rightarrow> bool"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   576
  "CR3_RED t \<tau> \<equiv> \<forall>t'. t\<longrightarrow>\<^isub>\<beta> t' \<longrightarrow>  t'\<in>RED \<tau>" 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   577
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   578
  "CR3" :: "ty \<Rightarrow> bool"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   579
  "CR3 \<tau> \<equiv> \<forall>t. (NEUT t \<and> CR3_RED t \<tau>) \<longrightarrow> t\<in>RED \<tau>"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   580
   
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   581
  "CR4" :: "ty \<Rightarrow> bool"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   582
  "CR4 \<tau> \<equiv> \<forall>t. (NEUT t \<and> NORMAL t) \<longrightarrow>t\<in>RED \<tau>"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   583
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   584
lemma CR3_CR4: "CR3 \<tau> \<Longrightarrow> CR4 \<tau>"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   585
apply(simp (no_asm_use) add: CR3_def CR3_RED_def CR4_def NORMAL_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   586
apply(blast)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   587
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   588
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   589
lemma sub_ind: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   590
  "SN(u)\<Longrightarrow>(u\<in>RED \<tau>\<longrightarrow>(\<forall>t. (NEUT t\<and>CR2 \<tau>\<and>CR3 \<sigma>\<and>CR3_RED t (\<tau>\<rightarrow>\<sigma>))\<longrightarrow>(App t u)\<in>RED \<sigma>))"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   591
apply(simp add: SN_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   592
apply(erule acc_induct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   593
apply(auto)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   594
apply(simp add: CR3_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   595
apply(rotate_tac 5)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   596
apply(drule_tac x="App t x" in spec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   597
apply(drule mp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   598
apply(rule conjI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   599
apply(force simp only: NEUT_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   600
apply(simp (no_asm) add: CR3_RED_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   601
apply(clarify)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   602
apply(ind_cases2 "App t x \<longrightarrow>\<^isub>\<beta> t'" for x t t')
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   603
apply(simp_all add: lam.inject)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   604
apply(simp only:  CR3_RED_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   605
apply(drule_tac x="s2" in spec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   606
apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   607
apply(drule_tac x="s2" in spec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   608
apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   609
apply(drule mp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   610
apply(simp (no_asm_use) add: CR2_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   611
apply(blast)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   612
apply(drule_tac x="ta" in spec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   613
apply(force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   614
apply(auto simp only: NEUT_def lam.inject lam.distinct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   615
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   616
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   617
lemma RED_props: 
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   618
  shows "CR1 \<tau>" and "CR2 \<tau>" and "CR3 \<tau>"
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   619
proof (nominal_induct \<tau> rule: ty.induct)
18611
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   620
  case (TVar a)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   621
  { case 1 show "CR1 (TVar a)" by (simp add: CR1_def)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   622
  next
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   623
    case 2 show "CR2 (TVar a)" by (force intro: SN_preserved simp add: CR2_def)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   624
  next
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   625
    case 3 show "CR3 (TVar a)" by (force intro: SN_intro simp add: CR3_def CR3_RED_def)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   626
  }
18599
e01112713fdc changed PRO_RED proof to conform with the new induction rules
urbanc
parents: 18383
diff changeset
   627
next
18611
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   628
  case (TArr \<tau>1 \<tau>2)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   629
  { case 1
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   630
    have ih_CR3_\<tau>1: "CR3 \<tau>1" by fact
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   631
    have ih_CR1_\<tau>2: "CR1 \<tau>2" by fact
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   632
    show "CR1 (\<tau>1 \<rightarrow> \<tau>2)"
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   633
    proof (simp add: CR1_def, intro strip)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   634
      fix t
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   635
      assume a: "\<forall>u. u \<in> RED \<tau>1 \<longrightarrow> App t u \<in> RED \<tau>2"
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   636
      from ih_CR3_\<tau>1 have "CR4 \<tau>1" by (simp add: CR3_CR4) 
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   637
      moreover
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   638
      have "NEUT (Var a)" by (force simp add: NEUT_def)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   639
      moreover
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   640
      have "NORMAL (Var a)" by (rule NORMAL_Var)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   641
      ultimately have "(Var a)\<in> RED \<tau>1" by (simp add: CR4_def)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   642
      with a have "App t (Var a) \<in> RED \<tau>2" by simp
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   643
      hence "SN (App t (Var a))" using ih_CR1_\<tau>2 by (simp add: CR1_def)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   644
      thus "SN(t)" by (rule qq3)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   645
    qed
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   646
  next
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   647
    case 2
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   648
    have ih_CR1_\<tau>1: "CR1 \<tau>1" by fact
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   649
    have ih_CR2_\<tau>2: "CR2 \<tau>2" by fact
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   650
    show "CR2 (\<tau>1 \<rightarrow> \<tau>2)"
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   651
    proof (simp add: CR2_def, intro strip)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   652
      fix t1 t2 u
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   653
      assume "(\<forall>u. u \<in> RED \<tau>1 \<longrightarrow> App t1 u \<in> RED \<tau>2) \<and>  t1 \<longrightarrow>\<^isub>\<beta> t2" 
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   654
	and  "u \<in> RED \<tau>1"
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   655
      hence "t1 \<longrightarrow>\<^isub>\<beta> t2" and "App t1 u \<in> RED \<tau>2" by simp_all
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   656
      thus "App t2 u \<in> RED \<tau>2" using ih_CR2_\<tau>2 by (force simp add: CR2_def)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   657
    qed
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   658
  next
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   659
    case 3
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   660
    have ih_CR1_\<tau>1: "CR1 \<tau>1" by fact
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   661
    have ih_CR2_\<tau>1: "CR2 \<tau>1" by fact
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   662
    have ih_CR3_\<tau>2: "CR3 \<tau>2" by fact
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   663
    show "CR3 (\<tau>1 \<rightarrow> \<tau>2)"
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   664
    proof (simp add: CR3_def, intro strip)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   665
      fix t u
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   666
      assume a1: "u \<in> RED \<tau>1"
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   667
      assume a2: "NEUT t \<and> CR3_RED t (\<tau>1 \<rightarrow> \<tau>2)"
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   668
      from a1 have "SN(u)" using ih_CR1_\<tau>1 by (simp add: CR1_def)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   669
      hence "u\<in>RED \<tau>1\<longrightarrow>(\<forall>t. (NEUT t\<and>CR2 \<tau>1\<and>CR3 \<tau>2\<and>CR3_RED t (\<tau>1\<rightarrow>\<tau>2))\<longrightarrow>(App t u)\<in>RED \<tau>2)" 
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   670
	by (rule sub_ind)
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   671
      with a1 a2 show "(App t u)\<in>RED \<tau>2" using ih_CR2_\<tau>1 ih_CR3_\<tau>2 by simp
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   672
    qed
687c9bffbca1 another change for the new induct-method
urbanc
parents: 18599
diff changeset
   673
  }
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   674
qed
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   675
    
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   676
lemma double_acc_aux:
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   677
  assumes a_acc: "acc r a"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   678
  and b_acc: "acc r b"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   679
  and hyp: "\<And>x z.
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   680
    (\<And>y. r y x \<Longrightarrow> acc r y) \<Longrightarrow>
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   681
    (\<And>y. r y x \<Longrightarrow> P y z) \<Longrightarrow>
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   682
    (\<And>u. r u z \<Longrightarrow> acc r u) \<Longrightarrow>
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   683
    (\<And>u. r u z \<Longrightarrow> P x u) \<Longrightarrow> P x z"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   684
  shows "P a b"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   685
proof -
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   686
  from a_acc
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   687
  have r: "\<And>b. acc r b \<Longrightarrow> P a b"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   688
  proof (induct a rule: acc.induct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   689
    case (accI x)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   690
    note accI' = accI
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   691
    have "acc r b" .
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   692
    thus ?case
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   693
    proof (induct b rule: acc.induct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   694
      case (accI y)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   695
      show ?case
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   696
	apply (rule hyp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   697
	apply (erule accI')
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   698
	apply (erule accI')
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   699
	apply (rule acc.accI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   700
	apply (erule accI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   701
	apply (erule accI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   702
	apply (erule accI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   703
	done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   704
    qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   705
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   706
  from b_acc show ?thesis by (rule r)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   707
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   708
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   709
lemma double_acc:
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   710
  "\<lbrakk>acc r a; acc r b; \<forall>x z. ((\<forall>y. r y x \<longrightarrow> P y z) \<and> (\<forall>u. r u z \<longrightarrow> P x u)) \<longrightarrow> P x z\<rbrakk> \<Longrightarrow> P a b"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   711
apply(rule_tac r="r" in double_acc_aux)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   712
apply(assumption)+
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   713
apply(blast)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   714
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   715
18263
7f75925498da cleaned up all examples so that they work with the
urbanc
parents: 18106
diff changeset
   716
lemma abs_RED: "(\<forall>s\<in>RED \<tau>. t[x::=s]\<in>RED \<sigma>)\<longrightarrow>Lam [x].t\<in>RED (\<tau>\<rightarrow>\<sigma>)"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   717
apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   718
apply(clarify)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   719
apply(subgoal_tac "termi Beta t")(*1*)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   720
apply(erule rev_mp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   721
apply(subgoal_tac "u \<in> RED \<tau>")(*A*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   722
apply(erule rev_mp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   723
apply(rule_tac a="t" and b="u" in double_acc)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   724
apply(assumption)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   725
apply(subgoal_tac "CR1 \<tau>")(*A*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   726
apply(simp add: CR1_def SN_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   727
(*A*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   728
apply(force simp add: RED_props)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   729
apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   730
apply(clarify)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   731
apply(subgoal_tac "CR3 \<sigma>")(*B*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   732
apply(simp add: CR3_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   733
apply(rotate_tac 6)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   734
apply(drule_tac x="App(Lam[x].xa ) z" in spec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   735
apply(drule mp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   736
apply(rule conjI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   737
apply(force simp add: NEUT_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   738
apply(simp add: CR3_RED_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   739
apply(clarify)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   740
apply(ind_cases2 "App(Lam[x].xa) z \<longrightarrow>\<^isub>\<beta> t'" for xa z t')
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   741
apply(auto simp add: lam.inject lam.distinct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   742
apply(drule beta_abs)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   743
apply(auto)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   744
apply(drule_tac x="t''" in spec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   745
apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   746
apply(drule mp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   747
apply(clarify)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   748
apply(drule_tac x="s" in bspec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   749
apply(assumption)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   750
apply(subgoal_tac "xa [ x ::= s ] \<longrightarrow>\<^isub>\<beta>  t'' [ x ::= s ]")(*B*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   751
apply(subgoal_tac "CR2 \<sigma>")(*C*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   752
apply(simp (no_asm_use) add: CR2_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   753
apply(blast)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   754
(*C*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   755
apply(force simp add: RED_props)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   756
(*B*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   757
apply(force intro!: beta_subst)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   758
apply(assumption)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   759
apply(rotate_tac 3)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   760
apply(drule_tac x="s2" in spec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   761
apply(subgoal_tac "s2\<in>RED \<tau>")(*D*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   762
apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   763
(*D*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   764
apply(subgoal_tac "CR2 \<tau>")(*E*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   765
apply(simp (no_asm_use) add: CR2_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   766
apply(blast)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   767
(*E*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   768
apply(force simp add: RED_props)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   769
apply(simp add: alpha)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   770
apply(erule disjE)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   771
apply(force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   772
apply(auto)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   773
apply(simp add: subst_rename)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   774
apply(drule_tac x="z" in bspec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   775
apply(assumption)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   776
(*B*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   777
apply(force simp add: RED_props)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   778
(*1*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   779
apply(drule_tac x="Var x" in bspec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   780
apply(subgoal_tac "CR3 \<tau>")(*2*) 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   781
apply(drule CR3_CR4)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   782
apply(simp add: CR4_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   783
apply(drule_tac x="Var x" in spec)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   784
apply(drule mp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   785
apply(rule conjI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   786
apply(force simp add: NEUT_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   787
apply(simp add: NORMAL_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   788
apply(clarify)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
   789
apply(ind_cases2 "Var x \<longrightarrow>\<^isub>\<beta> t'" for t')
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   790
apply(auto simp add: lam.inject lam.distinct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   791
apply(force simp add: RED_props)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   792
apply(simp add: id_subs)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   793
apply(subgoal_tac "CR1 \<sigma>")(*3*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   794
apply(simp add: CR1_def SN_def)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   795
(*3*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   796
apply(force simp add: RED_props)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   797
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   798
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   799
lemma psubst_subst:
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   800
  assumes h:"c\<sharp>\<theta>"
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   801
  shows "(\<theta><t>)[c::=s] = ((c,s)#\<theta>)<t>"
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   802
  using h
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   803
by (nominal_induct t avoiding: \<theta> c s rule: lam.induct)
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   804
   (auto simp add: fresh_list_cons fresh_atm forget lookup_fresh lookup_fresh')
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   805
 
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   806
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   807
abbreviation 
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   808
 mapsto :: "(name\<times>lam) list \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> bool" ("_ maps _ to _" [55,55,55] 55) 
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   809
where
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   810
 "\<theta> maps x to e\<equiv> (lookup \<theta> x) = e"
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   811
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   812
abbreviation 
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   813
  closes :: "(name\<times>lam) list \<Rightarrow> (name\<times>ty) list \<Rightarrow> bool" ("_ closes _" [55,55] 55) 
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   814
where
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   815
  "\<theta> closes \<Gamma> \<equiv> \<forall>x T. ((x,T) \<in> set \<Gamma> \<longrightarrow> (\<exists>t. \<theta> maps x to t \<and> t \<in> RED T))"
21107
e69c0e82955a new file for defining functions in the lambda-calculus
urbanc
parents: 19972
diff changeset
   816
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   817
lemma all_RED: 
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   818
  assumes a: "\<Gamma> \<turnstile> t : \<tau>"
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   819
  and     b: "\<theta> closes \<Gamma>"
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   820
  shows "\<theta><t> \<in> RED \<tau>"
18345
d37fb71754fe added an Isar-proof for the abs_ALL lemma
urbanc
parents: 18313
diff changeset
   821
using a b
18659
2ff0ae57431d changes to make use of the new induction principle proved by
urbanc
parents: 18654
diff changeset
   822
proof(nominal_induct t avoiding: \<Gamma> \<tau> \<theta> rule: lam.induct)
18345
d37fb71754fe added an Isar-proof for the abs_ALL lemma
urbanc
parents: 18313
diff changeset
   823
  case (Lam a t) --"lambda case"
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   824
  have ih: "\<And>\<Gamma> \<tau> \<theta>. \<Gamma> \<turnstile> t : \<tau> \<Longrightarrow> \<theta> closes \<Gamma> \<Longrightarrow> \<theta><t> \<in> RED \<tau>" 
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   825
  and  \<theta>_cond: "\<theta> closes \<Gamma>" 
18345
d37fb71754fe added an Isar-proof for the abs_ALL lemma
urbanc
parents: 18313
diff changeset
   826
  and fresh: "a\<sharp>\<Gamma>" "a\<sharp>\<theta>" 
d37fb71754fe added an Isar-proof for the abs_ALL lemma
urbanc
parents: 18313
diff changeset
   827
  and "\<Gamma> \<turnstile> Lam [a].t:\<tau>" by fact
d37fb71754fe added an Isar-proof for the abs_ALL lemma
urbanc
parents: 18313
diff changeset
   828
  hence "\<exists>\<tau>1 \<tau>2. \<tau>=\<tau>1\<rightarrow>\<tau>2 \<and> ((a,\<tau>1)#\<Gamma>)\<turnstile>t:\<tau>2" using t3_elim fresh by simp
d37fb71754fe added an Isar-proof for the abs_ALL lemma
urbanc
parents: 18313
diff changeset
   829
  then obtain \<tau>1 \<tau>2 where \<tau>_inst: "\<tau>=\<tau>1\<rightarrow>\<tau>2" and typing: "((a,\<tau>1)#\<Gamma>)\<turnstile>t:\<tau>2" by blast
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   830
  from ih have "\<forall>s\<in>RED \<tau>1. \<theta><t>[a::=s] \<in> RED \<tau>2" using fresh typing \<theta>_cond
18345
d37fb71754fe added an Isar-proof for the abs_ALL lemma
urbanc
parents: 18313
diff changeset
   831
    by (force dest: fresh_context simp add: psubst_subst)
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   832
  hence "(Lam [a].(\<theta><t>)) \<in> RED (\<tau>1 \<rightarrow> \<tau>2)" by (simp only: abs_RED)
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   833
  thus "\<theta><(Lam [a].t)> \<in> RED \<tau>" using fresh \<tau>_inst by simp
18345
d37fb71754fe added an Isar-proof for the abs_ALL lemma
urbanc
parents: 18313
diff changeset
   834
qed (force dest!: t1_elim t2_elim)+
d37fb71754fe added an Isar-proof for the abs_ALL lemma
urbanc
parents: 18313
diff changeset
   835
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   836
(* identity substitution generated from a context \<Gamma> *)
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   837
consts
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   838
  "id" :: "(name\<times>ty) list \<Rightarrow> (name\<times>lam) list"
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   839
primrec
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   840
  "id []    = []"
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   841
  "id (x#\<Gamma>) = ((fst x),Var (fst x))#(id \<Gamma>)"
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   842
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   843
lemma id_var:
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   844
  shows "(id \<Gamma>) maps a to Var a"
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   845
apply(induct \<Gamma>, auto)
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   846
done
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   847
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   848
lemma id_fresh:
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   849
  fixes a::"name"
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   850
  assumes a: "a\<sharp>\<Gamma>"
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   851
  shows "a\<sharp>(id \<Gamma>)"
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   852
using a
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   853
apply(induct \<Gamma>)
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   854
apply(auto simp add: fresh_list_nil fresh_list_cons fresh_prod)
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   855
done
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   856
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   857
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   858
lemma id_apply:  
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   859
  shows "(id \<Gamma>)<t> = t"
18659
2ff0ae57431d changes to make use of the new induction principle proved by
urbanc
parents: 18654
diff changeset
   860
apply(nominal_induct t avoiding: \<Gamma> rule: lam.induct)
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   861
apply(auto)
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   862
apply(rule id_var)
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   863
apply(drule id_fresh)+
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   864
apply(simp)
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   865
done
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   866
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   867
lemma id_mem:
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   868
  assumes a: "(a,\<tau>)\<in>set \<Gamma>"
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   869
  shows "lookup (id \<Gamma>) a = Var a"
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   870
using a
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   871
apply(induct \<Gamma>, auto)
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   872
done
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   873
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   874
lemma id_prop:
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   875
  shows "(id \<Gamma>) closes \<Gamma>"
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   876
apply(auto)
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   877
apply(simp add: id_mem)
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   878
apply(subgoal_tac "CR3 T") --"A"
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   879
apply(drule CR3_CR4)
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   880
apply(simp add: CR4_def)
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   881
apply(drule_tac x="Var x" in spec)
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   882
apply(force simp add: NEUT_def NORMAL_Var)
22418
49e2d9744ae1 major update of the nominal package; there is now an infrastructure
urbanc
parents: 22271
diff changeset
   883
--"A"
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   884
apply(rule RED_props)
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   885
done
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   886
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   887
lemma typing_implies_RED:  
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   888
  assumes a: "\<Gamma>\<turnstile>t:\<tau>"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   889
  shows "t \<in> RED \<tau>"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   890
proof -
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   891
  have "(id \<Gamma>)<t>\<in>RED \<tau>" 
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   892
  proof -
22420
4ccc8c1b08a3 updated this file to the new infrastructure
urbanc
parents: 22418
diff changeset
   893
    have "(id \<Gamma>) closes \<Gamma>" by (rule id_prop)
18383
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   894
    with a show ?thesis by (rule all_RED)
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   895
  qed
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   896
  thus"t \<in> RED \<tau>" by (simp add: id_apply)
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   897
qed
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   898
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   899
lemma typing_implies_SN: 
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   900
  assumes a: "\<Gamma>\<turnstile>t:\<tau>"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   901
  shows "SN(t)"
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   902
proof -
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   903
  from a have "t \<in> RED \<tau>" by (rule typing_implies_RED)
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   904
  moreover
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   905
  have "CR1 \<tau>" by (rule RED_props)
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   906
  ultimately show "SN(t)" by (simp add: CR1_def)
5f40a59a798b ISAR-fied some proofs
urbanc
parents: 18382
diff changeset
   907
qed
18382
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   908
44578c918349 completed the sn proof and changed the manual
urbanc
parents: 18378
diff changeset
   909
end