src/HOL/Nominal/Nominal.thy
author urbanc
Sun Oct 30 10:37:57 2005 +0100 (2005-10-30)
changeset 18047 3d643b13eb65
parent 18012 23e6cfda8c4b
child 18048 7003308ff73a
permissions -rw-r--r--
simplified the abs_supp_approx proof and tuned some comments in
nominal_permeq.ML
berghofe@17870
     1
(* $Id$ *)
berghofe@17870
     2
berghofe@17870
     3
theory nominal 
berghofe@17870
     4
imports Main
berghofe@17870
     5
  uses ("nominal_package.ML") ("nominal_induct.ML") ("nominal_permeq.ML")
berghofe@17870
     6
begin 
berghofe@17870
     7
berghofe@17870
     8
ML {* reset NameSpace.unique_names; *}
berghofe@17870
     9
berghofe@17870
    10
section {* Permutations *}
berghofe@17870
    11
(*======================*)
berghofe@17870
    12
berghofe@17870
    13
types 
berghofe@17870
    14
  'x prm = "('x \<times> 'x) list"
berghofe@17870
    15
berghofe@17870
    16
(* polymorphic operations for permutation and swapping*)
berghofe@17870
    17
consts 
berghofe@17870
    18
  perm :: "'x prm \<Rightarrow> 'a \<Rightarrow> 'a"     ("_ \<bullet> _" [80,80] 80)
berghofe@17870
    19
  swap :: "('x \<times> 'x) \<Rightarrow> 'x \<Rightarrow> 'x"
berghofe@17870
    20
berghofe@17870
    21
(* permutation on sets *)
berghofe@17870
    22
defs (overloaded)
berghofe@17870
    23
  perm_set_def:  "pi\<bullet>(X::'a set) \<equiv> {pi\<bullet>a | a. a\<in>X}"
berghofe@17870
    24
berghofe@17870
    25
(* permutation on units and products *)
berghofe@17870
    26
primrec (perm_unit)
berghofe@17870
    27
  "pi\<bullet>()    = ()"
berghofe@17870
    28
berghofe@17870
    29
primrec (perm_prod)
berghofe@17870
    30
  "pi\<bullet>(a,b) = (pi\<bullet>a,pi\<bullet>b)"
berghofe@17870
    31
berghofe@17870
    32
lemma perm_fst:
berghofe@17870
    33
  "pi\<bullet>(fst x) = fst (pi\<bullet>x)"
berghofe@17870
    34
 by (cases x, simp)
berghofe@17870
    35
berghofe@17870
    36
lemma perm_snd:
berghofe@17870
    37
  "pi\<bullet>(snd x) = snd (pi\<bullet>x)"
berghofe@17870
    38
 by (cases x, simp)
berghofe@17870
    39
berghofe@17870
    40
(* permutation on lists *)
berghofe@17870
    41
primrec (perm_list)
berghofe@17870
    42
  perm_nil_def:  "pi\<bullet>[]     = []"
berghofe@17870
    43
  perm_cons_def: "pi\<bullet>(x#xs) = (pi\<bullet>x)#(pi\<bullet>xs)"
berghofe@17870
    44
berghofe@17870
    45
lemma perm_append:
berghofe@17870
    46
  fixes pi :: "'x prm"
berghofe@17870
    47
  and   l1 :: "'a list"
berghofe@17870
    48
  and   l2 :: "'a list"
berghofe@17870
    49
  shows "pi\<bullet>(l1@l2) = (pi\<bullet>l1)@(pi\<bullet>l2)"
berghofe@17870
    50
  by (induct l1, auto)
berghofe@17870
    51
berghofe@17870
    52
lemma perm_rev:
berghofe@17870
    53
  fixes pi :: "'x prm"
berghofe@17870
    54
  and   l  :: "'a list"
berghofe@17870
    55
  shows "pi\<bullet>(rev l) = rev (pi\<bullet>l)"
berghofe@17870
    56
  by (induct l, simp_all add: perm_append)
berghofe@17870
    57
berghofe@17870
    58
(* permutation on functions *)
berghofe@17870
    59
defs (overloaded)
berghofe@17870
    60
  perm_fun_def: "pi\<bullet>(f::'a\<Rightarrow>'b) \<equiv> (\<lambda>x. pi\<bullet>f((rev pi)\<bullet>x))"
berghofe@17870
    61
berghofe@17870
    62
(* permutation on bools *)
berghofe@17870
    63
primrec (perm_bool)
berghofe@17870
    64
  perm_true_def:  "pi\<bullet>True  = True"
berghofe@17870
    65
  perm_false_def: "pi\<bullet>False = False"
berghofe@17870
    66
berghofe@17870
    67
(* permutation on options *)
berghofe@17870
    68
primrec (perm_option)
berghofe@17870
    69
  perm_some_def:  "pi\<bullet>Some(x) = Some(pi\<bullet>x)"
berghofe@17870
    70
  perm_none_def:  "pi\<bullet>None    = None"
berghofe@17870
    71
berghofe@17870
    72
(* a "private" copy of the option type used in the abstraction function *)
berghofe@17870
    73
datatype 'a nOption = nSome 'a | nNone
berghofe@17870
    74
berghofe@17870
    75
primrec (perm_noption)
berghofe@17870
    76
  perm_Nsome_def:  "pi\<bullet>nSome(x) = nSome(pi\<bullet>x)"
berghofe@17870
    77
  perm_Nnone_def:  "pi\<bullet>nNone    = nNone"
berghofe@17870
    78
berghofe@17870
    79
(* permutation on characters (used in strings) *)
berghofe@17870
    80
defs (overloaded)
berghofe@17870
    81
  perm_char_def: "pi\<bullet>(s::char) \<equiv> s"
berghofe@17870
    82
berghofe@17870
    83
(* permutation on ints *)
berghofe@17870
    84
defs (overloaded)
berghofe@17870
    85
  perm_int_def:    "pi\<bullet>(i::int) \<equiv> i"
berghofe@17870
    86
berghofe@17870
    87
(* permutation on nats *)
berghofe@17870
    88
defs (overloaded)
berghofe@17870
    89
  perm_nat_def:    "pi\<bullet>(i::nat) \<equiv> i"
berghofe@17870
    90
berghofe@17870
    91
section {* permutation equality *}
berghofe@17870
    92
(*==============================*)
berghofe@17870
    93
berghofe@17870
    94
constdefs
berghofe@17870
    95
  prm_eq :: "'x prm \<Rightarrow> 'x prm \<Rightarrow> bool"  (" _ \<sim> _ " [80,80] 80)
berghofe@17870
    96
  "pi1 \<sim> pi2 \<equiv> \<forall>a::'x. pi1\<bullet>a = pi2\<bullet>a"
berghofe@17870
    97
berghofe@17870
    98
section {* Support, Freshness and Supports*}
berghofe@17870
    99
(*========================================*)
berghofe@17870
   100
constdefs
berghofe@17870
   101
   supp :: "'a \<Rightarrow> ('x set)"  
berghofe@17870
   102
   "supp x \<equiv> {a . (infinite {b . [(a,b)]\<bullet>x \<noteq> x})}"
berghofe@17870
   103
urbanc@17871
   104
   fresh :: "'x \<Rightarrow> 'a \<Rightarrow> bool" ("_ \<sharp> _" [80,80] 80)
berghofe@17870
   105
   "a \<sharp> x \<equiv> a \<notin> supp x"
berghofe@17870
   106
berghofe@17870
   107
   supports :: "'x set \<Rightarrow> 'a \<Rightarrow> bool" (infixl 80)
berghofe@17870
   108
   "S supports x \<equiv> \<forall>a b. (a\<notin>S \<and> b\<notin>S \<longrightarrow> [(a,b)]\<bullet>x=x)"
berghofe@17870
   109
berghofe@17870
   110
lemma supp_fresh_iff: 
berghofe@17870
   111
  fixes x :: "'a"
berghofe@17870
   112
  shows "(supp x) = {a::'x. \<not>a\<sharp>x}"
berghofe@17870
   113
apply(simp add: fresh_def)
berghofe@17870
   114
done
berghofe@17870
   115
berghofe@17870
   116
lemma supp_unit:
berghofe@17870
   117
  shows "supp () = {}"
berghofe@17870
   118
  by (simp add: supp_def)
berghofe@17870
   119
berghofe@17870
   120
lemma supp_prod: 
berghofe@17870
   121
  fixes x :: "'a"
berghofe@17870
   122
  and   y :: "'b"
berghofe@17870
   123
  shows "(supp (x,y)) = (supp x)\<union>(supp y)"
berghofe@17870
   124
  by  (force simp add: supp_def Collect_imp_eq Collect_neg_eq)
berghofe@17870
   125
berghofe@17870
   126
lemma supp_list_nil:
berghofe@17870
   127
  shows "supp [] = {}"
berghofe@17870
   128
apply(simp add: supp_def)
berghofe@17870
   129
done
berghofe@17870
   130
berghofe@17870
   131
lemma supp_list_cons:
berghofe@17870
   132
  fixes x  :: "'a"
berghofe@17870
   133
  and   xs :: "'a list"
berghofe@17870
   134
  shows "supp (x#xs) = (supp x)\<union>(supp xs)"
berghofe@17870
   135
apply(auto simp add: supp_def Collect_imp_eq Collect_neg_eq)
berghofe@17870
   136
done
berghofe@17870
   137
berghofe@17870
   138
lemma supp_list_append:
berghofe@17870
   139
  fixes xs :: "'a list"
berghofe@17870
   140
  and   ys :: "'a list"
berghofe@17870
   141
  shows "supp (xs@ys) = (supp xs)\<union>(supp ys)"
berghofe@17870
   142
  by (induct xs, auto simp add: supp_list_nil supp_list_cons)
berghofe@17870
   143
berghofe@17870
   144
lemma supp_list_rev:
berghofe@17870
   145
  fixes xs :: "'a list"
berghofe@17870
   146
  shows "supp (rev xs) = (supp xs)"
berghofe@17870
   147
  by (induct xs, auto simp add: supp_list_append supp_list_cons supp_list_nil)
berghofe@17870
   148
berghofe@17870
   149
lemma supp_bool:
berghofe@17870
   150
  fixes x  :: "bool"
berghofe@17870
   151
  shows "supp (x) = {}"
berghofe@17870
   152
  apply(case_tac "x")
berghofe@17870
   153
  apply(simp_all add: supp_def)
berghofe@17870
   154
done
berghofe@17870
   155
berghofe@17870
   156
lemma supp_some:
berghofe@17870
   157
  fixes x :: "'a"
berghofe@17870
   158
  shows "supp (Some x) = (supp x)"
berghofe@17870
   159
  apply(simp add: supp_def)
berghofe@17870
   160
  done
berghofe@17870
   161
berghofe@17870
   162
lemma supp_none:
berghofe@17870
   163
  fixes x :: "'a"
berghofe@17870
   164
  shows "supp (None) = {}"
berghofe@17870
   165
  apply(simp add: supp_def)
berghofe@17870
   166
  done
berghofe@17870
   167
berghofe@17870
   168
lemma supp_int:
berghofe@17870
   169
  fixes i::"int"
berghofe@17870
   170
  shows "supp (i) = {}"
berghofe@17870
   171
  apply(simp add: supp_def perm_int_def)
berghofe@17870
   172
  done
berghofe@17870
   173
berghofe@17870
   174
lemma fresh_prod:
berghofe@17870
   175
  fixes a :: "'x"
berghofe@17870
   176
  and   x :: "'a"
berghofe@17870
   177
  and   y :: "'b"
berghofe@17870
   178
  shows "a\<sharp>(x,y) = (a\<sharp>x \<and> a\<sharp>y)"
berghofe@17870
   179
  by (simp add: fresh_def supp_prod)
berghofe@17870
   180
berghofe@17870
   181
lemma fresh_list_nil:
berghofe@17870
   182
  fixes a :: "'x"
berghofe@17870
   183
  shows "a\<sharp>([]::'a list)"
berghofe@17870
   184
  by (simp add: fresh_def supp_list_nil) 
berghofe@17870
   185
berghofe@17870
   186
lemma fresh_list_cons:
berghofe@17870
   187
  fixes a :: "'x"
berghofe@17870
   188
  and   x :: "'a"
berghofe@17870
   189
  and   xs :: "'a list"
berghofe@17870
   190
  shows "a\<sharp>(x#xs) = (a\<sharp>x \<and> a\<sharp>xs)"
berghofe@17870
   191
  by (simp add: fresh_def supp_list_cons)
berghofe@17870
   192
berghofe@17870
   193
lemma fresh_list_append:
berghofe@17870
   194
  fixes a :: "'x"
berghofe@17870
   195
  and   xs :: "'a list"
berghofe@17870
   196
  and   ys :: "'a list"
berghofe@17870
   197
  shows "a\<sharp>(xs@ys) = (a\<sharp>xs \<and> a\<sharp>ys)"
berghofe@17870
   198
  by (simp add: fresh_def supp_list_append)
berghofe@17870
   199
berghofe@17870
   200
lemma fresh_list_rev:
berghofe@17870
   201
  fixes a :: "'x"
berghofe@17870
   202
  and   xs :: "'a list"
berghofe@17870
   203
  shows "a\<sharp>(rev xs) = a\<sharp>xs"
berghofe@17870
   204
  by (simp add: fresh_def supp_list_rev)
berghofe@17870
   205
berghofe@17870
   206
lemma fresh_none:
berghofe@17870
   207
  fixes a :: "'x"
berghofe@17870
   208
  shows "a\<sharp>None"
berghofe@17870
   209
  apply(simp add: fresh_def supp_none)
berghofe@17870
   210
  done
berghofe@17870
   211
berghofe@17870
   212
lemma fresh_some:
berghofe@17870
   213
  fixes a :: "'x"
berghofe@17870
   214
  and   x :: "'a"
berghofe@17870
   215
  shows "a\<sharp>(Some x) = a\<sharp>x"
berghofe@17870
   216
  apply(simp add: fresh_def supp_some)
berghofe@17870
   217
  done
berghofe@17870
   218
berghofe@17870
   219
section {* Abstract Properties for Permutations and  Atoms *}
berghofe@17870
   220
(*=========================================================*)
berghofe@17870
   221
berghofe@17870
   222
(* properties for being a permutation type *)
berghofe@17870
   223
constdefs 
berghofe@17870
   224
  "pt TYPE('a) TYPE('x) \<equiv> 
berghofe@17870
   225
     (\<forall>(x::'a). ([]::'x prm)\<bullet>x = x) \<and> 
berghofe@17870
   226
     (\<forall>(pi1::'x prm) (pi2::'x prm) (x::'a). (pi1@pi2)\<bullet>x = pi1\<bullet>(pi2\<bullet>x)) \<and> 
berghofe@17870
   227
     (\<forall>(pi1::'x prm) (pi2::'x prm) (x::'a). pi1 \<sim> pi2 \<longrightarrow> pi1\<bullet>x = pi2\<bullet>x)"
berghofe@17870
   228
berghofe@17870
   229
(* properties for being an atom type *)
berghofe@17870
   230
constdefs 
berghofe@17870
   231
  "at TYPE('x) \<equiv> 
berghofe@17870
   232
     (\<forall>(x::'x). ([]::'x prm)\<bullet>x = x) \<and>
berghofe@17870
   233
     (\<forall>(a::'x) (b::'x) (pi::'x prm) (x::'x). ((a,b)#(pi::'x prm))\<bullet>x = swap (a,b) (pi\<bullet>x)) \<and> 
berghofe@17870
   234
     (\<forall>(a::'x) (b::'x) (c::'x). swap (a,b) c = (if a=c then b else (if b=c then a else c))) \<and> 
berghofe@17870
   235
     (infinite (UNIV::'x set))"
berghofe@17870
   236
berghofe@17870
   237
(* property of two atom-types being disjoint *)
berghofe@17870
   238
constdefs
berghofe@17870
   239
  "disjoint TYPE('x) TYPE('y) \<equiv> 
berghofe@17870
   240
       (\<forall>(pi::'x prm)(x::'y). pi\<bullet>x = x) \<and> 
berghofe@17870
   241
       (\<forall>(pi::'y prm)(x::'x). pi\<bullet>x = x)"
berghofe@17870
   242
berghofe@17870
   243
(* composition property of two permutation on a type 'a *)
berghofe@17870
   244
constdefs
berghofe@17870
   245
  "cp TYPE ('a) TYPE('x) TYPE('y) \<equiv> 
berghofe@17870
   246
      (\<forall>(pi2::'y prm) (pi1::'x prm) (x::'a) . pi1\<bullet>(pi2\<bullet>x) = (pi1\<bullet>pi2)\<bullet>(pi1\<bullet>x))" 
berghofe@17870
   247
berghofe@17870
   248
(* property of having finite support *)
berghofe@17870
   249
constdefs 
berghofe@17870
   250
  "fs TYPE('a) TYPE('x) \<equiv> \<forall>(x::'a). finite ((supp x)::'x set)"
berghofe@17870
   251
berghofe@17870
   252
section {* Lemmas about the atom-type properties*}
berghofe@17870
   253
(*==============================================*)
berghofe@17870
   254
berghofe@17870
   255
lemma at1: 
berghofe@17870
   256
  fixes x::"'x"
berghofe@17870
   257
  assumes a: "at TYPE('x)"
berghofe@17870
   258
  shows "([]::'x prm)\<bullet>x = x"
berghofe@17870
   259
  using a by (simp add: at_def)
berghofe@17870
   260
berghofe@17870
   261
lemma at2: 
berghofe@17870
   262
  fixes a ::"'x"
berghofe@17870
   263
  and   b ::"'x"
berghofe@17870
   264
  and   x ::"'x"
berghofe@17870
   265
  and   pi::"'x prm"
berghofe@17870
   266
  assumes a: "at TYPE('x)"
berghofe@17870
   267
  shows "((a,b)#pi)\<bullet>x = swap (a,b) (pi\<bullet>x)"
berghofe@17870
   268
  using a by (simp only: at_def)
berghofe@17870
   269
berghofe@17870
   270
lemma at3: 
berghofe@17870
   271
  fixes a ::"'x"
berghofe@17870
   272
  and   b ::"'x"
berghofe@17870
   273
  and   c ::"'x"
berghofe@17870
   274
  assumes a: "at TYPE('x)"
berghofe@17870
   275
  shows "swap (a,b) c = (if a=c then b else (if b=c then a else c))"
berghofe@17870
   276
  using a by (simp only: at_def)
berghofe@17870
   277
berghofe@17870
   278
(* rules to calculate simple premutations *)
berghofe@17870
   279
lemmas at_calc = at2 at1 at3
berghofe@17870
   280
berghofe@17870
   281
lemma at4: 
berghofe@17870
   282
  assumes a: "at TYPE('x)"
berghofe@17870
   283
  shows "infinite (UNIV::'x set)"
berghofe@17870
   284
  using a by (simp add: at_def)
berghofe@17870
   285
berghofe@17870
   286
lemma at_append:
berghofe@17870
   287
  fixes pi1 :: "'x prm"
berghofe@17870
   288
  and   pi2 :: "'x prm"
berghofe@17870
   289
  and   c   :: "'x"
berghofe@17870
   290
  assumes at: "at TYPE('x)" 
berghofe@17870
   291
  shows "(pi1@pi2)\<bullet>c = pi1\<bullet>(pi2\<bullet>c)"
berghofe@17870
   292
proof (induct pi1)
berghofe@17870
   293
  case Nil show ?case by (simp add: at1[OF at])
berghofe@17870
   294
next
berghofe@17870
   295
  case (Cons x xs)
berghofe@17870
   296
  assume i: "(xs @ pi2)\<bullet>c  =  xs\<bullet>(pi2\<bullet>c)"
berghofe@17870
   297
  have "(x#xs)@pi2 = x#(xs@pi2)" by simp
berghofe@17870
   298
  thus ?case using i by (cases "x", simp add:  at2[OF at])
berghofe@17870
   299
qed
berghofe@17870
   300
 
berghofe@17870
   301
lemma at_swap:
berghofe@17870
   302
  fixes a :: "'x"
berghofe@17870
   303
  and   b :: "'x"
berghofe@17870
   304
  and   c :: "'x"
berghofe@17870
   305
  assumes at: "at TYPE('x)" 
berghofe@17870
   306
  shows "swap (a,b) (swap (a,b) c) = c"
berghofe@17870
   307
  by (auto simp add: at3[OF at])
berghofe@17870
   308
berghofe@17870
   309
lemma at_rev_pi:
berghofe@17870
   310
  fixes pi :: "'x prm"
berghofe@17870
   311
  and   c  :: "'x"
berghofe@17870
   312
  assumes at: "at TYPE('x)"
berghofe@17870
   313
  shows "(rev pi)\<bullet>(pi\<bullet>c) = c"
berghofe@17870
   314
proof(induct pi)
berghofe@17870
   315
  case Nil show ?case by (simp add: at1[OF at])
berghofe@17870
   316
next
berghofe@17870
   317
  case (Cons x xs) thus ?case 
berghofe@17870
   318
    by (cases "x", simp add: at2[OF at] at_append[OF at] at1[OF at] at_swap[OF at])
berghofe@17870
   319
qed
berghofe@17870
   320
berghofe@17870
   321
lemma at_pi_rev:
berghofe@17870
   322
  fixes pi :: "'x prm"
berghofe@17870
   323
  and   x  :: "'x"
berghofe@17870
   324
  assumes at: "at TYPE('x)"
berghofe@17870
   325
  shows "pi\<bullet>((rev pi)\<bullet>x) = x"
berghofe@17870
   326
  by (rule at_rev_pi[OF at, of "rev pi" _,simplified])
berghofe@17870
   327
berghofe@17870
   328
lemma at_bij1: 
berghofe@17870
   329
  fixes pi :: "'x prm"
berghofe@17870
   330
  and   x  :: "'x"
berghofe@17870
   331
  and   y  :: "'x"
berghofe@17870
   332
  assumes at: "at TYPE('x)"
berghofe@17870
   333
  and     a:  "(pi\<bullet>x) = y"
berghofe@17870
   334
  shows   "x=(rev pi)\<bullet>y"
berghofe@17870
   335
proof -
berghofe@17870
   336
  from a have "y=(pi\<bullet>x)" by (rule sym)
berghofe@17870
   337
  thus ?thesis by (simp only: at_rev_pi[OF at])
berghofe@17870
   338
qed
berghofe@17870
   339
berghofe@17870
   340
lemma at_bij2: 
berghofe@17870
   341
  fixes pi :: "'x prm"
berghofe@17870
   342
  and   x  :: "'x"
berghofe@17870
   343
  and   y  :: "'x"
berghofe@17870
   344
  assumes at: "at TYPE('x)"
berghofe@17870
   345
  and     a:  "((rev pi)\<bullet>x) = y"
berghofe@17870
   346
  shows   "x=pi\<bullet>y"
berghofe@17870
   347
proof -
berghofe@17870
   348
  from a have "y=((rev pi)\<bullet>x)" by (rule sym)
berghofe@17870
   349
  thus ?thesis by (simp only: at_pi_rev[OF at])
berghofe@17870
   350
qed
berghofe@17870
   351
berghofe@17870
   352
lemma at_bij:
berghofe@17870
   353
  fixes pi :: "'x prm"
berghofe@17870
   354
  and   x  :: "'x"
berghofe@17870
   355
  and   y  :: "'x"
berghofe@17870
   356
  assumes at: "at TYPE('x)"
berghofe@17870
   357
  shows "(pi\<bullet>x = pi\<bullet>y) = (x=y)"
berghofe@17870
   358
proof 
berghofe@17870
   359
  assume "pi\<bullet>x = pi\<bullet>y" 
berghofe@17870
   360
  hence  "x=(rev pi)\<bullet>(pi\<bullet>y)" by (rule at_bij1[OF at]) 
berghofe@17870
   361
  thus "x=y" by (simp only: at_rev_pi[OF at])
berghofe@17870
   362
next
berghofe@17870
   363
  assume "x=y"
berghofe@17870
   364
  thus "pi\<bullet>x = pi\<bullet>y" by simp
berghofe@17870
   365
qed
berghofe@17870
   366
berghofe@17870
   367
lemma at_supp:
berghofe@17870
   368
  fixes x :: "'x"
berghofe@17870
   369
  assumes at: "at TYPE('x)"
berghofe@17870
   370
  shows "supp x = {x}"
berghofe@17870
   371
proof (simp add: supp_def Collect_conj_eq Collect_imp_eq at_calc[OF at], auto)
berghofe@17870
   372
  assume f: "finite {b::'x. b \<noteq> x}"
berghofe@17870
   373
  have a1: "{b::'x. b \<noteq> x} = UNIV-{x}" by force
berghofe@17870
   374
  have a2: "infinite (UNIV::'x set)" by (rule at4[OF at])
berghofe@17870
   375
  from f a1 a2 show False by force
berghofe@17870
   376
qed
berghofe@17870
   377
berghofe@17870
   378
lemma at_fresh:
berghofe@17870
   379
  fixes a :: "'x"
berghofe@17870
   380
  and   b :: "'x"
berghofe@17870
   381
  assumes at: "at TYPE('x)"
berghofe@17870
   382
  shows "(a\<sharp>b) = (a\<noteq>b)" 
berghofe@17870
   383
  by (simp add: at_supp[OF at] fresh_def)
berghofe@17870
   384
berghofe@17870
   385
lemma at_prm_fresh[rule_format]:
berghofe@17870
   386
  fixes c :: "'x"
berghofe@17870
   387
  and   pi:: "'x prm"
berghofe@17870
   388
  assumes at: "at TYPE('x)"
berghofe@17870
   389
  shows "c\<sharp>pi \<longrightarrow> pi\<bullet>c = c"
berghofe@17870
   390
apply(induct pi)
berghofe@17870
   391
apply(simp add: at1[OF at]) 
berghofe@17870
   392
apply(force simp add: fresh_list_cons at2[OF at] fresh_prod at_fresh[OF at] at3[OF at])
berghofe@17870
   393
done
berghofe@17870
   394
berghofe@17870
   395
lemma at_prm_rev_eq:
berghofe@17870
   396
  fixes pi1 :: "'x prm"
berghofe@17870
   397
  and   pi2 :: "'x prm"
berghofe@17870
   398
  assumes at: "at TYPE('x)"
berghofe@17870
   399
  shows a: "((rev pi1) \<sim> (rev pi2)) = (pi1 \<sim> pi2)"
berghofe@17870
   400
proof (simp add: prm_eq_def, auto)
berghofe@17870
   401
  fix x
berghofe@17870
   402
  assume "\<forall>x::'x. (rev pi1)\<bullet>x = (rev pi2)\<bullet>x"
berghofe@17870
   403
  hence "(rev (pi1::'x prm))\<bullet>(pi2\<bullet>(x::'x)) = (rev (pi2::'x prm))\<bullet>(pi2\<bullet>x)" by simp
berghofe@17870
   404
  hence "(rev (pi1::'x prm))\<bullet>((pi2::'x prm)\<bullet>x) = (x::'x)" by (simp add: at_rev_pi[OF at])
berghofe@17870
   405
  hence "(pi2::'x prm)\<bullet>x = (pi1::'x prm)\<bullet>x" by (simp add: at_bij2[OF at])
berghofe@17870
   406
  thus "pi1 \<bullet> x  =  pi2 \<bullet> x" by simp
berghofe@17870
   407
next
berghofe@17870
   408
  fix x
berghofe@17870
   409
  assume "\<forall>x::'x. pi1\<bullet>x = pi2\<bullet>x"
berghofe@17870
   410
  hence "(pi1::'x prm)\<bullet>((rev pi2)\<bullet>x) = (pi2::'x prm)\<bullet>((rev pi2)\<bullet>(x::'x))" by simp
berghofe@17870
   411
  hence "(pi1::'x prm)\<bullet>((rev pi2)\<bullet>(x::'x)) = x" by (simp add: at_pi_rev[OF at])
berghofe@17870
   412
  hence "(rev pi2)\<bullet>x = (rev pi1)\<bullet>(x::'x)" by (simp add: at_bij1[OF at])
berghofe@17870
   413
  thus "(rev pi1)\<bullet>x = (rev pi2)\<bullet>(x::'x)" by simp
berghofe@17870
   414
qed
berghofe@17870
   415
  
berghofe@17870
   416
lemma at_prm_rev_eq1:
berghofe@17870
   417
  fixes pi1 :: "'x prm"
berghofe@17870
   418
  and   pi2 :: "'x prm"
berghofe@17870
   419
  assumes at: "at TYPE('x)"
berghofe@17870
   420
  shows "pi1 \<sim> pi2 \<Longrightarrow> (rev pi1) \<sim> (rev pi2)"
berghofe@17870
   421
  by (simp add: at_prm_rev_eq[OF at])
berghofe@17870
   422
berghofe@17870
   423
lemma at_ds1:
berghofe@17870
   424
  fixes a  :: "'x"
berghofe@17870
   425
  assumes at: "at TYPE('x)"
berghofe@17870
   426
  shows "[(a,a)] \<sim> []"
berghofe@17870
   427
  by (force simp add: prm_eq_def at_calc[OF at])
berghofe@17870
   428
berghofe@17870
   429
lemma at_ds2: 
berghofe@17870
   430
  fixes pi :: "'x prm"
berghofe@17870
   431
  and   a  :: "'x"
berghofe@17870
   432
  and   b  :: "'x"
berghofe@17870
   433
  assumes at: "at TYPE('x)"
berghofe@17870
   434
  shows "(pi@[((rev pi)\<bullet>a,(rev pi)\<bullet>b)]) \<sim> ([(a,b)]@pi)"
berghofe@17870
   435
  by (force simp add: prm_eq_def at_append[OF at] at_bij[OF at] at_pi_rev[OF at] 
berghofe@17870
   436
      at_rev_pi[OF at] at_calc[OF at])
berghofe@17870
   437
berghofe@17870
   438
lemma at_ds3: 
berghofe@17870
   439
  fixes a  :: "'x"
berghofe@17870
   440
  and   b  :: "'x"
berghofe@17870
   441
  and   c  :: "'x"
berghofe@17870
   442
  assumes at: "at TYPE('x)"
berghofe@17870
   443
  and     a:  "distinct [a,b,c]"
berghofe@17870
   444
  shows "[(a,c),(b,c),(a,c)] \<sim> [(a,b)]"
berghofe@17870
   445
  using a by (force simp add: prm_eq_def at_calc[OF at])
berghofe@17870
   446
berghofe@17870
   447
lemma at_ds4: 
berghofe@17870
   448
  fixes a  :: "'x"
berghofe@17870
   449
  and   b  :: "'x"
berghofe@17870
   450
  and   pi  :: "'x prm"
berghofe@17870
   451
  assumes at: "at TYPE('x)"
berghofe@17870
   452
  shows "(pi@[(a,(rev pi)\<bullet>b)]) \<sim> ([(pi\<bullet>a,b)]@pi)"
berghofe@17870
   453
  by (force simp add: prm_eq_def at_append[OF at] at_calc[OF at] at_bij[OF at] 
berghofe@17870
   454
      at_pi_rev[OF at] at_rev_pi[OF at])
berghofe@17870
   455
berghofe@17870
   456
lemma at_ds5: 
berghofe@17870
   457
  fixes a  :: "'x"
berghofe@17870
   458
  and   b  :: "'x"
berghofe@17870
   459
  assumes at: "at TYPE('x)"
berghofe@17870
   460
  shows "[(a,b)] \<sim> [(b,a)]"
berghofe@17870
   461
  by (force simp add: prm_eq_def at_calc[OF at])
berghofe@17870
   462
berghofe@17870
   463
lemma at_ds6: 
berghofe@17870
   464
  fixes a  :: "'x"
berghofe@17870
   465
  and   b  :: "'x"
berghofe@17870
   466
  and   c  :: "'x"
berghofe@17870
   467
  assumes at: "at TYPE('x)"
berghofe@17870
   468
  and     a: "distinct [a,b,c]"
berghofe@17870
   469
  shows "[(a,c),(a,b)] \<sim> [(b,c),(a,c)]"
berghofe@17870
   470
  using a by (force simp add: prm_eq_def at_calc[OF at])
berghofe@17870
   471
berghofe@17870
   472
lemma at_ds7:
berghofe@17870
   473
  fixes pi :: "'x prm"
berghofe@17870
   474
  assumes at: "at TYPE('x)"
berghofe@17870
   475
  shows "((rev pi)@pi) \<sim> []"
berghofe@17870
   476
  by (simp add: prm_eq_def at1[OF at] at_append[OF at] at_rev_pi[OF at])
berghofe@17870
   477
berghofe@17870
   478
lemma at_ds8_aux:
berghofe@17870
   479
  fixes pi :: "'x prm"
berghofe@17870
   480
  and   a  :: "'x"
berghofe@17870
   481
  and   b  :: "'x"
berghofe@17870
   482
  and   c  :: "'x"
berghofe@17870
   483
  assumes at: "at TYPE('x)"
berghofe@17870
   484
  shows "pi\<bullet>(swap (a,b) c) = swap (pi\<bullet>a,pi\<bullet>b) (pi\<bullet>c)"
berghofe@17870
   485
  by (force simp add: at_calc[OF at] at_bij[OF at])
berghofe@17870
   486
berghofe@17870
   487
lemma at_ds8: 
berghofe@17870
   488
  fixes pi1 :: "'x prm"
berghofe@17870
   489
  and   pi2 :: "'x prm"
berghofe@17870
   490
  and   a  :: "'x"
berghofe@17870
   491
  and   b  :: "'x"
berghofe@17870
   492
  assumes at: "at TYPE('x)"
berghofe@17870
   493
  shows "(pi1@pi2) \<sim> ((pi1\<bullet>pi2)@pi1)"
berghofe@17870
   494
apply(induct_tac pi2)
berghofe@17870
   495
apply(simp add: prm_eq_def)
berghofe@17870
   496
apply(auto simp add: prm_eq_def)
berghofe@17870
   497
apply(simp add: at2[OF at])
berghofe@17870
   498
apply(drule_tac x="aa" in spec)
berghofe@17870
   499
apply(drule sym)
berghofe@17870
   500
apply(simp)
berghofe@17870
   501
apply(simp add: at_append[OF at])
berghofe@17870
   502
apply(simp add: at2[OF at])
berghofe@17870
   503
apply(simp add: at_ds8_aux[OF at])
berghofe@17870
   504
done
berghofe@17870
   505
berghofe@17870
   506
lemma at_ds9: 
berghofe@17870
   507
  fixes pi1 :: "'x prm"
berghofe@17870
   508
  and   pi2 :: "'x prm"
berghofe@17870
   509
  and   a  :: "'x"
berghofe@17870
   510
  and   b  :: "'x"
berghofe@17870
   511
  assumes at: "at TYPE('x)"
berghofe@17870
   512
  shows " ((rev pi2)@(rev pi1)) \<sim> ((rev pi1)@(rev (pi1\<bullet>pi2)))"
berghofe@17870
   513
apply(induct_tac pi2)
berghofe@17870
   514
apply(simp add: prm_eq_def)
berghofe@17870
   515
apply(auto simp add: prm_eq_def)
berghofe@17870
   516
apply(simp add: at_append[OF at])
berghofe@17870
   517
apply(simp add: at2[OF at] at1[OF at])
berghofe@17870
   518
apply(drule_tac x="swap(pi1\<bullet>a,pi1\<bullet>b) aa" in spec)
berghofe@17870
   519
apply(drule sym)
berghofe@17870
   520
apply(simp)
berghofe@17870
   521
apply(simp add: at_ds8_aux[OF at])
berghofe@17870
   522
apply(simp add: at_rev_pi[OF at])
berghofe@17870
   523
done
berghofe@17870
   524
berghofe@17870
   525
--"there always exists an atom not being in a finite set"
berghofe@17870
   526
lemma ex_in_inf:
berghofe@17870
   527
  fixes   A::"'x set"
berghofe@17870
   528
  assumes at: "at TYPE('x)"
berghofe@17870
   529
  and     fs: "finite A"
berghofe@17870
   530
  shows "\<exists>c::'x. c\<notin>A"
berghofe@17870
   531
proof -
berghofe@17870
   532
  from  fs at4[OF at] have "infinite ((UNIV::'x set) - A)" 
berghofe@17870
   533
    by (simp add: Diff_infinite_finite)
berghofe@17870
   534
  hence "((UNIV::'x set) - A) \<noteq> ({}::'x set)" by (force simp only:)
berghofe@17870
   535
  hence "\<exists>c::'x. c\<in>((UNIV::'x set) - A)" by force
berghofe@17870
   536
  thus "\<exists>c::'x. c\<notin>A" by force
berghofe@17870
   537
qed
berghofe@17870
   538
berghofe@17870
   539
--"there always exists a fresh name for an object with finite support"
berghofe@17870
   540
lemma at_exists_fresh: 
berghofe@17870
   541
  fixes  x :: "'a"
berghofe@17870
   542
  assumes at: "at TYPE('x)"
berghofe@17870
   543
  and     fs: "finite ((supp x)::'x set)"
berghofe@17870
   544
  shows "\<exists>c::'x. c\<sharp>x"
berghofe@17870
   545
  by (simp add: fresh_def, rule ex_in_inf[OF at, OF fs])
berghofe@17870
   546
berghofe@17870
   547
--"the at-props imply the pt-props"
berghofe@17870
   548
lemma at_pt_inst:
berghofe@17870
   549
  assumes at: "at TYPE('x)"
berghofe@17870
   550
  shows "pt TYPE('x) TYPE('x)"
berghofe@17870
   551
apply(auto simp only: pt_def)
berghofe@17870
   552
apply(simp only: at1[OF at])
berghofe@17870
   553
apply(simp only: at_append[OF at]) 
berghofe@17870
   554
apply(simp add: prm_eq_def)
berghofe@17870
   555
done
berghofe@17870
   556
berghofe@17870
   557
section {* finite support properties *}
berghofe@17870
   558
(*===================================*)
berghofe@17870
   559
berghofe@17870
   560
lemma fs1:
berghofe@17870
   561
  fixes x :: "'a"
berghofe@17870
   562
  assumes a: "fs TYPE('a) TYPE('x)"
berghofe@17870
   563
  shows "finite ((supp x)::'x set)"
berghofe@17870
   564
  using a by (simp add: fs_def)
berghofe@17870
   565
berghofe@17870
   566
lemma fs_at_inst:
berghofe@17870
   567
  fixes a :: "'x"
berghofe@17870
   568
  assumes at: "at TYPE('x)"
berghofe@17870
   569
  shows "fs TYPE('x) TYPE('x)"
berghofe@17870
   570
apply(simp add: fs_def) 
berghofe@17870
   571
apply(simp add: at_supp[OF at])
berghofe@17870
   572
done
berghofe@17870
   573
berghofe@17870
   574
lemma fs_unit_inst:
berghofe@17870
   575
  shows "fs TYPE(unit) TYPE('x)"
berghofe@17870
   576
apply(simp add: fs_def)
berghofe@17870
   577
apply(simp add: supp_unit)
berghofe@17870
   578
done
berghofe@17870
   579
berghofe@17870
   580
lemma fs_prod_inst:
berghofe@17870
   581
  assumes fsa: "fs TYPE('a) TYPE('x)"
berghofe@17870
   582
  and     fsb: "fs TYPE('b) TYPE('x)"
berghofe@17870
   583
  shows "fs TYPE('a\<times>'b) TYPE('x)"
berghofe@17870
   584
apply(unfold fs_def)
berghofe@17870
   585
apply(auto simp add: supp_prod)
berghofe@17870
   586
apply(rule fs1[OF fsa])
berghofe@17870
   587
apply(rule fs1[OF fsb])
berghofe@17870
   588
done
berghofe@17870
   589
berghofe@17870
   590
lemma fs_list_inst:
berghofe@17870
   591
  assumes fs: "fs TYPE('a) TYPE('x)"
berghofe@17870
   592
  shows "fs TYPE('a list) TYPE('x)"
berghofe@17870
   593
apply(simp add: fs_def, rule allI)
berghofe@17870
   594
apply(induct_tac x)
berghofe@17870
   595
apply(simp add: supp_list_nil)
berghofe@17870
   596
apply(simp add: supp_list_cons)
berghofe@17870
   597
apply(rule fs1[OF fs])
berghofe@17870
   598
done
berghofe@17870
   599
berghofe@17870
   600
lemma fs_bool_inst:
berghofe@17870
   601
  shows "fs TYPE(bool) TYPE('x)"
berghofe@17870
   602
apply(simp add: fs_def, rule allI)
berghofe@17870
   603
apply(simp add: supp_bool)
berghofe@17870
   604
done
berghofe@17870
   605
berghofe@17870
   606
lemma fs_int_inst:
berghofe@17870
   607
  shows "fs TYPE(int) TYPE('x)"
berghofe@17870
   608
apply(simp add: fs_def, rule allI)
berghofe@17870
   609
apply(simp add: supp_int)
berghofe@17870
   610
done
berghofe@17870
   611
berghofe@17870
   612
section {* Lemmas about the permutation properties *}
berghofe@17870
   613
(*=================================================*)
berghofe@17870
   614
berghofe@17870
   615
lemma pt1:
berghofe@17870
   616
  fixes x::"'a"
berghofe@17870
   617
  assumes a: "pt TYPE('a) TYPE('x)"
berghofe@17870
   618
  shows "([]::'x prm)\<bullet>x = x"
berghofe@17870
   619
  using a by (simp add: pt_def)
berghofe@17870
   620
berghofe@17870
   621
lemma pt2: 
berghofe@17870
   622
  fixes pi1::"'x prm"
berghofe@17870
   623
  and   pi2::"'x prm"
berghofe@17870
   624
  and   x  ::"'a"
berghofe@17870
   625
  assumes a: "pt TYPE('a) TYPE('x)"
berghofe@17870
   626
  shows "(pi1@pi2)\<bullet>x = pi1\<bullet>(pi2\<bullet>x)"
berghofe@17870
   627
  using a by (simp add: pt_def)
berghofe@17870
   628
berghofe@17870
   629
lemma pt3:
berghofe@17870
   630
  fixes pi1::"'x prm"
berghofe@17870
   631
  and   pi2::"'x prm"
berghofe@17870
   632
  and   x  ::"'a"
berghofe@17870
   633
  assumes a: "pt TYPE('a) TYPE('x)"
berghofe@17870
   634
  shows "pi1 \<sim> pi2 \<Longrightarrow> pi1\<bullet>x = pi2\<bullet>x"
berghofe@17870
   635
  using a by (simp add: pt_def)
berghofe@17870
   636
berghofe@17870
   637
lemma pt3_rev:
berghofe@17870
   638
  fixes pi1::"'x prm"
berghofe@17870
   639
  and   pi2::"'x prm"
berghofe@17870
   640
  and   x  ::"'a"
berghofe@17870
   641
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   642
  and     at: "at TYPE('x)"
berghofe@17870
   643
  shows "pi1 \<sim> pi2 \<Longrightarrow> (rev pi1)\<bullet>x = (rev pi2)\<bullet>x"
berghofe@17870
   644
  by (rule pt3[OF pt], simp add: at_prm_rev_eq[OF at])
berghofe@17870
   645
berghofe@17870
   646
section {* composition properties *}
berghofe@17870
   647
(* ============================== *)
berghofe@17870
   648
lemma cp1:
berghofe@17870
   649
  fixes pi1::"'x prm"
berghofe@17870
   650
  and   pi2::"'y prm"
berghofe@17870
   651
  and   x  ::"'a"
berghofe@17870
   652
  assumes cp: "cp TYPE ('a) TYPE('x) TYPE('y)"
berghofe@17870
   653
  shows "pi1\<bullet>(pi2\<bullet>x) = (pi1\<bullet>pi2)\<bullet>(pi1\<bullet>x)"
berghofe@17870
   654
  using cp by (simp add: cp_def)
berghofe@17870
   655
berghofe@17870
   656
lemma cp_pt_inst:
berghofe@17870
   657
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   658
  and     at: "at TYPE('x)"
berghofe@17870
   659
  shows "cp TYPE('a) TYPE('x) TYPE('x)"
berghofe@17870
   660
apply(auto simp add: cp_def pt2[OF pt,symmetric])
berghofe@17870
   661
apply(rule pt3[OF pt])
berghofe@17870
   662
apply(rule at_ds8[OF at])
berghofe@17870
   663
done
berghofe@17870
   664
berghofe@17870
   665
section {* permutation type instances *}
berghofe@17870
   666
(* ===================================*)
berghofe@17870
   667
berghofe@17870
   668
lemma pt_set_inst:
berghofe@17870
   669
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   670
  shows  "pt TYPE('a set) TYPE('x)"
berghofe@17870
   671
apply(simp add: pt_def)
berghofe@17870
   672
apply(simp_all add: perm_set_def)
berghofe@17870
   673
apply(simp add: pt1[OF pt])
berghofe@17870
   674
apply(force simp add: pt2[OF pt] pt3[OF pt])
berghofe@17870
   675
done
berghofe@17870
   676
berghofe@17870
   677
lemma pt_list_nil: 
berghofe@17870
   678
  fixes xs :: "'a list"
berghofe@17870
   679
  assumes pt: "pt TYPE('a) TYPE ('x)"
berghofe@17870
   680
  shows "([]::'x prm)\<bullet>xs = xs" 
berghofe@17870
   681
apply(induct_tac xs)
berghofe@17870
   682
apply(simp_all add: pt1[OF pt])
berghofe@17870
   683
done
berghofe@17870
   684
berghofe@17870
   685
lemma pt_list_append: 
berghofe@17870
   686
  fixes pi1 :: "'x prm"
berghofe@17870
   687
  and   pi2 :: "'x prm"
berghofe@17870
   688
  and   xs  :: "'a list"
berghofe@17870
   689
  assumes pt: "pt TYPE('a) TYPE ('x)"
berghofe@17870
   690
  shows "(pi1@pi2)\<bullet>xs = pi1\<bullet>(pi2\<bullet>xs)"
berghofe@17870
   691
apply(induct_tac xs)
berghofe@17870
   692
apply(simp_all add: pt2[OF pt])
berghofe@17870
   693
done
berghofe@17870
   694
berghofe@17870
   695
lemma pt_list_prm_eq: 
berghofe@17870
   696
  fixes pi1 :: "'x prm"
berghofe@17870
   697
  and   pi2 :: "'x prm"
berghofe@17870
   698
  and   xs  :: "'a list"
berghofe@17870
   699
  assumes pt: "pt TYPE('a) TYPE ('x)"
berghofe@17870
   700
  shows "pi1 \<sim> pi2  \<Longrightarrow> pi1\<bullet>xs = pi2\<bullet>xs"
berghofe@17870
   701
apply(induct_tac xs)
berghofe@17870
   702
apply(simp_all add: prm_eq_def pt3[OF pt])
berghofe@17870
   703
done
berghofe@17870
   704
berghofe@17870
   705
lemma pt_list_inst:
berghofe@17870
   706
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   707
  shows  "pt TYPE('a list) TYPE('x)"
berghofe@17870
   708
apply(auto simp only: pt_def)
berghofe@17870
   709
apply(rule pt_list_nil[OF pt])
berghofe@17870
   710
apply(rule pt_list_append[OF pt])
berghofe@17870
   711
apply(rule pt_list_prm_eq[OF pt],assumption)
berghofe@17870
   712
done
berghofe@17870
   713
berghofe@17870
   714
lemma pt_unit_inst:
berghofe@17870
   715
  shows  "pt TYPE(unit) TYPE('x)"
berghofe@17870
   716
  by (simp add: pt_def)
berghofe@17870
   717
berghofe@17870
   718
lemma pt_prod_inst:
berghofe@17870
   719
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
   720
  and     ptb: "pt TYPE('b) TYPE('x)"
berghofe@17870
   721
  shows  "pt TYPE('a \<times> 'b) TYPE('x)"
berghofe@17870
   722
  apply(auto simp add: pt_def)
berghofe@17870
   723
  apply(rule pt1[OF pta])
berghofe@17870
   724
  apply(rule pt1[OF ptb])
berghofe@17870
   725
  apply(rule pt2[OF pta])
berghofe@17870
   726
  apply(rule pt2[OF ptb])
berghofe@17870
   727
  apply(rule pt3[OF pta],assumption)
berghofe@17870
   728
  apply(rule pt3[OF ptb],assumption)
berghofe@17870
   729
  done
berghofe@17870
   730
berghofe@17870
   731
lemma pt_fun_inst:
berghofe@17870
   732
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
   733
  and     ptb: "pt TYPE('b) TYPE('x)"
berghofe@17870
   734
  and     at:  "at TYPE('x)"
berghofe@17870
   735
  shows  "pt TYPE('a\<Rightarrow>'b) TYPE('x)"
berghofe@17870
   736
apply(auto simp only: pt_def)
berghofe@17870
   737
apply(simp_all add: perm_fun_def)
berghofe@17870
   738
apply(simp add: pt1[OF pta] pt1[OF ptb])
berghofe@17870
   739
apply(simp add: pt2[OF pta] pt2[OF ptb])
berghofe@17870
   740
apply(subgoal_tac "(rev pi1) \<sim> (rev pi2)")(*A*)
berghofe@17870
   741
apply(simp add: pt3[OF pta] pt3[OF ptb])
berghofe@17870
   742
(*A*)
berghofe@17870
   743
apply(simp add: at_prm_rev_eq[OF at])
berghofe@17870
   744
done
berghofe@17870
   745
berghofe@17870
   746
lemma pt_option_inst:
berghofe@17870
   747
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
   748
  shows  "pt TYPE('a option) TYPE('x)"
berghofe@17870
   749
apply(auto simp only: pt_def)
berghofe@17870
   750
apply(case_tac "x")
berghofe@17870
   751
apply(simp_all add: pt1[OF pta])
berghofe@17870
   752
apply(case_tac "x")
berghofe@17870
   753
apply(simp_all add: pt2[OF pta])
berghofe@17870
   754
apply(case_tac "x")
berghofe@17870
   755
apply(simp_all add: pt3[OF pta])
berghofe@17870
   756
done
berghofe@17870
   757
berghofe@17870
   758
lemma pt_noption_inst:
berghofe@17870
   759
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
   760
  shows  "pt TYPE('a nOption) TYPE('x)"
berghofe@17870
   761
apply(auto simp only: pt_def)
berghofe@17870
   762
apply(case_tac "x")
berghofe@17870
   763
apply(simp_all add: pt1[OF pta])
berghofe@17870
   764
apply(case_tac "x")
berghofe@17870
   765
apply(simp_all add: pt2[OF pta])
berghofe@17870
   766
apply(case_tac "x")
berghofe@17870
   767
apply(simp_all add: pt3[OF pta])
berghofe@17870
   768
done
berghofe@17870
   769
berghofe@17870
   770
lemma pt_bool_inst:
berghofe@17870
   771
  shows  "pt TYPE(bool) TYPE('x)"
berghofe@17870
   772
  apply(auto simp add: pt_def)
berghofe@17870
   773
  apply(case_tac "x=True", simp add: perm_bool_def, simp add: perm_bool_def)+
berghofe@17870
   774
  done
berghofe@17870
   775
berghofe@17870
   776
lemma pt_prm_inst:
berghofe@17870
   777
  assumes at: "at TYPE('x)"
berghofe@17870
   778
  shows  "pt TYPE('x prm) TYPE('x)"
berghofe@17870
   779
apply(rule pt_list_inst)
berghofe@17870
   780
apply(rule pt_prod_inst)
berghofe@17870
   781
apply(rule at_pt_inst[OF at])+
berghofe@17870
   782
done
berghofe@17870
   783
berghofe@17870
   784
section {* further lemmas for permutation types *}
berghofe@17870
   785
(*==============================================*)
berghofe@17870
   786
berghofe@17870
   787
lemma pt_rev_pi:
berghofe@17870
   788
  fixes pi :: "'x prm"
berghofe@17870
   789
  and   x  :: "'a"
berghofe@17870
   790
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   791
  and     at: "at TYPE('x)"
berghofe@17870
   792
  shows "(rev pi)\<bullet>(pi\<bullet>x) = x"
berghofe@17870
   793
proof -
berghofe@17870
   794
  have "((rev pi)@pi) \<sim> ([]::'x prm)" by (simp add: at_ds7[OF at])
berghofe@17870
   795
  hence "((rev pi)@pi)\<bullet>(x::'a) = ([]::'x prm)\<bullet>x" by (simp add: pt3[OF pt]) 
berghofe@17870
   796
  thus ?thesis by (simp add: pt1[OF pt] pt2[OF pt])
berghofe@17870
   797
qed
berghofe@17870
   798
berghofe@17870
   799
lemma pt_pi_rev:
berghofe@17870
   800
  fixes pi :: "'x prm"
berghofe@17870
   801
  and   x  :: "'a"
berghofe@17870
   802
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   803
  and     at: "at TYPE('x)"
berghofe@17870
   804
  shows "pi\<bullet>((rev pi)\<bullet>x) = x"
berghofe@17870
   805
  by (simp add: pt_rev_pi[OF pt, OF at,of "rev pi" "x",simplified])
berghofe@17870
   806
berghofe@17870
   807
lemma pt_bij1: 
berghofe@17870
   808
  fixes pi :: "'x prm"
berghofe@17870
   809
  and   x  :: "'a"
berghofe@17870
   810
  and   y  :: "'a"
berghofe@17870
   811
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   812
  and     at: "at TYPE('x)"
berghofe@17870
   813
  and     a:  "(pi\<bullet>x) = y"
berghofe@17870
   814
  shows   "x=(rev pi)\<bullet>y"
berghofe@17870
   815
proof -
berghofe@17870
   816
  from a have "y=(pi\<bullet>x)" by (rule sym)
berghofe@17870
   817
  thus ?thesis by (simp only: pt_rev_pi[OF pt, OF at])
berghofe@17870
   818
qed
berghofe@17870
   819
berghofe@17870
   820
lemma pt_bij2: 
berghofe@17870
   821
  fixes pi :: "'x prm"
berghofe@17870
   822
  and   x  :: "'a"
berghofe@17870
   823
  and   y  :: "'a"
berghofe@17870
   824
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   825
  and     at: "at TYPE('x)"
berghofe@17870
   826
  and     a:  "x = (rev pi)\<bullet>y"
berghofe@17870
   827
  shows   "(pi\<bullet>x)=y"
berghofe@17870
   828
  using a by (simp add: pt_pi_rev[OF pt, OF at])
berghofe@17870
   829
berghofe@17870
   830
lemma pt_bij:
berghofe@17870
   831
  fixes pi :: "'x prm"
berghofe@17870
   832
  and   x  :: "'a"
berghofe@17870
   833
  and   y  :: "'a"
berghofe@17870
   834
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   835
  and     at: "at TYPE('x)"
berghofe@17870
   836
  shows "(pi\<bullet>x = pi\<bullet>y) = (x=y)"
berghofe@17870
   837
proof 
berghofe@17870
   838
  assume "pi\<bullet>x = pi\<bullet>y" 
berghofe@17870
   839
  hence  "x=(rev pi)\<bullet>(pi\<bullet>y)" by (rule pt_bij1[OF pt, OF at]) 
berghofe@17870
   840
  thus "x=y" by (simp only: pt_rev_pi[OF pt, OF at])
berghofe@17870
   841
next
berghofe@17870
   842
  assume "x=y"
berghofe@17870
   843
  thus "pi\<bullet>x = pi\<bullet>y" by simp
berghofe@17870
   844
qed
berghofe@17870
   845
berghofe@17870
   846
lemma pt_bij3:
berghofe@17870
   847
  fixes pi :: "'x prm"
berghofe@17870
   848
  and   x  :: "'a"
berghofe@17870
   849
  and   y  :: "'a"
berghofe@17870
   850
  assumes a:  "x=y"
berghofe@17870
   851
  shows "(pi\<bullet>x = pi\<bullet>y)"
berghofe@17870
   852
using a by simp 
berghofe@17870
   853
berghofe@17870
   854
lemma pt_bij4:
berghofe@17870
   855
  fixes pi :: "'x prm"
berghofe@17870
   856
  and   x  :: "'a"
berghofe@17870
   857
  and   y  :: "'a"
berghofe@17870
   858
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   859
  and     at: "at TYPE('x)"
berghofe@17870
   860
  and     a:  "pi\<bullet>x = pi\<bullet>y"
berghofe@17870
   861
  shows "x = y"
berghofe@17870
   862
using a by (simp add: pt_bij[OF pt, OF at])
berghofe@17870
   863
berghofe@17870
   864
lemma pt_swap_bij:
berghofe@17870
   865
  fixes a  :: "'x"
berghofe@17870
   866
  and   b  :: "'x"
berghofe@17870
   867
  and   x  :: "'a"
berghofe@17870
   868
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   869
  and     at: "at TYPE('x)"
berghofe@17870
   870
  shows "[(a,b)]\<bullet>([(a,b)]\<bullet>x) = x"
berghofe@17870
   871
  by (rule pt_bij2[OF pt, OF at], simp)
berghofe@17870
   872
berghofe@17870
   873
lemma pt_set_bij1:
berghofe@17870
   874
  fixes pi :: "'x prm"
berghofe@17870
   875
  and   x  :: "'a"
berghofe@17870
   876
  and   X  :: "'a set"
berghofe@17870
   877
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   878
  and     at: "at TYPE('x)"
berghofe@17870
   879
  shows "((pi\<bullet>x)\<in>X) = (x\<in>((rev pi)\<bullet>X))"
berghofe@17870
   880
  by (force simp add: perm_set_def pt_rev_pi[OF pt, OF at] pt_pi_rev[OF pt, OF at])
berghofe@17870
   881
berghofe@17870
   882
lemma pt_set_bij1a:
berghofe@17870
   883
  fixes pi :: "'x prm"
berghofe@17870
   884
  and   x  :: "'a"
berghofe@17870
   885
  and   X  :: "'a set"
berghofe@17870
   886
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   887
  and     at: "at TYPE('x)"
berghofe@17870
   888
  shows "(x\<in>(pi\<bullet>X)) = (((rev pi)\<bullet>x)\<in>X)"
berghofe@17870
   889
  by (force simp add: perm_set_def pt_rev_pi[OF pt, OF at] pt_pi_rev[OF pt, OF at])
berghofe@17870
   890
berghofe@17870
   891
lemma pt_set_bij:
berghofe@17870
   892
  fixes pi :: "'x prm"
berghofe@17870
   893
  and   x  :: "'a"
berghofe@17870
   894
  and   X  :: "'a set"
berghofe@17870
   895
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   896
  and     at: "at TYPE('x)"
berghofe@17870
   897
  shows "((pi\<bullet>x)\<in>(pi\<bullet>X)) = (x\<in>X)"
berghofe@17870
   898
  by (simp add: perm_set_def pt_set_bij1[OF pt, OF at] pt_bij[OF pt, OF at])
berghofe@17870
   899
berghofe@17870
   900
lemma pt_set_bij2:
berghofe@17870
   901
  fixes pi :: "'x prm"
berghofe@17870
   902
  and   x  :: "'a"
berghofe@17870
   903
  and   X  :: "'a set"
berghofe@17870
   904
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   905
  and     at: "at TYPE('x)"
berghofe@17870
   906
  and     a:  "x\<in>X"
berghofe@17870
   907
  shows "(pi\<bullet>x)\<in>(pi\<bullet>X)"
berghofe@17870
   908
  using a by (simp add: pt_set_bij[OF pt, OF at])
berghofe@17870
   909
berghofe@17870
   910
lemma pt_set_bij3:
berghofe@17870
   911
  fixes pi :: "'x prm"
berghofe@17870
   912
  and   x  :: "'a"
berghofe@17870
   913
  and   X  :: "'a set"
berghofe@17870
   914
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   915
  and     at: "at TYPE('x)"
berghofe@17870
   916
  shows "pi\<bullet>(x\<in>X) = (x\<in>X)"
berghofe@17870
   917
apply(case_tac "x\<in>X = True")
berghofe@17870
   918
apply(auto)
berghofe@17870
   919
done
berghofe@17870
   920
berghofe@17870
   921
lemma pt_list_set_pi:
berghofe@17870
   922
  fixes pi :: "'x prm"
berghofe@17870
   923
  and   xs :: "'a list"
berghofe@17870
   924
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
   925
  shows "pi\<bullet>(set xs) = set (pi\<bullet>xs)"
berghofe@17870
   926
by (induct xs, auto simp add: perm_set_def pt1[OF pt])
berghofe@17870
   927
berghofe@17870
   928
-- "some helper lemmas for the pt_perm_supp_ineq lemma"
berghofe@17870
   929
lemma Collect_permI: 
berghofe@17870
   930
  fixes pi :: "'x prm"
berghofe@17870
   931
  and   x  :: "'a"
berghofe@17870
   932
  assumes a: "\<forall>x. (P1 x = P2 x)" 
berghofe@17870
   933
  shows "{pi\<bullet>x| x. P1 x} = {pi\<bullet>x| x. P2 x}"
berghofe@17870
   934
  using a by force
berghofe@17870
   935
berghofe@17870
   936
lemma Infinite_cong:
berghofe@17870
   937
  assumes a: "X = Y"
berghofe@17870
   938
  shows "infinite X = infinite Y"
berghofe@17870
   939
  using a by (simp)
berghofe@17870
   940
berghofe@17870
   941
lemma pt_set_eq_ineq:
berghofe@17870
   942
  fixes pi :: "'y prm"
berghofe@17870
   943
  assumes pt: "pt TYPE('x) TYPE('y)"
berghofe@17870
   944
  and     at: "at TYPE('y)"
berghofe@17870
   945
  shows "{pi\<bullet>x| x::'x. P x} = {x::'x. P ((rev pi)\<bullet>x)}"
berghofe@17870
   946
  by (force simp only: pt_rev_pi[OF pt, OF at] pt_pi_rev[OF pt, OF at])
berghofe@17870
   947
berghofe@17870
   948
lemma pt_inject_on_ineq:
berghofe@17870
   949
  fixes X  :: "'y set"
berghofe@17870
   950
  and   pi :: "'x prm"
berghofe@17870
   951
  assumes pt: "pt TYPE('y) TYPE('x)"
berghofe@17870
   952
  and     at: "at TYPE('x)"
berghofe@17870
   953
  shows "inj_on (perm pi) X"
berghofe@17870
   954
proof (unfold inj_on_def, intro strip)
berghofe@17870
   955
  fix x::"'y" and y::"'y"
berghofe@17870
   956
  assume "pi\<bullet>x = pi\<bullet>y"
berghofe@17870
   957
  thus "x=y" by (simp add: pt_bij[OF pt, OF at])
berghofe@17870
   958
qed
berghofe@17870
   959
berghofe@17870
   960
lemma pt_set_finite_ineq: 
berghofe@17870
   961
  fixes X  :: "'x set"
berghofe@17870
   962
  and   pi :: "'y prm"
berghofe@17870
   963
  assumes pt: "pt TYPE('x) TYPE('y)"
berghofe@17870
   964
  and     at: "at TYPE('y)"
berghofe@17870
   965
  shows "finite (pi\<bullet>X) = finite X"
berghofe@17870
   966
proof -
berghofe@17870
   967
  have image: "(pi\<bullet>X) = (perm pi ` X)" by (force simp only: perm_set_def)
berghofe@17870
   968
  show ?thesis
berghofe@17870
   969
  proof (rule iffI)
berghofe@17870
   970
    assume "finite (pi\<bullet>X)"
berghofe@17870
   971
    hence "finite (perm pi ` X)" using image by (simp)
berghofe@17870
   972
    thus "finite X" using pt_inject_on_ineq[OF pt, OF at] by (rule finite_imageD)
berghofe@17870
   973
  next
berghofe@17870
   974
    assume "finite X"
berghofe@17870
   975
    hence "finite (perm pi ` X)" by (rule finite_imageI)
berghofe@17870
   976
    thus "finite (pi\<bullet>X)" using image by (simp)
berghofe@17870
   977
  qed
berghofe@17870
   978
qed
berghofe@17870
   979
berghofe@17870
   980
lemma pt_set_infinite_ineq: 
berghofe@17870
   981
  fixes X  :: "'x set"
berghofe@17870
   982
  and   pi :: "'y prm"
berghofe@17870
   983
  assumes pt: "pt TYPE('x) TYPE('y)"
berghofe@17870
   984
  and     at: "at TYPE('y)"
berghofe@17870
   985
  shows "infinite (pi\<bullet>X) = infinite X"
berghofe@17870
   986
using pt at by (simp add: pt_set_finite_ineq)
berghofe@17870
   987
berghofe@17870
   988
lemma pt_perm_supp_ineq:
berghofe@17870
   989
  fixes  pi  :: "'x prm"
berghofe@17870
   990
  and    x   :: "'a"
berghofe@17870
   991
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
   992
  and     ptb: "pt TYPE('y) TYPE('x)"
berghofe@17870
   993
  and     at:  "at TYPE('x)"
berghofe@17870
   994
  and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
berghofe@17870
   995
  shows "(pi\<bullet>((supp x)::'y set)) = supp (pi\<bullet>x)" (is "?LHS = ?RHS")
berghofe@17870
   996
proof -
berghofe@17870
   997
  have "?LHS = {pi\<bullet>a | a. infinite {b. [(a,b)]\<bullet>x \<noteq> x}}" by (simp add: supp_def perm_set_def)
berghofe@17870
   998
  also have "\<dots> = {pi\<bullet>a | a. infinite {pi\<bullet>b | b. [(a,b)]\<bullet>x \<noteq> x}}" 
berghofe@17870
   999
  proof (rule Collect_permI, rule allI, rule iffI)
berghofe@17870
  1000
    fix a
berghofe@17870
  1001
    assume "infinite {b::'y. [(a,b)]\<bullet>x  \<noteq> x}"
berghofe@17870
  1002
    hence "infinite (pi\<bullet>{b::'y. [(a,b)]\<bullet>x \<noteq> x})" by (simp add: pt_set_infinite_ineq[OF ptb, OF at])
berghofe@17870
  1003
    thus "infinite {pi\<bullet>b |b::'y. [(a,b)]\<bullet>x  \<noteq> x}" by (simp add: perm_set_def)
berghofe@17870
  1004
  next
berghofe@17870
  1005
    fix a
berghofe@17870
  1006
    assume "infinite {pi\<bullet>b |b::'y. [(a,b)]\<bullet>x \<noteq> x}"
berghofe@17870
  1007
    hence "infinite (pi\<bullet>{b::'y. [(a,b)]\<bullet>x \<noteq> x})" by (simp add: perm_set_def)
berghofe@17870
  1008
    thus "infinite {b::'y. [(a,b)]\<bullet>x  \<noteq> x}" 
berghofe@17870
  1009
      by (simp add: pt_set_infinite_ineq[OF ptb, OF at])
berghofe@17870
  1010
  qed
berghofe@17870
  1011
  also have "\<dots> = {a. infinite {b::'y. [((rev pi)\<bullet>a,(rev pi)\<bullet>b)]\<bullet>x \<noteq> x}}" 
berghofe@17870
  1012
    by (simp add: pt_set_eq_ineq[OF ptb, OF at])
berghofe@17870
  1013
  also have "\<dots> = {a. infinite {b. pi\<bullet>([((rev pi)\<bullet>a,(rev pi)\<bullet>b)]\<bullet>x) \<noteq> (pi\<bullet>x)}}"
berghofe@17870
  1014
    by (simp add: pt_bij[OF pta, OF at])
berghofe@17870
  1015
  also have "\<dots> = {a. infinite {b. [(a,b)]\<bullet>(pi\<bullet>x) \<noteq> (pi\<bullet>x)}}"
berghofe@17870
  1016
  proof (rule Collect_cong, rule Infinite_cong, rule Collect_cong)
berghofe@17870
  1017
    fix a::"'y" and b::"'y"
berghofe@17870
  1018
    have "pi\<bullet>(([((rev pi)\<bullet>a,(rev pi)\<bullet>b)])\<bullet>x) = [(a,b)]\<bullet>(pi\<bullet>x)"
berghofe@17870
  1019
      by (simp add: cp1[OF cp] pt_pi_rev[OF ptb, OF at])
berghofe@17870
  1020
    thus "(pi\<bullet>([((rev pi)\<bullet>a,(rev pi)\<bullet>b)]\<bullet>x) \<noteq>  pi\<bullet>x) = ([(a,b)]\<bullet>(pi\<bullet>x) \<noteq> pi\<bullet>x)" by simp
berghofe@17870
  1021
  qed
berghofe@17870
  1022
  finally show "?LHS = ?RHS" by (simp add: supp_def) 
berghofe@17870
  1023
qed
berghofe@17870
  1024
berghofe@17870
  1025
lemma pt_perm_supp:
berghofe@17870
  1026
  fixes  pi  :: "'x prm"
berghofe@17870
  1027
  and    x   :: "'a"
berghofe@17870
  1028
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1029
  and     at: "at TYPE('x)"
berghofe@17870
  1030
  shows "(pi\<bullet>((supp x)::'x set)) = supp (pi\<bullet>x)"
berghofe@17870
  1031
apply(rule pt_perm_supp_ineq)
berghofe@17870
  1032
apply(rule pt)
berghofe@17870
  1033
apply(rule at_pt_inst)
berghofe@17870
  1034
apply(rule at)+
berghofe@17870
  1035
apply(rule cp_pt_inst)
berghofe@17870
  1036
apply(rule pt)
berghofe@17870
  1037
apply(rule at)
berghofe@17870
  1038
done
berghofe@17870
  1039
berghofe@17870
  1040
lemma pt_supp_finite_pi:
berghofe@17870
  1041
  fixes  pi  :: "'x prm"
berghofe@17870
  1042
  and    x   :: "'a"
berghofe@17870
  1043
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1044
  and     at: "at TYPE('x)"
berghofe@17870
  1045
  and     f: "finite ((supp x)::'x set)"
berghofe@17870
  1046
  shows "finite ((supp (pi\<bullet>x))::'x set)"
berghofe@17870
  1047
apply(simp add: pt_perm_supp[OF pt, OF at, symmetric])
berghofe@17870
  1048
apply(simp add: pt_set_finite_ineq[OF at_pt_inst[OF at], OF at])
berghofe@17870
  1049
apply(rule f)
berghofe@17870
  1050
done
berghofe@17870
  1051
berghofe@17870
  1052
lemma pt_fresh_left_ineq:  
berghofe@17870
  1053
  fixes  pi :: "'x prm"
berghofe@17870
  1054
  and     x :: "'a"
berghofe@17870
  1055
  and     a :: "'y"
berghofe@17870
  1056
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1057
  and     ptb: "pt TYPE('y) TYPE('x)"
berghofe@17870
  1058
  and     at:  "at TYPE('x)"
berghofe@17870
  1059
  and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
berghofe@17870
  1060
  shows "a\<sharp>(pi\<bullet>x) = ((rev pi)\<bullet>a)\<sharp>x"
berghofe@17870
  1061
apply(simp add: fresh_def)
berghofe@17870
  1062
apply(simp add: pt_set_bij1[OF ptb, OF at])
berghofe@17870
  1063
apply(simp add: pt_perm_supp_ineq[OF pta, OF ptb, OF at, OF cp])
berghofe@17870
  1064
done
berghofe@17870
  1065
berghofe@17870
  1066
lemma pt_fresh_right_ineq:  
berghofe@17870
  1067
  fixes  pi :: "'x prm"
berghofe@17870
  1068
  and     x :: "'a"
berghofe@17870
  1069
  and     a :: "'y"
berghofe@17870
  1070
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1071
  and     ptb: "pt TYPE('y) TYPE('x)"
berghofe@17870
  1072
  and     at:  "at TYPE('x)"
berghofe@17870
  1073
  and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
berghofe@17870
  1074
  shows "(pi\<bullet>a)\<sharp>x = a\<sharp>((rev pi)\<bullet>x)"
berghofe@17870
  1075
apply(simp add: fresh_def)
berghofe@17870
  1076
apply(simp add: pt_set_bij1[OF ptb, OF at])
berghofe@17870
  1077
apply(simp add: pt_perm_supp_ineq[OF pta, OF ptb, OF at, OF cp])
berghofe@17870
  1078
done
berghofe@17870
  1079
berghofe@17870
  1080
lemma pt_fresh_bij_ineq:
berghofe@17870
  1081
  fixes  pi :: "'x prm"
berghofe@17870
  1082
  and     x :: "'a"
berghofe@17870
  1083
  and     a :: "'y"
berghofe@17870
  1084
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1085
  and     ptb: "pt TYPE('y) TYPE('x)"
berghofe@17870
  1086
  and     at:  "at TYPE('x)"
berghofe@17870
  1087
  and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
berghofe@17870
  1088
  shows "(pi\<bullet>a)\<sharp>(pi\<bullet>x) = a\<sharp>x"
berghofe@17870
  1089
apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
berghofe@17870
  1090
apply(simp add: pt_rev_pi[OF ptb, OF at])
berghofe@17870
  1091
done
berghofe@17870
  1092
berghofe@17870
  1093
lemma pt_fresh_left:  
berghofe@17870
  1094
  fixes  pi :: "'x prm"
berghofe@17870
  1095
  and     x :: "'a"
berghofe@17870
  1096
  and     a :: "'x"
berghofe@17870
  1097
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1098
  and     at: "at TYPE('x)"
berghofe@17870
  1099
  shows "a\<sharp>(pi\<bullet>x) = ((rev pi)\<bullet>a)\<sharp>x"
berghofe@17870
  1100
apply(rule pt_fresh_left_ineq)
berghofe@17870
  1101
apply(rule pt)
berghofe@17870
  1102
apply(rule at_pt_inst)
berghofe@17870
  1103
apply(rule at)+
berghofe@17870
  1104
apply(rule cp_pt_inst)
berghofe@17870
  1105
apply(rule pt)
berghofe@17870
  1106
apply(rule at)
berghofe@17870
  1107
done
berghofe@17870
  1108
berghofe@17870
  1109
lemma pt_fresh_right:  
berghofe@17870
  1110
  fixes  pi :: "'x prm"
berghofe@17870
  1111
  and     x :: "'a"
berghofe@17870
  1112
  and     a :: "'x"
berghofe@17870
  1113
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1114
  and     at: "at TYPE('x)"
berghofe@17870
  1115
  shows "(pi\<bullet>a)\<sharp>x = a\<sharp>((rev pi)\<bullet>x)"
berghofe@17870
  1116
apply(rule pt_fresh_right_ineq)
berghofe@17870
  1117
apply(rule pt)
berghofe@17870
  1118
apply(rule at_pt_inst)
berghofe@17870
  1119
apply(rule at)+
berghofe@17870
  1120
apply(rule cp_pt_inst)
berghofe@17870
  1121
apply(rule pt)
berghofe@17870
  1122
apply(rule at)
berghofe@17870
  1123
done
berghofe@17870
  1124
berghofe@17870
  1125
lemma pt_fresh_bij:
berghofe@17870
  1126
  fixes  pi :: "'x prm"
berghofe@17870
  1127
  and     x :: "'a"
berghofe@17870
  1128
  and     a :: "'x"
berghofe@17870
  1129
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1130
  and     at: "at TYPE('x)"
berghofe@17870
  1131
  shows "(pi\<bullet>a)\<sharp>(pi\<bullet>x) = a\<sharp>x"
berghofe@17870
  1132
apply(rule pt_fresh_bij_ineq)
berghofe@17870
  1133
apply(rule pt)
berghofe@17870
  1134
apply(rule at_pt_inst)
berghofe@17870
  1135
apply(rule at)+
berghofe@17870
  1136
apply(rule cp_pt_inst)
berghofe@17870
  1137
apply(rule pt)
berghofe@17870
  1138
apply(rule at)
berghofe@17870
  1139
done
berghofe@17870
  1140
berghofe@17870
  1141
lemma pt_fresh_bij1:
berghofe@17870
  1142
  fixes  pi :: "'x prm"
berghofe@17870
  1143
  and     x :: "'a"
berghofe@17870
  1144
  and     a :: "'x"
berghofe@17870
  1145
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1146
  and     at: "at TYPE('x)"
berghofe@17870
  1147
  and     a:  "a\<sharp>x"
berghofe@17870
  1148
  shows "(pi\<bullet>a)\<sharp>(pi\<bullet>x)"
berghofe@17870
  1149
using a by (simp add: pt_fresh_bij[OF pt, OF at])
berghofe@17870
  1150
berghofe@17870
  1151
lemma pt_perm_fresh1:
berghofe@17870
  1152
  fixes a :: "'x"
berghofe@17870
  1153
  and   b :: "'x"
berghofe@17870
  1154
  and   x :: "'a"
berghofe@17870
  1155
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1156
  and     at: "at TYPE ('x)"
berghofe@17870
  1157
  and     a1: "\<not>(a\<sharp>x)"
berghofe@17870
  1158
  and     a2: "b\<sharp>x"
berghofe@17870
  1159
  shows "[(a,b)]\<bullet>x \<noteq> x"
berghofe@17870
  1160
proof
berghofe@17870
  1161
  assume neg: "[(a,b)]\<bullet>x = x"
berghofe@17870
  1162
  from a1 have a1':"a\<in>(supp x)" by (simp add: fresh_def) 
berghofe@17870
  1163
  from a2 have a2':"b\<notin>(supp x)" by (simp add: fresh_def) 
berghofe@17870
  1164
  from a1' a2' have a3: "a\<noteq>b" by force
berghofe@17870
  1165
  from a1' have "([(a,b)]\<bullet>a)\<in>([(a,b)]\<bullet>(supp x))" 
berghofe@17870
  1166
    by (simp only: pt_set_bij[OF at_pt_inst[OF at], OF at])
berghofe@17870
  1167
  hence "b\<in>([(a,b)]\<bullet>(supp x))" by (simp add: at_append[OF at] at_calc[OF at])
berghofe@17870
  1168
  hence "b\<in>(supp ([(a,b)]\<bullet>x))" by (simp add: pt_perm_supp[OF pt,OF at])
berghofe@17870
  1169
  with a2' neg show False by simp
berghofe@17870
  1170
qed
berghofe@17870
  1171
berghofe@17870
  1172
-- "three helper lemmas for the perm_fresh_fresh-lemma"
berghofe@17870
  1173
lemma comprehension_neg_UNIV: "{b. \<not> P b} = UNIV - {b. P b}"
berghofe@17870
  1174
  by (auto)
berghofe@17870
  1175
berghofe@17870
  1176
lemma infinite_or_neg_infinite:
berghofe@17870
  1177
  assumes h:"infinite (UNIV::'a set)"
berghofe@17870
  1178
  shows "infinite {b::'a. P b} \<or> infinite {b::'a. \<not> P b}"
berghofe@17870
  1179
proof (subst comprehension_neg_UNIV, case_tac "finite {b. P b}")
berghofe@17870
  1180
  assume j:"finite {b::'a. P b}"
berghofe@17870
  1181
  have "infinite ((UNIV::'a set) - {b::'a. P b})"
berghofe@17870
  1182
    using Diff_infinite_finite[OF j h] by auto
berghofe@17870
  1183
  thus "infinite {b::'a. P b} \<or> infinite (UNIV - {b::'a. P b})" ..
berghofe@17870
  1184
next
berghofe@17870
  1185
  assume j:"infinite {b::'a. P b}"
berghofe@17870
  1186
  thus "infinite {b::'a. P b} \<or> infinite (UNIV - {b::'a. P b})" by simp
berghofe@17870
  1187
qed
berghofe@17870
  1188
berghofe@17870
  1189
--"the co-set of a finite set is infinte"
berghofe@17870
  1190
lemma finite_infinite:
berghofe@17870
  1191
  assumes a: "finite {b::'x. P b}"
berghofe@17870
  1192
  and     b: "infinite (UNIV::'x set)"        
berghofe@17870
  1193
  shows "infinite {b. \<not>P b}"
berghofe@17870
  1194
  using a and infinite_or_neg_infinite[OF b] by simp
berghofe@17870
  1195
berghofe@17870
  1196
lemma pt_fresh_fresh:
berghofe@17870
  1197
  fixes   x :: "'a"
berghofe@17870
  1198
  and     a :: "'x"
berghofe@17870
  1199
  and     b :: "'x"
berghofe@17870
  1200
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1201
  and     at: "at TYPE ('x)"
berghofe@17870
  1202
  and     a1: "a\<sharp>x" and a2: "b\<sharp>x" 
berghofe@17870
  1203
  shows "[(a,b)]\<bullet>x=x"
berghofe@17870
  1204
proof (cases "a=b")
berghofe@17870
  1205
  assume c1: "a=b"
berghofe@17870
  1206
  have "[(a,a)] \<sim> []" by (rule at_ds1[OF at])
berghofe@17870
  1207
  hence "[(a,b)] \<sim> []" using c1 by simp
berghofe@17870
  1208
  hence "[(a,b)]\<bullet>x=([]::'x prm)\<bullet>x" by (rule pt3[OF pt])
berghofe@17870
  1209
  thus ?thesis by (simp only: pt1[OF pt])
berghofe@17870
  1210
next
berghofe@17870
  1211
  assume c2: "a\<noteq>b"
berghofe@17870
  1212
  from a1 have f1: "finite {c. [(a,c)]\<bullet>x \<noteq> x}" by (simp add: fresh_def supp_def)
berghofe@17870
  1213
  from a2 have f2: "finite {c. [(b,c)]\<bullet>x \<noteq> x}" by (simp add: fresh_def supp_def)
berghofe@17870
  1214
  from f1 and f2 have f3: "finite {c. perm [(a,c)] x \<noteq> x \<or> perm [(b,c)] x \<noteq> x}" 
berghofe@17870
  1215
    by (force simp only: Collect_disj_eq)
berghofe@17870
  1216
  have "infinite {c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}" 
berghofe@17870
  1217
    by (simp add: finite_infinite[OF f3,OF at4[OF at], simplified])
berghofe@17870
  1218
  hence "infinite ({c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}-{a,b})" 
berghofe@17870
  1219
    by (force dest: Diff_infinite_finite)
berghofe@17870
  1220
  hence "({c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}-{a,b}) \<noteq> {}" 
berghofe@17870
  1221
    by (auto iff del: finite_Diff_insert Diff_eq_empty_iff)
berghofe@17870
  1222
  hence "\<exists>c. c\<in>({c. [(a,c)]\<bullet>x = x \<and> [(b,c)]\<bullet>x = x}-{a,b})" by (force)
berghofe@17870
  1223
  then obtain c 
berghofe@17870
  1224
    where eq1: "[(a,c)]\<bullet>x = x" 
berghofe@17870
  1225
      and eq2: "[(b,c)]\<bullet>x = x" 
berghofe@17870
  1226
      and ineq: "a\<noteq>c \<and> b\<noteq>c"
berghofe@17870
  1227
    by (force)
berghofe@17870
  1228
  hence "[(a,c)]\<bullet>([(b,c)]\<bullet>([(a,c)]\<bullet>x)) = x" by simp 
berghofe@17870
  1229
  hence eq3: "[(a,c),(b,c),(a,c)]\<bullet>x = x" by (simp add: pt2[OF pt,symmetric])
berghofe@17870
  1230
  from c2 ineq have "[(a,c),(b,c),(a,c)] \<sim> [(a,b)]" by (simp add: at_ds3[OF at])
berghofe@17870
  1231
  hence "[(a,c),(b,c),(a,c)]\<bullet>x = [(a,b)]\<bullet>x" by (rule pt3[OF pt])
berghofe@17870
  1232
  thus ?thesis using eq3 by simp
berghofe@17870
  1233
qed
berghofe@17870
  1234
berghofe@17870
  1235
lemma pt_perm_compose:
berghofe@17870
  1236
  fixes pi1 :: "'x prm"
berghofe@17870
  1237
  and   pi2 :: "'x prm"
berghofe@17870
  1238
  and   x  :: "'a"
berghofe@17870
  1239
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1240
  and     at: "at TYPE('x)"
berghofe@17870
  1241
  shows "pi2\<bullet>(pi1\<bullet>x) = (pi2\<bullet>pi1)\<bullet>(pi2\<bullet>x)" 
berghofe@17870
  1242
proof -
berghofe@17870
  1243
  have "(pi2@pi1) \<sim> ((pi2\<bullet>pi1)@pi2)" by (rule at_ds8)
berghofe@17870
  1244
  hence "(pi2@pi1)\<bullet>x = ((pi2\<bullet>pi1)@pi2)\<bullet>x" by (rule pt3[OF pt])
berghofe@17870
  1245
  thus ?thesis by (simp add: pt2[OF pt])
berghofe@17870
  1246
qed
berghofe@17870
  1247
berghofe@17870
  1248
lemma pt_perm_compose_rev:
berghofe@17870
  1249
  fixes pi1 :: "'x prm"
berghofe@17870
  1250
  and   pi2 :: "'x prm"
berghofe@17870
  1251
  and   x  :: "'a"
berghofe@17870
  1252
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1253
  and     at: "at TYPE('x)"
berghofe@17870
  1254
  shows "(rev pi2)\<bullet>((rev pi1)\<bullet>x) = (rev pi1)\<bullet>(rev (pi1\<bullet>pi2)\<bullet>x)" 
berghofe@17870
  1255
proof -
berghofe@17870
  1256
  have "((rev pi2)@(rev pi1)) \<sim> ((rev pi1)@(rev (pi1\<bullet>pi2)))" by (rule at_ds9[OF at])
berghofe@17870
  1257
  hence "((rev pi2)@(rev pi1))\<bullet>x = ((rev pi1)@(rev (pi1\<bullet>pi2)))\<bullet>x" by (rule pt3[OF pt])
berghofe@17870
  1258
  thus ?thesis by (simp add: pt2[OF pt])
berghofe@17870
  1259
qed
berghofe@17870
  1260
berghofe@17870
  1261
section {* facts about supports *}
berghofe@17870
  1262
(*==============================*)
berghofe@17870
  1263
berghofe@17870
  1264
lemma supports_subset:
berghofe@17870
  1265
  fixes x  :: "'a"
berghofe@17870
  1266
  and   S1 :: "'x set"
berghofe@17870
  1267
  and   S2 :: "'x set"
berghofe@17870
  1268
  assumes  a: "S1 supports x"
berghofe@17870
  1269
  and      b: "S1\<subseteq>S2"
berghofe@17870
  1270
  shows "S2 supports x"
berghofe@17870
  1271
  using a b
berghofe@17870
  1272
  by (force simp add: "op supports_def")
berghofe@17870
  1273
berghofe@17870
  1274
lemma supp_supports:
berghofe@17870
  1275
  fixes x :: "'a"
berghofe@17870
  1276
  assumes  pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1277
  and      at: "at TYPE ('x)"
berghofe@17870
  1278
  shows "((supp x)::'x set) supports x"
berghofe@17870
  1279
proof (unfold "op supports_def", intro strip)
berghofe@17870
  1280
  fix a b
berghofe@17870
  1281
  assume "(a::'x)\<notin>(supp x) \<and> (b::'x)\<notin>(supp x)"
berghofe@17870
  1282
  hence "a\<sharp>x" and "b\<sharp>x" by (auto simp add: fresh_def)
berghofe@17870
  1283
  thus "[(a,b)]\<bullet>x = x" by (rule pt_fresh_fresh[OF pt, OF at])
berghofe@17870
  1284
qed
berghofe@17870
  1285
berghofe@17870
  1286
lemma supp_is_subset:
berghofe@17870
  1287
  fixes S :: "'x set"
berghofe@17870
  1288
  and   x :: "'a"
berghofe@17870
  1289
  assumes a1: "S supports x"
berghofe@17870
  1290
  and     a2: "finite S"
berghofe@17870
  1291
  shows "(supp x)\<subseteq>S"
berghofe@17870
  1292
proof (rule ccontr)
berghofe@17870
  1293
  assume "\<not>(supp x \<subseteq> S)"
berghofe@17870
  1294
  hence "\<exists>a. a\<in>(supp x) \<and> a\<notin>S" by force
berghofe@17870
  1295
  then obtain a where b1: "a\<in>supp x" and b2: "a\<notin>S" by force
berghofe@17870
  1296
  from a1 b2 have "\<forall>b. (b\<notin>S \<longrightarrow> ([(a,b)]\<bullet>x = x))" by (unfold "op supports_def", force)
berghofe@17870
  1297
  with a1 have "{b. [(a,b)]\<bullet>x \<noteq> x}\<subseteq>S" by (unfold "op supports_def", force)
berghofe@17870
  1298
  with a2 have "finite {b. [(a,b)]\<bullet>x \<noteq> x}" by (simp add: finite_subset)
berghofe@17870
  1299
  hence "a\<notin>(supp x)" by (unfold supp_def, auto)
berghofe@17870
  1300
  with b1 show False by simp
berghofe@17870
  1301
qed
berghofe@17870
  1302
berghofe@17870
  1303
lemma supports_finite:
berghofe@17870
  1304
  fixes S :: "'x set"
berghofe@17870
  1305
  and   x :: "'a"
berghofe@17870
  1306
  assumes a1: "S supports x"
berghofe@17870
  1307
  and     a2: "finite S"
berghofe@17870
  1308
  shows "finite ((supp x)::'x set)"
berghofe@17870
  1309
proof -
berghofe@17870
  1310
  have "(supp x)\<subseteq>S" using a1 a2 by (rule supp_is_subset)
berghofe@17870
  1311
  thus ?thesis using a2 by (simp add: finite_subset)
berghofe@17870
  1312
qed
berghofe@17870
  1313
  
berghofe@17870
  1314
lemma supp_is_inter:
berghofe@17870
  1315
  fixes  x :: "'a"
berghofe@17870
  1316
  assumes  pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1317
  and      at: "at TYPE ('x)"
berghofe@17870
  1318
  and      fs: "fs TYPE('a) TYPE('x)"
berghofe@17870
  1319
  shows "((supp x)::'x set) = (\<Inter> {S. finite S \<and> S supports x})"
berghofe@17870
  1320
proof (rule equalityI)
berghofe@17870
  1321
  show "((supp x)::'x set) \<subseteq> (\<Inter> {S. finite S \<and> S supports x})"
berghofe@17870
  1322
  proof (clarify)
berghofe@17870
  1323
    fix S c
berghofe@17870
  1324
    assume b: "c\<in>((supp x)::'x set)" and "finite (S::'x set)" and "S supports x"
berghofe@17870
  1325
    hence  "((supp x)::'x set)\<subseteq>S" by (simp add: supp_is_subset) 
berghofe@17870
  1326
    with b show "c\<in>S" by force
berghofe@17870
  1327
  qed
berghofe@17870
  1328
next
berghofe@17870
  1329
  show "(\<Inter> {S. finite S \<and> S supports x}) \<subseteq> ((supp x)::'x set)"
berghofe@17870
  1330
  proof (clarify, simp)
berghofe@17870
  1331
    fix c
berghofe@17870
  1332
    assume d: "\<forall>(S::'x set). finite S \<and> S supports x \<longrightarrow> c\<in>S"
berghofe@17870
  1333
    have "((supp x)::'x set) supports x" by (rule supp_supports[OF pt, OF at])
berghofe@17870
  1334
    with d fs1[OF fs] show "c\<in>supp x" by force
berghofe@17870
  1335
  qed
berghofe@17870
  1336
qed
berghofe@17870
  1337
    
berghofe@17870
  1338
lemma supp_is_least_supports:
berghofe@17870
  1339
  fixes S :: "'x set"
berghofe@17870
  1340
  and   x :: "'a"
berghofe@17870
  1341
  assumes  pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1342
  and      at: "at TYPE ('x)"
berghofe@17870
  1343
  and      a1: "S supports x"
berghofe@17870
  1344
  and      a2: "finite S"
berghofe@17870
  1345
  and      a3: "\<forall>S'. (finite S' \<and> S' supports x) \<longrightarrow> S\<subseteq>S'"
berghofe@17870
  1346
  shows "S = (supp x)"
berghofe@17870
  1347
proof (rule equalityI)
berghofe@17870
  1348
  show "((supp x)::'x set)\<subseteq>S" using a1 a2 by (rule supp_is_subset)
berghofe@17870
  1349
next
berghofe@17870
  1350
  have s1: "((supp x)::'x set) supports x" by (rule supp_supports[OF pt, OF at])
berghofe@17870
  1351
  have "((supp x)::'x set)\<subseteq>S" using a1 a2 by (rule supp_is_subset)
berghofe@17870
  1352
  hence "finite ((supp x)::'x set)" using a2 by (simp add: finite_subset)
berghofe@17870
  1353
  with s1 a3 show "S\<subseteq>supp x" by force
berghofe@17870
  1354
qed
berghofe@17870
  1355
berghofe@17870
  1356
lemma supports_set:
berghofe@17870
  1357
  fixes S :: "'x set"
berghofe@17870
  1358
  and   X :: "'a set"
berghofe@17870
  1359
  assumes  pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1360
  and      at: "at TYPE ('x)"
berghofe@17870
  1361
  and      a: "\<forall>x\<in>X. (\<forall>(a::'x) (b::'x). a\<notin>S\<and>b\<notin>S \<longrightarrow> ([(a,b)]\<bullet>x)\<in>X)"
berghofe@17870
  1362
  shows  "S supports X"
berghofe@17870
  1363
using a
berghofe@17870
  1364
apply(auto simp add: "op supports_def")
berghofe@17870
  1365
apply(simp add: pt_set_bij1a[OF pt, OF at])
berghofe@17870
  1366
apply(force simp add: pt_swap_bij[OF pt, OF at])
berghofe@17870
  1367
apply(simp add: pt_set_bij1a[OF pt, OF at])
berghofe@17870
  1368
done
berghofe@17870
  1369
berghofe@17870
  1370
lemma supports_fresh:
berghofe@17870
  1371
  fixes S :: "'x set"
berghofe@17870
  1372
  and   a :: "'x"
berghofe@17870
  1373
  and   x :: "'a"
berghofe@17870
  1374
  assumes a1: "S supports x"
berghofe@17870
  1375
  and     a2: "finite S"
berghofe@17870
  1376
  and     a3: "a\<notin>S"
berghofe@17870
  1377
  shows "a\<sharp>x"
berghofe@17870
  1378
proof (simp add: fresh_def)
berghofe@17870
  1379
  have "(supp x)\<subseteq>S" using a1 a2 by (rule supp_is_subset)
berghofe@17870
  1380
  thus "a\<notin>(supp x)" using a3 by force
berghofe@17870
  1381
qed
berghofe@17870
  1382
berghofe@17870
  1383
lemma at_fin_set_supports:
berghofe@17870
  1384
  fixes X::"'x set"
berghofe@17870
  1385
  assumes at: "at TYPE('x)"
berghofe@17870
  1386
  shows "X supports X"
berghofe@17870
  1387
proof (simp add: "op supports_def", intro strip)
berghofe@17870
  1388
  fix a b
berghofe@17870
  1389
  assume "a\<notin>X \<and> b\<notin>X"
berghofe@17870
  1390
  thus "[(a,b)]\<bullet>X = X" by (force simp add: perm_set_def at_calc[OF at])
berghofe@17870
  1391
qed
berghofe@17870
  1392
berghofe@17870
  1393
lemma at_fin_set_supp:
berghofe@17870
  1394
  fixes X::"'x set"
berghofe@17870
  1395
  assumes at: "at TYPE('x)"
berghofe@17870
  1396
  and     fs: "finite X"
berghofe@17870
  1397
  shows "(supp X) = X"
berghofe@17870
  1398
proof -
berghofe@17870
  1399
  have pt_set: "pt TYPE('x set) TYPE('x)" 
berghofe@17870
  1400
    by (rule pt_set_inst[OF at_pt_inst[OF at]])
berghofe@17870
  1401
  have X_supports_X: "X supports X" by (rule at_fin_set_supports[OF at])
berghofe@17870
  1402
  show ?thesis using  pt_set at X_supports_X fs
berghofe@17870
  1403
  proof (rule supp_is_least_supports[symmetric])
berghofe@17870
  1404
    show "\<forall>S'. finite S' \<and> S' supports X \<longrightarrow> X \<subseteq> S'"
berghofe@17870
  1405
    proof (auto)
berghofe@17870
  1406
      fix S'::"'x set" and x::"'x"
berghofe@17870
  1407
      assume f: "finite S'"
berghofe@17870
  1408
      and    s: "S' supports X"
berghofe@17870
  1409
      and    e1: "x\<in>X"
berghofe@17870
  1410
      show "x\<in>S'"
berghofe@17870
  1411
      proof (rule ccontr)
berghofe@17870
  1412
	assume e2: "x\<notin>S'"
berghofe@17870
  1413
	have "\<exists>b. b\<notin>(X\<union>S')" by (force intro: ex_in_inf[OF at] simp only: fs f)
berghofe@17870
  1414
	then obtain b where b1: "b\<notin>X" and b2: "b\<notin>S'" by (auto)
berghofe@17870
  1415
	from s e2 b2 have c1: "[(x,b)]\<bullet>X=X" by (simp add: "op supports_def")
berghofe@17870
  1416
	from e1 b1 have c2: "[(x,b)]\<bullet>X\<noteq>X" by (force simp add: perm_set_def at_calc[OF at])
berghofe@17870
  1417
	show "False" using c1 c2 by simp
berghofe@17870
  1418
      qed
berghofe@17870
  1419
    qed
berghofe@17870
  1420
  qed
berghofe@17870
  1421
qed
berghofe@17870
  1422
berghofe@17870
  1423
section {* Permutations acting on Functions *}
berghofe@17870
  1424
(*==========================================*)
berghofe@17870
  1425
berghofe@17870
  1426
lemma pt_fun_app_eq:
berghofe@17870
  1427
  fixes f  :: "'a\<Rightarrow>'b"
berghofe@17870
  1428
  and   x  :: "'a"
berghofe@17870
  1429
  and   pi :: "'x prm"
berghofe@17870
  1430
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1431
  and     at: "at TYPE('x)"
berghofe@17870
  1432
  shows "pi\<bullet>(f x) = (pi\<bullet>f)(pi\<bullet>x)"
berghofe@17870
  1433
  by (simp add: perm_fun_def pt_rev_pi[OF pt, OF at])
berghofe@17870
  1434
berghofe@17870
  1435
berghofe@17870
  1436
--"sometimes pt_fun_app_eq does to much; this lemma 'corrects it'"
berghofe@17870
  1437
lemma pt_perm:
berghofe@17870
  1438
  fixes x  :: "'a"
berghofe@17870
  1439
  and   pi1 :: "'x prm"
berghofe@17870
  1440
  and   pi2 :: "'x prm"
berghofe@17870
  1441
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1442
  and     at: "at TYPE ('x)"
berghofe@17870
  1443
  shows "(pi1\<bullet>perm pi2)(pi1\<bullet>x) = pi1\<bullet>(pi2\<bullet>x)" 
berghofe@17870
  1444
  by (simp add: pt_fun_app_eq[OF pt, OF at])
berghofe@17870
  1445
berghofe@17870
  1446
berghofe@17870
  1447
lemma pt_fun_eq:
berghofe@17870
  1448
  fixes f  :: "'a\<Rightarrow>'b"
berghofe@17870
  1449
  and   pi :: "'x prm"
berghofe@17870
  1450
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1451
  and     at: "at TYPE('x)"
berghofe@17870
  1452
  shows "(pi\<bullet>f = f) = (\<forall> x. pi\<bullet>(f x) = f (pi\<bullet>x))" (is "?LHS = ?RHS")
berghofe@17870
  1453
proof
berghofe@17870
  1454
  assume a: "?LHS"
berghofe@17870
  1455
  show "?RHS"
berghofe@17870
  1456
  proof
berghofe@17870
  1457
    fix x
berghofe@17870
  1458
    have "pi\<bullet>(f x) = (pi\<bullet>f)(pi\<bullet>x)" by (simp add: pt_fun_app_eq[OF pt, OF at])
berghofe@17870
  1459
    also have "\<dots> = f (pi\<bullet>x)" using a by simp
berghofe@17870
  1460
    finally show "pi\<bullet>(f x) = f (pi\<bullet>x)" by simp
berghofe@17870
  1461
  qed
berghofe@17870
  1462
next
berghofe@17870
  1463
  assume b: "?RHS"
berghofe@17870
  1464
  show "?LHS"
berghofe@17870
  1465
  proof (rule ccontr)
berghofe@17870
  1466
    assume "(pi\<bullet>f) \<noteq> f"
berghofe@17870
  1467
    hence "\<exists>c. (pi\<bullet>f) c \<noteq> f c" by (simp add: expand_fun_eq)
berghofe@17870
  1468
    then obtain c where b1: "(pi\<bullet>f) c \<noteq> f c" by force
berghofe@17870
  1469
    from b have "pi\<bullet>(f ((rev pi)\<bullet>c)) = f (pi\<bullet>((rev pi)\<bullet>c))" by force
berghofe@17870
  1470
    hence "(pi\<bullet>f)(pi\<bullet>((rev pi)\<bullet>c)) = f (pi\<bullet>((rev pi)\<bullet>c))" 
berghofe@17870
  1471
      by (simp add: pt_fun_app_eq[OF pt, OF at])
berghofe@17870
  1472
    hence "(pi\<bullet>f) c = f c" by (simp add: pt_pi_rev[OF pt, OF at])
berghofe@17870
  1473
    with b1 show "False" by simp
berghofe@17870
  1474
  qed
berghofe@17870
  1475
qed
berghofe@17870
  1476
berghofe@17870
  1477
-- "two helper lemmas for the equivariance of functions"
berghofe@17870
  1478
lemma pt_swap_eq_aux:
berghofe@17870
  1479
  fixes   y :: "'a"
berghofe@17870
  1480
  and    pi :: "'x prm"
berghofe@17870
  1481
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1482
  and     a: "\<forall>(a::'x) (b::'x). [(a,b)]\<bullet>y = y"
berghofe@17870
  1483
  shows "pi\<bullet>y = y"
berghofe@17870
  1484
proof(induct pi)
berghofe@17870
  1485
    case Nil show ?case by (simp add: pt1[OF pt])
berghofe@17870
  1486
  next
berghofe@17870
  1487
    case (Cons x xs)
berghofe@17870
  1488
    have "\<exists>a b. x=(a,b)" by force
berghofe@17870
  1489
    then obtain a b where p: "x=(a,b)" by force
berghofe@17870
  1490
    assume i: "xs\<bullet>y = y"
berghofe@17870
  1491
    have "x#xs = [x]@xs" by simp
berghofe@17870
  1492
    hence "(x#xs)\<bullet>y = ([x]@xs)\<bullet>y" by simp
berghofe@17870
  1493
    hence "(x#xs)\<bullet>y = [x]\<bullet>(xs\<bullet>y)" by (simp only: pt2[OF pt])
berghofe@17870
  1494
    thus ?case using a i p by (force)
berghofe@17870
  1495
  qed
berghofe@17870
  1496
berghofe@17870
  1497
lemma pt_swap_eq:
berghofe@17870
  1498
  fixes   y :: "'a"
berghofe@17870
  1499
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1500
  shows "(\<forall>(a::'x) (b::'x). [(a,b)]\<bullet>y = y) = (\<forall>pi::'x prm. pi\<bullet>y = y)"
berghofe@17870
  1501
  by (force intro: pt_swap_eq_aux[OF pt])
berghofe@17870
  1502
berghofe@17870
  1503
lemma pt_eqvt_fun1a:
berghofe@17870
  1504
  fixes f     :: "'a\<Rightarrow>'b"
berghofe@17870
  1505
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1506
  and     ptb: "pt TYPE('b) TYPE('x)"
berghofe@17870
  1507
  and     at:  "at TYPE('x)"
berghofe@17870
  1508
  and     a:   "((supp f)::'x set)={}"
berghofe@17870
  1509
  shows "\<forall>(pi::'x prm). pi\<bullet>f = f" 
berghofe@17870
  1510
proof (intro strip)
berghofe@17870
  1511
  fix pi
berghofe@17870
  1512
  have "\<forall>a b. a\<notin>((supp f)::'x set) \<and> b\<notin>((supp f)::'x set) \<longrightarrow> (([(a,b)]\<bullet>f) = f)" 
berghofe@17870
  1513
    by (intro strip, fold fresh_def, 
berghofe@17870
  1514
      simp add: pt_fresh_fresh[OF pt_fun_inst[OF pta, OF ptb, OF at],OF at])
berghofe@17870
  1515
  with a have "\<forall>(a::'x) (b::'x). ([(a,b)]\<bullet>f) = f" by force
berghofe@17870
  1516
  hence "\<forall>(pi::'x prm). pi\<bullet>f = f" 
berghofe@17870
  1517
    by (simp add: pt_swap_eq[OF pt_fun_inst[OF pta, OF ptb, OF at]])
berghofe@17870
  1518
  thus "(pi::'x prm)\<bullet>f = f" by simp
berghofe@17870
  1519
qed
berghofe@17870
  1520
berghofe@17870
  1521
lemma pt_eqvt_fun1b:
berghofe@17870
  1522
  fixes f     :: "'a\<Rightarrow>'b"
berghofe@17870
  1523
  assumes a: "\<forall>(pi::'x prm). pi\<bullet>f = f"
berghofe@17870
  1524
  shows "((supp f)::'x set)={}"
berghofe@17870
  1525
using a by (simp add: supp_def)
berghofe@17870
  1526
berghofe@17870
  1527
lemma pt_eqvt_fun1:
berghofe@17870
  1528
  fixes f     :: "'a\<Rightarrow>'b"
berghofe@17870
  1529
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1530
  and     ptb: "pt TYPE('b) TYPE('x)"
berghofe@17870
  1531
  and     at: "at TYPE('x)"
berghofe@17870
  1532
  shows "(((supp f)::'x set)={}) = (\<forall>(pi::'x prm). pi\<bullet>f = f)" (is "?LHS = ?RHS")
berghofe@17870
  1533
by (rule iffI, simp add: pt_eqvt_fun1a[OF pta, OF ptb, OF at], simp add: pt_eqvt_fun1b)
berghofe@17870
  1534
berghofe@17870
  1535
lemma pt_eqvt_fun2a:
berghofe@17870
  1536
  fixes f     :: "'a\<Rightarrow>'b"
berghofe@17870
  1537
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1538
  and     ptb: "pt TYPE('b) TYPE('x)"
berghofe@17870
  1539
  and     at: "at TYPE('x)"
berghofe@17870
  1540
  assumes a: "((supp f)::'x set)={}"
berghofe@17870
  1541
  shows "\<forall>(pi::'x prm) (x::'a). pi\<bullet>(f x) = f(pi\<bullet>x)" 
berghofe@17870
  1542
proof (intro strip)
berghofe@17870
  1543
  fix pi x
berghofe@17870
  1544
  from a have b: "\<forall>(pi::'x prm). pi\<bullet>f = f" by (simp add: pt_eqvt_fun1[OF pta, OF ptb, OF at]) 
berghofe@17870
  1545
  have "(pi::'x prm)\<bullet>(f x) = (pi\<bullet>f)(pi\<bullet>x)" by (simp add: pt_fun_app_eq[OF pta, OF at]) 
berghofe@17870
  1546
  with b show "(pi::'x prm)\<bullet>(f x) = f (pi\<bullet>x)" by force 
berghofe@17870
  1547
qed
berghofe@17870
  1548
berghofe@17870
  1549
lemma pt_eqvt_fun2b:
berghofe@17870
  1550
  fixes f     :: "'a\<Rightarrow>'b"
berghofe@17870
  1551
  assumes pt1: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1552
  and     pt2: "pt TYPE('b) TYPE('x)"
berghofe@17870
  1553
  and     at: "at TYPE('x)"
berghofe@17870
  1554
  assumes a: "\<forall>(pi::'x prm) (x::'a). pi\<bullet>(f x) = f(pi\<bullet>x)"
berghofe@17870
  1555
  shows "((supp f)::'x set)={}"
berghofe@17870
  1556
proof -
berghofe@17870
  1557
  from a have "\<forall>(pi::'x prm). pi\<bullet>f = f" by (simp add: pt_fun_eq[OF pt1, OF at, symmetric])
berghofe@17870
  1558
  thus ?thesis by (simp add: supp_def)
berghofe@17870
  1559
qed
berghofe@17870
  1560
berghofe@17870
  1561
lemma pt_eqvt_fun2:
berghofe@17870
  1562
  fixes f     :: "'a\<Rightarrow>'b"
berghofe@17870
  1563
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1564
  and     ptb: "pt TYPE('b) TYPE('x)"
berghofe@17870
  1565
  and     at: "at TYPE('x)"
berghofe@17870
  1566
  shows "(((supp f)::'x set)={}) = (\<forall>(pi::'x prm) (x::'a). pi\<bullet>(f x) = f(pi\<bullet>x))" 
berghofe@17870
  1567
by (rule iffI, 
berghofe@17870
  1568
    simp add: pt_eqvt_fun2a[OF pta, OF ptb, OF at], 
berghofe@17870
  1569
    simp add: pt_eqvt_fun2b[OF pta, OF ptb, OF at])
berghofe@17870
  1570
berghofe@17870
  1571
lemma pt_supp_fun_subset:
berghofe@17870
  1572
  fixes f :: "'a\<Rightarrow>'b"
berghofe@17870
  1573
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1574
  and     ptb: "pt TYPE('b) TYPE('x)"
berghofe@17870
  1575
  and     at: "at TYPE('x)" 
berghofe@17870
  1576
  and     f1: "finite ((supp f)::'x set)"
berghofe@17870
  1577
  and     f2: "finite ((supp x)::'x set)"
berghofe@17870
  1578
  shows "supp (f x) \<subseteq> (((supp f)\<union>(supp x))::'x set)"
berghofe@17870
  1579
proof -
berghofe@17870
  1580
  have s1: "((supp f)\<union>((supp x)::'x set)) supports (f x)"
berghofe@17870
  1581
  proof (simp add: "op supports_def", fold fresh_def, auto)
berghofe@17870
  1582
    fix a::"'x" and b::"'x"
berghofe@17870
  1583
    assume "a\<sharp>f" and "b\<sharp>f"
berghofe@17870
  1584
    hence a1: "[(a,b)]\<bullet>f = f" 
berghofe@17870
  1585
      by (rule pt_fresh_fresh[OF pt_fun_inst[OF pta, OF ptb, OF at], OF at])
berghofe@17870
  1586
    assume "a\<sharp>x" and "b\<sharp>x"
berghofe@17870
  1587
    hence a2: "[(a,b)]\<bullet>x = x" by (rule pt_fresh_fresh[OF pta, OF at])
berghofe@17870
  1588
    from a1 a2 show "[(a,b)]\<bullet>(f x) = (f x)" by (simp add: pt_fun_app_eq[OF pta, OF at])
berghofe@17870
  1589
  qed
berghofe@17870
  1590
  from f1 f2 have "finite ((supp f)\<union>((supp x)::'x set))" by force
berghofe@17870
  1591
  with s1 show ?thesis by (rule supp_is_subset)
berghofe@17870
  1592
qed
berghofe@17870
  1593
      
berghofe@17870
  1594
lemma pt_empty_supp_fun_subset:
berghofe@17870
  1595
  fixes f :: "'a\<Rightarrow>'b"
berghofe@17870
  1596
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1597
  and     ptb: "pt TYPE('b) TYPE('x)"
berghofe@17870
  1598
  and     at:  "at TYPE('x)" 
berghofe@17870
  1599
  and     e:   "(supp f)=({}::'x set)"
berghofe@17870
  1600
  shows "supp (f x) \<subseteq> ((supp x)::'x set)"
berghofe@17870
  1601
proof (unfold supp_def, auto)
berghofe@17870
  1602
  fix a::"'x"
berghofe@17870
  1603
  assume a1: "finite {b. [(a, b)]\<bullet>x \<noteq> x}"
berghofe@17870
  1604
  assume "infinite {b. [(a, b)]\<bullet>(f x) \<noteq> f x}"
berghofe@17870
  1605
  hence a2: "infinite {b. f ([(a, b)]\<bullet>x) \<noteq> f x}" using e
berghofe@17870
  1606
    by (simp add: pt_eqvt_fun2[OF pta, OF ptb, OF at])
berghofe@17870
  1607
  have a3: "{b. f ([(a,b)]\<bullet>x) \<noteq> f x}\<subseteq>{b. [(a,b)]\<bullet>x \<noteq> x}" by force
berghofe@17870
  1608
  from a1 a2 a3 show False by (force dest: finite_subset)
berghofe@17870
  1609
qed
berghofe@17870
  1610
berghofe@17870
  1611
section {* Andy's freshness lemma *}
berghofe@17870
  1612
(*================================*)
berghofe@17870
  1613
berghofe@17870
  1614
lemma freshness_lemma:
berghofe@17870
  1615
  fixes h :: "'x\<Rightarrow>'a"
berghofe@17870
  1616
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1617
  and     at:  "at TYPE('x)" 
berghofe@17870
  1618
  and     f1:  "finite ((supp h)::'x set)"
berghofe@17870
  1619
  and     a: "\<exists>a::'x. (a\<sharp>h \<and> a\<sharp>(h a))"
berghofe@17870
  1620
  shows  "\<exists>fr::'a. \<forall>a::'x. a\<sharp>h \<longrightarrow> (h a) = fr"
berghofe@17870
  1621
proof -
berghofe@17870
  1622
  have ptb: "pt TYPE('x) TYPE('x)" by (simp add: at_pt_inst[OF at]) 
berghofe@17870
  1623
  have ptc: "pt TYPE('x\<Rightarrow>'a) TYPE('x)" by (simp add: pt_fun_inst[OF ptb, OF pta, OF at]) 
berghofe@17870
  1624
  from a obtain a0 where a1: "a0\<sharp>h" and a2: "a0\<sharp>(h a0)" by force
berghofe@17870
  1625
  show ?thesis
berghofe@17870
  1626
  proof
berghofe@17870
  1627
    let ?fr = "h (a0::'x)"
berghofe@17870
  1628
    show "\<forall>(a::'x). (a\<sharp>h \<longrightarrow> ((h a) = ?fr))" 
berghofe@17870
  1629
    proof (intro strip)
berghofe@17870
  1630
      fix a
berghofe@17870
  1631
      assume a3: "(a::'x)\<sharp>h"
berghofe@17870
  1632
      show "h (a::'x) = h a0"
berghofe@17870
  1633
      proof (cases "a=a0")
berghofe@17870
  1634
	case True thus "h (a::'x) = h a0" by simp
berghofe@17870
  1635
      next
berghofe@17870
  1636
	case False 
berghofe@17870
  1637
	assume "a\<noteq>a0"
berghofe@17870
  1638
	hence c1: "a\<notin>((supp a0)::'x set)" by  (simp add: fresh_def[symmetric] at_fresh[OF at])
berghofe@17870
  1639
	have c2: "a\<notin>((supp h)::'x set)" using a3 by (simp add: fresh_def)
berghofe@17870
  1640
	from c1 c2 have c3: "a\<notin>((supp h)\<union>((supp a0)::'x set))" by force
berghofe@17870
  1641
	have f2: "finite ((supp a0)::'x set)" by (simp add: at_supp[OF at])
berghofe@17870
  1642
	from f1 f2 have "((supp (h a0))::'x set)\<subseteq>((supp h)\<union>(supp a0))"
berghofe@17870
  1643
	  by (simp add: pt_supp_fun_subset[OF ptb, OF pta, OF at])
berghofe@17870
  1644
	hence "a\<notin>((supp (h a0))::'x set)" using c3 by force
berghofe@17870
  1645
	hence "a\<sharp>(h a0)" by (simp add: fresh_def) 
berghofe@17870
  1646
	with a2 have d1: "[(a0,a)]\<bullet>(h a0) = (h a0)" by (rule pt_fresh_fresh[OF pta, OF at])
berghofe@17870
  1647
	from a1 a3 have d2: "[(a0,a)]\<bullet>h = h" by (rule pt_fresh_fresh[OF ptc, OF at])
berghofe@17870
  1648
	from d1 have "h a0 = [(a0,a)]\<bullet>(h a0)" by simp
berghofe@17870
  1649
	also have "\<dots>= ([(a0,a)]\<bullet>h)([(a0,a)]\<bullet>a0)" by (simp add: pt_fun_app_eq[OF ptb, OF at])
berghofe@17870
  1650
	also have "\<dots> = h ([(a0,a)]\<bullet>a0)" using d2 by simp
berghofe@17870
  1651
	also have "\<dots> = h a" by (simp add: at_calc[OF at])
berghofe@17870
  1652
	finally show "h a = h a0" by simp
berghofe@17870
  1653
      qed
berghofe@17870
  1654
    qed
berghofe@17870
  1655
  qed
berghofe@17870
  1656
qed
berghofe@17870
  1657
	    
berghofe@17870
  1658
lemma freshness_lemma_unique:
berghofe@17870
  1659
  fixes h :: "'x\<Rightarrow>'a"
berghofe@17870
  1660
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1661
  and     at: "at TYPE('x)" 
berghofe@17870
  1662
  and     f1: "finite ((supp h)::'x set)"
berghofe@17870
  1663
  and     a: "\<exists>(a::'x). (a\<sharp>h \<and> a\<sharp>(h a))"
berghofe@17870
  1664
  shows  "\<exists>!(fr::'a). \<forall>(a::'x). a\<sharp>h \<longrightarrow> (h a) = fr"
berghofe@17870
  1665
proof
berghofe@17870
  1666
  from pt at f1 a show "\<exists>fr::'a. \<forall>a::'x. a\<sharp>h \<longrightarrow> h a = fr" by (simp add: freshness_lemma)
berghofe@17870
  1667
next
berghofe@17870
  1668
  fix fr1 fr2
berghofe@17870
  1669
  assume b1: "\<forall>a::'x. a\<sharp>h \<longrightarrow> h a = fr1"
berghofe@17870
  1670
  assume b2: "\<forall>a::'x. a\<sharp>h \<longrightarrow> h a = fr2"
berghofe@17870
  1671
  from a obtain a where "(a::'x)\<sharp>h" by force 
berghofe@17870
  1672
  with b1 b2 have "h a = fr1 \<and> h a = fr2" by force
berghofe@17870
  1673
  thus "fr1 = fr2" by force
berghofe@17870
  1674
qed
berghofe@17870
  1675
berghofe@17870
  1676
-- "packaging the freshness lemma into a function"
berghofe@17870
  1677
constdefs
berghofe@17870
  1678
  fresh_fun :: "('x\<Rightarrow>'a)\<Rightarrow>'a"
berghofe@17870
  1679
  "fresh_fun (h) \<equiv> THE fr. (\<forall>(a::'x). a\<sharp>h \<longrightarrow> (h a) = fr)"
berghofe@17870
  1680
berghofe@17870
  1681
lemma fresh_fun_app:
berghofe@17870
  1682
  fixes h :: "'x\<Rightarrow>'a"
berghofe@17870
  1683
  and   a :: "'x"
berghofe@17870
  1684
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1685
  and     at: "at TYPE('x)" 
berghofe@17870
  1686
  and     f1: "finite ((supp h)::'x set)"
berghofe@17870
  1687
  and     a: "\<exists>(a::'x). (a\<sharp>h \<and> a\<sharp>(h a))"
berghofe@17870
  1688
  and     b: "a\<sharp>h"
berghofe@17870
  1689
  shows "(fresh_fun h) = (h a)"
berghofe@17870
  1690
proof (unfold fresh_fun_def, rule the_equality)
berghofe@17870
  1691
  show "\<forall>(a'::'x). a'\<sharp>h \<longrightarrow> h a' = h a"
berghofe@17870
  1692
  proof (intro strip)
berghofe@17870
  1693
    fix a'::"'x"
berghofe@17870
  1694
    assume c: "a'\<sharp>h"
berghofe@17870
  1695
    from pt at f1 a have "\<exists>(fr::'a). \<forall>(a::'x). a\<sharp>h \<longrightarrow> (h a) = fr" by (rule freshness_lemma)
berghofe@17870
  1696
    with b c show "h a' = h a" by force
berghofe@17870
  1697
  qed
berghofe@17870
  1698
next
berghofe@17870
  1699
  fix fr::"'a"
berghofe@17870
  1700
  assume "\<forall>a. a\<sharp>h \<longrightarrow> h a = fr"
berghofe@17870
  1701
  with b show "fr = h a" by force
berghofe@17870
  1702
qed
berghofe@17870
  1703
berghofe@17870
  1704
berghofe@17870
  1705
lemma fresh_fun_supports:
berghofe@17870
  1706
  fixes h :: "'x\<Rightarrow>'a"
berghofe@17870
  1707
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1708
  and     at: "at TYPE('x)" 
berghofe@17870
  1709
  and     f1: "finite ((supp h)::'x set)"
berghofe@17870
  1710
  and     a: "\<exists>(a::'x). (a\<sharp>h \<and> a\<sharp>(h a))"
berghofe@17870
  1711
  shows "((supp h)::'x set) supports (fresh_fun h)"
berghofe@17870
  1712
  apply(simp add: "op supports_def")
berghofe@17870
  1713
  apply(fold fresh_def)
berghofe@17870
  1714
  apply(auto)
berghofe@17870
  1715
  apply(subgoal_tac "\<exists>(a''::'x). a''\<sharp>(h,a,b)")(*A*)
berghofe@17870
  1716
  apply(erule exE)
berghofe@17870
  1717
  apply(simp add: fresh_prod)
berghofe@17870
  1718
  apply(auto)
berghofe@17870
  1719
  apply(rotate_tac 2)
berghofe@17870
  1720
  apply(drule fresh_fun_app[OF pt, OF at, OF f1, OF a])
berghofe@17870
  1721
  apply(simp add: at_fresh[OF at])
berghofe@17870
  1722
  apply(simp add: pt_fun_app_eq[OF at_pt_inst[OF at], OF at])
berghofe@17870
  1723
  apply(auto simp add: at_calc[OF at])
berghofe@17870
  1724
  apply(subgoal_tac "[(a, b)]\<bullet>h = h")(*B*)
berghofe@17870
  1725
  apply(simp)
berghofe@17870
  1726
  (*B*)
berghofe@17870
  1727
  apply(rule pt_fresh_fresh[OF pt_fun_inst[OF at_pt_inst[OF at], OF pt], OF at, OF at])
berghofe@17870
  1728
  apply(assumption)+
berghofe@17870
  1729
  (*A*)
berghofe@17870
  1730
  apply(rule at_exists_fresh[OF at])
berghofe@17870
  1731
  apply(simp add: supp_prod)
berghofe@17870
  1732
  apply(simp add: f1 at_supp[OF at])
berghofe@17870
  1733
  done
berghofe@17870
  1734
berghofe@17870
  1735
lemma fresh_fun_equiv:
berghofe@17870
  1736
  fixes h :: "'x\<Rightarrow>'a"
berghofe@17870
  1737
  and   pi:: "'x prm"
berghofe@17870
  1738
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1739
  and     at:  "at TYPE('x)" 
berghofe@17870
  1740
  and     f1:  "finite ((supp h)::'x set)"
berghofe@17870
  1741
  and     a1: "\<exists>(a::'x). (a\<sharp>h \<and> a\<sharp>(h a))"
berghofe@17870
  1742
  shows "pi\<bullet>(fresh_fun h) = fresh_fun(pi\<bullet>h)" (is "?LHS = ?RHS")
berghofe@17870
  1743
proof -
berghofe@17870
  1744
  have ptb: "pt TYPE('x) TYPE('x)" by (simp add: at_pt_inst[OF at]) 
berghofe@17870
  1745
  have ptc: "pt TYPE('x\<Rightarrow>'a) TYPE('x)" by (simp add: pt_fun_inst[OF ptb, OF pta, OF at]) 
berghofe@17870
  1746
  have f2: "finite ((supp (pi\<bullet>h))::'x set)"
berghofe@17870
  1747
  proof -
berghofe@17870
  1748
    from f1 have "finite (pi\<bullet>((supp h)::'x set))" by (simp add: pt_set_finite_ineq[OF ptb, OF at])
berghofe@17870
  1749
    thus ?thesis by (simp add: pt_perm_supp[OF ptc, OF at])
berghofe@17870
  1750
  qed
berghofe@17870
  1751
  from a1 obtain a' where c0: "a'\<sharp>h \<and> a'\<sharp>(h a')" by force
berghofe@17870
  1752
  hence c1: "a'\<sharp>h" and c2: "a'\<sharp>(h a')" by simp_all
berghofe@17870
  1753
  have c3: "(pi\<bullet>a')\<sharp>(pi\<bullet>h)" using c1 by (simp add: pt_fresh_bij[OF ptc, OF at])
berghofe@17870
  1754
  have c4: "(pi\<bullet>a')\<sharp>(pi\<bullet>h) (pi\<bullet>a')"
berghofe@17870
  1755
  proof -
berghofe@17870
  1756
    from c2 have "(pi\<bullet>a')\<sharp>(pi\<bullet>(h a'))" by (simp add: pt_fresh_bij[OF pta, OF at])
berghofe@17870
  1757
    thus ?thesis by (simp add: pt_fun_app_eq[OF ptb, OF at])
berghofe@17870
  1758
  qed
berghofe@17870
  1759
  have a2: "\<exists>(a::'x). (a\<sharp>(pi\<bullet>h) \<and> a\<sharp>((pi\<bullet>h) a))" using c3 c4 by force
berghofe@17870
  1760
  have d1: "?LHS = pi\<bullet>(h a')" using c1 a1 by (simp add: fresh_fun_app[OF pta, OF at, OF f1])
berghofe@17870
  1761
  have d2: "?RHS = (pi\<bullet>h) (pi\<bullet>a')" using c3 a2 by (simp add: fresh_fun_app[OF pta, OF at, OF f2])
berghofe@17870
  1762
  show ?thesis using d1 d2 by (simp add: pt_fun_app_eq[OF ptb, OF at])
berghofe@17870
  1763
qed
berghofe@17870
  1764
  
berghofe@17870
  1765
section {* disjointness properties *}
berghofe@17870
  1766
(*=================================*)
berghofe@17870
  1767
lemma dj_perm_forget:
berghofe@17870
  1768
  fixes pi::"'y prm"
berghofe@17870
  1769
  and   x ::"'x"
berghofe@17870
  1770
  assumes dj: "disjoint TYPE('x) TYPE('y)"
berghofe@17870
  1771
  shows "pi\<bullet>x=x"
berghofe@17870
  1772
  using dj by (simp add: disjoint_def)
berghofe@17870
  1773
berghofe@17870
  1774
lemma dj_perm_perm_forget:
berghofe@17870
  1775
  fixes pi1::"'x prm"
berghofe@17870
  1776
  and   pi2::"'y prm"
berghofe@17870
  1777
  assumes dj: "disjoint TYPE('x) TYPE('y)"
berghofe@17870
  1778
  shows "pi2\<bullet>pi1=pi1"
berghofe@17870
  1779
  using dj by (induct pi1, auto simp add: disjoint_def)
berghofe@17870
  1780
berghofe@17870
  1781
lemma dj_cp:
berghofe@17870
  1782
  fixes pi1::"'x prm"
berghofe@17870
  1783
  and   pi2::"'y prm"
berghofe@17870
  1784
  and   x  ::"'a"
berghofe@17870
  1785
  assumes cp: "cp TYPE ('a) TYPE('x) TYPE('y)"
berghofe@17870
  1786
  and     dj: "disjoint TYPE('y) TYPE('x)"
berghofe@17870
  1787
  shows "pi1\<bullet>(pi2\<bullet>x) = (pi2)\<bullet>(pi1\<bullet>x)"
berghofe@17870
  1788
  by (simp add: cp1[OF cp] dj_perm_perm_forget[OF dj])
berghofe@17870
  1789
berghofe@17870
  1790
lemma dj_supp:
berghofe@17870
  1791
  fixes a::"'x"
berghofe@17870
  1792
  assumes dj: "disjoint TYPE('x) TYPE('y)"
berghofe@17870
  1793
  shows "(supp a) = ({}::'y set)"
berghofe@17870
  1794
apply(simp add: supp_def dj_perm_forget[OF dj])
berghofe@17870
  1795
done
berghofe@17870
  1796
berghofe@17870
  1797
berghofe@17870
  1798
section {* composition instances *}
berghofe@17870
  1799
(* ============================= *)
berghofe@17870
  1800
berghofe@17870
  1801
lemma cp_list_inst:
berghofe@17870
  1802
  assumes c1: "cp TYPE ('a) TYPE('x) TYPE('y)"
berghofe@17870
  1803
  shows "cp TYPE ('a list) TYPE('x) TYPE('y)"
berghofe@17870
  1804
using c1
berghofe@17870
  1805
apply(simp add: cp_def)
berghofe@17870
  1806
apply(auto)
berghofe@17870
  1807
apply(induct_tac x)
berghofe@17870
  1808
apply(auto)
berghofe@17870
  1809
done
berghofe@17870
  1810
berghofe@17870
  1811
lemma cp_set_inst:
berghofe@17870
  1812
  assumes c1: "cp TYPE ('a) TYPE('x) TYPE('y)"
berghofe@17870
  1813
  shows "cp TYPE ('a set) TYPE('x) TYPE('y)"
berghofe@17870
  1814
using c1
berghofe@17870
  1815
apply(simp add: cp_def)
berghofe@17870
  1816
apply(auto)
berghofe@17870
  1817
apply(auto simp add: perm_set_def)
berghofe@17870
  1818
apply(rule_tac x="pi2\<bullet>aa" in exI)
berghofe@17870
  1819
apply(auto)
berghofe@17870
  1820
done
berghofe@17870
  1821
berghofe@17870
  1822
lemma cp_option_inst:
berghofe@17870
  1823
  assumes c1: "cp TYPE ('a) TYPE('x) TYPE('y)"
berghofe@17870
  1824
  shows "cp TYPE ('a option) TYPE('x) TYPE('y)"
berghofe@17870
  1825
using c1
berghofe@17870
  1826
apply(simp add: cp_def)
berghofe@17870
  1827
apply(auto)
berghofe@17870
  1828
apply(case_tac x)
berghofe@17870
  1829
apply(auto)
berghofe@17870
  1830
done
berghofe@17870
  1831
berghofe@17870
  1832
lemma cp_noption_inst:
berghofe@17870
  1833
  assumes c1: "cp TYPE ('a) TYPE('x) TYPE('y)"
berghofe@17870
  1834
  shows "cp TYPE ('a nOption) TYPE('x) TYPE('y)"
berghofe@17870
  1835
using c1
berghofe@17870
  1836
apply(simp add: cp_def)
berghofe@17870
  1837
apply(auto)
berghofe@17870
  1838
apply(case_tac x)
berghofe@17870
  1839
apply(auto)
berghofe@17870
  1840
done
berghofe@17870
  1841
berghofe@17870
  1842
lemma cp_unit_inst:
berghofe@17870
  1843
  shows "cp TYPE (unit) TYPE('x) TYPE('y)"
berghofe@17870
  1844
apply(simp add: cp_def)
berghofe@17870
  1845
done
berghofe@17870
  1846
berghofe@17870
  1847
lemma cp_bool_inst:
berghofe@17870
  1848
  shows "cp TYPE (bool) TYPE('x) TYPE('y)"
berghofe@17870
  1849
apply(simp add: cp_def)
berghofe@17870
  1850
apply(rule allI)+
berghofe@17870
  1851
apply(induct_tac x)
berghofe@17870
  1852
apply(simp_all)
berghofe@17870
  1853
done
berghofe@17870
  1854
berghofe@17870
  1855
lemma cp_prod_inst:
berghofe@17870
  1856
  assumes c1: "cp TYPE ('a) TYPE('x) TYPE('y)"
berghofe@17870
  1857
  and     c2: "cp TYPE ('b) TYPE('x) TYPE('y)"
berghofe@17870
  1858
  shows "cp TYPE ('a\<times>'b) TYPE('x) TYPE('y)"
berghofe@17870
  1859
using c1 c2
berghofe@17870
  1860
apply(simp add: cp_def)
berghofe@17870
  1861
done
berghofe@17870
  1862
berghofe@17870
  1863
lemma cp_fun_inst:
berghofe@17870
  1864
  assumes c1: "cp TYPE ('a) TYPE('x) TYPE('y)"
berghofe@17870
  1865
  and     c2: "cp TYPE ('b) TYPE('x) TYPE('y)"
berghofe@17870
  1866
  and     pt: "pt TYPE ('y) TYPE('x)"
berghofe@17870
  1867
  and     at: "at TYPE ('x)"
berghofe@17870
  1868
  shows "cp TYPE ('a\<Rightarrow>'b) TYPE('x) TYPE('y)"
berghofe@17870
  1869
using c1 c2
berghofe@17870
  1870
apply(auto simp add: cp_def perm_fun_def expand_fun_eq)
berghofe@17870
  1871
apply(simp add: perm_rev[symmetric])
berghofe@17870
  1872
apply(simp add: pt_rev_pi[OF pt_list_inst[OF pt_prod_inst[OF pt, OF pt]], OF at])
berghofe@17870
  1873
done
berghofe@17870
  1874
berghofe@17870
  1875
berghofe@17870
  1876
section {* Abstraction function *}
berghofe@17870
  1877
(*==============================*)
berghofe@17870
  1878
berghofe@17870
  1879
lemma pt_abs_fun_inst:
berghofe@17870
  1880
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1881
  and     at: "at TYPE('x)"
berghofe@17870
  1882
  shows "pt TYPE('x\<Rightarrow>('a nOption)) TYPE('x)"
berghofe@17870
  1883
  by (rule pt_fun_inst[OF at_pt_inst[OF at],OF pt_noption_inst[OF pt],OF at])
berghofe@17870
  1884
berghofe@17870
  1885
constdefs
berghofe@17870
  1886
  abs_fun :: "'x\<Rightarrow>'a\<Rightarrow>('x\<Rightarrow>('a nOption))" ("[_]._" [100,100] 100)
berghofe@17870
  1887
  "[a].x \<equiv> (\<lambda>b. (if b=a then nSome(x) else (if b\<sharp>x then nSome([(a,b)]\<bullet>x) else nNone)))"
berghofe@17870
  1888
berghofe@17870
  1889
lemma abs_fun_if: 
berghofe@17870
  1890
  fixes pi :: "'x prm"
berghofe@17870
  1891
  and   x  :: "'a"
berghofe@17870
  1892
  and   y  :: "'a"
berghofe@17870
  1893
  and   c  :: "bool"
berghofe@17870
  1894
  shows "pi\<bullet>(if c then x else y) = (if c then (pi\<bullet>x) else (pi\<bullet>y))"   
berghofe@17870
  1895
  by force
berghofe@17870
  1896
berghofe@17870
  1897
lemma abs_fun_pi_ineq:
berghofe@17870
  1898
  fixes a  :: "'y"
berghofe@17870
  1899
  and   x  :: "'a"
berghofe@17870
  1900
  and   pi :: "'x prm"
berghofe@17870
  1901
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1902
  and     ptb: "pt TYPE('y) TYPE('x)"
berghofe@17870
  1903
  and     at:  "at TYPE('x)"
berghofe@17870
  1904
  and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
berghofe@17870
  1905
  shows "pi\<bullet>([a].x) = [(pi\<bullet>a)].(pi\<bullet>x)"
berghofe@17870
  1906
  apply(simp add: abs_fun_def perm_fun_def abs_fun_if)
berghofe@17870
  1907
  apply(simp only: expand_fun_eq)
berghofe@17870
  1908
  apply(rule allI)
berghofe@17870
  1909
  apply(subgoal_tac "(((rev pi)\<bullet>(xa::'y)) = (a::'y)) = (xa = pi\<bullet>a)")(*A*)
berghofe@17870
  1910
  apply(subgoal_tac "(((rev pi)\<bullet>xa)\<sharp>x) = (xa\<sharp>(pi\<bullet>x))")(*B*)
berghofe@17870
  1911
  apply(subgoal_tac "pi\<bullet>([(a,(rev pi)\<bullet>xa)]\<bullet>x) = [(pi\<bullet>a,xa)]\<bullet>(pi\<bullet>x)")(*C*)
berghofe@17870
  1912
  apply(simp)
berghofe@17870
  1913
(*C*)
berghofe@17870
  1914
  apply(simp add: cp1[OF cp])
berghofe@17870
  1915
  apply(simp add: pt_pi_rev[OF ptb, OF at])
berghofe@17870
  1916
(*B*)
berghofe@17870
  1917
  apply(simp add: pt_fresh_left_ineq[OF pta, OF ptb, OF at, OF cp])
berghofe@17870
  1918
(*A*)
berghofe@17870
  1919
  apply(rule iffI)
berghofe@17870
  1920
  apply(rule pt_bij2[OF ptb, OF at, THEN sym])
berghofe@17870
  1921
  apply(simp)
berghofe@17870
  1922
  apply(rule pt_bij2[OF ptb, OF at])
berghofe@17870
  1923
  apply(simp)
berghofe@17870
  1924
done
berghofe@17870
  1925
berghofe@17870
  1926
lemma abs_fun_pi:
berghofe@17870
  1927
  fixes a  :: "'x"
berghofe@17870
  1928
  and   x  :: "'a"
berghofe@17870
  1929
  and   pi :: "'x prm"
berghofe@17870
  1930
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1931
  and     at: "at TYPE('x)"
berghofe@17870
  1932
  shows "pi\<bullet>([a].x) = [(pi\<bullet>a)].(pi\<bullet>x)"
berghofe@17870
  1933
apply(rule abs_fun_pi_ineq)
berghofe@17870
  1934
apply(rule pt)
berghofe@17870
  1935
apply(rule at_pt_inst)
berghofe@17870
  1936
apply(rule at)+
berghofe@17870
  1937
apply(rule cp_pt_inst)
berghofe@17870
  1938
apply(rule pt)
berghofe@17870
  1939
apply(rule at)
berghofe@17870
  1940
done
berghofe@17870
  1941
berghofe@17870
  1942
lemma abs_fun_eq1: 
berghofe@17870
  1943
  fixes x  :: "'a"
berghofe@17870
  1944
  and   y  :: "'a"
berghofe@17870
  1945
  and   a  :: "'x"
berghofe@17870
  1946
  shows "([a].x = [a].y) = (x = y)"
berghofe@17870
  1947
apply(auto simp add: abs_fun_def)
berghofe@17870
  1948
apply(auto simp add: expand_fun_eq)
berghofe@17870
  1949
apply(drule_tac x="a" in spec)
berghofe@17870
  1950
apply(simp)
berghofe@17870
  1951
done
berghofe@17870
  1952
berghofe@17870
  1953
lemma abs_fun_eq2:
berghofe@17870
  1954
  fixes x  :: "'a"
berghofe@17870
  1955
  and   y  :: "'a"
berghofe@17870
  1956
  and   a  :: "'x"
berghofe@17870
  1957
  and   b  :: "'x"
berghofe@17870
  1958
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1959
      and at: "at TYPE('x)"
berghofe@17870
  1960
      and a1: "a\<noteq>b" 
berghofe@17870
  1961
      and a2: "[a].x = [b].y" 
berghofe@17870
  1962
  shows "x=[(a,b)]\<bullet>y\<and>a\<sharp>y"
berghofe@17870
  1963
proof -
berghofe@17870
  1964
  from a2 have a3: 
berghofe@17870
  1965
         "\<forall>c::'x. (if c=a then nSome(x) else (if c\<sharp>x then nSome([(a,c)]\<bullet>x) else nNone))
berghofe@17870
  1966
                = (if c=b then nSome(y) else (if c\<sharp>y then nSome([(b,c)]\<bullet>y) else nNone))"
berghofe@17870
  1967
         (is "\<forall>c::'x. ?P c = ?Q c")
berghofe@17870
  1968
    by (force simp add: abs_fun_def expand_fun_eq)
berghofe@17870
  1969
  from a3 have "?P a = ?Q a" by (blast)
berghofe@17870
  1970
  hence a4: "nSome(x) = ?Q a" by simp
berghofe@17870
  1971
  from a3 have "?P b = ?Q b" by (blast)
berghofe@17870
  1972
  hence a5: "nSome(y) = ?P b" by simp
berghofe@17870
  1973
  show ?thesis using a4 a5
berghofe@17870
  1974
  proof (cases "a\<sharp>y")
berghofe@17870
  1975
    assume a6: "a\<sharp>y"
berghofe@17870
  1976
    hence a7: "x = [(b,a)]\<bullet>y" using a4 a1 by simp
berghofe@17870
  1977
    have "[(a,b)]\<bullet>y = [(b,a)]\<bullet>y" by (rule pt3[OF pt], rule at_ds5[OF at])
berghofe@17870
  1978
    thus ?thesis using a6 a7 by simp
berghofe@17870
  1979
  next
berghofe@17870
  1980
    assume "\<not>a\<sharp>y"
berghofe@17870
  1981
    hence "nSome(x) = nNone" using a1 a4 by simp
berghofe@17870
  1982
    hence False by force
berghofe@17870
  1983
    thus ?thesis by force
berghofe@17870
  1984
  qed
berghofe@17870
  1985
qed
berghofe@17870
  1986
berghofe@17870
  1987
lemma abs_fun_eq3: 
berghofe@17870
  1988
  fixes x  :: "'a"
berghofe@17870
  1989
  and   y  :: "'a"
berghofe@17870
  1990
  and   a   :: "'x"
berghofe@17870
  1991
  and   b   :: "'x"
berghofe@17870
  1992
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  1993
      and at: "at TYPE('x)"
berghofe@17870
  1994
      and a1: "a\<noteq>b" 
berghofe@17870
  1995
      and a2: "x=[(a,b)]\<bullet>y" 
berghofe@17870
  1996
      and a3: "a\<sharp>y" 
berghofe@17870
  1997
  shows "[a].x =[b].y"
berghofe@17870
  1998
proof -
berghofe@17870
  1999
  show ?thesis using a1 a2 a3
berghofe@17870
  2000
    apply(auto simp add: abs_fun_def)
berghofe@17870
  2001
    apply(simp only: expand_fun_eq)
berghofe@17870
  2002
    apply(rule allI)
berghofe@17870
  2003
    apply(case_tac "x=a")
berghofe@17870
  2004
    apply(simp)
berghofe@17870
  2005
    apply(rule pt3[OF pt], rule at_ds5[OF at])
berghofe@17870
  2006
    apply(case_tac "x=b")
berghofe@17870
  2007
    apply(simp add: pt_swap_bij[OF pt, OF at])
berghofe@17870
  2008
    apply(simp add: at_calc[OF at] at_bij[OF at] pt_fresh_left[OF pt, OF at])
berghofe@17870
  2009
    apply(simp only: if_False)
berghofe@17870
  2010
    apply(simp add: at_calc[OF at] at_bij[OF at] pt_fresh_left[OF pt, OF at])
berghofe@17870
  2011
    apply(rule impI)
berghofe@17870
  2012
    apply(subgoal_tac "[(a,x)]\<bullet>([(a,b)]\<bullet>y) = [(b,x)]\<bullet>([(a,x)]\<bullet>y)")(*A*)
berghofe@17870
  2013
    apply(simp)
berghofe@17870
  2014
    apply(simp only:  pt_bij[OF pt, OF at])
berghofe@17870
  2015
    apply(rule pt_fresh_fresh[OF pt, OF at])
berghofe@17870
  2016
    apply(assumption)+
berghofe@17870
  2017
    (*A*)
berghofe@17870
  2018
    apply(simp only: pt2[OF pt, symmetric])
berghofe@17870
  2019
    apply(rule pt3[OF pt])
berghofe@17870
  2020
    apply(simp, rule at_ds6[OF at])
berghofe@17870
  2021
    apply(force)
berghofe@17870
  2022
    done
berghofe@17870
  2023
  qed
berghofe@17870
  2024
berghofe@17870
  2025
lemma abs_fun_eq: 
berghofe@17870
  2026
  fixes x  :: "'a"
berghofe@17870
  2027
  and   y  :: "'a"
berghofe@17870
  2028
  and   a  :: "'x"
berghofe@17870
  2029
  and   b  :: "'x"
berghofe@17870
  2030
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  2031
      and at: "at TYPE('x)"
berghofe@17870
  2032
  shows "([a].x = [b].y) = ((a=b \<and> x=y)\<or>(a\<noteq>b \<and> x=[(a,b)]\<bullet>y \<and> a\<sharp>y))"
berghofe@17870
  2033
proof (rule iffI)
berghofe@17870
  2034
  assume b: "[a].x = [b].y"
berghofe@17870
  2035
  show "(a=b \<and> x=y)\<or>(a\<noteq>b \<and> x=[(a,b)]\<bullet>y \<and> a\<sharp>y)"
berghofe@17870
  2036
  proof (cases "a=b")
berghofe@17870
  2037
    case True with b show ?thesis by (simp add: abs_fun_eq1)
berghofe@17870
  2038
  next
berghofe@17870
  2039
    case False with b show ?thesis by (simp add: abs_fun_eq2[OF pt, OF at])
berghofe@17870
  2040
  qed
berghofe@17870
  2041
next
berghofe@17870
  2042
  assume "(a=b \<and> x=y)\<or>(a\<noteq>b \<and> x=[(a,b)]\<bullet>y \<and> a\<sharp>y)"
berghofe@17870
  2043
  thus "[a].x = [b].y"
berghofe@17870
  2044
  proof
berghofe@17870
  2045
    assume "a=b \<and> x=y" thus ?thesis by simp
berghofe@17870
  2046
  next
berghofe@17870
  2047
    assume "a\<noteq>b \<and> x=[(a,b)]\<bullet>y \<and> a\<sharp>y" 
berghofe@17870
  2048
    thus ?thesis by (simp add: abs_fun_eq3[OF pt, OF at])
berghofe@17870
  2049
  qed
berghofe@17870
  2050
qed
berghofe@17870
  2051
berghofe@17870
  2052
lemma abs_fun_supp_approx:
berghofe@17870
  2053
  fixes x :: "'a"
berghofe@17870
  2054
  and   a :: "'x"
berghofe@17870
  2055
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  2056
  and     at: "at TYPE('x)"
berghofe@17870
  2057
  shows "((supp ([a].x))::'x set) \<subseteq> (supp x)\<union>{a}"
urbanc@18047
  2058
proof -
urbanc@18047
  2059
  have "((supp ([a].x))::'x set) \<subseteq> (supp (x,a))" 
urbanc@18047
  2060
    proof 
urbanc@18047
  2061
      fix c
urbanc@18047
  2062
      assume "c\<in>((supp ([a].x))::'x set)"
urbanc@18047
  2063
      hence "infinite {b. [(c,b)]\<bullet>([a].x) \<noteq> [a].x}" by (simp add: supp_def)
urbanc@18047
  2064
      hence "infinite {b. [([(c,b)]\<bullet>a)].([(c,b)]\<bullet>x) \<noteq> [a].x}" by (simp add: abs_fun_pi[OF pt, OF at])
urbanc@18047
  2065
      moreover
urbanc@18047
  2066
      have "{b. [([(c,b)]\<bullet>a)].([(c,b)]\<bullet>x) \<noteq> [a].x} \<subseteq> {b. ([(c,b)]\<bullet>x,[(c,b)]\<bullet>a) \<noteq> (x, a)}"
urbanc@18047
  2067
	apply(rule subsetI)
urbanc@18047
  2068
	apply(simp only: mem_Collect_eq)
urbanc@18047
  2069
	apply(auto)
urbanc@18047
  2070
	done
urbanc@18047
  2071
      (*by force*)
urbanc@18047
  2072
      ultimately have "infinite {b. ([(c,b)]\<bullet>x,[(c,b)]\<bullet>a) \<noteq> (x, a)}" by (simp add: infinite_super)
urbanc@18047
  2073
      thus "c\<in>(supp (x,a))" by (simp add: supp_def)
urbanc@18047
  2074
    qed
urbanc@18047
  2075
  thus ?thesis by (simp add: supp_prod at_supp[OF at])
berghofe@17870
  2076
qed
berghofe@17870
  2077
berghofe@17870
  2078
lemma abs_fun_finite_supp:
berghofe@17870
  2079
  fixes x :: "'a"
berghofe@17870
  2080
  and   a :: "'x"
berghofe@17870
  2081
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  2082
  and     at: "at TYPE('x)"
berghofe@17870
  2083
  and     f:  "finite ((supp x)::'x set)"
berghofe@17870
  2084
  shows "finite ((supp ([a].x))::'x set)"
berghofe@17870
  2085
proof -
berghofe@17870
  2086
  from f have f1: "finite (((supp x)::'x set)\<union>{a})" by force
berghofe@17870
  2087
  thus ?thesis using abs_fun_supp_approx[OF pt, OF at, of "a" "x"]
berghofe@17870
  2088
   by (simp add: finite_subset)
berghofe@17870
  2089
qed
berghofe@17870
  2090
berghofe@17870
  2091
lemma fresh_abs_funI1:
berghofe@17870
  2092
  fixes  x :: "'a"
berghofe@17870
  2093
  and    a :: "'x"
berghofe@17870
  2094
  and    b :: "'x"
berghofe@17870
  2095
  assumes pt:  "pt TYPE('a) TYPE('x)"
berghofe@17870
  2096
  and     at:   "at TYPE('x)"
berghofe@17870
  2097
  and f:  "finite ((supp x)::'x set)"
berghofe@17870
  2098
  and a1: "b\<sharp>x" 
berghofe@17870
  2099
  and a2: "a\<noteq>b"
berghofe@17870
  2100
  shows "b\<sharp>([a].x)"
berghofe@17870
  2101
  proof -
berghofe@17870
  2102
    have "\<exists>c::'x. c\<sharp>(b,a,x,[a].x)" 
berghofe@17870
  2103
    proof (rule at_exists_fresh[OF at], auto simp add: supp_prod at_supp[OF at] f)
berghofe@17870
  2104
      show "finite ((supp ([a].x))::'x set)" using f
berghofe@17870
  2105
	by (simp add: abs_fun_finite_supp[OF pt, OF at])	
berghofe@17870
  2106
    qed
berghofe@17870
  2107
    then obtain c where fr1: "c\<noteq>b"
berghofe@17870
  2108
                  and   fr2: "c\<noteq>a"
berghofe@17870
  2109
                  and   fr3: "c\<sharp>x"
berghofe@17870
  2110
                  and   fr4: "c\<sharp>([a].x)"
berghofe@17870
  2111
                  by (force simp add: fresh_prod at_fresh[OF at])
berghofe@17870
  2112
    have e: "[(c,b)]\<bullet>([a].x) = [a].([(c,b)]\<bullet>x)" using a2 fr1 fr2 
berghofe@17870
  2113
      by (force simp add: abs_fun_pi[OF pt, OF at] at_calc[OF at])
berghofe@17870
  2114
    from fr4 have "([(c,b)]\<bullet>c)\<sharp> ([(c,b)]\<bullet>([a].x))"
berghofe@17870
  2115
      by (simp add: pt_fresh_bij[OF pt_abs_fun_inst[OF pt, OF at], OF at])
berghofe@17870
  2116
    hence "b\<sharp>([a].([(c,b)]\<bullet>x))" using fr1 fr2 e  
berghofe@17870
  2117
      by (simp add: at_calc[OF at])
berghofe@17870
  2118
    thus ?thesis using a1 fr3 
berghofe@17870
  2119
      by (simp add: pt_fresh_fresh[OF pt, OF at])
berghofe@17870
  2120
qed
berghofe@17870
  2121
berghofe@17870
  2122
lemma fresh_abs_funE:
berghofe@17870
  2123
  fixes a :: "'x"
berghofe@17870
  2124
  and   b :: "'x"
berghofe@17870
  2125
  and   x :: "'a"
berghofe@17870
  2126
  assumes pt:  "pt TYPE('a) TYPE('x)"
berghofe@17870
  2127
  and     at:  "at TYPE('x)"
berghofe@17870
  2128
  and     f:  "finite ((supp x)::'x set)"
berghofe@17870
  2129
  and     a1: "b\<sharp>([a].x)" 
berghofe@17870
  2130
  and     a2: "b\<noteq>a" 
berghofe@17870
  2131
  shows "b\<sharp>x"
berghofe@17870
  2132
proof -
berghofe@17870
  2133
  have "\<exists>c::'x. c\<sharp>(b,a,x,[a].x)"
berghofe@17870
  2134
  proof (rule at_exists_fresh[OF at], auto simp add: supp_prod at_supp[OF at] f)
berghofe@17870
  2135
    show "finite ((supp ([a].x))::'x set)" using f
berghofe@17870
  2136
      by (simp add: abs_fun_finite_supp[OF pt, OF at])	
berghofe@17870
  2137
  qed
berghofe@17870
  2138
  then obtain c where fr1: "b\<noteq>c"
berghofe@17870
  2139
                and   fr2: "c\<noteq>a"
berghofe@17870
  2140
                and   fr3: "c\<sharp>x"
berghofe@17870
  2141
                and   fr4: "c\<sharp>([a].x)" by (force simp add: fresh_prod at_fresh[OF at])
berghofe@17870
  2142
  have "[a].x = [(b,c)]\<bullet>([a].x)" using a1 fr4 
berghofe@17870
  2143
    by (simp add: pt_fresh_fresh[OF pt_abs_fun_inst[OF pt, OF at], OF at])
berghofe@17870
  2144
  hence "[a].x = [a].([(b,c)]\<bullet>x)" using fr2 a2 
berghofe@17870
  2145
    by (force simp add: abs_fun_pi[OF pt, OF at] at_calc[OF at])
berghofe@17870
  2146
  hence b: "([(b,c)]\<bullet>x) = x" by (simp add: abs_fun_eq1)
berghofe@17870
  2147
  from fr3 have "([(b,c)]\<bullet>c)\<sharp>([(b,c)]\<bullet>x)" 
berghofe@17870
  2148
    by (simp add: pt_fresh_bij[OF pt, OF at]) 
berghofe@17870
  2149
  thus ?thesis using b fr1 by (simp add: at_calc[OF at])
berghofe@17870
  2150
qed
berghofe@17870
  2151
berghofe@17870
  2152
lemma fresh_abs_funI2:
berghofe@17870
  2153
  fixes a :: "'x"
berghofe@17870
  2154
  and   x :: "'a"
berghofe@17870
  2155
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  2156
  and     at: "at TYPE('x)"
berghofe@17870
  2157
  and     f: "finite ((supp x)::'x set)"
berghofe@17870
  2158
  shows "a\<sharp>([a].x)"
berghofe@17870
  2159
proof -
berghofe@17870
  2160
  have "\<exists>c::'x. c\<sharp>(a,x)"
berghofe@17870
  2161
    by  (rule at_exists_fresh[OF at], auto simp add: supp_prod at_supp[OF at] f) 
berghofe@17870
  2162
  then obtain c where fr1: "a\<noteq>c" and fr1_sym: "c\<noteq>a" 
berghofe@17870
  2163
                and   fr2: "c\<sharp>x" by (force simp add: fresh_prod at_fresh[OF at])
berghofe@17870
  2164
  have "c\<sharp>([a].x)" using f fr1 fr2 by (simp add: fresh_abs_funI1[OF pt, OF at])
berghofe@17870
  2165
  hence "([(c,a)]\<bullet>c)\<sharp>([(c,a)]\<bullet>([a].x))" using fr1  
berghofe@17870
  2166
    by (simp only: pt_fresh_bij[OF pt_abs_fun_inst[OF pt, OF at], OF at])
berghofe@17870
  2167
  hence a: "a\<sharp>([c].([(c,a)]\<bullet>x))" using fr1_sym 
berghofe@17870
  2168
    by (simp add: abs_fun_pi[OF pt, OF at] at_calc[OF at])
berghofe@17870
  2169
  have "[c].([(c,a)]\<bullet>x) = ([a].x)" using fr1_sym fr2 
berghofe@17870
  2170
    by (simp add: abs_fun_eq[OF pt, OF at])
berghofe@17870
  2171
  thus ?thesis using a by simp
berghofe@17870
  2172
qed
berghofe@17870
  2173
berghofe@17870
  2174
lemma fresh_abs_fun_iff: 
berghofe@17870
  2175
  fixes a :: "'x"
berghofe@17870
  2176
  and   b :: "'x"
berghofe@17870
  2177
  and   x :: "'a"
berghofe@17870
  2178
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  2179
  and     at: "at TYPE('x)"
berghofe@17870
  2180
  and     f: "finite ((supp x)::'x set)"
berghofe@17870
  2181
  shows "(b\<sharp>([a].x)) = (b=a \<or> b\<sharp>x)" 
berghofe@17870
  2182
  by (auto  dest: fresh_abs_funE[OF pt, OF at,OF f] 
berghofe@17870
  2183
           intro: fresh_abs_funI1[OF pt, OF at,OF f] 
berghofe@17870
  2184
                  fresh_abs_funI2[OF pt, OF at,OF f])
berghofe@17870
  2185
berghofe@17870
  2186
lemma abs_fun_supp: 
berghofe@17870
  2187
  fixes a :: "'x"
berghofe@17870
  2188
  and   x :: "'a"
berghofe@17870
  2189
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  2190
  and     at: "at TYPE('x)"
berghofe@17870
  2191
  and     f: "finite ((supp x)::'x set)"
berghofe@17870
  2192
  shows "supp ([a].x) = (supp x)-{a}"
berghofe@17870
  2193
 by (force simp add: supp_fresh_iff fresh_abs_fun_iff[OF pt, OF at, OF f])
berghofe@17870
  2194
berghofe@17870
  2195
(* maybe needs to be stated by supp -supp *)
berghofe@17870
  2196
berghofe@17870
  2197
lemma abs_fun_supp_ineq: 
berghofe@17870
  2198
  fixes a :: "'y"
berghofe@17870
  2199
  and   x :: "'a"
berghofe@17870
  2200
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  2201
  and     ptb: "pt TYPE('y) TYPE('x)"
berghofe@17870
  2202
  and     at:  "at TYPE('x)"
berghofe@17870
  2203
  and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
berghofe@17870
  2204
  and     dj:  "disjoint TYPE('y) TYPE('x)"
berghofe@17870
  2205
  shows "((supp ([a].x))::'x set) = (supp x)"
berghofe@17870
  2206
apply(auto simp add: supp_def)
berghofe@17870
  2207
apply(auto simp add: abs_fun_pi_ineq[OF pta, OF ptb, OF at, OF cp])
berghofe@17870
  2208
apply(auto simp add: dj_perm_forget[OF dj])
berghofe@17870
  2209
apply(auto simp add: abs_fun_eq1) 
berghofe@17870
  2210
done
berghofe@17870
  2211
berghofe@17870
  2212
lemma fresh_abs_fun_iff_ineq: 
berghofe@17870
  2213
  fixes a :: "'y"
berghofe@17870
  2214
  and   b :: "'x"
berghofe@17870
  2215
  and   x :: "'a"
berghofe@17870
  2216
  assumes pta: "pt TYPE('a) TYPE('x)"
berghofe@17870
  2217
  and     ptb: "pt TYPE('y) TYPE('x)"
berghofe@17870
  2218
  and     at:  "at TYPE('x)"
berghofe@17870
  2219
  and     cp:  "cp TYPE('a) TYPE('x) TYPE('y)"
berghofe@17870
  2220
  and     dj:  "disjoint TYPE('y) TYPE('x)"
berghofe@17870
  2221
  shows "b\<sharp>([a].x) = b\<sharp>x" 
berghofe@17870
  2222
  by (simp add: fresh_def abs_fun_supp_ineq[OF pta, OF ptb, OF at, OF cp, OF dj])
berghofe@17870
  2223
berghofe@17870
  2224
section {* abstraction type for the datatype package (not really needed anymore) *}
berghofe@17870
  2225
(*===============================================================================*)
berghofe@17870
  2226
consts
berghofe@17870
  2227
  "ABS_set" :: "('x\<Rightarrow>('a nOption)) set"
berghofe@17870
  2228
inductive ABS_set
berghofe@17870
  2229
  intros
berghofe@17870
  2230
  ABS_in: "(abs_fun a x)\<in>ABS_set"
berghofe@17870
  2231
berghofe@17870
  2232
typedef (ABS) ('x,'a) ABS = "ABS_set::('x\<Rightarrow>('a nOption)) set"
berghofe@17870
  2233
proof 
berghofe@17870
  2234
  fix x::"'a" and a::"'x"
berghofe@17870
  2235
  show "(abs_fun a x)\<in> ABS_set" by (rule ABS_in)
berghofe@17870
  2236
qed
berghofe@17870
  2237
berghofe@17870
  2238
syntax ABS :: "type \<Rightarrow> type \<Rightarrow> type" ("\<guillemotleft>_\<guillemotright>_" [1000,1000] 1000)
berghofe@17870
  2239
berghofe@17870
  2240
berghofe@17870
  2241
section {* Lemmas for Deciding Permutation Equations *}
berghofe@17870
  2242
(*===================================================*)
berghofe@17870
  2243
berghofe@17870
  2244
lemma perm_eq_app:
berghofe@17870
  2245
  fixes f  :: "'a\<Rightarrow>'b"
berghofe@17870
  2246
  and   x  :: "'a"
berghofe@17870
  2247
  and   pi :: "'x prm"
berghofe@17870
  2248
  assumes pt: "pt TYPE('a) TYPE('x)"
berghofe@17870
  2249
  and     at: "at TYPE('x)"
berghofe@17870
  2250
  shows "(pi\<bullet>(f x)=y) = ((pi\<bullet>f)(pi\<bullet>x)=y)"
berghofe@17870
  2251
  by (simp add: pt_fun_app_eq[OF pt, OF at])
berghofe@17870
  2252
berghofe@17870
  2253
lemma perm_eq_lam:
berghofe@17870
  2254
  fixes f  :: "'a\<Rightarrow>'b"
berghofe@17870
  2255
  and   x  :: "'a"
berghofe@17870
  2256
  and   pi :: "'x prm"
berghofe@17870
  2257
  shows "((pi\<bullet>(\<lambda>x. f x))=y) = ((\<lambda>x. (pi\<bullet>(f ((rev pi)\<bullet>x))))=y)"
berghofe@17870
  2258
  by (simp add: perm_fun_def)
berghofe@17870
  2259
berghofe@17870
  2260
berghofe@17870
  2261
(***************************************)
berghofe@17870
  2262
(* setup for the individial atom-kinds *)
urbanc@18047
  2263
(* and nominal datatypes               *)
berghofe@17870
  2264
use "nominal_package.ML"
berghofe@17870
  2265
setup "NominalPackage.setup"
berghofe@17870
  2266
urbanc@18047
  2267
(*****************************************)
urbanc@18047
  2268
(* setup for induction principles method *)
berghofe@17870
  2269
use "nominal_induct.ML";
berghofe@17870
  2270
method_setup nominal_induct =
berghofe@17870
  2271
  {* nominal_induct_method *}
berghofe@17870
  2272
  {* nominal induction *}
berghofe@17870
  2273
berghofe@17870
  2274
(*******************************)
berghofe@17870
  2275
(* permutation equality tactic *)
berghofe@17870
  2276
use "nominal_permeq.ML";
urbanc@18012
  2277
berghofe@17870
  2278
method_setup perm_simp =
berghofe@17870
  2279
  {* perm_eq_meth *}
berghofe@17870
  2280
  {* tactic for deciding equalities involving permutations *}
berghofe@17870
  2281
berghofe@17870
  2282
method_setup perm_simp_debug =
berghofe@17870
  2283
  {* perm_eq_meth_debug *}
urbanc@18047
  2284
  {* tactic for deciding equalities involving permutations including debuging facilities *}
berghofe@17870
  2285
berghofe@17870
  2286
method_setup supports_simp =
berghofe@17870
  2287
  {* supports_meth *}
berghofe@17870
  2288
  {* tactic for deciding whether something supports semthing else *}
berghofe@17870
  2289
berghofe@17870
  2290
method_setup supports_simp_debug =
berghofe@17870
  2291
  {* supports_meth_debug *}
urbanc@18047
  2292
  {* tactic for deciding equalities involving permutations including debuging facilities *}
berghofe@17870
  2293
berghofe@17870
  2294
end
berghofe@17870
  2295
berghofe@17870
  2296