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