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