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