src/HOL/Nominal/Examples/CR.thy
author urbanc
Wed, 30 Nov 2005 17:56:08 +0100
changeset 18303 b18fabea0fd0
parent 18269 3f36e2165e51
child 18312 c68296902ddb
permissions -rw-r--r--
modified almost everything for the new nominal_induct (at the end there are some "normal" inductions which need a bit more attention)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18269
3f36e2165e51 some small tuning
urbanc
parents: 18106
diff changeset
     1
(* $Id$ *)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     2
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     3
theory cr
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     4
imports lam_substs
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     5
begin
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     6
18269
3f36e2165e51 some small tuning
urbanc
parents: 18106
diff changeset
     7
text {* The Church-Rosser proof from Barendregt's book *}
3f36e2165e51 some small tuning
urbanc
parents: 18106
diff changeset
     8
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
     9
lemma forget[rule_format]: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    10
  shows "a\<sharp>t1 \<longrightarrow> t1[a::=t2] = t1"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    11
proof (nominal_induct t1 fresh: a t2 rule: lam_induct)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    12
  case (Var a t2 b) 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    13
  show ?case by (simp, simp add: fresh_atm)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    14
next 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    15
  case App
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    16
  thus ?case by (simp add: fresh_prod)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    17
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    18
  case (Lam c t a t2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    19
  have i: "\<And>c t2. c\<sharp>t \<longrightarrow>  t[c::=t2] = t" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    20
  have a: "c\<sharp>t2" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    21
  have "c\<sharp>a" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    22
  hence b: "a\<noteq>c" by (simp add: fresh_atm)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    23
  show ?case
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    24
  proof 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    25
    assume "a\<sharp>Lam [c].t" 
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    26
    hence "a\<sharp>t" using b by (simp add: abs_fresh)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    27
    hence "t[a::=t2] = t" using i by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    28
    thus "(Lam [c].t)[a::=t2] = Lam [c].t" using a b by (simp add: alpha)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    29
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    30
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    31
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    32
lemma forget[rule_format]: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    33
  shows "a\<sharp>t1 \<longrightarrow> t1[a::=t2] = t1"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    34
apply (nominal_induct t1 fresh: a t2 rule: lam_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    35
apply(auto simp add: abs_fresh fresh_atm)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    36
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    37
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    38
lemma fresh_fact[rule_format]: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    39
  fixes   b :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    40
  and    a  :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    41
  and    t1 :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    42
  and    t2 :: "lam" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    43
  shows "a\<sharp>t1\<longrightarrow>a\<sharp>t2\<longrightarrow>a\<sharp>(t1[b::=t2])"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    44
proof (nominal_induct t1 fresh: a b t2 rule: lam_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    45
  case (Var c a b t2) 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    46
  show ?case by simp
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    47
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    48
  case App thus ?case by simp 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    49
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    50
  case (Lam c t a b t2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    51
  have  i: "\<And>(a::name) b t2. a\<sharp>t\<longrightarrow>a\<sharp>t2\<longrightarrow>a\<sharp>(t[b::=t2])" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    52
  have fr: "c\<sharp>a" "c\<sharp>b" "c\<sharp>t2" by fact+
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    53
  hence fr': "c\<noteq>a" by (simp add: fresh_atm) 
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    54
  show ?case 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    55
  proof (intro strip)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    56
    assume a1: "a\<sharp>t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    57
    assume a2: "a\<sharp>Lam [c].t"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    58
    hence "a\<sharp>t" using fr' by (simp add: abs_fresh)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    59
    hence "a\<sharp>t[b::=t2]" using a1 i by simp
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    60
    thus "a\<sharp>(Lam [c].t)[b::=t2]" using fr  by (simp add: abs_fresh)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    61
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    62
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    63
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    64
lemma fresh_fact[rule_format]: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    65
  fixes   b :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    66
  and    a  :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    67
  and    t1 :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    68
  and    t2 :: "lam" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    69
  shows "a\<sharp>t1\<longrightarrow>a\<sharp>t2\<longrightarrow>a\<sharp>(t1[b::=t2])"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    70
apply(nominal_induct t1 fresh: a b t2 rule: lam_induct)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    71
apply(auto simp add: abs_fresh fresh_prod fresh_atm)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    72
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    73
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    74
lemma subs_lemma:  
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    75
  fixes x::"name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    76
  and   y::"name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    77
  and   L::"lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    78
  and   M::"lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
    79
  and   N::"lam"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    80
  assumes a: "x\<noteq>y"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    81
  and     b: "x\<sharp>L"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    82
  shows "M[x::=N][y::=L] = M[y::=L][x::=N[y::=L]]"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    83
using a b
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    84
proof (nominal_induct M fresh: x y N L rule: lam_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    85
  case (Var z) (* case 1: Variables*)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    86
  have "x\<noteq>y" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    87
  have "x\<sharp>L" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    88
  show "Var z[x::=N][y::=L] = Var z[y::=L][x::=N[y::=L]]" (is "?LHS = ?RHS")
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    89
  proof -
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    90
    { (*Case 1.1*)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    91
      assume  "z=x"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    92
      have "(1)": "?LHS = N[y::=L]" using `z=x` by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    93
      have "(2)": "?RHS = N[y::=L]" using `z=x` `x\<noteq>y` by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    94
      from "(1)" "(2)" have "?LHS = ?RHS"  by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    95
    }
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    96
    moreover 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    97
    { (*Case 1.2*)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    98
      assume "z\<noteq>x" and "z=y"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
    99
      have "(1)": "?LHS = L"               using `z\<noteq>x` `z=y` by force
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   100
      have "(2)": "?RHS = L[x::=N[y::=L]]" using `z=y` by force
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   101
      have "(3)": "L[x::=N[y::=L]] = L"    using `x\<sharp>L` by (simp add: forget)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   102
      from "(1)" "(2)" "(3)" have "?LHS = ?RHS" by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   103
    }
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   104
    moreover 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   105
    { (*Case 1.3*)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   106
      assume "z\<noteq>x" and "z\<noteq>y"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   107
      have "(1)": "?LHS = Var z" using `z\<noteq>x` `z\<noteq>y` by force
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   108
      have "(2)": "?RHS = Var z" using `z\<noteq>x` `z\<noteq>y` by force
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   109
      from "(1)" "(2)" have "?LHS = ?RHS" by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   110
    }
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   111
    ultimately show "?LHS = ?RHS" by blast
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   112
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   113
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   114
  case (Lam z M1) (* case 2: lambdas *)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   115
  have ih: "\<And>x y N L. x\<noteq>y \<Longrightarrow> x\<sharp>L \<Longrightarrow> M1[x::=N][y::=L] = M1[y::=L][x::=N[y::=L]]" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   116
  have "x\<noteq>y" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   117
  have "x\<sharp>L" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   118
  have "z\<sharp>x" "z\<sharp>y" "z\<sharp>N" "z\<sharp>L" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   119
  hence "z\<sharp>N[y::=L]" by (simp add: fresh_fact)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   120
  show "(Lam [z].M1)[x::=N][y::=L] = (Lam [z].M1)[y::=L][x::=N[y::=L]]" (is "?LHS=?RHS") 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   121
  proof -
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   122
    have "?LHS = Lam [z].(M1[x::=N][y::=L])" using `z\<sharp>x` `z\<sharp>y` `z\<sharp>N` `z\<sharp>L` by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   123
    also from ih have "\<dots> = Lam [z].(M1[y::=L][x::=N[y::=L]])" using `x\<noteq>y` `x\<sharp>L` by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   124
    also have "\<dots> = (Lam [z].(M1[y::=L]))[x::=N[y::=L]]" using `z\<sharp>x` `z\<sharp>N[y::=L]` by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   125
    also have "\<dots> = ?RHS" using  `z\<sharp>y` `z\<sharp>L` by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   126
    finally show "?LHS = ?RHS" .
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   127
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   128
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   129
  case (App M1 M2) (* case 3: applications *)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   130
  thus ?case by simp
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   131
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   132
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   133
lemma subs_lemma:  
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   134
  fixes x::"name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   135
  and   y::"name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   136
  and   L::"lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   137
  and   M::"lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   138
  and   N::"lam"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   139
  assumes "x\<noteq>y"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   140
  and     "x\<sharp>L"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   141
  shows "M[x::=N][y::=L] = M[y::=L][x::=N[y::=L]]"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   142
using prems
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   143
by (nominal_induct M fresh: x y N L rule: lam_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   144
   (auto simp add: fresh_fact forget)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   145
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   146
lemma subst_rename[rule_format]: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   147
  fixes  c  :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   148
  and    a  :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   149
  and    t1 :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   150
  and    t2 :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   151
  shows "c\<sharp>t1 \<longrightarrow> (t1[a::=t2] = ([(c,a)]\<bullet>t1)[c::=t2])"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   152
proof (nominal_induct t1 fresh: a c t2 rule: lam_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   153
  case (Var b)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   154
  show "c\<sharp>(Var b) \<longrightarrow> (Var b)[a::=t2] = ([(c,a)]\<bullet>(Var b))[c::=t2]" by (simp add: calc_atm fresh_atm)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   155
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   156
  case App thus ?case by force
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   157
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   158
  case (Lam b s)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   159
  have i: "\<And>a c t2. c\<sharp>s \<longrightarrow> (s[a::=t2] = ([(c,a)]\<bullet>s)[c::=t2])" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   160
  have f: "b\<sharp>a" "b\<sharp>c" "b\<sharp>t2" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   161
  from f have a:"b\<noteq>c" and b: "b\<noteq>a" and c: "b\<sharp>t2" by (simp add: fresh_atm)+
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   162
  show "c\<sharp>Lam [b].s \<longrightarrow> (Lam [b].s)[a::=t2] = ([(c,a)]\<bullet>(Lam [b].s))[c::=t2]" (is "_ \<longrightarrow> ?LHS = ?RHS")
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   163
  proof
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   164
    assume "c\<sharp>Lam [b].s"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   165
    hence "c\<sharp>s" using a by (simp add: abs_fresh)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   166
    hence d: "s[a::=t2] = ([(c,a)]\<bullet>s)[c::=t2]" using i by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   167
    have    "?LHS = Lam [b].(s[a::=t2])" using b c by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   168
    also have "\<dots> = Lam [b].(([(c,a)]\<bullet>s)[c::=t2])" using d by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   169
    also have "\<dots> = (Lam [b].([(c,a)]\<bullet>s))[c::=t2]" using a c by simp
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   170
    also have "\<dots> = ?RHS" using a b by (simp add: calc_atm)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   171
    finally show "?LHS = ?RHS" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   172
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   173
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   174
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   175
lemma subst_rename[rule_format]: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   176
  fixes  c  :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   177
  and    a  :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   178
  and    t1 :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   179
  and    t2 :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   180
  shows "c\<sharp>t1 \<longrightarrow> (t1[a::=t2] = ([(c,a)]\<bullet>t1)[c::=t2])"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   181
apply(nominal_induct t1 fresh: a c t2 rule: lam_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   182
apply(auto simp add: calc_atm fresh_atm abs_fresh)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   183
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   184
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   185
section {* Beta Reduction *}
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   186
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   187
consts
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   188
  Beta :: "(lam\<times>lam) set"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   189
syntax 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   190
  "_Beta"       :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta> _" [80,80] 80)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   191
  "_Beta_star"  :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>\<beta>\<^sup>* _" [80,80] 80)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   192
translations 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   193
  "t1 \<longrightarrow>\<^isub>\<beta> t2" \<rightleftharpoons> "(t1,t2) \<in> Beta"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   194
  "t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t2" \<rightleftharpoons> "(t1,t2) \<in> Beta\<^sup>*"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   195
inductive Beta
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   196
  intros
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   197
  b1[intro!]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (App s1 t)\<longrightarrow>\<^isub>\<beta>(App s2 t)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   198
  b2[intro!]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (App t s1)\<longrightarrow>\<^isub>\<beta>(App t s2)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   199
  b3[intro!]: "s1\<longrightarrow>\<^isub>\<beta>s2 \<Longrightarrow> (Lam [a].s1)\<longrightarrow>\<^isub>\<beta> (Lam [(a::name)].s2)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   200
  b4[intro!]: "(App (Lam [(a::name)].s1) s2)\<longrightarrow>\<^isub>\<beta>(s1[a::=s2])"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   201
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   202
lemma eqvt_beta: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   203
  fixes pi :: "name prm"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   204
  and   t  :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   205
  and   s  :: "lam"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   206
  assumes a: "t\<longrightarrow>\<^isub>\<beta>s"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   207
  shows "(pi\<bullet>t)\<longrightarrow>\<^isub>\<beta>(pi\<bullet>s)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   208
  using a by (induct, auto)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   209
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   210
lemma beta_induct[consumes 1, case_names b1 b2 b3 b4]:
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   211
  fixes  P :: "'a::fs_name\<Rightarrow>lam \<Rightarrow> lam \<Rightarrow>bool"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   212
  and    t :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   213
  and    s :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   214
  and    x :: "'a::fs_name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   215
  assumes a: "t\<longrightarrow>\<^isub>\<beta>s"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   216
  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)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   217
  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)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   218
  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)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   219
  and a4:    "\<And>a t1 s1 x. a\<sharp>(s1,x) \<Longrightarrow> P x (App (Lam [a].t1) s1) (t1[a::=s1])"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   220
  shows "P x t s"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   221
proof -
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   222
  from a have "\<And>(pi::name prm) x. P x (pi\<bullet>t) (pi\<bullet>s)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   223
  proof (induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   224
    case b1 thus ?case using a1 by (simp, blast intro: eqvt_beta)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   225
  next
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   226
    case b2 thus ?case using a2 by (simp, blast intro: eqvt_beta)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   227
  next
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   228
    case (b3 a s1 s2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   229
    have j1: "s1 \<longrightarrow>\<^isub>\<beta> s2" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   230
    have j2: "\<And>x (pi::name prm). P x (pi\<bullet>s1) (pi\<bullet>s2)" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   231
    show ?case 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   232
    proof (simp)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   233
      have f: "\<exists>c::name. c\<sharp>(pi\<bullet>a,pi\<bullet>s1,pi\<bullet>s2,x)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   234
	by (rule at_exists_fresh[OF at_name_inst], simp add: fs_name1)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   235
      then obtain c::"name" 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   236
	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)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   237
	by (force simp add: fresh_prod fresh_atm)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   238
      have x: "P x (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>s1)) (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>s2))"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   239
	using a3 f2 j1 j2 by (simp, blast intro: eqvt_beta)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   240
      have alpha1: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>s1))) = (Lam [(pi\<bullet>a)].(pi\<bullet>s1))" using f1 f3
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   241
	by (simp add: lam.inject alpha)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   242
      have alpha2: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>s2))) = (Lam [(pi\<bullet>a)].(pi\<bullet>s2))" using f1 f3
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   243
	by (simp add: lam.inject alpha)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   244
      show " P x (Lam [(pi\<bullet>a)].(pi\<bullet>s1)) (Lam [(pi\<bullet>a)].(pi\<bullet>s2))"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   245
	using x alpha1 alpha2 by (simp only: pt_name2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   246
    qed
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   247
  next
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   248
    case (b4 a s1 s2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   249
    show ?case
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   250
    proof (simp add: subst_eqvt)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   251
      have f: "\<exists>c::name. c\<sharp>(pi\<bullet>a,pi\<bullet>s1,pi\<bullet>s2,x)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   252
	by (rule at_exists_fresh[OF at_name_inst], simp add: fs_name1)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   253
      then obtain c::"name" 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   254
	where f1: "c\<noteq>(pi\<bullet>a)" and f2: "c\<sharp>(pi\<bullet>s2,x)" and f3: "c\<sharp>(pi\<bullet>s1)" and f4: "c\<sharp>(pi\<bullet>s2)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   255
	by (force simp add: fresh_prod fresh_atm)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   256
      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)])"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   257
	using a4 f2 by (blast intro!: eqvt_beta)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   258
      have alpha1: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>s1))) = (Lam [(pi\<bullet>a)].(pi\<bullet>s1))" using f1 f3
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   259
	by (simp add: lam.inject alpha)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   260
      have alpha2: "(([(c,pi\<bullet>a)]@pi)\<bullet>s1)[c::=(pi\<bullet>s2)] = (pi\<bullet>s1)[(pi\<bullet>a)::=(pi\<bullet>s2)]"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   261
	using f3 by (simp only: subst_rename[symmetric] pt_name2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   262
      show "P x (App (Lam [(pi\<bullet>a)].(pi\<bullet>s1)) (pi\<bullet>s2)) ((pi\<bullet>s1)[(pi\<bullet>a)::=(pi\<bullet>s2)])"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   263
	using x alpha1 alpha2 by (simp only: pt_name2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   264
    qed
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   265
  qed
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   266
  hence "P x (([]::name prm)\<bullet>t) (([]::name prm)\<bullet>s)" by blast 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   267
  thus ?thesis by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   268
qed
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   269
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   270
section {* One-Reduction *}
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   271
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   272
consts
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   273
  One :: "(lam\<times>lam) set"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   274
syntax 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   275
  "_One"       :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>1 _" [80,80] 80)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   276
  "_One_star"  :: "lam\<Rightarrow>lam\<Rightarrow>bool" (" _ \<longrightarrow>\<^isub>1\<^sup>* _" [80,80] 80)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   277
translations 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   278
  "t1 \<longrightarrow>\<^isub>1 t2" \<rightleftharpoons> "(t1,t2) \<in> One"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   279
  "t1 \<longrightarrow>\<^isub>1\<^sup>* t2" \<rightleftharpoons> "(t1,t2) \<in> One\<^sup>*"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   280
inductive One
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   281
  intros
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   282
  o1[intro!]:      "M\<longrightarrow>\<^isub>1M"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   283
  o2[simp,intro!]: "\<lbrakk>t1\<longrightarrow>\<^isub>1t2;s1\<longrightarrow>\<^isub>1s2\<rbrakk> \<Longrightarrow> (App t1 s1)\<longrightarrow>\<^isub>1(App t2 s2)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   284
  o3[simp,intro!]: "s1\<longrightarrow>\<^isub>1s2 \<Longrightarrow> (Lam [(a::name)].s1)\<longrightarrow>\<^isub>1(Lam [a].s2)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   285
  o4[simp,intro!]: "\<lbrakk>s1\<longrightarrow>\<^isub>1s2;t1\<longrightarrow>\<^isub>1t2\<rbrakk> \<Longrightarrow> (App (Lam [(a::name)].t1) s1)\<longrightarrow>\<^isub>1(t2[a::=s2])"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   286
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   287
lemma eqvt_one: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   288
  fixes pi :: "name prm"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   289
  and   t  :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   290
  and   s  :: "lam"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   291
  assumes a: "t\<longrightarrow>\<^isub>1s"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   292
  shows "(pi\<bullet>t)\<longrightarrow>\<^isub>1(pi\<bullet>s)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   293
  using a by (induct, auto)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   294
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   295
lemma one_induct[consumes 1, case_names o1 o2 o3 o4]:
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   296
  fixes  P :: "'a::fs_name\<Rightarrow>lam \<Rightarrow> lam \<Rightarrow>bool"
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   297
  and    t :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   298
  and    s :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   299
  and    x :: "'a::fs_name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   300
  assumes a: "t\<longrightarrow>\<^isub>1s"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   301
  and a1:    "\<And>t x. P x t t"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   302
  and a2:    "\<And>t1 t2 s1 s2 x. t1\<longrightarrow>\<^isub>1t2 \<Longrightarrow> (\<And>z. P z t1 t2) \<Longrightarrow> s1\<longrightarrow>\<^isub>1s2 \<Longrightarrow> (\<And>z. P z s1 s2) \<Longrightarrow> 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   303
              P x (App t1 s1) (App t2 s2)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   304
  and a3:    "\<And>a s1 s2 x. a\<sharp>x \<Longrightarrow> s1\<longrightarrow>\<^isub>1s2 \<Longrightarrow> (\<And>z. P z s1 s2) \<Longrightarrow> P x (Lam [a].s1) (Lam [a].s2)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   305
  and a4:    "\<And>a t1 t2 s1 s2 x. 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   306
              a\<sharp>(s1,s2,x) \<Longrightarrow> t1\<longrightarrow>\<^isub>1t2 \<Longrightarrow> (\<And>z. P z t1 t2) \<Longrightarrow> s1\<longrightarrow>\<^isub>1s2 \<Longrightarrow> (\<And>z. P z s1 s2) 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   307
              \<Longrightarrow> P x (App (Lam [a].t1) s1) (t2[a::=s2])"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   308
  shows "P x t s"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   309
proof -
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   310
  from a have "\<And>(pi::name prm) x. P x (pi\<bullet>t) (pi\<bullet>s)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   311
  proof (induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   312
    case o1 show ?case using a1 by force
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   313
  next
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   314
    case (o2 s1 s2 t1 t2) 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   315
    thus ?case using a2 by (simp, blast intro: eqvt_one)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   316
  next
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   317
    case (o3 a t1 t2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   318
    have j1: "t1 \<longrightarrow>\<^isub>1 t2" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   319
    have j2: "\<And>(pi::name prm) x. P x (pi\<bullet>t1) (pi\<bullet>t2)" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   320
    show ?case 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   321
    proof (simp)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   322
      have f: "\<exists>c::name. c\<sharp>(pi\<bullet>a,pi\<bullet>t1,pi\<bullet>t2,x)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   323
	by (rule at_exists_fresh[OF at_name_inst], simp add: fs_name1)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   324
      then obtain c::"name" 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   325
	where f1: "c\<noteq>(pi\<bullet>a)" and f2: "c\<sharp>x" and f3: "c\<sharp>(pi\<bullet>t1)" and f4: "c\<sharp>(pi\<bullet>t2)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   326
	by (force simp add: fresh_prod fresh_atm)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   327
      have x: "P x (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>t1)) (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>t2))"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   328
	using a3 f2 j1 j2 by (simp, blast intro: eqvt_one)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   329
      have alpha1: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>t1))) = (Lam [(pi\<bullet>a)].(pi\<bullet>t1))" using f1 f3
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   330
	by (simp add: lam.inject alpha)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   331
      have alpha2: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>t2))) = (Lam [(pi\<bullet>a)].(pi\<bullet>t2))" using f1 f3
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   332
	by (simp add: lam.inject alpha)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   333
      show " P x (Lam [(pi\<bullet>a)].(pi\<bullet>t1)) (Lam [(pi\<bullet>a)].(pi\<bullet>t2))"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   334
	using x alpha1 alpha2 by (simp only: pt_name2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   335
    qed
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   336
  next
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   337
    case (o4 a s1 s2 t1 t2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   338
    have j0: "t1 \<longrightarrow>\<^isub>1 t2" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   339
    have j1: "s1 \<longrightarrow>\<^isub>1 s2" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   340
    have j2: "\<And>(pi::name prm) x. P x (pi\<bullet>t1) (pi\<bullet>t2)" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   341
    have j3: "\<And>(pi::name prm) x. P x (pi\<bullet>s1) (pi\<bullet>s2)" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   342
    show ?case
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   343
    proof (simp)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   344
      have f: "\<exists>c::name. c\<sharp>(pi\<bullet>a,pi\<bullet>t1,pi\<bullet>t2,pi\<bullet>s1,pi\<bullet>s2,x)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   345
	by (rule at_exists_fresh[OF at_name_inst], simp add: fs_name1)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   346
      then obtain c::"name" 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   347
	where f1: "c\<noteq>(pi\<bullet>a)" and f2: "c\<sharp>(pi\<bullet>s1,pi\<bullet>s2,x)" and f3: "c\<sharp>(pi\<bullet>t1)" and f4: "c\<sharp>(pi\<bullet>t2)"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   348
	by (force simp add: fresh_prod at_fresh[OF at_name_inst])
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   349
      have x: "P x (App (Lam [c].(([(c,pi\<bullet>a)]@pi)\<bullet>t1)) (pi\<bullet>s1)) ((([(c,pi\<bullet>a)]@pi)\<bullet>t2)[c::=(pi\<bullet>s2)])"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   350
	using a4 f2 j0 j1 j2 j3 by (simp, blast intro!: eqvt_one)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   351
      have alpha1: "(Lam [c].([(c,pi\<bullet>a)]\<bullet>(pi\<bullet>t1))) = (Lam [(pi\<bullet>a)].(pi\<bullet>t1))" using f1 f3
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   352
	by (simp add: lam.inject alpha)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   353
      have alpha2: "(([(c,pi\<bullet>a)]@pi)\<bullet>t2)[c::=(pi\<bullet>s2)] = (pi\<bullet>t2)[(pi\<bullet>a)::=(pi\<bullet>s2)]"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   354
	using f4 by (simp only: subst_rename[symmetric] pt_name2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   355
      show "P x (App (Lam [(pi\<bullet>a)].(pi\<bullet>t1)) (pi\<bullet>s1)) ((pi\<bullet>t2)[(pi\<bullet>a)::=(pi\<bullet>s2)])"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   356
	using x alpha1 alpha2 by (simp only: pt_name2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   357
    qed
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   358
  qed
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   359
  hence "P x (([]::name prm)\<bullet>t) (([]::name prm)\<bullet>s)" by blast
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   360
  thus ?thesis by simp
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   361
qed
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   362
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   363
lemma fresh_fact':  
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   364
  assumes a: "a\<sharp>t2" 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   365
  shows "a\<sharp>(t1[a::=t2])"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   366
using a 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   367
proof (nominal_induct t1 fresh: a t2 rule: lam_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   368
  case (Var b) 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   369
  thus ?case by (simp add: fresh_atm)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   370
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   371
  case App thus ?case by simp
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   372
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   373
  case (Lam c t)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   374
  have "a\<sharp>t2" "c\<sharp>a" "c\<sharp>t2" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   375
  moreover
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   376
  have ih: "\<And>a t2. a\<sharp>t2 \<Longrightarrow> a\<sharp>(t[a::=t2])" by fact
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   377
  ultimately show ?case by (simp add: abs_fresh)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   378
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   379
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   380
lemma one_fresh_preserv[rule_format]:
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   381
  fixes    t :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   382
  and      s :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   383
  and      a :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   384
  assumes a: "t\<longrightarrow>\<^isub>1s"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   385
  shows "a\<sharp>t \<longrightarrow> a\<sharp>s"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   386
using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   387
proof (induct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   388
  case o1 show ?case by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   389
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   390
  case o2 thus ?case by (simp add: fresh_prod)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   391
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   392
  case (o3 c s1 s2)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   393
  assume i: "a\<sharp>s1 \<longrightarrow>  a\<sharp>s2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   394
  show ?case
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   395
  proof (intro strip, cases "a=c")
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   396
    assume "a=c" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   397
    thus "a\<sharp>Lam [c].s2" by (simp add: abs_fresh)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   398
  next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   399
    assume b: "a\<noteq>c" and "a\<sharp>Lam [c].s1"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   400
    hence "a\<sharp>s1" by (simp add: abs_fresh)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   401
    hence "a\<sharp>s2" using i by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   402
    thus "a\<sharp>Lam [c].s2" using b by (simp add: abs_fresh) 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   403
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   404
next 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   405
  case (o4 c t1 t2 s1 s2)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   406
  assume i1: "a\<sharp>t1 \<longrightarrow> a\<sharp>t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   407
     and i2: "a\<sharp>s1 \<longrightarrow> a\<sharp>s2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   408
  show "a\<sharp>App (Lam [c].s1) t1 \<longrightarrow> a\<sharp>s2[c::=t2]"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   409
  proof
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   410
    assume "a\<sharp>App (Lam [c].s1) t1"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   411
    hence c1: "a\<sharp>Lam [c].s1" and c2: "a\<sharp>t1" by (simp add: fresh_prod)+
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   412
    from c2 i1 have c3: "a\<sharp>t2" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   413
    show "a\<sharp>s2[c::=t2]"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   414
    proof (cases "a=c")
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   415
      assume "a=c"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   416
      thus "a\<sharp>s2[c::=t2]" using c3 by (simp add: fresh_fact')
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   417
    next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   418
      assume d1: "a\<noteq>c"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   419
      from c1 d1 have "a\<sharp>s1" by (simp add: abs_fresh)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   420
      hence "a\<sharp>s2" using i2 by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   421
      thus "a\<sharp>s2[c::=t2]" using c3 by (simp add: fresh_fact)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   422
    qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   423
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   424
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   425
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   426
lemma one_abs: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   427
  fixes    t :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   428
  and      t':: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   429
  and      a :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   430
  shows "(Lam [a].t)\<longrightarrow>\<^isub>1t'\<Longrightarrow>\<exists>t''. t'=Lam [a].t'' \<and> t\<longrightarrow>\<^isub>1t''"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   431
  apply(ind_cases "(Lam [a].t)\<longrightarrow>\<^isub>1t'")
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   432
  apply(auto simp add: lam.distinct lam.inject alpha)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   433
  apply(rule_tac x="[(a,aa)]\<bullet>s2" in exI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   434
  apply(rule conjI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   435
  apply(rule pt_bij2[OF pt_name_inst, OF at_name_inst, symmetric])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   436
  apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   437
  apply(rule pt_name3)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   438
  apply(rule at_ds5[OF at_name_inst])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   439
  apply(frule_tac a="a" in one_fresh_preserv)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   440
  apply(assumption)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   441
  apply(rule conjI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   442
  apply(simp add: pt_fresh_left[OF pt_name_inst, OF at_name_inst])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   443
  apply(simp add: calc_atm)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   444
  apply(force intro!: eqvt_one)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   445
  done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   446
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   447
lemma one_app: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   448
  "App t1 t2 \<longrightarrow>\<^isub>1 t' \<Longrightarrow> 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   449
  (\<exists>s1 s2. t' = App s1 s2 \<and> t1 \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2) \<or> 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   450
  (\<exists>a s s1 s2. t1 = Lam [a].s \<and> t' = s1[a::=s2] \<and> s \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2)" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   451
  apply(ind_cases "App t1 s1 \<longrightarrow>\<^isub>1 t'")
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   452
  apply(auto simp add: lam.distinct lam.inject)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   453
  done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   454
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   455
lemma one_red: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   456
  "App (Lam [a].t1) t2 \<longrightarrow>\<^isub>1 M \<Longrightarrow>
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   457
  (\<exists>s1 s2. M = App (Lam [a].s1) s2 \<and> t1 \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2) \<or> 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   458
  (\<exists>s1 s2. M = s1[a::=s2] \<and> t1 \<longrightarrow>\<^isub>1 s1 \<and> t2 \<longrightarrow>\<^isub>1 s2)" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   459
  apply(ind_cases "App (Lam [a].t1) s1 \<longrightarrow>\<^isub>1 M")
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   460
  apply(simp_all add: lam.inject)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   461
  apply(force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   462
  apply(erule conjE)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   463
  apply(drule sym[of "Lam [a].t1"])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   464
  apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   465
  apply(drule one_abs)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   466
  apply(erule exE)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   467
  apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   468
  apply(force simp add: alpha)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   469
  apply(erule conjE)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   470
  apply(simp add: lam.inject alpha)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   471
  apply(erule disjE)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   472
  apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   473
  apply(force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   474
  apply(simp)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   475
  apply(rule disjI2)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   476
  apply(rule_tac x="[(a,aa)]\<bullet>t2a" in exI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   477
  apply(rule_tac x="s2" in exI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   478
  apply(auto)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   479
  apply(subgoal_tac "a\<sharp>t2a")(*A*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   480
  apply(simp add: subst_rename)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   481
  (*A*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   482
  apply(force intro: one_fresh_preserv)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   483
  apply(force intro: eqvt_one)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   484
  done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   485
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   486
text {* first case in Lemma 3.2.4*}
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   487
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   488
lemma one_subst_aux:
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   489
  fixes    M :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   490
  and      N :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   491
  and      N':: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   492
  and      x :: "name"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   493
  assumes a: "N\<longrightarrow>\<^isub>1N'"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   494
  shows "M[x::=N] \<longrightarrow>\<^isub>1 M[x::=N']"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   495
using a
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   496
proof (nominal_induct M fresh: x N N' rule: lam_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   497
  case (Var y) 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   498
  show "Var y[x::=N] \<longrightarrow>\<^isub>1 Var y[x::=N']" by (cases "x=y", auto)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   499
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   500
  case (App P Q) (* application case - third line *)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   501
  thus "(App P Q)[x::=N] \<longrightarrow>\<^isub>1  (App P Q)[x::=N']" using o2 by simp
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   502
next 
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   503
  case (Lam y P) (* abstraction case - fourth line *)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   504
  thus "(Lam [y].P)[x::=N] \<longrightarrow>\<^isub>1 (Lam [y].P)[x::=N']" using o3 by simp
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   505
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   506
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   507
lemma one_subst_aux:
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   508
  fixes    M :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   509
  and      N :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   510
  and      N':: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   511
  and      x :: "name"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   512
  assumes a: "N\<longrightarrow>\<^isub>1N'"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   513
  shows "M[x::=N] \<longrightarrow>\<^isub>1 M[x::=N']"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   514
using a
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   515
apply(nominal_induct M fresh: x N N' rule: lam_induct)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   516
apply(auto simp add: fresh_prod fresh_atm)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   517
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   518
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   519
lemma one_subst[rule_format]: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   520
  fixes    M :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   521
  and      M':: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   522
  and      N :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   523
  and      N':: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   524
  and      x :: "name"
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   525
  assumes a: "M\<longrightarrow>\<^isub>1M'"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   526
  and     b: "N\<longrightarrow>\<^isub>1N'"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   527
  shows "M[x::=N]\<longrightarrow>\<^isub>1M'[x::=N']" 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   528
using prems
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   529
proof (nominal_induct M M' fresh: N N' x rule: one_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   530
  case (o1 M)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   531
  thus ?case by (simp add: one_subst_aux)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   532
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   533
  case (o2 M1 M2 N1 N2)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   534
  thus ?case by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   535
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   536
  case (o3 a M1 M2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   537
  thus ?case by simp
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   538
next
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   539
  case (o4 a M1 M2 N1 N2)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   540
  have e3: "a\<sharp>N1" "a\<sharp>N2" "a\<sharp>N" "a\<sharp>N'" "a\<sharp>x" by fact
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   541
  show ?case
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   542
  proof -
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   543
    have "(App (Lam [a].M1) N1)[x::=N] = App (Lam [a].(M1[x::=N])) (N1[x::=N])" using e3 by simp
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   544
    also have "App (Lam [a].(M1[x::=N])) (N1[x::=N]) \<longrightarrow>\<^isub>1 M2[x::=N'][a::=N2[x::=N']]" 
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   545
      using  o4 b by force
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   546
    also have "M2[x::=N'][a::=N2[x::=N']] = M2[a::=N2][x::=N']" 
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   547
      using e3 by (simp add: subs_lemma fresh_atm)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   548
    ultimately show "(App (Lam [a].M1) N1)[x::=N] \<longrightarrow>\<^isub>1 M2[a::=N2][x::=N']" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   549
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   550
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   551
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   552
lemma one_subst[rule_format]: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   553
  assumes a: "M\<longrightarrow>\<^isub>1M'" 
18303
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   554
  and     b: "N\<longrightarrow>\<^isub>1N'"
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   555
  shows "M[x::=N]\<longrightarrow>\<^isub>1M'[x::=N']" 
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   556
using a b
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   557
apply(nominal_induct M M' fresh: N N' x rule: one_induct)
b18fabea0fd0 modified almost everything for the new nominal_induct
urbanc
parents: 18269
diff changeset
   558
apply(auto simp add: one_subst_aux subs_lemma fresh_atm)
18106
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   559
done
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   560
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   561
lemma diamond[rule_format]:
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   562
  fixes    M :: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   563
  and      M1:: "lam"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   564
  assumes a: "M\<longrightarrow>\<^isub>1M1" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   565
  shows "\<forall>M2. (M\<longrightarrow>\<^isub>1M2) \<longrightarrow> (\<exists>M3. M1\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   566
  using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   567
proof (induct)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   568
  case (o1 M) (* case 1 --- M1 = M *)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   569
  show "\<forall>M2. M\<longrightarrow>\<^isub>1M2 \<longrightarrow> (\<exists>M3. M\<longrightarrow>\<^isub>1M3 \<and>  M2\<longrightarrow>\<^isub>1M3)" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   570
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   571
  case (o4 x Q Q' P P') (* case 2 --- a beta-reduction occurs*)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   572
  assume i1: "\<forall>M2. Q \<longrightarrow>\<^isub>1M2 \<longrightarrow> (\<exists>M3. Q'\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   573
  assume i2: "\<forall>M2. P \<longrightarrow>\<^isub>1M2 \<longrightarrow> (\<exists>M3. P'\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   574
  show "\<forall>M2. App (Lam [x].P) Q\<longrightarrow>\<^isub>1M2 \<longrightarrow> (\<exists>M3. P'[x::=Q']\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   575
  proof (intro strip)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   576
    fix M2
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   577
    assume "App (Lam [x].P) Q \<longrightarrow>\<^isub>1 M2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   578
    hence "(\<exists>P' Q'. M2 = App (Lam [x].P') Q' \<and> P\<longrightarrow>\<^isub>1P' \<and> Q\<longrightarrow>\<^isub>1Q') \<or> 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   579
           (\<exists>P' Q'. M2 = P'[x::=Q'] \<and> P\<longrightarrow>\<^isub>1P' \<and> Q\<longrightarrow>\<^isub>1Q')" by (simp add: one_red)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   580
    moreover (* subcase 2.1 *)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   581
    { assume "\<exists>P' Q'. M2 = App (Lam [x].P') Q' \<and> P\<longrightarrow>\<^isub>1P' \<and> Q\<longrightarrow>\<^isub>1Q'"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   582
      then obtain P'' and Q'' where 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   583
	b1: "M2=App (Lam [x].P'') Q''" and b2: "P\<longrightarrow>\<^isub>1P''" and b3: "Q\<longrightarrow>\<^isub>1Q''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   584
      from b2 i2 have "(\<exists>M3. P'\<longrightarrow>\<^isub>1M3 \<and> P''\<longrightarrow>\<^isub>1M3)" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   585
      then obtain P''' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   586
	c1: "P'\<longrightarrow>\<^isub>1P'''" and c2: "P''\<longrightarrow>\<^isub>1P'''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   587
      from b3 i1 have "(\<exists>M3. Q'\<longrightarrow>\<^isub>1M3 \<and> Q''\<longrightarrow>\<^isub>1M3)" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   588
      then obtain Q''' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   589
	d1: "Q'\<longrightarrow>\<^isub>1Q'''" and d2: "Q''\<longrightarrow>\<^isub>1Q'''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   590
      from c1 c2 d1 d2 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   591
      have "P'[x::=Q']\<longrightarrow>\<^isub>1P'''[x::=Q'''] \<and> App (Lam [x].P'') Q'' \<longrightarrow>\<^isub>1 P'''[x::=Q''']" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   592
	by (force simp add: one_subst)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   593
      hence "\<exists>M3. P'[x::=Q']\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3" using b1 by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   594
    }
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   595
    moreover (* subcase 2.2 *)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   596
    { assume "\<exists>P' Q'. M2 = P'[x::=Q'] \<and> P\<longrightarrow>\<^isub>1P' \<and> Q\<longrightarrow>\<^isub>1Q'"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   597
      then obtain P'' Q'' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   598
	b1: "M2=P''[x::=Q'']" and b2: "P\<longrightarrow>\<^isub>1P''" and  b3: "Q\<longrightarrow>\<^isub>1Q''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   599
      from b2 i2 have "(\<exists>M3. P'\<longrightarrow>\<^isub>1M3 \<and> P''\<longrightarrow>\<^isub>1M3)" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   600
      then obtain P''' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   601
	c1: "P'\<longrightarrow>\<^isub>1P'''" and c2: "P''\<longrightarrow>\<^isub>1P'''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   602
      from b3 i1 have "(\<exists>M3. Q'\<longrightarrow>\<^isub>1M3 \<and> Q''\<longrightarrow>\<^isub>1M3)" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   603
      then obtain Q''' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   604
	d1: "Q'\<longrightarrow>\<^isub>1Q'''" and d2: "Q''\<longrightarrow>\<^isub>1Q'''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   605
      from c1 c2 d1 d2 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   606
      have "P'[x::=Q']\<longrightarrow>\<^isub>1P'''[x::=Q'''] \<and> P''[x::=Q'']\<longrightarrow>\<^isub>1P'''[x::=Q''']" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   607
	by (force simp add: one_subst)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   608
      hence "\<exists>M3. P'[x::=Q']\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3" using b1 by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   609
    }
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   610
    ultimately show "\<exists>M3. P'[x::=Q']\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3" by blast
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   611
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   612
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   613
  case (o2 Q Q' P P') (* case 3 *)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   614
  assume i0: "P\<longrightarrow>\<^isub>1P'"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   615
  assume i1: "\<forall>M2. Q \<longrightarrow>\<^isub>1M2 \<longrightarrow> (\<exists>M3. Q'\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   616
  assume i2: "\<forall>M2. P \<longrightarrow>\<^isub>1M2 \<longrightarrow> (\<exists>M3. P'\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   617
  show "\<forall>M2. App P Q\<longrightarrow>\<^isub>1M2 \<longrightarrow> (\<exists>M3. App P' Q'\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   618
  proof (intro strip)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   619
    fix M2
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   620
    assume "App P Q \<longrightarrow>\<^isub>1 M2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   621
    hence "(\<exists>P'' Q''. M2 = App P'' Q'' \<and> P\<longrightarrow>\<^isub>1P'' \<and> Q\<longrightarrow>\<^isub>1Q'') \<or> 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   622
           (\<exists>x P' P'' Q'. P = Lam [x].P' \<and> M2 = P''[x::=Q'] \<and> P'\<longrightarrow>\<^isub>1 P'' \<and> Q\<longrightarrow>\<^isub>1Q')" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   623
      by (simp add: one_app[simplified])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   624
    moreover (* subcase 3.1 *)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   625
    { assume "\<exists>P'' Q''. M2 = App P'' Q'' \<and> P\<longrightarrow>\<^isub>1P'' \<and> Q\<longrightarrow>\<^isub>1Q''"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   626
      then obtain P'' and Q'' where 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   627
	b1: "M2=App P'' Q''" and b2: "P\<longrightarrow>\<^isub>1P''" and b3: "Q\<longrightarrow>\<^isub>1Q''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   628
      from b2 i2 have "(\<exists>M3. P'\<longrightarrow>\<^isub>1M3 \<and> P''\<longrightarrow>\<^isub>1M3)" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   629
      then obtain P''' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   630
	c1: "P'\<longrightarrow>\<^isub>1P'''" and c2: "P''\<longrightarrow>\<^isub>1P'''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   631
      from b3 i1 have "(\<exists>M3. Q'\<longrightarrow>\<^isub>1M3 \<and> Q''\<longrightarrow>\<^isub>1M3)" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   632
      then obtain Q''' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   633
	d1: "Q'\<longrightarrow>\<^isub>1Q'''" and d2: "Q''\<longrightarrow>\<^isub>1Q'''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   634
      from c1 c2 d1 d2 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   635
      have "App P' Q'\<longrightarrow>\<^isub>1App P''' Q''' \<and> App P'' Q'' \<longrightarrow>\<^isub>1 App P''' Q'''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   636
      hence "\<exists>M3. App P' Q'\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3" using b1 by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   637
    }
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   638
    moreover (* subcase 3.2 *)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   639
    { assume "\<exists>x P1 P'' Q''. P = Lam [x].P1 \<and> M2 = P''[x::=Q''] \<and> P1\<longrightarrow>\<^isub>1 P'' \<and> Q\<longrightarrow>\<^isub>1Q''"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   640
      then obtain x P1 P1'' Q'' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   641
	b0: "P=Lam [x].P1" and b1: "M2=P1''[x::=Q'']" and 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   642
        b2: "P1\<longrightarrow>\<^isub>1P1''" and  b3: "Q\<longrightarrow>\<^isub>1Q''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   643
      from b0 i0 have "\<exists>P1'. P'=Lam [x].P1' \<and> P1\<longrightarrow>\<^isub>1P1'" by (simp add: one_abs)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   644
      then obtain P1' where g1: "P'=Lam [x].P1'" and g2: "P1\<longrightarrow>\<^isub>1P1'" by force 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   645
      from g1 b0 b2 i2 have "(\<exists>M3. (Lam [x].P1')\<longrightarrow>\<^isub>1M3 \<and> (Lam [x].P1'')\<longrightarrow>\<^isub>1M3)" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   646
      then obtain P1''' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   647
	c1: "(Lam [x].P1')\<longrightarrow>\<^isub>1P1'''" and c2: "(Lam [x].P1'')\<longrightarrow>\<^isub>1P1'''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   648
      from c1 have "\<exists>R1. P1'''=Lam [x].R1 \<and> P1'\<longrightarrow>\<^isub>1R1" by (simp add: one_abs)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   649
      then obtain R1 where r1: "P1'''=Lam [x].R1" and r2: "P1'\<longrightarrow>\<^isub>1R1" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   650
      from c2 have "\<exists>R2. P1'''=Lam [x].R2 \<and> P1''\<longrightarrow>\<^isub>1R2" by (simp add: one_abs)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   651
      then obtain R2 where r3: "P1'''=Lam [x].R2" and r4: "P1''\<longrightarrow>\<^isub>1R2" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   652
      from r1 r3 have r5: "R1=R2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   653
	by (simp add: lam.inject alpha)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   654
      from b3 i1 have "(\<exists>M3. Q'\<longrightarrow>\<^isub>1M3 \<and> Q''\<longrightarrow>\<^isub>1M3)" by simp
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   655
      then obtain Q''' where
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   656
	d1: "Q'\<longrightarrow>\<^isub>1Q'''" and d2: "Q''\<longrightarrow>\<^isub>1Q'''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   657
      from g1 r2 d1 r4 r5 d2 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   658
      have "App P' Q'\<longrightarrow>\<^isub>1R1[x::=Q'''] \<and> P1''[x::=Q'']\<longrightarrow>\<^isub>1R1[x::=Q''']" by (simp add: one_subst)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   659
      hence "\<exists>M3. App P' Q'\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3" using b1 by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   660
    }
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   661
    ultimately show "\<exists>M3. App P' Q'\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3" by blast
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   662
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   663
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   664
  case (o3 x P P') (* case 4 *)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   665
  assume i1: "P\<longrightarrow>\<^isub>1P'"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   666
  assume i2: "\<forall>M2. P \<longrightarrow>\<^isub>1M2 \<longrightarrow> (\<exists>M3. P'\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   667
  show "\<forall>M2. (Lam [x].P)\<longrightarrow>\<^isub>1M2 \<longrightarrow> (\<exists>M3. (Lam [x].P')\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   668
  proof (intro strip)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   669
    fix M2
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   670
    assume "(Lam [x].P)\<longrightarrow>\<^isub>1 M2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   671
    hence "\<exists>P''. M2=Lam [x].P'' \<and> P\<longrightarrow>\<^isub>1P''" by (simp add: one_abs)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   672
    then obtain P'' where b1: "M2=Lam [x].P''" and b2: "P\<longrightarrow>\<^isub>1P''" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   673
    from i2 b1 b2 have "\<exists>M3. (Lam [x].P')\<longrightarrow>\<^isub>1M3 \<and> (Lam [x].P'')\<longrightarrow>\<^isub>1M3" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   674
    then obtain M3 where c1: "(Lam [x].P')\<longrightarrow>\<^isub>1M3" and c2: "(Lam [x].P'')\<longrightarrow>\<^isub>1M3" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   675
    from c1 have "\<exists>R1. M3=Lam [x].R1 \<and> P'\<longrightarrow>\<^isub>1R1" by (simp add: one_abs)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   676
    then obtain R1 where r1: "M3=Lam [x].R1" and r2: "P'\<longrightarrow>\<^isub>1R1" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   677
    from c2 have "\<exists>R2. M3=Lam [x].R2 \<and> P''\<longrightarrow>\<^isub>1R2" by (simp add: one_abs)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   678
    then obtain R2 where r3: "M3=Lam [x].R2" and r4: "P''\<longrightarrow>\<^isub>1R2" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   679
    from r1 r3 have r5: "R1=R2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   680
      by (simp add: lam.inject alpha)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   681
    from r2 r4 have "(Lam [x].P')\<longrightarrow>\<^isub>1(Lam [x].R1) \<and> (Lam [x].P'')\<longrightarrow>\<^isub>1(Lam [x].R2)" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   682
      by (simp add: one_subst)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   683
    thus "\<exists>M3. (Lam [x].P')\<longrightarrow>\<^isub>1M3 \<and> M2\<longrightarrow>\<^isub>1M3" using b1 r5 by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   684
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   685
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   686
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   687
lemma one_abs_cong: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   688
  fixes a :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   689
  assumes a: "t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   690
  shows "(Lam [a].t1)\<longrightarrow>\<^isub>\<beta>\<^sup>*(Lam [a].t2)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   691
  using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   692
proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   693
  case 1 thus ?case by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   694
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   695
  case (2 y z) 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   696
  thus ?case by (force dest: b3 intro: rtrancl_trans)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   697
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   698
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   699
lemma one_pr_congL: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   700
  assumes a: "t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   701
  shows "App t1 s\<longrightarrow>\<^isub>\<beta>\<^sup>* App t2 s"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   702
  using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   703
proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   704
  case 1 thus ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   705
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   706
  case 2 thus ?case by (force dest: b1 intro: rtrancl_trans)
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 one_pr_congR: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   710
  assumes a: "t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   711
  shows "App s t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* App s t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   712
using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   713
proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   714
  case 1 thus ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   715
next 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   716
  case 2 thus ?case by (force dest: b2 intro: rtrancl_trans)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   717
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   718
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   719
lemma one_pr_cong: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   720
  assumes a1: "t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   721
  and a2: "s1\<longrightarrow>\<^isub>\<beta>\<^sup>*s2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   722
  shows "App t1 s1\<longrightarrow>\<^isub>\<beta>\<^sup>* App t2 s2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   723
proof -
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   724
  have b1: "App t1 s1 \<longrightarrow>\<^isub>\<beta>\<^sup>* App t2 s1" using a1 by (rule one_pr_congL)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   725
  have b2: "App t2 s1 \<longrightarrow>\<^isub>\<beta>\<^sup>* App t2 s2" using a2 by (rule one_pr_congR)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   726
  show ?thesis using b1 and b2 by (force intro: rtrancl_trans)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   727
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   728
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   729
lemma one_beta_star: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   730
  assumes a: "(t1\<longrightarrow>\<^isub>1t2)" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   731
  shows "(t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t2)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   732
  using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   733
proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   734
  case o1 thus ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   735
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   736
  case o2 thus ?case by (force intro!: one_pr_cong)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   737
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   738
  case o3 thus ?case by (force intro!: one_abs_cong)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   739
next 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   740
  case (o4 a s1 s2 t1 t2)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   741
  have a1: "t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t2" and a2: "s1\<longrightarrow>\<^isub>\<beta>\<^sup>*s2" .
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   742
  have c1: "(App (Lam [a].t2) s2) \<longrightarrow>\<^isub>\<beta> (t2 [a::= s2])" by (rule b4)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   743
  from a1 a2 have c2: "App (Lam [a].t1 ) s1 \<longrightarrow>\<^isub>\<beta>\<^sup>* App (Lam [a].t2 ) s2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   744
    by (force intro!: one_pr_cong one_abs_cong)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   745
  show ?case using c1 c2 by (force intro: rtrancl_trans)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   746
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   747
 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   748
lemma one_star_abs_cong: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   749
  fixes a :: "name"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   750
  assumes a: "t1\<longrightarrow>\<^isub>1\<^sup>*t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   751
  shows "(Lam  [a].t1)\<longrightarrow>\<^isub>1\<^sup>* (Lam [a].t2)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   752
  using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   753
proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   754
  case 1 thus ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   755
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   756
  case 2 thus ?case by (force intro: rtrancl_trans)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   757
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   758
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   759
lemma one_star_pr_congL: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   760
  assumes a: "t1\<longrightarrow>\<^isub>1\<^sup>*t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   761
  shows "App t1 s\<longrightarrow>\<^isub>1\<^sup>* App t2 s"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   762
  using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   763
proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   764
  case 1 thus ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   765
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   766
  case 2 thus ?case by (force intro: rtrancl_trans)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   767
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   768
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   769
lemma one_star_pr_congR: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   770
  assumes a: "t1\<longrightarrow>\<^isub>1\<^sup>*t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   771
  shows "App s t1 \<longrightarrow>\<^isub>1\<^sup>* App s t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   772
  using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   773
proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   774
  case 1 thus ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   775
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   776
  case 2 thus ?case by (force intro: rtrancl_trans)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   777
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   778
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   779
lemma beta_one_star: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   780
  assumes a: "t1\<longrightarrow>\<^isub>\<beta>t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   781
  shows "t1\<longrightarrow>\<^isub>1\<^sup>*t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   782
  using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   783
proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   784
  case b1 thus ?case by (force intro!: one_star_pr_congL)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   785
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   786
  case b2 thus ?case by (force intro!: one_star_pr_congR)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   787
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   788
  case b3 thus ?case by (force intro!: one_star_abs_cong)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   789
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   790
  case b4 thus ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   791
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   792
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   793
lemma trans_closure: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   794
  shows "(t1\<longrightarrow>\<^isub>1\<^sup>*t2) = (t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t2)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   795
proof
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   796
  assume "t1 \<longrightarrow>\<^isub>1\<^sup>* t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   797
  thus "t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   798
  proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   799
    case 1 thus ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   800
  next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   801
    case 2 thus ?case by (force intro: rtrancl_trans simp add: one_beta_star)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   802
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   803
next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   804
  assume "t1 \<longrightarrow>\<^isub>\<beta>\<^sup>* t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   805
  thus "t1\<longrightarrow>\<^isub>1\<^sup>*t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   806
  proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   807
    case 1 thus ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   808
  next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   809
    case 2 thus ?case by (force intro: rtrancl_trans simp add: beta_one_star)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   810
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   811
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   812
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   813
lemma cr_one:
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   814
  assumes a: "t\<longrightarrow>\<^isub>1\<^sup>*t1" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   815
  and b: "t\<longrightarrow>\<^isub>1t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   816
  shows "\<exists>t3. t1\<longrightarrow>\<^isub>1t3 \<and> t2\<longrightarrow>\<^isub>1\<^sup>*t3"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   817
proof -
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   818
  have stronger: "\<forall>t2. t\<longrightarrow>\<^isub>1t2\<longrightarrow>(\<exists>t3. t1\<longrightarrow>\<^isub>1t3\<and>t2\<longrightarrow>\<^isub>1\<^sup>*t3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   819
    using a 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   820
  proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   821
    case 1 show ?case by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   822
  next
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   823
    case (2 s1 s2)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   824
    assume b: "s1 \<longrightarrow>\<^isub>1 s2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   825
    assume h: "\<forall>t2. t \<longrightarrow>\<^isub>1 t2 \<longrightarrow> (\<exists>t3. s1 \<longrightarrow>\<^isub>1 t3 \<and> t2 \<longrightarrow>\<^isub>1\<^sup>* t3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   826
    show ?case
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   827
    proof (rule allI, rule impI)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   828
      fix t2
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   829
      assume  c: "t \<longrightarrow>\<^isub>1 t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   830
      show "(\<exists>t3.  s2 \<longrightarrow>\<^isub>1 t3 \<and>  t2 \<longrightarrow>\<^isub>1\<^sup>* t3)" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   831
      proof -
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   832
	from c h have "(\<exists>t3. s1 \<longrightarrow>\<^isub>1 t3 \<and> t2 \<longrightarrow>\<^isub>1\<^sup>* t3)" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   833
	then obtain t3 where c1: "s1 \<longrightarrow>\<^isub>1 t3"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   834
                         and c2: "t2 \<longrightarrow>\<^isub>1\<^sup>* t3" by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   835
	have "(\<exists>t4. s2 \<longrightarrow>\<^isub>1 t4 \<and> t3 \<longrightarrow>\<^isub>1 t4)" using b c1 by (force intro: diamond)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   836
	thus ?thesis using c2 by (force intro: rtrancl_trans)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   837
      qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   838
    qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   839
  qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   840
  from a b stronger show ?thesis by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   841
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   842
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   843
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   844
lemma cr_one_star: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   845
  assumes a: "t\<longrightarrow>\<^isub>1\<^sup>*t2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   846
      and b: "t\<longrightarrow>\<^isub>1\<^sup>*t1"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   847
    shows "(\<exists>t3. t1\<longrightarrow>\<^isub>1\<^sup>*t3\<and>t2\<longrightarrow>\<^isub>1\<^sup>*t3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   848
using a
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   849
proof induct
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   850
  case 1
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   851
  show ?case using b by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   852
next 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   853
  case (2 s1 s2)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   854
  assume d: "s1 \<longrightarrow>\<^isub>1 s2"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   855
  assume "\<exists>t3.  t1 \<longrightarrow>\<^isub>1\<^sup>* t3 \<and>  s1 \<longrightarrow>\<^isub>1\<^sup>* t3"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   856
  then obtain t3 where f1: "t1 \<longrightarrow>\<^isub>1\<^sup>* t3"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   857
                   and f2: "s1 \<longrightarrow>\<^isub>1\<^sup>* t3" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   858
  from cr_one d f2 have "\<exists>t4. t3\<longrightarrow>\<^isub>1t4 \<and> s2\<longrightarrow>\<^isub>1\<^sup>*t4" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   859
  then obtain t4 where g1: "t3\<longrightarrow>\<^isub>1t4"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   860
                   and g2: "s2\<longrightarrow>\<^isub>1\<^sup>*t4" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   861
  have "t1\<longrightarrow>\<^isub>1\<^sup>*t4" using f1 g1 by (force intro: rtrancl_trans)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   862
  thus ?case using g2 by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   863
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   864
  
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   865
lemma cr_beta_star: 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   866
  assumes a1: "t\<longrightarrow>\<^isub>\<beta>\<^sup>*t1" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   867
  and a2: "t\<longrightarrow>\<^isub>\<beta>\<^sup>*t2" 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   868
  shows "(\<exists>t3. t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t3\<and>t2\<longrightarrow>\<^isub>\<beta>\<^sup>*t3)"
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   869
proof -
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   870
  from a1 have b1: "t\<longrightarrow>\<^isub>1\<^sup>*t1" by (simp add: trans_closure[symmetric])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   871
  from a2 have b2: "t\<longrightarrow>\<^isub>1\<^sup>*t2" by (simp add: trans_closure[symmetric])
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   872
  from b1 and b2 have c: "\<exists>t3. (t1\<longrightarrow>\<^isub>1\<^sup>*t3 \<and> t2\<longrightarrow>\<^isub>1\<^sup>*t3)" by (force intro!: cr_one_star) 
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   873
  from c obtain t3 where d1: "t1\<longrightarrow>\<^isub>1\<^sup>*t3" and d2: "t2\<longrightarrow>\<^isub>1\<^sup>*t3" by force
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   874
  from d1 have e1: "t1\<longrightarrow>\<^isub>\<beta>\<^sup>*t3" by (simp add: trans_closure)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   875
  from d2 have e2: "t2\<longrightarrow>\<^isub>\<beta>\<^sup>*t3" by (simp add: trans_closure)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   876
  show ?thesis using e1 and e2 by (force)
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   877
qed
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   878
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   879
end
836135c8acb2 Initial commit.
urbanc
parents:
diff changeset
   880