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