src/HOL/Nominal/Examples/Iteration.thy
author urbanc
Tue, 16 May 2006 14:11:39 +0200
changeset 19651 247ca17caddd
parent 19496 79dbe35c6cba
child 19858 d319e39a2e0e
permissions -rw-r--r--
added a much simpler proof for the iteration and recursion combinator - this also fixes a bug which prevented the nightly build from being build (sorry)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
     1
(* $Id$ *)
19496
79dbe35c6cba Capitalized theory names.
berghofe
parents: 19477
diff changeset
     2
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
     3
theory Iteration
19496
79dbe35c6cba Capitalized theory names.
berghofe
parents: 19477
diff changeset
     4
imports "../Nominal"
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
     5
begin
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
     6
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
     7
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
     8
atom_decl name
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
     9
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    10
nominal_datatype lam = Var "name"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    11
                     | App "lam" "lam"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    12
                     | Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._" [100,100] 100)
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    13
 
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    14
types 'a f1_ty  = "name\<Rightarrow>('a::pt_name)"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    15
      'a f2_ty  = "'a\<Rightarrow>'a\<Rightarrow>('a::pt_name)"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    16
      'a f3_ty  = "name\<Rightarrow>'a\<Rightarrow>('a::pt_name)"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    17
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    18
consts
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    19
  it :: "'a f1_ty \<Rightarrow> 'a f2_ty \<Rightarrow> 'a f3_ty \<Rightarrow> (lam \<times> 'a::pt_name) set"
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    20
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    21
inductive "it f1 f2 f3"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    22
intros
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    23
it1: "(Var a, f1 a) \<in> it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    24
it2: "\<lbrakk>(t1,r1) \<in> it f1 f2 f3; (t2,r2) \<in> it f1 f2 f3\<rbrakk> \<Longrightarrow> (App t1 t2, f2 r1 r2) \<in> it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    25
it3: "\<lbrakk>a\<sharp>(f1,f2,f3); (t,r) \<in> it f1 f2 f3\<rbrakk> \<Longrightarrow> (Lam [a].t,f3 a r) \<in> it f1 f2 f3"
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    26
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    27
lemma it_equiv:
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    28
  fixes pi::"name prm"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    29
  assumes a: "(t,r) \<in> it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    30
  shows "(pi\<bullet>t,pi\<bullet>r) \<in> it (pi\<bullet>f1) (pi\<bullet>f2) (pi\<bullet>f3)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    31
  using a
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    32
  apply(induct)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    33
  apply(perm_simp | auto intro!: it.intros simp add: fresh_right)+
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    34
  done
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    35
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    36
lemma it_fin_supp:
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    37
  assumes f: "finite ((supp (f1,f2,f3))::name set)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    38
  and     a: "(t,r) \<in> it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    39
  shows "finite ((supp r)::name set)" 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    40
  using a f
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    41
  apply(induct)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    42
  apply(finite_guess, simp add: supp_prod fs_name1)+
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    43
  done
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    44
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    45
lemma it_total:
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    46
  assumes a: "finite ((supp (f1,f2,f3))::name set)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    47
  and     b: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    48
  shows "\<exists>r. (t,r)\<in>it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    49
apply(rule_tac lam.induct'[of "\<lambda>_. (supp (f1,f2,f3))::name set" 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    50
                              "\<lambda>z. \<lambda>t. \<exists>r. (t,r)\<in>it f1 f2 f3", simplified])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    51
apply(fold fresh_def)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    52
apply(auto intro: it.intros a)
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    53
done
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    54
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    55
lemma it_unique: 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    56
  assumes a: "finite ((supp (f1,f2,f3))::name set)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    57
  and     b: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(y::'a::pt_name). a\<sharp>f3 a y)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    58
  and     c1: "(t,r)\<in>it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    59
  and     c2: "(t,r')\<in>it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    60
  shows   "r=r'"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    61
using c1 c2
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    62
proof (induct fixing: r')
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    63
  case it1
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    64
  then show ?case by cases (simp_all add: lam.inject)
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    65
next
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    66
  case (it2 r1 r2 t1 t2)
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    67
  have ih1: "\<And>r'. (t1,r') \<in> it f1 f2 f3 \<Longrightarrow> r1 = r'" by fact
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    68
  have ih2: "\<And>r'. (t2,r') \<in> it f1 f2 f3 \<Longrightarrow> r2 = r'" by fact
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    69
  have "(App t1 t2, r') \<in>it f1 f2 f3" by fact
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    70
  then show ?case
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    71
  proof cases
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    72
    case it2
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    73
    then show ?thesis using ih1 ih2 by (simp add: lam.inject) 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    74
  qed (simp_all (no_asm_use))
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    75
next
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    76
  case (it3 a1 r1 t1)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    77
  have f1: "a1\<sharp>(f1,f2,f3)" by fact
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    78
  have ih: "\<And>r'. (t1,r') \<in> it f1 f2 f3 \<Longrightarrow> r1 = r'" by fact
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    79
  have it1: "(t1,r1) \<in> it f1 f2 f3" by fact
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    80
  have "(Lam [a1].t1, r') \<in> it f1 f2 f3" by fact
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    81
  then show ?case
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    82
  proof cases
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    83
    case (it3 a2 r2 t2)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    84
    then have f2: "a2\<sharp>(f1,f2,f3)" 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    85
         and  it2: "(t2,r2) \<in> it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    86
         and  eq1: "[a1].t1 = [a2].t2" and eq2: "r' = f3 a2 r2" by (simp_all add: lam.inject) 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    87
    have "\<exists>(c::name). c\<sharp>(f1,f2,f3,a1,a2,t1,t2,r1,r2)" using a it1 it2
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    88
      by (auto intro!: at_exists_fresh[OF at_name_inst] simp add: supp_prod fs_name1 it_fin_supp[OF a])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    89
    then obtain c where fresh: "c\<sharp>f1" "c\<sharp>f2" "c\<sharp>f3" "c\<noteq>a1" "c\<noteq>a2" "c\<sharp>t1" "c\<sharp>t2" "c\<sharp>r1" "c\<sharp>r2"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    90
      by (force simp add: fresh_prod fresh_atm)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    91
    have eq3: "[(a1,c)]\<bullet>t1 = [(a2,c)]\<bullet>t2" using eq1 fresh
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    92
      apply(auto simp add: alpha)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    93
      apply(rule trans)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    94
      apply(rule perm_compose)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    95
      apply(simp add: calc_atm perm_fresh_fresh)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    96
      apply(rule pt_name3, rule at_ds5[OF at_name_inst])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    97
      done
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    98
    have eq4: "[(a1,c)]\<bullet>r1 = [(a2,c)]\<bullet>r2" using eq3 it2 f1 f2 fresh
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    99
      apply(drule_tac sym)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   100
      apply(rule_tac pt_bij2[OF pt_name_inst, OF at_name_inst])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   101
      apply(rule ih)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   102
      apply(drule_tac pi="[(a2,c)]" in it_equiv)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   103
      apply(perm_simp only: fresh_prod)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   104
      apply(drule_tac pi="[(a1,c)]" in it_equiv)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   105
      apply(perm_simp)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   106
      done
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   107
    have fs1: "a1\<sharp>f3 a1 r1" using b f1
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   108
      apply(auto)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   109
      apply(case_tac "a=a1")
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   110
      apply(simp)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   111
      apply(rule_tac pi="[(a1,a)]" in pt_fresh_bij2[OF pt_name_inst, OF at_name_inst])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   112
      apply(perm_simp add: calc_atm fresh_prod)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   113
      done      
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   114
    have fs2: "a2\<sharp>f3 a2 r2" using b f2
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   115
      apply(auto)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   116
      apply(case_tac "a=a2")
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   117
      apply(simp)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   118
      apply(rule_tac pi="[(a2,a)]" in pt_fresh_bij2[OF pt_name_inst, OF at_name_inst])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   119
      apply(perm_simp add: calc_atm fresh_prod)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   120
      done      
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   121
    have fs3: "c\<sharp>f3 a1 r1" using fresh it1 a
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   122
      apply(rule_tac S="supp (f3,a1,r1)" in supports_fresh)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   123
      apply(supports_simp)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   124
      apply(simp add: supp_prod fs_name1 it_fin_supp[OF a])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   125
      apply(simp add: fresh_def[symmetric] fresh_prod fresh_atm)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   126
      done
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   127
    have fs4: "c\<sharp>f3 a2 r2" using fresh it2 a
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   128
      apply(rule_tac S="supp (f3,a2,r2)" in supports_fresh)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   129
      apply(supports_simp)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   130
      apply(simp add: supp_prod fs_name1 it_fin_supp[OF a])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   131
      apply(simp add: fresh_def[symmetric] fresh_prod fresh_atm)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   132
      done
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   133
    have "f3 a1 r1 = [(a1,c)]\<bullet>(f3 a1 r1)" using fs1 fs3 by perm_simp
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   134
    also have "\<dots> = f3 c ([(a1,c)]\<bullet>r1)" using f1 fresh by (perm_simp add: calc_atm fresh_prod)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   135
    also have "\<dots> = f3 c ([(a2,c)]\<bullet>r2)" using eq4 by simp
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   136
    also have "\<dots> = [(a2,c)]\<bullet>(f3 a2 r2)" using f2 fresh by (perm_simp add: calc_atm fresh_prod)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   137
    also have "\<dots> = f3 a2 r2" using fs2 fs4 by perm_simp
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   138
    finally have eq4: "f3 a1 r1 = f3 a2 r2" by simp
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   139
    then show ?thesis using eq2 by simp
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   140
  qed (simp_all (no_asm_use))
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   141
qed
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   142
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   143
lemma it_function:
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   144
  assumes f: "finite ((supp (f1,f2,f3))::name set)"
19158
3cca1e0a2a79 some minor tuning on the proofs
urbanc
parents: 19157
diff changeset
   145
  and     c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(r::'a::pt_name). a\<sharp>f3 a r)"
3cca1e0a2a79 some minor tuning on the proofs
urbanc
parents: 19157
diff changeset
   146
  shows "\<exists>!r. (t,r) \<in> it f1 f2 f3"
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   147
proof (rule ex_ex1I, rule it_total[OF f, OF c])
19225
a23af144eb47 tuned some proofs
urbanc
parents: 19217
diff changeset
   148
  case (goal1 r1 r2)
19158
3cca1e0a2a79 some minor tuning on the proofs
urbanc
parents: 19157
diff changeset
   149
  have a1: "(t,r1) \<in> it f1 f2 f3" and a2: "(t,r2) \<in> it f1 f2 f3" by fact
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   150
  thus "r1 = r2" using it_unique[OF f, OF c] by simp
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   151
qed
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   152
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   153
constdefs
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   154
  itfun :: "'a f1_ty \<Rightarrow> 'a f2_ty \<Rightarrow> 'a f3_ty \<Rightarrow> lam \<Rightarrow> ('a::pt_name)" 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   155
  "itfun f1 f2 f3 t \<equiv> (THE r. (t,r) \<in> it f1 f2 f3)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   156
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   157
lemma itfun_eqvt:
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   158
  fixes pi::"name prm"
19158
3cca1e0a2a79 some minor tuning on the proofs
urbanc
parents: 19157
diff changeset
   159
  assumes f: "finite ((supp (f1,f2,f3))::name set)"
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   160
  and     c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(r::'a::pt_name). a\<sharp>f3 a r)"
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   161
  shows "pi\<bullet>(itfun f1 f2 f3 t) = itfun (pi\<bullet>f1) (pi\<bullet>f2) (pi\<bullet>f3) (pi\<bullet>t)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   162
proof -
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   163
  have f_pi: "finite ((supp (pi\<bullet>f1,pi\<bullet>f2,pi\<bullet>f3))::name set)" using f
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   164
    by (simp add: supp_prod pt_supp_finite_pi[OF pt_name_inst, OF at_name_inst])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   165
  have fs_pi: "\<exists>(a::name). a\<sharp>(pi\<bullet>f3) \<and> (\<forall>(r::'a::pt_name). a\<sharp>(pi\<bullet>f3) a r)" 
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   166
  proof -
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   167
    from c obtain a where fs1: "a\<sharp>f3" and fs2: "\<forall>(r::'a::pt_name). a\<sharp>f3 a r" by force
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   168
    have "(pi\<bullet>a)\<sharp>(pi\<bullet>f3)" using fs1 by (simp add: fresh_eqvt)
19168
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   169
    moreover
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   170
    have "\<forall>(r::'a::pt_name). (pi\<bullet>a)\<sharp>((pi\<bullet>f3) (pi\<bullet>a) r)" using fs2 by (perm_simp add: fresh_right)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   171
    ultimately show "\<exists>(a::name). a\<sharp>(pi\<bullet>f3) \<and> (\<forall>(r::'a::pt_name). a\<sharp>(pi\<bullet>f3) a r)" by blast
19168
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   172
  qed
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   173
  show ?thesis
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   174
    apply(rule sym)
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   175
    apply(auto simp add: itfun_def)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   176
    apply(rule the1_equality[OF it_function, OF f_pi, OF fs_pi])
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   177
    apply(rule it_equiv)
19168
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   178
    apply(rule theI'[OF it_function,OF f, OF c])
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   179
    done
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   180
qed
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   181
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   182
lemma itfun_Var:
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   183
  assumes f: "finite ((supp (f1,f2,f3))::name set)"
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   184
  and     c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(r::'a::pt_name). a\<sharp>f3 a r)"
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   185
  shows "itfun f1 f2 f3 (Var c) = (f1 c)"
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   186
using f c by (auto intro!: the1_equality it_function it.intros simp add: itfun_def)
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   187
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   188
lemma itfun_App:
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   189
  assumes f: "finite ((supp (f1,f2,f3))::name set)"
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   190
  and     c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(r::'a::pt_name). a\<sharp>f3 a r)"
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   191
  shows "itfun f1 f2 f3 (App t1 t2) = (f2 (itfun f1 f2 f3 t1) (itfun f1 f2 f3 t2))"
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   192
by (auto intro!: the1_equality it_function[OF f, OF c] it.intros 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   193
         intro: theI'[OF it_function, OF f, OF c] simp add: itfun_def)
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   194
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   195
lemma itfun_Lam:
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   196
  assumes f: "finite ((supp (f1,f2,f3))::name set)"
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   197
  and     c: "\<exists>(a::name). a\<sharp>f3 \<and> (\<forall>(r::'a::pt_name). a\<sharp>f3 a r)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   198
  and     a: "a\<sharp>(f1,f2,f3)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   199
  shows "itfun f1 f2 f3 (Lam [a].t) = f3 a (itfun f1 f2 f3 t)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   200
using a
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   201
by (auto intro!: the1_equality it_function[OF f, OF c] it.intros 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   202
         intro: theI'[OF it_function, OF f, OF c] simp add: itfun_def)
19496
79dbe35c6cba Capitalized theory names.
berghofe
parents: 19477
diff changeset
   203
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   204
end