1062
+ − 1
(* Title: Nominal2_Base
+ − 2
Authors: Brian Huffman, Christian Urban
+ − 3
+ − 4
Basic definitions and lemma infrastructure for
+ − 5
Nominal Isabelle.
+ − 6
*)
+ − 7
theory Nominal2_Base
+ − 8
imports Main Infinite_Set
+ − 9
begin
+ − 10
+ − 11
section {* Atoms and Sorts *}
+ − 12
+ − 13
text {* A simple implementation for atom_sorts is strings. *}
+ − 14
(* types atom_sort = string *)
+ − 15
+ − 16
text {* To deal with Church-like binding we use trees of
+ − 17
strings as sorts. *}
+ − 18
+ − 19
datatype atom_sort = Sort "string" "atom_sort list"
+ − 20
+ − 21
datatype atom = Atom atom_sort nat
+ − 22
+ − 23
+ − 24
text {* Basic projection function. *}
+ − 25
+ − 26
primrec
+ − 27
sort_of :: "atom \<Rightarrow> atom_sort"
+ − 28
where
+ − 29
"sort_of (Atom s i) = s"
+ − 30
+ − 31
+ − 32
text {* There are infinitely many atoms of each sort. *}
+ − 33
lemma INFM_sort_of_eq:
+ − 34
shows "INFM a. sort_of a = s"
+ − 35
proof -
+ − 36
have "INFM i. sort_of (Atom s i) = s" by simp
+ − 37
moreover have "inj (Atom s)" by (simp add: inj_on_def)
+ − 38
ultimately show "INFM a. sort_of a = s" by (rule INFM_inj)
+ − 39
qed
+ − 40
+ − 41
lemma infinite_sort_of_eq:
+ − 42
shows "infinite {a. sort_of a = s}"
+ − 43
using INFM_sort_of_eq unfolding INFM_iff_infinite .
+ − 44
+ − 45
lemma atom_infinite [simp]:
+ − 46
shows "infinite (UNIV :: atom set)"
+ − 47
using subset_UNIV infinite_sort_of_eq
+ − 48
by (rule infinite_super)
+ − 49
+ − 50
lemma obtain_atom:
+ − 51
fixes X :: "atom set"
+ − 52
assumes X: "finite X"
+ − 53
obtains a where "a \<notin> X" "sort_of a = s"
+ − 54
proof -
+ − 55
from X have "MOST a. a \<notin> X"
+ − 56
unfolding MOST_iff_cofinite by simp
+ − 57
with INFM_sort_of_eq
+ − 58
have "INFM a. sort_of a = s \<and> a \<notin> X"
+ − 59
by (rule INFM_conjI)
+ − 60
then obtain a where "a \<notin> X" "sort_of a = s"
+ − 61
by (auto elim: INFM_E)
+ − 62
then show ?thesis ..
+ − 63
qed
+ − 64
+ − 65
section {* Sort-Respecting Permutations *}
+ − 66
+ − 67
typedef perm =
+ − 68
"{f. bij f \<and> finite {a. f a \<noteq> a} \<and> (\<forall>a. sort_of (f a) = sort_of a)}"
+ − 69
proof
+ − 70
show "id \<in> ?perm" by simp
+ − 71
qed
+ − 72
+ − 73
lemma permI:
+ − 74
assumes "bij f" and "MOST x. f x = x" and "\<And>a. sort_of (f a) = sort_of a"
+ − 75
shows "f \<in> perm"
+ − 76
using assms unfolding perm_def MOST_iff_cofinite by simp
+ − 77
+ − 78
lemma perm_is_bij: "f \<in> perm \<Longrightarrow> bij f"
+ − 79
unfolding perm_def by simp
+ − 80
+ − 81
lemma perm_is_finite: "f \<in> perm \<Longrightarrow> finite {a. f a \<noteq> a}"
+ − 82
unfolding perm_def by simp
+ − 83
+ − 84
lemma perm_is_sort_respecting: "f \<in> perm \<Longrightarrow> sort_of (f a) = sort_of a"
+ − 85
unfolding perm_def by simp
+ − 86
+ − 87
lemma perm_MOST: "f \<in> perm \<Longrightarrow> MOST x. f x = x"
+ − 88
unfolding perm_def MOST_iff_cofinite by simp
+ − 89
+ − 90
lemma perm_id: "id \<in> perm"
+ − 91
unfolding perm_def by simp
+ − 92
+ − 93
lemma perm_comp:
+ − 94
assumes f: "f \<in> perm" and g: "g \<in> perm"
+ − 95
shows "(f \<circ> g) \<in> perm"
+ − 96
apply (rule permI)
+ − 97
apply (rule bij_comp)
+ − 98
apply (rule perm_is_bij [OF g])
+ − 99
apply (rule perm_is_bij [OF f])
+ − 100
apply (rule MOST_rev_mp [OF perm_MOST [OF g]])
+ − 101
apply (rule MOST_rev_mp [OF perm_MOST [OF f]])
+ − 102
apply (simp)
+ − 103
apply (simp add: perm_is_sort_respecting [OF f])
+ − 104
apply (simp add: perm_is_sort_respecting [OF g])
+ − 105
done
+ − 106
+ − 107
lemma perm_inv:
+ − 108
assumes f: "f \<in> perm"
+ − 109
shows "(inv f) \<in> perm"
+ − 110
apply (rule permI)
+ − 111
apply (rule bij_imp_bij_inv)
+ − 112
apply (rule perm_is_bij [OF f])
+ − 113
apply (rule MOST_mono [OF perm_MOST [OF f]])
+ − 114
apply (erule subst, rule inv_f_f)
+ − 115
apply (rule bij_is_inj [OF perm_is_bij [OF f]])
+ − 116
apply (rule perm_is_sort_respecting [OF f, THEN sym, THEN trans])
+ − 117
apply (simp add: surj_f_inv_f [OF bij_is_surj [OF perm_is_bij [OF f]]])
+ − 118
done
+ − 119
+ − 120
lemma bij_Rep_perm: "bij (Rep_perm p)"
+ − 121
using Rep_perm [of p] unfolding perm_def by simp
+ − 122
+ − 123
lemma finite_Rep_perm: "finite {a. Rep_perm p a \<noteq> a}"
+ − 124
using Rep_perm [of p] unfolding perm_def by simp
+ − 125
+ − 126
lemma sort_of_Rep_perm: "sort_of (Rep_perm p a) = sort_of a"
+ − 127
using Rep_perm [of p] unfolding perm_def by simp
+ − 128
+ − 129
lemma Rep_perm_ext:
+ − 130
"Rep_perm p1 = Rep_perm p2 \<Longrightarrow> p1 = p2"
+ − 131
by (simp add: expand_fun_eq Rep_perm_inject [symmetric])
+ − 132
+ − 133
+ − 134
subsection {* Permutations form a group *}
+ − 135
+ − 136
instantiation perm :: group_add
+ − 137
begin
+ − 138
+ − 139
definition
+ − 140
"0 = Abs_perm id"
+ − 141
+ − 142
definition
+ − 143
"- p = Abs_perm (inv (Rep_perm p))"
+ − 144
+ − 145
definition
+ − 146
"p + q = Abs_perm (Rep_perm p \<circ> Rep_perm q)"
+ − 147
+ − 148
definition
+ − 149
"(p1::perm) - p2 = p1 + - p2"
+ − 150
+ − 151
lemma Rep_perm_0: "Rep_perm 0 = id"
+ − 152
unfolding zero_perm_def
+ − 153
by (simp add: Abs_perm_inverse perm_id)
+ − 154
+ − 155
lemma Rep_perm_add:
+ − 156
"Rep_perm (p1 + p2) = Rep_perm p1 \<circ> Rep_perm p2"
+ − 157
unfolding plus_perm_def
+ − 158
by (simp add: Abs_perm_inverse perm_comp Rep_perm)
+ − 159
+ − 160
lemma Rep_perm_uminus:
+ − 161
"Rep_perm (- p) = inv (Rep_perm p)"
+ − 162
unfolding uminus_perm_def
+ − 163
by (simp add: Abs_perm_inverse perm_inv Rep_perm)
+ − 164
+ − 165
instance
+ − 166
apply default
+ − 167
unfolding Rep_perm_inject [symmetric]
+ − 168
unfolding minus_perm_def
+ − 169
unfolding Rep_perm_add
+ − 170
unfolding Rep_perm_uminus
+ − 171
unfolding Rep_perm_0
+ − 172
by (simp_all add: o_assoc inv_o_cancel [OF bij_is_inj [OF bij_Rep_perm]])
+ − 173
+ − 174
end
+ − 175
+ − 176
+ − 177
section {* Implementation of swappings *}
+ − 178
+ − 179
definition
+ − 180
swap :: "atom \<Rightarrow> atom \<Rightarrow> perm" ("'(_ \<rightleftharpoons> _')")
+ − 181
where
+ − 182
"(a \<rightleftharpoons> b) =
+ − 183
Abs_perm (if sort_of a = sort_of b
+ − 184
then (\<lambda>c. if a = c then b else if b = c then a else c)
+ − 185
else id)"
+ − 186
+ − 187
lemma Rep_perm_swap:
+ − 188
"Rep_perm (a \<rightleftharpoons> b) =
+ − 189
(if sort_of a = sort_of b
+ − 190
then (\<lambda>c. if a = c then b else if b = c then a else c)
+ − 191
else id)"
+ − 192
unfolding swap_def
+ − 193
apply (rule Abs_perm_inverse)
+ − 194
apply (rule permI)
+ − 195
apply (auto simp add: bij_def inj_on_def surj_def)[1]
+ − 196
apply (rule MOST_rev_mp [OF MOST_neq(1) [of a]])
+ − 197
apply (rule MOST_rev_mp [OF MOST_neq(1) [of b]])
+ − 198
apply (simp)
+ − 199
apply (simp)
+ − 200
done
+ − 201
+ − 202
lemmas Rep_perm_simps =
+ − 203
Rep_perm_0
+ − 204
Rep_perm_add
+ − 205
Rep_perm_uminus
+ − 206
Rep_perm_swap
+ − 207
+ − 208
lemma swap_different_sorts [simp]:
+ − 209
"sort_of a \<noteq> sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) = 0"
+ − 210
by (rule Rep_perm_ext) (simp add: Rep_perm_simps)
+ − 211
+ − 212
lemma swap_cancel:
+ − 213
"(a \<rightleftharpoons> b) + (a \<rightleftharpoons> b) = 0"
+ − 214
by (rule Rep_perm_ext)
+ − 215
(simp add: Rep_perm_simps expand_fun_eq)
+ − 216
+ − 217
lemma swap_self [simp]:
+ − 218
"(a \<rightleftharpoons> a) = 0"
+ − 219
by (rule Rep_perm_ext, simp add: Rep_perm_simps expand_fun_eq)
+ − 220
+ − 221
lemma minus_swap [simp]:
+ − 222
"- (a \<rightleftharpoons> b) = (a \<rightleftharpoons> b)"
+ − 223
by (rule minus_unique [OF swap_cancel])
+ − 224
+ − 225
lemma swap_commute:
+ − 226
"(a \<rightleftharpoons> b) = (b \<rightleftharpoons> a)"
+ − 227
by (rule Rep_perm_ext)
+ − 228
(simp add: Rep_perm_swap expand_fun_eq)
+ − 229
+ − 230
lemma swap_triple:
+ − 231
assumes "a \<noteq> b" and "c \<noteq> b"
+ − 232
assumes "sort_of a = sort_of b" "sort_of b = sort_of c"
+ − 233
shows "(a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c) = (a \<rightleftharpoons> b)"
+ − 234
using assms
+ − 235
by (rule_tac Rep_perm_ext)
+ − 236
(auto simp add: Rep_perm_simps expand_fun_eq)
+ − 237
+ − 238
+ − 239
section {* Permutation Types *}
+ − 240
+ − 241
text {*
+ − 242
Infix syntax for @{text permute} has higher precedence than
+ − 243
addition, but lower than unary minus.
+ − 244
*}
+ − 245
+ − 246
class pt =
+ − 247
fixes permute :: "perm \<Rightarrow> 'a \<Rightarrow> 'a" ("_ \<bullet> _" [76, 75] 75)
+ − 248
assumes permute_zero [simp]: "0 \<bullet> x = x"
+ − 249
assumes permute_plus [simp]: "(p + q) \<bullet> x = p \<bullet> (q \<bullet> x)"
+ − 250
begin
+ − 251
+ − 252
lemma permute_diff [simp]:
+ − 253
shows "(p - q) \<bullet> x = p \<bullet> - q \<bullet> x"
+ − 254
unfolding diff_minus by simp
+ − 255
+ − 256
lemma permute_minus_cancel [simp]:
+ − 257
shows "p \<bullet> - p \<bullet> x = x"
+ − 258
and "- p \<bullet> p \<bullet> x = x"
+ − 259
unfolding permute_plus [symmetric] by simp_all
+ − 260
+ − 261
lemma permute_swap_cancel [simp]:
+ − 262
shows "(a \<rightleftharpoons> b) \<bullet> (a \<rightleftharpoons> b) \<bullet> x = x"
+ − 263
unfolding permute_plus [symmetric]
+ − 264
by (simp add: swap_cancel)
+ − 265
+ − 266
lemma permute_swap_cancel2 [simp]:
+ − 267
shows "(a \<rightleftharpoons> b) \<bullet> (b \<rightleftharpoons> a) \<bullet> x = x"
+ − 268
unfolding permute_plus [symmetric]
+ − 269
by (simp add: swap_commute)
+ − 270
+ − 271
lemma inj_permute [simp]:
+ − 272
shows "inj (permute p)"
+ − 273
by (rule inj_on_inverseI)
+ − 274
(rule permute_minus_cancel)
+ − 275
+ − 276
lemma surj_permute [simp]:
+ − 277
shows "surj (permute p)"
+ − 278
by (rule surjI, rule permute_minus_cancel)
+ − 279
+ − 280
lemma bij_permute [simp]:
+ − 281
shows "bij (permute p)"
+ − 282
by (rule bijI [OF inj_permute surj_permute])
+ − 283
+ − 284
lemma inv_permute:
+ − 285
shows "inv (permute p) = permute (- p)"
+ − 286
by (rule inv_equality) (simp_all)
+ − 287
+ − 288
lemma permute_minus:
+ − 289
shows "permute (- p) = inv (permute p)"
+ − 290
by (simp add: inv_permute)
+ − 291
+ − 292
lemma permute_eq_iff [simp]:
+ − 293
shows "p \<bullet> x = p \<bullet> y \<longleftrightarrow> x = y"
+ − 294
by (rule inj_permute [THEN inj_eq])
+ − 295
+ − 296
end
+ − 297
+ − 298
subsection {* Permutations for atoms *}
+ − 299
+ − 300
instantiation atom :: pt
+ − 301
begin
+ − 302
+ − 303
definition
+ − 304
"p \<bullet> a = Rep_perm p a"
+ − 305
+ − 306
instance
+ − 307
apply(default)
+ − 308
apply(simp_all add: permute_atom_def Rep_perm_simps)
+ − 309
done
+ − 310
+ − 311
end
+ − 312
+ − 313
lemma sort_of_permute [simp]:
+ − 314
shows "sort_of (p \<bullet> a) = sort_of a"
+ − 315
unfolding permute_atom_def by (rule sort_of_Rep_perm)
+ − 316
+ − 317
lemma swap_atom:
+ − 318
shows "(a \<rightleftharpoons> b) \<bullet> c =
+ − 319
(if sort_of a = sort_of b
+ − 320
then (if c = a then b else if c = b then a else c) else c)"
+ − 321
unfolding permute_atom_def
+ − 322
by (simp add: Rep_perm_swap)
+ − 323
+ − 324
lemma swap_atom_simps [simp]:
+ − 325
"sort_of a = sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> a = b"
+ − 326
"sort_of a = sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> b = a"
+ − 327
"c \<noteq> a \<Longrightarrow> c \<noteq> b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> c = c"
+ − 328
unfolding swap_atom by simp_all
+ − 329
+ − 330
lemma expand_perm_eq:
+ − 331
fixes p q :: "perm"
+ − 332
shows "p = q \<longleftrightarrow> (\<forall>a::atom. p \<bullet> a = q \<bullet> a)"
+ − 333
unfolding permute_atom_def
+ − 334
by (metis Rep_perm_ext ext)
+ − 335
+ − 336
+ − 337
subsection {* Permutations for permutations *}
+ − 338
+ − 339
instantiation perm :: pt
+ − 340
begin
+ − 341
+ − 342
definition
+ − 343
"p \<bullet> q = p + q - p"
+ − 344
+ − 345
instance
+ − 346
apply default
+ − 347
apply (simp add: permute_perm_def)
+ − 348
apply (simp add: permute_perm_def diff_minus minus_add add_assoc)
+ − 349
done
+ − 350
+ − 351
end
+ − 352
+ − 353
lemma permute_self: "p \<bullet> p = p"
+ − 354
unfolding permute_perm_def by (simp add: diff_minus add_assoc)
+ − 355
+ − 356
lemma permute_eqvt:
+ − 357
shows "p \<bullet> (q \<bullet> x) = (p \<bullet> q) \<bullet> (p \<bullet> x)"
+ − 358
unfolding permute_perm_def by simp
+ − 359
+ − 360
lemma zero_perm_eqvt:
+ − 361
shows "p \<bullet> (0::perm) = 0"
+ − 362
unfolding permute_perm_def by simp
+ − 363
+ − 364
lemma add_perm_eqvt:
+ − 365
fixes p p1 p2 :: perm
+ − 366
shows "p \<bullet> (p1 + p2) = p \<bullet> p1 + p \<bullet> p2"
+ − 367
unfolding permute_perm_def
+ − 368
by (simp add: expand_perm_eq)
+ − 369
+ − 370
lemma swap_eqvt:
+ − 371
shows "p \<bullet> (a \<rightleftharpoons> b) = (p \<bullet> a \<rightleftharpoons> p \<bullet> b)"
+ − 372
unfolding permute_perm_def
+ − 373
by (auto simp add: swap_atom expand_perm_eq)
+ − 374
+ − 375
+ − 376
subsection {* Permutations for functions *}
+ − 377
+ − 378
instantiation "fun" :: (pt, pt) pt
+ − 379
begin
+ − 380
+ − 381
definition
+ − 382
"p \<bullet> f = (\<lambda>x. p \<bullet> (f (- p \<bullet> x)))"
+ − 383
+ − 384
instance
+ − 385
apply default
+ − 386
apply (simp add: permute_fun_def)
+ − 387
apply (simp add: permute_fun_def minus_add)
+ − 388
done
+ − 389
+ − 390
end
+ − 391
+ − 392
lemma permute_fun_app_eq:
+ − 393
shows "p \<bullet> (f x) = (p \<bullet> f) (p \<bullet> x)"
+ − 394
unfolding permute_fun_def by simp
+ − 395
+ − 396
+ − 397
subsection {* Permutations for booleans *}
+ − 398
+ − 399
instantiation bool :: pt
+ − 400
begin
+ − 401
+ − 402
definition "p \<bullet> (b::bool) = b"
+ − 403
+ − 404
instance
+ − 405
apply(default)
+ − 406
apply(simp_all add: permute_bool_def)
+ − 407
done
+ − 408
+ − 409
end
+ − 410
+ − 411
lemma Not_eqvt:
+ − 412
shows "p \<bullet> (\<not> A) = (\<not> (p \<bullet> A))"
+ − 413
by (simp add: permute_bool_def)
+ − 414
1557
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 415
lemma permute_boolE:
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 416
fixes P::"bool"
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 417
shows "p \<bullet> P \<Longrightarrow> P"
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 418
by (simp add: permute_bool_def)
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 419
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 420
lemma permute_boolI:
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 421
fixes P::"bool"
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 422
shows "P \<Longrightarrow> p \<bullet> P"
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 423
by(simp add: permute_bool_def)
1062
+ − 424
+ − 425
subsection {* Permutations for sets *}
+ − 426
+ − 427
lemma permute_set_eq:
+ − 428
fixes x::"'a::pt"
+ − 429
and p::"perm"
+ − 430
shows "(p \<bullet> X) = {p \<bullet> x | x. x \<in> X}"
+ − 431
apply(auto simp add: permute_fun_def permute_bool_def mem_def)
+ − 432
apply(rule_tac x="- p \<bullet> x" in exI)
+ − 433
apply(simp)
+ − 434
done
+ − 435
+ − 436
lemma permute_set_eq_image:
+ − 437
shows "p \<bullet> X = permute p ` X"
+ − 438
unfolding permute_set_eq by auto
+ − 439
+ − 440
lemma permute_set_eq_vimage:
+ − 441
shows "p \<bullet> X = permute (- p) -` X"
+ − 442
unfolding permute_fun_def permute_bool_def
+ − 443
unfolding vimage_def Collect_def mem_def ..
+ − 444
+ − 445
lemma swap_set_not_in:
+ − 446
assumes a: "a \<notin> S" "b \<notin> S"
+ − 447
shows "(a \<rightleftharpoons> b) \<bullet> S = S"
+ − 448
using a by (auto simp add: permute_set_eq swap_atom)
+ − 449
+ − 450
lemma swap_set_in:
+ − 451
assumes a: "a \<in> S" "b \<notin> S" "sort_of a = sort_of b"
+ − 452
shows "(a \<rightleftharpoons> b) \<bullet> S \<noteq> S"
+ − 453
using a by (auto simp add: permute_set_eq swap_atom)
+ − 454
+ − 455
+ − 456
subsection {* Permutations for units *}
+ − 457
+ − 458
instantiation unit :: pt
+ − 459
begin
+ − 460
+ − 461
definition "p \<bullet> (u::unit) = u"
+ − 462
+ − 463
instance proof
+ − 464
qed (simp_all add: permute_unit_def)
+ − 465
+ − 466
end
+ − 467
+ − 468
+ − 469
subsection {* Permutations for products *}
+ − 470
+ − 471
instantiation "*" :: (pt, pt) pt
+ − 472
begin
+ − 473
+ − 474
primrec
+ − 475
permute_prod
+ − 476
where
+ − 477
Pair_eqvt: "p \<bullet> (x, y) = (p \<bullet> x, p \<bullet> y)"
+ − 478
+ − 479
instance
+ − 480
by default auto
+ − 481
+ − 482
end
+ − 483
+ − 484
subsection {* Permutations for sums *}
+ − 485
+ − 486
instantiation "+" :: (pt, pt) pt
+ − 487
begin
+ − 488
+ − 489
primrec
+ − 490
permute_sum
+ − 491
where
+ − 492
"p \<bullet> (Inl x) = Inl (p \<bullet> x)"
+ − 493
| "p \<bullet> (Inr y) = Inr (p \<bullet> y)"
+ − 494
+ − 495
instance proof
+ − 496
qed (case_tac [!] x, simp_all)
+ − 497
+ − 498
end
+ − 499
+ − 500
subsection {* Permutations for lists *}
+ − 501
+ − 502
instantiation list :: (pt) pt
+ − 503
begin
+ − 504
+ − 505
primrec
+ − 506
permute_list
+ − 507
where
+ − 508
"p \<bullet> [] = []"
+ − 509
| "p \<bullet> (x # xs) = p \<bullet> x # p \<bullet> xs"
+ − 510
+ − 511
instance proof
+ − 512
qed (induct_tac [!] x, simp_all)
+ − 513
+ − 514
end
+ − 515
+ − 516
subsection {* Permutations for options *}
+ − 517
+ − 518
instantiation option :: (pt) pt
+ − 519
begin
+ − 520
+ − 521
primrec
+ − 522
permute_option
+ − 523
where
+ − 524
"p \<bullet> None = None"
+ − 525
| "p \<bullet> (Some x) = Some (p \<bullet> x)"
+ − 526
+ − 527
instance proof
+ − 528
qed (induct_tac [!] x, simp_all)
+ − 529
+ − 530
end
+ − 531
+ − 532
subsection {* Permutations for @{typ char}, @{typ nat}, and @{typ int} *}
+ − 533
+ − 534
instantiation char :: pt
+ − 535
begin
+ − 536
+ − 537
definition "p \<bullet> (c::char) = c"
+ − 538
+ − 539
instance proof
+ − 540
qed (simp_all add: permute_char_def)
+ − 541
+ − 542
end
+ − 543
+ − 544
instantiation nat :: pt
+ − 545
begin
+ − 546
+ − 547
definition "p \<bullet> (n::nat) = n"
+ − 548
+ − 549
instance proof
+ − 550
qed (simp_all add: permute_nat_def)
+ − 551
+ − 552
end
+ − 553
+ − 554
instantiation int :: pt
+ − 555
begin
+ − 556
+ − 557
definition "p \<bullet> (i::int) = i"
+ − 558
+ − 559
instance proof
+ − 560
qed (simp_all add: permute_int_def)
+ − 561
+ − 562
end
+ − 563
+ − 564
+ − 565
section {* Pure types *}
+ − 566
+ − 567
text {* Pure types will have always empty support. *}
+ − 568
+ − 569
class pure = pt +
+ − 570
assumes permute_pure: "p \<bullet> x = x"
+ − 571
+ − 572
text {* Types @{typ unit} and @{typ bool} are pure. *}
+ − 573
+ − 574
instance unit :: pure
+ − 575
proof qed (rule permute_unit_def)
+ − 576
+ − 577
instance bool :: pure
+ − 578
proof qed (rule permute_bool_def)
+ − 579
+ − 580
text {* Other type constructors preserve purity. *}
+ − 581
+ − 582
instance "fun" :: (pure, pure) pure
+ − 583
by default (simp add: permute_fun_def permute_pure)
+ − 584
+ − 585
instance "*" :: (pure, pure) pure
+ − 586
by default (induct_tac x, simp add: permute_pure)
+ − 587
+ − 588
instance "+" :: (pure, pure) pure
+ − 589
by default (induct_tac x, simp_all add: permute_pure)
+ − 590
+ − 591
instance list :: (pure) pure
+ − 592
by default (induct_tac x, simp_all add: permute_pure)
+ − 593
+ − 594
instance option :: (pure) pure
+ − 595
by default (induct_tac x, simp_all add: permute_pure)
+ − 596
+ − 597
+ − 598
subsection {* Types @{typ char}, @{typ nat}, and @{typ int} *}
+ − 599
+ − 600
instance char :: pure
+ − 601
proof qed (rule permute_char_def)
+ − 602
+ − 603
instance nat :: pure
+ − 604
proof qed (rule permute_nat_def)
+ − 605
+ − 606
instance int :: pure
+ − 607
proof qed (rule permute_int_def)
+ − 608
+ − 609
+ − 610
subsection {* Supp, Freshness and Supports *}
+ − 611
+ − 612
context pt
+ − 613
begin
+ − 614
+ − 615
definition
+ − 616
supp :: "'a \<Rightarrow> atom set"
+ − 617
where
+ − 618
"supp x = {a. infinite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}}"
+ − 619
+ − 620
end
+ − 621
+ − 622
definition
+ − 623
fresh :: "atom \<Rightarrow> 'a::pt \<Rightarrow> bool" ("_ \<sharp> _" [55, 55] 55)
+ − 624
where
+ − 625
"a \<sharp> x \<equiv> a \<notin> supp x"
+ − 626
+ − 627
lemma supp_conv_fresh:
+ − 628
shows "supp x = {a. \<not> a \<sharp> x}"
+ − 629
unfolding fresh_def by simp
+ − 630
+ − 631
lemma swap_rel_trans:
+ − 632
assumes "sort_of a = sort_of b"
+ − 633
assumes "sort_of b = sort_of c"
+ − 634
assumes "(a \<rightleftharpoons> c) \<bullet> x = x"
+ − 635
assumes "(b \<rightleftharpoons> c) \<bullet> x = x"
+ − 636
shows "(a \<rightleftharpoons> b) \<bullet> x = x"
+ − 637
proof (cases)
+ − 638
assume "a = b \<or> c = b"
+ − 639
with assms show "(a \<rightleftharpoons> b) \<bullet> x = x" by auto
+ − 640
next
+ − 641
assume *: "\<not> (a = b \<or> c = b)"
+ − 642
have "((a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c)) \<bullet> x = x"
+ − 643
using assms by simp
+ − 644
also have "(a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c) = (a \<rightleftharpoons> b)"
+ − 645
using assms * by (simp add: swap_triple)
+ − 646
finally show "(a \<rightleftharpoons> b) \<bullet> x = x" .
+ − 647
qed
+ − 648
+ − 649
lemma swap_fresh_fresh:
+ − 650
assumes a: "a \<sharp> x"
+ − 651
and b: "b \<sharp> x"
+ − 652
shows "(a \<rightleftharpoons> b) \<bullet> x = x"
+ − 653
proof (cases)
+ − 654
assume asm: "sort_of a = sort_of b"
+ − 655
have "finite {c. (a \<rightleftharpoons> c) \<bullet> x \<noteq> x}" "finite {c. (b \<rightleftharpoons> c) \<bullet> x \<noteq> x}"
+ − 656
using a b unfolding fresh_def supp_def by simp_all
+ − 657
then have "finite ({c. (a \<rightleftharpoons> c) \<bullet> x \<noteq> x} \<union> {c. (b \<rightleftharpoons> c) \<bullet> x \<noteq> x})" by simp
+ − 658
then obtain c
+ − 659
where "(a \<rightleftharpoons> c) \<bullet> x = x" "(b \<rightleftharpoons> c) \<bullet> x = x" "sort_of c = sort_of b"
+ − 660
by (rule obtain_atom) (auto)
+ − 661
then show "(a \<rightleftharpoons> b) \<bullet> x = x" using asm by (rule_tac swap_rel_trans) (simp_all)
+ − 662
next
+ − 663
assume "sort_of a \<noteq> sort_of b"
+ − 664
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by simp
+ − 665
qed
+ − 666
+ − 667
+ − 668
subsection {* supp and fresh are equivariant *}
+ − 669
+ − 670
lemma finite_Collect_bij:
+ − 671
assumes a: "bij f"
+ − 672
shows "finite {x. P (f x)} = finite {x. P x}"
+ − 673
by (metis a finite_vimage_iff vimage_Collect_eq)
+ − 674
+ − 675
lemma fresh_permute_iff:
+ − 676
shows "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> a \<sharp> x"
+ − 677
proof -
+ − 678
have "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}"
+ − 679
unfolding fresh_def supp_def by simp
+ − 680
also have "\<dots> \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> p \<bullet> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}"
+ − 681
using bij_permute by (rule finite_Collect_bij [symmetric])
+ − 682
also have "\<dots> \<longleftrightarrow> finite {b. p \<bullet> (a \<rightleftharpoons> b) \<bullet> x \<noteq> p \<bullet> x}"
+ − 683
by (simp only: permute_eqvt [of p] swap_eqvt)
+ − 684
also have "\<dots> \<longleftrightarrow> finite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}"
+ − 685
by (simp only: permute_eq_iff)
+ − 686
also have "\<dots> \<longleftrightarrow> a \<sharp> x"
+ − 687
unfolding fresh_def supp_def by simp
+ − 688
finally show ?thesis .
+ − 689
qed
+ − 690
+ − 691
lemma fresh_eqvt:
+ − 692
shows "p \<bullet> (a \<sharp> x) = (p \<bullet> a) \<sharp> (p \<bullet> x)"
+ − 693
by (simp add: permute_bool_def fresh_permute_iff)
+ − 694
+ − 695
lemma supp_eqvt:
+ − 696
fixes p :: "perm"
+ − 697
and x :: "'a::pt"
+ − 698
shows "p \<bullet> (supp x) = supp (p \<bullet> x)"
+ − 699
unfolding supp_conv_fresh
+ − 700
unfolding permute_fun_def Collect_def
+ − 701
by (simp add: Not_eqvt fresh_eqvt)
+ − 702
+ − 703
subsection {* supports *}
+ − 704
+ − 705
definition
+ − 706
supports :: "atom set \<Rightarrow> 'a::pt \<Rightarrow> bool" (infixl "supports" 80)
+ − 707
where
+ − 708
"S supports x \<equiv> \<forall>a b. (a \<notin> S \<and> b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x)"
+ − 709
+ − 710
lemma supp_is_subset:
+ − 711
fixes S :: "atom set"
+ − 712
and x :: "'a::pt"
+ − 713
assumes a1: "S supports x"
+ − 714
and a2: "finite S"
+ − 715
shows "(supp x) \<subseteq> S"
+ − 716
proof (rule ccontr)
+ − 717
assume "\<not>(supp x \<subseteq> S)"
+ − 718
then obtain a where b1: "a \<in> supp x" and b2: "a \<notin> S" by auto
+ − 719
from a1 b2 have "\<forall>b. b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x" by (unfold supports_def) (auto)
+ − 720
hence "{b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x} \<subseteq> S" by auto
+ − 721
with a2 have "finite {b. (a \<rightleftharpoons> b)\<bullet>x \<noteq> x}" by (simp add: finite_subset)
+ − 722
then have "a \<notin> (supp x)" unfolding supp_def by simp
+ − 723
with b1 show False by simp
+ − 724
qed
+ − 725
+ − 726
lemma supports_finite:
+ − 727
fixes S :: "atom set"
+ − 728
and x :: "'a::pt"
+ − 729
assumes a1: "S supports x"
+ − 730
and a2: "finite S"
+ − 731
shows "finite (supp x)"
+ − 732
proof -
+ − 733
have "(supp x) \<subseteq> S" using a1 a2 by (rule supp_is_subset)
+ − 734
then show "finite (supp x)" using a2 by (simp add: finite_subset)
+ − 735
qed
+ − 736
+ − 737
lemma supp_supports:
+ − 738
fixes x :: "'a::pt"
+ − 739
shows "(supp x) supports x"
+ − 740
proof (unfold supports_def, intro strip)
+ − 741
fix a b
+ − 742
assume "a \<notin> (supp x) \<and> b \<notin> (supp x)"
+ − 743
then have "a \<sharp> x" and "b \<sharp> x" by (simp_all add: fresh_def)
+ − 744
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by (rule swap_fresh_fresh)
+ − 745
qed
+ − 746
+ − 747
lemma supp_is_least_supports:
+ − 748
fixes S :: "atom set"
+ − 749
and x :: "'a::pt"
+ − 750
assumes a1: "S supports x"
+ − 751
and a2: "finite S"
+ − 752
and a3: "\<And>S'. finite S' \<Longrightarrow> (S' supports x) \<Longrightarrow> S \<subseteq> S'"
+ − 753
shows "(supp x) = S"
+ − 754
proof (rule equalityI)
+ − 755
show "(supp x) \<subseteq> S" using a1 a2 by (rule supp_is_subset)
+ − 756
with a2 have fin: "finite (supp x)" by (rule rev_finite_subset)
+ − 757
have "(supp x) supports x" by (rule supp_supports)
+ − 758
with fin a3 show "S \<subseteq> supp x" by blast
+ − 759
qed
+ − 760
+ − 761
lemma subsetCI:
+ − 762
shows "(\<And>x. x \<in> A \<Longrightarrow> x \<notin> B \<Longrightarrow> False) \<Longrightarrow> A \<subseteq> B"
+ − 763
by auto
+ − 764
+ − 765
lemma finite_supp_unique:
+ − 766
assumes a1: "S supports x"
+ − 767
assumes a2: "finite S"
+ − 768
assumes a3: "\<And>a b. \<lbrakk>a \<in> S; b \<notin> S; sort_of a = sort_of b\<rbrakk> \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> x \<noteq> x"
+ − 769
shows "(supp x) = S"
+ − 770
using a1 a2
+ − 771
proof (rule supp_is_least_supports)
+ − 772
fix S'
+ − 773
assume "finite S'" and "S' supports x"
+ − 774
show "S \<subseteq> S'"
+ − 775
proof (rule subsetCI)
+ − 776
fix a
+ − 777
assume "a \<in> S" and "a \<notin> S'"
+ − 778
have "finite (S \<union> S')"
+ − 779
using `finite S` `finite S'` by simp
+ − 780
then obtain b where "b \<notin> S \<union> S'" and "sort_of b = sort_of a"
+ − 781
by (rule obtain_atom)
+ − 782
then have "b \<notin> S" and "b \<notin> S'" and "sort_of a = sort_of b"
+ − 783
by simp_all
+ − 784
then have "(a \<rightleftharpoons> b) \<bullet> x = x"
+ − 785
using `a \<notin> S'` `S' supports x` by (simp add: supports_def)
+ − 786
moreover have "(a \<rightleftharpoons> b) \<bullet> x \<noteq> x"
+ − 787
using `a \<in> S` `b \<notin> S` `sort_of a = sort_of b`
+ − 788
by (rule a3)
+ − 789
ultimately show "False" by simp
+ − 790
qed
+ − 791
qed
+ − 792
+ − 793
section {* Finitely-supported types *}
+ − 794
+ − 795
class fs = pt +
+ − 796
assumes finite_supp: "finite (supp x)"
+ − 797
+ − 798
lemma pure_supp:
+ − 799
shows "supp (x::'a::pure) = {}"
+ − 800
unfolding supp_def by (simp add: permute_pure)
+ − 801
+ − 802
lemma pure_fresh:
+ − 803
fixes x::"'a::pure"
+ − 804
shows "a \<sharp> x"
+ − 805
unfolding fresh_def by (simp add: pure_supp)
+ − 806
+ − 807
instance pure < fs
+ − 808
by default (simp add: pure_supp)
+ − 809
+ − 810
+ − 811
subsection {* Type @{typ atom} is finitely-supported. *}
+ − 812
+ − 813
lemma supp_atom:
+ − 814
shows "supp a = {a}"
+ − 815
apply (rule finite_supp_unique)
+ − 816
apply (clarsimp simp add: supports_def)
+ − 817
apply simp
+ − 818
apply simp
+ − 819
done
+ − 820
+ − 821
lemma fresh_atom:
+ − 822
shows "a \<sharp> b \<longleftrightarrow> a \<noteq> b"
+ − 823
unfolding fresh_def supp_atom by simp
+ − 824
+ − 825
instance atom :: fs
+ − 826
by default (simp add: supp_atom)
+ − 827
+ − 828
+ − 829
section {* Type @{typ perm} is finitely-supported. *}
+ − 830
+ − 831
lemma perm_swap_eq:
+ − 832
shows "(a \<rightleftharpoons> b) \<bullet> p = p \<longleftrightarrow> (p \<bullet> (a \<rightleftharpoons> b)) = (a \<rightleftharpoons> b)"
+ − 833
unfolding permute_perm_def
+ − 834
by (metis add_diff_cancel minus_perm_def)
+ − 835
+ − 836
lemma supports_perm:
+ − 837
shows "{a. p \<bullet> a \<noteq> a} supports p"
+ − 838
unfolding supports_def
+ − 839
by (simp add: perm_swap_eq swap_eqvt)
+ − 840
+ − 841
lemma finite_perm_lemma:
+ − 842
shows "finite {a::atom. p \<bullet> a \<noteq> a}"
+ − 843
using finite_Rep_perm [of p]
+ − 844
unfolding permute_atom_def .
+ − 845
+ − 846
lemma supp_perm:
+ − 847
shows "supp p = {a. p \<bullet> a \<noteq> a}"
+ − 848
apply (rule finite_supp_unique)
+ − 849
apply (rule supports_perm)
+ − 850
apply (rule finite_perm_lemma)
+ − 851
apply (simp add: perm_swap_eq swap_eqvt)
+ − 852
apply (auto simp add: expand_perm_eq swap_atom)
+ − 853
done
+ − 854
+ − 855
lemma fresh_perm:
+ − 856
shows "a \<sharp> p \<longleftrightarrow> p \<bullet> a = a"
+ − 857
unfolding fresh_def by (simp add: supp_perm)
+ − 858
+ − 859
lemma supp_swap:
+ − 860
shows "supp (a \<rightleftharpoons> b) = (if a = b \<or> sort_of a \<noteq> sort_of b then {} else {a, b})"
+ − 861
by (auto simp add: supp_perm swap_atom)
+ − 862
+ − 863
lemma fresh_zero_perm:
+ − 864
shows "a \<sharp> (0::perm)"
+ − 865
unfolding fresh_perm by simp
+ − 866
+ − 867
lemma supp_zero_perm:
+ − 868
shows "supp (0::perm) = {}"
+ − 869
unfolding supp_perm by simp
+ − 870
1087
+ − 871
lemma fresh_plus_perm:
+ − 872
fixes p q::perm
+ − 873
assumes "a \<sharp> p" "a \<sharp> q"
+ − 874
shows "a \<sharp> (p + q)"
+ − 875
using assms
+ − 876
unfolding fresh_def
+ − 877
by (auto simp add: supp_perm)
+ − 878
1062
+ − 879
lemma supp_plus_perm:
+ − 880
fixes p q::perm
+ − 881
shows "supp (p + q) \<subseteq> supp p \<union> supp q"
+ − 882
by (auto simp add: supp_perm)
+ − 883
1087
+ − 884
lemma fresh_minus_perm:
+ − 885
fixes p::perm
+ − 886
shows "a \<sharp> (- p) \<longleftrightarrow> a \<sharp> p"
+ − 887
unfolding fresh_def
+ − 888
apply(auto simp add: supp_perm)
+ − 889
apply(metis permute_minus_cancel)+
+ − 890
done
+ − 891
1062
+ − 892
lemma supp_minus_perm:
+ − 893
fixes p::perm
+ − 894
shows "supp (- p) = supp p"
1087
+ − 895
unfolding supp_conv_fresh
+ − 896
by (simp add: fresh_minus_perm)
1062
+ − 897
+ − 898
instance perm :: fs
+ − 899
by default (simp add: supp_perm finite_perm_lemma)
+ − 900
1305
+ − 901
lemma plus_perm_eq:
+ − 902
fixes p q::"perm"
+ − 903
assumes asm: "supp p \<inter> supp q = {}"
+ − 904
shows "p + q = q + p"
+ − 905
unfolding expand_perm_eq
+ − 906
proof
+ − 907
fix a::"atom"
+ − 908
show "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 909
proof -
+ − 910
{ assume "a \<notin> supp p" "a \<notin> supp q"
+ − 911
then have "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 912
by (simp add: supp_perm)
+ − 913
}
+ − 914
moreover
+ − 915
{ assume a: "a \<in> supp p" "a \<notin> supp q"
+ − 916
then have "p \<bullet> a \<in> supp p" by (simp add: supp_perm)
+ − 917
then have "p \<bullet> a \<notin> supp q" using asm by auto
+ − 918
with a have "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 919
by (simp add: supp_perm)
+ − 920
}
+ − 921
moreover
+ − 922
{ assume a: "a \<notin> supp p" "a \<in> supp q"
+ − 923
then have "q \<bullet> a \<in> supp q" by (simp add: supp_perm)
+ − 924
then have "q \<bullet> a \<notin> supp p" using asm by auto
+ − 925
with a have "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 926
by (simp add: supp_perm)
+ − 927
}
+ − 928
ultimately show "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 929
using asm by blast
+ − 930
qed
+ − 931
qed
1062
+ − 932
+ − 933
section {* Finite Support instances for other types *}
+ − 934
+ − 935
subsection {* Type @{typ "'a \<times> 'b"} is finitely-supported. *}
+ − 936
+ − 937
lemma supp_Pair:
+ − 938
shows "supp (x, y) = supp x \<union> supp y"
+ − 939
by (simp add: supp_def Collect_imp_eq Collect_neg_eq)
+ − 940
+ − 941
lemma fresh_Pair:
+ − 942
shows "a \<sharp> (x, y) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> y"
+ − 943
by (simp add: fresh_def supp_Pair)
+ − 944
+ − 945
instance "*" :: (fs, fs) fs
+ − 946
apply default
+ − 947
apply (induct_tac x)
+ − 948
apply (simp add: supp_Pair finite_supp)
+ − 949
done
+ − 950
+ − 951
subsection {* Type @{typ "'a + 'b"} is finitely supported *}
+ − 952
+ − 953
lemma supp_Inl:
+ − 954
shows "supp (Inl x) = supp x"
+ − 955
by (simp add: supp_def)
+ − 956
+ − 957
lemma supp_Inr:
+ − 958
shows "supp (Inr x) = supp x"
+ − 959
by (simp add: supp_def)
+ − 960
+ − 961
lemma fresh_Inl:
+ − 962
shows "a \<sharp> Inl x \<longleftrightarrow> a \<sharp> x"
+ − 963
by (simp add: fresh_def supp_Inl)
+ − 964
+ − 965
lemma fresh_Inr:
+ − 966
shows "a \<sharp> Inr y \<longleftrightarrow> a \<sharp> y"
+ − 967
by (simp add: fresh_def supp_Inr)
+ − 968
+ − 969
instance "+" :: (fs, fs) fs
+ − 970
apply default
+ − 971
apply (induct_tac x)
+ − 972
apply (simp_all add: supp_Inl supp_Inr finite_supp)
+ − 973
done
+ − 974
+ − 975
subsection {* Type @{typ "'a option"} is finitely supported *}
+ − 976
+ − 977
lemma supp_None:
+ − 978
shows "supp None = {}"
+ − 979
by (simp add: supp_def)
+ − 980
+ − 981
lemma supp_Some:
+ − 982
shows "supp (Some x) = supp x"
+ − 983
by (simp add: supp_def)
+ − 984
+ − 985
lemma fresh_None:
+ − 986
shows "a \<sharp> None"
+ − 987
by (simp add: fresh_def supp_None)
+ − 988
+ − 989
lemma fresh_Some:
+ − 990
shows "a \<sharp> Some x \<longleftrightarrow> a \<sharp> x"
+ − 991
by (simp add: fresh_def supp_Some)
+ − 992
+ − 993
instance option :: (fs) fs
+ − 994
apply default
+ − 995
apply (induct_tac x)
+ − 996
apply (simp_all add: supp_None supp_Some finite_supp)
+ − 997
done
+ − 998
+ − 999
subsubsection {* Type @{typ "'a list"} is finitely supported *}
+ − 1000
+ − 1001
lemma supp_Nil:
+ − 1002
shows "supp [] = {}"
+ − 1003
by (simp add: supp_def)
+ − 1004
+ − 1005
lemma supp_Cons:
+ − 1006
shows "supp (x # xs) = supp x \<union> supp xs"
+ − 1007
by (simp add: supp_def Collect_imp_eq Collect_neg_eq)
+ − 1008
+ − 1009
lemma fresh_Nil:
+ − 1010
shows "a \<sharp> []"
+ − 1011
by (simp add: fresh_def supp_Nil)
+ − 1012
+ − 1013
lemma fresh_Cons:
+ − 1014
shows "a \<sharp> (x # xs) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> xs"
+ − 1015
by (simp add: fresh_def supp_Cons)
+ − 1016
+ − 1017
instance list :: (fs) fs
+ − 1018
apply default
+ − 1019
apply (induct_tac x)
+ − 1020
apply (simp_all add: supp_Nil supp_Cons finite_supp)
+ − 1021
done
+ − 1022
+ − 1023
section {* Support and freshness for applications *}
+ − 1024
+ − 1025
lemma supp_fun_app:
+ − 1026
shows "supp (f x) \<subseteq> (supp f) \<union> (supp x)"
+ − 1027
proof (rule subsetCI)
+ − 1028
fix a::"atom"
+ − 1029
assume a: "a \<in> supp (f x)"
+ − 1030
assume b: "a \<notin> supp f \<union> supp x"
+ − 1031
then have "finite {b. (a \<rightleftharpoons> b) \<bullet> f \<noteq> f}" "finite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}"
+ − 1032
unfolding supp_def by auto
+ − 1033
then have "finite ({b. (a \<rightleftharpoons> b) \<bullet> f \<noteq> f} \<union> {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x})" by simp
+ − 1034
moreover
+ − 1035
have "{b. ((a \<rightleftharpoons> b) \<bullet> f) ((a \<rightleftharpoons> b) \<bullet> x) \<noteq> f x} \<subseteq> ({b. (a \<rightleftharpoons> b) \<bullet> f \<noteq> f} \<union> {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x})"
+ − 1036
by auto
+ − 1037
ultimately have "finite {b. ((a \<rightleftharpoons> b) \<bullet> f) ((a \<rightleftharpoons> b) \<bullet> x) \<noteq> f x}"
+ − 1038
using finite_subset by auto
+ − 1039
then have "a \<notin> supp (f x)" unfolding supp_def
+ − 1040
by (simp add: permute_fun_app_eq)
+ − 1041
with a show "False" by simp
+ − 1042
qed
+ − 1043
+ − 1044
lemma fresh_fun_app:
+ − 1045
shows "a \<sharp> (f, x) \<Longrightarrow> a \<sharp> f x"
+ − 1046
unfolding fresh_def
+ − 1047
using supp_fun_app
+ − 1048
by (auto simp add: supp_Pair)
+ − 1049
+ − 1050
lemma fresh_fun_eqvt_app:
+ − 1051
assumes a: "\<forall>p. p \<bullet> f = f"
+ − 1052
shows "a \<sharp> x \<Longrightarrow> a \<sharp> f x"
+ − 1053
proof -
+ − 1054
from a have b: "supp f = {}"
+ − 1055
unfolding supp_def by simp
+ − 1056
show "a \<sharp> x \<Longrightarrow> a \<sharp> f x"
+ − 1057
unfolding fresh_def
+ − 1058
using supp_fun_app b
+ − 1059
by auto
+ − 1060
qed
+ − 1061
+ − 1062
end