src/HOL/Nominal/Examples/Iteration.thy
author wenzelm
Mon, 11 Sep 2006 21:35:19 +0200
changeset 20503 503ac4c5ef91
parent 19972 89c5afe4139a
permissions -rw-r--r--
induct method: renamed 'fixing' to 'arbitrary';
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
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
     7
atom_decl name
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
     8
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
     9
nominal_datatype lam = Var "name"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    10
                     | App "lam" "lam"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    11
                     | Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._" [100,100] 100)
19858
d319e39a2e0e added lemma fresh_unit to Nominal.thy
urbanc
parents: 19651
diff changeset
    12
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    13
types 'a f1_ty  = "name\<Rightarrow>('a::pt_name)"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    14
      '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
    15
      '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
    16
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    17
consts
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    18
  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
    19
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    20
inductive "it f1 f2 f3"
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    21
intros
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    22
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
    23
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
    24
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
    25
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    26
lemma it_equiv:
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    27
  fixes pi::"name prm"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    28
  assumes a: "(t,r) \<in> it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    29
  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
    30
  using a
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    31
  apply(induct)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    32
  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
    33
  done
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    34
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    35
lemma it_fin_supp:
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    36
  assumes f: "finite ((supp (f1,f2,f3))::name set)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    37
  and     a: "(t,r) \<in> it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    38
  shows "finite ((supp r)::name set)" 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    39
  using a f
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    40
  apply(induct)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    41
  apply(finite_guess, simp add: supp_prod fs_name1)+
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    42
  done
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    43
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    44
lemma it_total:
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    45
  assumes a: "finite ((supp (f1,f2,f3))::name set)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    46
  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
    47
  shows "\<exists>r. (t,r)\<in>it f1 f2 f3"
19858
d319e39a2e0e added lemma fresh_unit to Nominal.thy
urbanc
parents: 19651
diff changeset
    48
apply(rule_tac lam.induct'[of "\<lambda>_. (supp (f1,f2,f3))" "\<lambda>z. \<lambda>t. \<exists>r. (t,r)\<in>it f1 f2 f3", simplified])
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    49
apply(fold fresh_def)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    50
apply(auto intro: it.intros a)
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    51
done
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    52
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    53
lemma it_unique: 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    54
  assumes a: "finite ((supp (f1,f2,f3))::name set)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    55
  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
    56
  and     c1: "(t,r)\<in>it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    57
  and     c2: "(t,r')\<in>it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    58
  shows   "r=r'"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    59
using c1 c2
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19972
diff changeset
    60
proof (induct arbitrary: r')
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    61
  case it1
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    62
  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
    63
next
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    64
  case (it2 r1 r2 t1 t2)
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    65
  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
    66
  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
    67
  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
    68
  then show ?case
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    69
  proof cases
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    70
    case it2
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    71
    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
    72
  qed (simp_all (no_asm_use))
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
    73
next
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    74
  case (it3 a1 r1 t1)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    75
  have f1: "a1\<sharp>(f1,f2,f3)" by fact
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    76
  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
    77
  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
    78
  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
    79
  then show ?case
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    80
  proof cases
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    81
    case (it3 a2 r2 t2)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    82
    then have f2: "a2\<sharp>(f1,f2,f3)" 
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    83
         and  it2: "(t2,r2) \<in> it f1 f2 f3"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    84
         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
    85
    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
    86
      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
    87
    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
    88
      by (force simp add: fresh_prod fresh_atm)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    89
    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
    90
      apply(auto simp add: alpha)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    91
      apply(rule trans)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    92
      apply(rule perm_compose)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    93
      apply(simp add: calc_atm perm_fresh_fresh)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    94
      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
    95
      done
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    96
    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
    97
      apply(drule_tac sym)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
    98
      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
    99
      apply(rule ih)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   100
      apply(drule_tac pi="[(a2,c)]" in it_equiv)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   101
      apply(perm_simp only: fresh_prod)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   102
      apply(drule_tac pi="[(a1,c)]" in it_equiv)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   103
      apply(perm_simp)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   104
      done
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   105
    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
   106
      apply(auto)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   107
      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
   108
      apply(perm_simp add: calc_atm fresh_prod)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   109
      done      
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   110
    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
   111
      apply(auto)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   112
      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
   113
      apply(perm_simp add: calc_atm fresh_prod)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   114
      done      
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   115
    have fs3: "c\<sharp>f3 a1 r1" using fresh it1 a
19858
d319e39a2e0e added lemma fresh_unit to Nominal.thy
urbanc
parents: 19651
diff changeset
   116
      by (fresh_guess add: supp_prod fs_name1 it_fin_supp[OF a] fresh_atm)
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   117
    have fs4: "c\<sharp>f3 a2 r2" using fresh it2 a
19858
d319e39a2e0e added lemma fresh_unit to Nominal.thy
urbanc
parents: 19651
diff changeset
   118
      by (fresh_guess add: supp_prod fs_name1 it_fin_supp[OF a] fresh_atm)
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   119
    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
   120
    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
   121
    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
   122
    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
   123
    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
   124
    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
   125
    then show ?thesis using eq2 by simp
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   126
  qed (simp_all (no_asm_use))
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   127
qed
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   128
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   129
lemma it_function:
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   130
  assumes f: "finite ((supp (f1,f2,f3))::name set)"
19158
3cca1e0a2a79 some minor tuning on the proofs
urbanc
parents: 19157
diff changeset
   131
  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
   132
  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
   133
proof (rule ex_ex1I, rule it_total[OF f, OF c])
19225
a23af144eb47 tuned some proofs
urbanc
parents: 19217
diff changeset
   134
  case (goal1 r1 r2)
19158
3cca1e0a2a79 some minor tuning on the proofs
urbanc
parents: 19157
diff changeset
   135
  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
   136
  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
   137
qed
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   138
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   139
constdefs
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   140
  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
   141
  "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
   142
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   143
lemma itfun_eqvt:
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   144
  fixes pi::"name prm"
19158
3cca1e0a2a79 some minor tuning on the proofs
urbanc
parents: 19157
diff changeset
   145
  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
   146
  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
   147
  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
   148
proof -
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   149
  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
   150
    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
   151
  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
   152
  proof -
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   153
    from c obtain a where fs1: "a\<sharp>f3" and fs2: "\<forall>(r::'a::pt_name). a\<sharp>f3 a r" by force
19972
89c5afe4139a added more infrastructure for the recursion combinator
urbanc
parents: 19858
diff changeset
   154
    have "(pi\<bullet>a)\<sharp>(pi\<bullet>f3)" using fs1 by (simp add: fresh_bij)
19168
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   155
    moreover
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   156
    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
   157
    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
   158
  qed
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   159
  show ?thesis
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   160
    apply(rule sym)
19651
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   161
    apply(auto simp add: itfun_def)
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   162
    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
   163
    apply(rule it_equiv)
19168
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   164
    apply(rule theI'[OF it_function,OF f, OF c])
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   165
    done
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   166
qed
c8faffc8e6fb streamlined the proof
urbanc
parents: 19158
diff changeset
   167
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   168
lemma itfun_Var:
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   169
  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
   170
  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
   171
  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
   172
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
   173
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   174
lemma itfun_App:
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   175
  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
   176
  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
   177
  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
   178
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
   179
         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
   180
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   181
lemma itfun_Lam:
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   182
  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
   183
  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
   184
  and     a: "a\<sharp>(f1,f2,f3)"
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   185
  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
   186
using a
247ca17caddd added a much simpler proof for the iteration and
urbanc
parents: 19496
diff changeset
   187
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
   188
         intro: theI'[OF it_function, OF f, OF c] simp add: itfun_def)
19496
79dbe35c6cba Capitalized theory names.
berghofe
parents: 19477
diff changeset
   189
19157
6e4ce7402dbe initial commit (especially 2nd half needs to be cleaned up)
urbanc
parents:
diff changeset
   190
end