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
2635
+ − 8
imports Main
+ − 9
"~~/src/HOL/Library/Infinite_Set"
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 10
"~~/src/HOL/Quotient_Examples/FSet"
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 11
uses ("nominal_library.ML")
2467
+ − 12
("nominal_atoms.ML")
1062
+ − 13
begin
+ − 14
+ − 15
section {* Atoms and Sorts *}
+ − 16
+ − 17
text {* A simple implementation for atom_sorts is strings. *}
+ − 18
(* types atom_sort = string *)
+ − 19
+ − 20
text {* To deal with Church-like binding we use trees of
+ − 21
strings as sorts. *}
+ − 22
+ − 23
datatype atom_sort = Sort "string" "atom_sort list"
+ − 24
+ − 25
datatype atom = Atom atom_sort nat
+ − 26
+ − 27
+ − 28
text {* Basic projection function. *}
+ − 29
+ − 30
primrec
+ − 31
sort_of :: "atom \<Rightarrow> atom_sort"
+ − 32
where
+ − 33
"sort_of (Atom s i) = s"
+ − 34
1930
+ − 35
primrec
+ − 36
nat_of :: "atom \<Rightarrow> nat"
+ − 37
where
+ − 38
"nat_of (Atom s n) = n"
+ − 39
1062
+ − 40
+ − 41
text {* There are infinitely many atoms of each sort. *}
+ − 42
lemma INFM_sort_of_eq:
+ − 43
shows "INFM a. sort_of a = s"
+ − 44
proof -
+ − 45
have "INFM i. sort_of (Atom s i) = s" by simp
+ − 46
moreover have "inj (Atom s)" by (simp add: inj_on_def)
+ − 47
ultimately show "INFM a. sort_of a = s" by (rule INFM_inj)
+ − 48
qed
+ − 49
+ − 50
lemma infinite_sort_of_eq:
+ − 51
shows "infinite {a. sort_of a = s}"
+ − 52
using INFM_sort_of_eq unfolding INFM_iff_infinite .
+ − 53
+ − 54
lemma atom_infinite [simp]:
+ − 55
shows "infinite (UNIV :: atom set)"
+ − 56
using subset_UNIV infinite_sort_of_eq
+ − 57
by (rule infinite_super)
+ − 58
+ − 59
lemma obtain_atom:
+ − 60
fixes X :: "atom set"
+ − 61
assumes X: "finite X"
+ − 62
obtains a where "a \<notin> X" "sort_of a = s"
+ − 63
proof -
+ − 64
from X have "MOST a. a \<notin> X"
+ − 65
unfolding MOST_iff_cofinite by simp
+ − 66
with INFM_sort_of_eq
+ − 67
have "INFM a. sort_of a = s \<and> a \<notin> X"
+ − 68
by (rule INFM_conjI)
+ − 69
then obtain a where "a \<notin> X" "sort_of a = s"
+ − 70
by (auto elim: INFM_E)
+ − 71
then show ?thesis ..
+ − 72
qed
+ − 73
1930
+ − 74
lemma atom_components_eq_iff:
+ − 75
fixes a b :: atom
+ − 76
shows "a = b \<longleftrightarrow> sort_of a = sort_of b \<and> nat_of a = nat_of b"
+ − 77
by (induct a, induct b, simp)
+ − 78
1062
+ − 79
section {* Sort-Respecting Permutations *}
+ − 80
+ − 81
typedef perm =
+ − 82
"{f. bij f \<and> finite {a. f a \<noteq> a} \<and> (\<forall>a. sort_of (f a) = sort_of a)}"
+ − 83
proof
+ − 84
show "id \<in> ?perm" by simp
+ − 85
qed
+ − 86
+ − 87
lemma permI:
+ − 88
assumes "bij f" and "MOST x. f x = x" and "\<And>a. sort_of (f a) = sort_of a"
+ − 89
shows "f \<in> perm"
+ − 90
using assms unfolding perm_def MOST_iff_cofinite by simp
+ − 91
+ − 92
lemma perm_is_bij: "f \<in> perm \<Longrightarrow> bij f"
+ − 93
unfolding perm_def by simp
+ − 94
+ − 95
lemma perm_is_finite: "f \<in> perm \<Longrightarrow> finite {a. f a \<noteq> a}"
+ − 96
unfolding perm_def by simp
+ − 97
+ − 98
lemma perm_is_sort_respecting: "f \<in> perm \<Longrightarrow> sort_of (f a) = sort_of a"
+ − 99
unfolding perm_def by simp
+ − 100
+ − 101
lemma perm_MOST: "f \<in> perm \<Longrightarrow> MOST x. f x = x"
+ − 102
unfolding perm_def MOST_iff_cofinite by simp
+ − 103
+ − 104
lemma perm_id: "id \<in> perm"
+ − 105
unfolding perm_def by simp
+ − 106
+ − 107
lemma perm_comp:
+ − 108
assumes f: "f \<in> perm" and g: "g \<in> perm"
+ − 109
shows "(f \<circ> g) \<in> perm"
+ − 110
apply (rule permI)
+ − 111
apply (rule bij_comp)
+ − 112
apply (rule perm_is_bij [OF g])
+ − 113
apply (rule perm_is_bij [OF f])
+ − 114
apply (rule MOST_rev_mp [OF perm_MOST [OF g]])
+ − 115
apply (rule MOST_rev_mp [OF perm_MOST [OF f]])
+ − 116
apply (simp)
+ − 117
apply (simp add: perm_is_sort_respecting [OF f])
+ − 118
apply (simp add: perm_is_sort_respecting [OF g])
+ − 119
done
+ − 120
+ − 121
lemma perm_inv:
+ − 122
assumes f: "f \<in> perm"
+ − 123
shows "(inv f) \<in> perm"
+ − 124
apply (rule permI)
+ − 125
apply (rule bij_imp_bij_inv)
+ − 126
apply (rule perm_is_bij [OF f])
+ − 127
apply (rule MOST_mono [OF perm_MOST [OF f]])
+ − 128
apply (erule subst, rule inv_f_f)
+ − 129
apply (rule bij_is_inj [OF perm_is_bij [OF f]])
+ − 130
apply (rule perm_is_sort_respecting [OF f, THEN sym, THEN trans])
+ − 131
apply (simp add: surj_f_inv_f [OF bij_is_surj [OF perm_is_bij [OF f]]])
+ − 132
done
+ − 133
+ − 134
lemma bij_Rep_perm: "bij (Rep_perm p)"
+ − 135
using Rep_perm [of p] unfolding perm_def by simp
+ − 136
+ − 137
lemma finite_Rep_perm: "finite {a. Rep_perm p a \<noteq> a}"
+ − 138
using Rep_perm [of p] unfolding perm_def by simp
+ − 139
+ − 140
lemma sort_of_Rep_perm: "sort_of (Rep_perm p a) = sort_of a"
+ − 141
using Rep_perm [of p] unfolding perm_def by simp
+ − 142
+ − 143
lemma Rep_perm_ext:
+ − 144
"Rep_perm p1 = Rep_perm p2 \<Longrightarrow> p1 = p2"
2479
+ − 145
by (simp add: fun_eq_iff Rep_perm_inject [symmetric])
1062
+ − 146
2560
+ − 147
instance perm :: size ..
1062
+ − 148
2732
+ − 149
subsection {* Permutations form a (multiplicative) group *}
+ − 150
1062
+ − 151
+ − 152
instantiation perm :: group_add
+ − 153
begin
+ − 154
+ − 155
definition
+ − 156
"0 = Abs_perm id"
+ − 157
+ − 158
definition
+ − 159
"- p = Abs_perm (inv (Rep_perm p))"
+ − 160
+ − 161
definition
+ − 162
"p + q = Abs_perm (Rep_perm p \<circ> Rep_perm q)"
+ − 163
+ − 164
definition
+ − 165
"(p1::perm) - p2 = p1 + - p2"
+ − 166
+ − 167
lemma Rep_perm_0: "Rep_perm 0 = id"
+ − 168
unfolding zero_perm_def
+ − 169
by (simp add: Abs_perm_inverse perm_id)
+ − 170
+ − 171
lemma Rep_perm_add:
+ − 172
"Rep_perm (p1 + p2) = Rep_perm p1 \<circ> Rep_perm p2"
+ − 173
unfolding plus_perm_def
+ − 174
by (simp add: Abs_perm_inverse perm_comp Rep_perm)
+ − 175
+ − 176
lemma Rep_perm_uminus:
+ − 177
"Rep_perm (- p) = inv (Rep_perm p)"
+ − 178
unfolding uminus_perm_def
+ − 179
by (simp add: Abs_perm_inverse perm_inv Rep_perm)
+ − 180
+ − 181
instance
+ − 182
apply default
+ − 183
unfolding Rep_perm_inject [symmetric]
+ − 184
unfolding minus_perm_def
+ − 185
unfolding Rep_perm_add
+ − 186
unfolding Rep_perm_uminus
+ − 187
unfolding Rep_perm_0
+ − 188
by (simp_all add: o_assoc inv_o_cancel [OF bij_is_inj [OF bij_Rep_perm]])
+ − 189
+ − 190
end
+ − 191
+ − 192
+ − 193
section {* Implementation of swappings *}
+ − 194
+ − 195
definition
+ − 196
swap :: "atom \<Rightarrow> atom \<Rightarrow> perm" ("'(_ \<rightleftharpoons> _')")
+ − 197
where
+ − 198
"(a \<rightleftharpoons> b) =
+ − 199
Abs_perm (if sort_of a = sort_of b
+ − 200
then (\<lambda>c. if a = c then b else if b = c then a else c)
+ − 201
else id)"
+ − 202
+ − 203
lemma Rep_perm_swap:
+ − 204
"Rep_perm (a \<rightleftharpoons> b) =
+ − 205
(if sort_of a = sort_of b
+ − 206
then (\<lambda>c. if a = c then b else if b = c then a else c)
+ − 207
else id)"
+ − 208
unfolding swap_def
+ − 209
apply (rule Abs_perm_inverse)
+ − 210
apply (rule permI)
+ − 211
apply (auto simp add: bij_def inj_on_def surj_def)[1]
+ − 212
apply (rule MOST_rev_mp [OF MOST_neq(1) [of a]])
+ − 213
apply (rule MOST_rev_mp [OF MOST_neq(1) [of b]])
+ − 214
apply (simp)
+ − 215
apply (simp)
+ − 216
done
+ − 217
+ − 218
lemmas Rep_perm_simps =
+ − 219
Rep_perm_0
+ − 220
Rep_perm_add
+ − 221
Rep_perm_uminus
+ − 222
Rep_perm_swap
+ − 223
+ − 224
lemma swap_different_sorts [simp]:
+ − 225
"sort_of a \<noteq> sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) = 0"
+ − 226
by (rule Rep_perm_ext) (simp add: Rep_perm_simps)
+ − 227
+ − 228
lemma swap_cancel:
2679
+ − 229
shows "(a \<rightleftharpoons> b) + (a \<rightleftharpoons> b) = 0"
+ − 230
and "(a \<rightleftharpoons> b) + (b \<rightleftharpoons> a) = 0"
+ − 231
by (rule_tac [!] Rep_perm_ext)
+ − 232
(simp_all add: Rep_perm_simps fun_eq_iff)
1062
+ − 233
+ − 234
lemma swap_self [simp]:
+ − 235
"(a \<rightleftharpoons> a) = 0"
2479
+ − 236
by (rule Rep_perm_ext, simp add: Rep_perm_simps fun_eq_iff)
1062
+ − 237
+ − 238
lemma minus_swap [simp]:
+ − 239
"- (a \<rightleftharpoons> b) = (a \<rightleftharpoons> b)"
2679
+ − 240
by (rule minus_unique [OF swap_cancel(1)])
1062
+ − 241
+ − 242
lemma swap_commute:
+ − 243
"(a \<rightleftharpoons> b) = (b \<rightleftharpoons> a)"
+ − 244
by (rule Rep_perm_ext)
2479
+ − 245
(simp add: Rep_perm_swap fun_eq_iff)
1062
+ − 246
+ − 247
lemma swap_triple:
+ − 248
assumes "a \<noteq> b" and "c \<noteq> b"
+ − 249
assumes "sort_of a = sort_of b" "sort_of b = sort_of c"
+ − 250
shows "(a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c) = (a \<rightleftharpoons> b)"
+ − 251
using assms
+ − 252
by (rule_tac Rep_perm_ext)
2479
+ − 253
(auto simp add: Rep_perm_simps fun_eq_iff)
1062
+ − 254
+ − 255
+ − 256
section {* Permutation Types *}
+ − 257
+ − 258
text {*
+ − 259
Infix syntax for @{text permute} has higher precedence than
+ − 260
addition, but lower than unary minus.
+ − 261
*}
+ − 262
+ − 263
class pt =
+ − 264
fixes permute :: "perm \<Rightarrow> 'a \<Rightarrow> 'a" ("_ \<bullet> _" [76, 75] 75)
+ − 265
assumes permute_zero [simp]: "0 \<bullet> x = x"
+ − 266
assumes permute_plus [simp]: "(p + q) \<bullet> x = p \<bullet> (q \<bullet> x)"
+ − 267
begin
+ − 268
+ − 269
lemma permute_diff [simp]:
+ − 270
shows "(p - q) \<bullet> x = p \<bullet> - q \<bullet> x"
+ − 271
unfolding diff_minus by simp
+ − 272
+ − 273
lemma permute_minus_cancel [simp]:
+ − 274
shows "p \<bullet> - p \<bullet> x = x"
+ − 275
and "- p \<bullet> p \<bullet> x = x"
+ − 276
unfolding permute_plus [symmetric] by simp_all
+ − 277
+ − 278
lemma permute_swap_cancel [simp]:
+ − 279
shows "(a \<rightleftharpoons> b) \<bullet> (a \<rightleftharpoons> b) \<bullet> x = x"
+ − 280
unfolding permute_plus [symmetric]
+ − 281
by (simp add: swap_cancel)
+ − 282
+ − 283
lemma permute_swap_cancel2 [simp]:
+ − 284
shows "(a \<rightleftharpoons> b) \<bullet> (b \<rightleftharpoons> a) \<bullet> x = x"
+ − 285
unfolding permute_plus [symmetric]
+ − 286
by (simp add: swap_commute)
+ − 287
+ − 288
lemma inj_permute [simp]:
+ − 289
shows "inj (permute p)"
+ − 290
by (rule inj_on_inverseI)
+ − 291
(rule permute_minus_cancel)
+ − 292
+ − 293
lemma surj_permute [simp]:
+ − 294
shows "surj (permute p)"
+ − 295
by (rule surjI, rule permute_minus_cancel)
+ − 296
+ − 297
lemma bij_permute [simp]:
+ − 298
shows "bij (permute p)"
+ − 299
by (rule bijI [OF inj_permute surj_permute])
+ − 300
+ − 301
lemma inv_permute:
+ − 302
shows "inv (permute p) = permute (- p)"
+ − 303
by (rule inv_equality) (simp_all)
+ − 304
+ − 305
lemma permute_minus:
+ − 306
shows "permute (- p) = inv (permute p)"
+ − 307
by (simp add: inv_permute)
+ − 308
+ − 309
lemma permute_eq_iff [simp]:
+ − 310
shows "p \<bullet> x = p \<bullet> y \<longleftrightarrow> x = y"
+ − 311
by (rule inj_permute [THEN inj_eq])
+ − 312
+ − 313
end
+ − 314
+ − 315
subsection {* Permutations for atoms *}
+ − 316
+ − 317
instantiation atom :: pt
+ − 318
begin
+ − 319
+ − 320
definition
1879
+ − 321
"p \<bullet> a = (Rep_perm p) a"
1062
+ − 322
+ − 323
instance
+ − 324
apply(default)
+ − 325
apply(simp_all add: permute_atom_def Rep_perm_simps)
+ − 326
done
+ − 327
+ − 328
end
+ − 329
+ − 330
lemma sort_of_permute [simp]:
+ − 331
shows "sort_of (p \<bullet> a) = sort_of a"
+ − 332
unfolding permute_atom_def by (rule sort_of_Rep_perm)
+ − 333
+ − 334
lemma swap_atom:
+ − 335
shows "(a \<rightleftharpoons> b) \<bullet> c =
+ − 336
(if sort_of a = sort_of b
+ − 337
then (if c = a then b else if c = b then a else c) else c)"
+ − 338
unfolding permute_atom_def
+ − 339
by (simp add: Rep_perm_swap)
+ − 340
+ − 341
lemma swap_atom_simps [simp]:
+ − 342
"sort_of a = sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> a = b"
+ − 343
"sort_of a = sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> b = a"
+ − 344
"c \<noteq> a \<Longrightarrow> c \<noteq> b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> c = c"
+ − 345
unfolding swap_atom by simp_all
+ − 346
2732
+ − 347
lemma perm_eq_iff:
1062
+ − 348
fixes p q :: "perm"
+ − 349
shows "p = q \<longleftrightarrow> (\<forall>a::atom. p \<bullet> a = q \<bullet> a)"
+ − 350
unfolding permute_atom_def
+ − 351
by (metis Rep_perm_ext ext)
+ − 352
+ − 353
+ − 354
subsection {* Permutations for permutations *}
+ − 355
+ − 356
instantiation perm :: pt
+ − 357
begin
+ − 358
+ − 359
definition
+ − 360
"p \<bullet> q = p + q - p"
+ − 361
+ − 362
instance
+ − 363
apply default
+ − 364
apply (simp add: permute_perm_def)
+ − 365
apply (simp add: permute_perm_def diff_minus minus_add add_assoc)
+ − 366
done
+ − 367
+ − 368
end
+ − 369
1879
+ − 370
lemma permute_self:
+ − 371
shows "p \<bullet> p = p"
+ − 372
unfolding permute_perm_def
+ − 373
by (simp add: diff_minus add_assoc)
1062
+ − 374
2732
+ − 375
lemma pemute_minus_self:
+ − 376
shows "- p \<bullet> p = p"
+ − 377
unfolding permute_perm_def
+ − 378
by (simp add: diff_minus add_assoc)
+ − 379
1062
+ − 380
lemma permute_eqvt:
+ − 381
shows "p \<bullet> (q \<bullet> x) = (p \<bullet> q) \<bullet> (p \<bullet> x)"
+ − 382
unfolding permute_perm_def by simp
+ − 383
+ − 384
lemma zero_perm_eqvt:
+ − 385
shows "p \<bullet> (0::perm) = 0"
+ − 386
unfolding permute_perm_def by simp
+ − 387
+ − 388
lemma add_perm_eqvt:
+ − 389
fixes p p1 p2 :: perm
+ − 390
shows "p \<bullet> (p1 + p2) = p \<bullet> p1 + p \<bullet> p2"
+ − 391
unfolding permute_perm_def
2732
+ − 392
by (simp add: perm_eq_iff)
1062
+ − 393
+ − 394
lemma swap_eqvt:
+ − 395
shows "p \<bullet> (a \<rightleftharpoons> b) = (p \<bullet> a \<rightleftharpoons> p \<bullet> b)"
+ − 396
unfolding permute_perm_def
2732
+ − 397
by (auto simp add: swap_atom perm_eq_iff)
1062
+ − 398
2310
+ − 399
lemma uminus_eqvt:
+ − 400
fixes p q::"perm"
+ − 401
shows "p \<bullet> (- q) = - (p \<bullet> q)"
+ − 402
unfolding permute_perm_def
+ − 403
by (simp add: diff_minus minus_add add_assoc)
1062
+ − 404
+ − 405
subsection {* Permutations for functions *}
+ − 406
+ − 407
instantiation "fun" :: (pt, pt) pt
+ − 408
begin
+ − 409
+ − 410
definition
+ − 411
"p \<bullet> f = (\<lambda>x. p \<bullet> (f (- p \<bullet> x)))"
+ − 412
+ − 413
instance
+ − 414
apply default
+ − 415
apply (simp add: permute_fun_def)
+ − 416
apply (simp add: permute_fun_def minus_add)
+ − 417
done
+ − 418
+ − 419
end
+ − 420
+ − 421
lemma permute_fun_app_eq:
+ − 422
shows "p \<bullet> (f x) = (p \<bullet> f) (p \<bullet> x)"
1879
+ − 423
unfolding permute_fun_def by simp
1062
+ − 424
2663
+ − 425
1062
+ − 426
subsection {* Permutations for booleans *}
+ − 427
+ − 428
instantiation bool :: pt
+ − 429
begin
+ − 430
+ − 431
definition "p \<bullet> (b::bool) = b"
+ − 432
+ − 433
instance
+ − 434
apply(default)
+ − 435
apply(simp_all add: permute_bool_def)
+ − 436
done
+ − 437
+ − 438
end
+ − 439
+ − 440
lemma Not_eqvt:
+ − 441
shows "p \<bullet> (\<not> A) = (\<not> (p \<bullet> A))"
+ − 442
by (simp add: permute_bool_def)
+ − 443
2466
+ − 444
lemma conj_eqvt:
+ − 445
shows "p \<bullet> (A \<and> B) = ((p \<bullet> A) \<and> (p \<bullet> B))"
+ − 446
by (simp add: permute_bool_def)
+ − 447
+ − 448
lemma imp_eqvt:
+ − 449
shows "p \<bullet> (A \<longrightarrow> B) = ((p \<bullet> A) \<longrightarrow> (p \<bullet> B))"
+ − 450
by (simp add: permute_bool_def)
+ − 451
+ − 452
lemma ex_eqvt:
+ − 453
shows "p \<bullet> (\<exists>x. P x) = (\<exists>x. (p \<bullet> P) x)"
+ − 454
unfolding permute_fun_def permute_bool_def
+ − 455
by (auto, rule_tac x="p \<bullet> x" in exI, simp)
+ − 456
2470
+ − 457
lemma all_eqvt:
+ − 458
shows "p \<bullet> (\<forall>x. P x) = (\<forall>x. (p \<bullet> P) x)"
+ − 459
unfolding permute_fun_def permute_bool_def
+ − 460
by (auto, drule_tac x="p \<bullet> x" in spec, simp)
+ − 461
2663
+ − 462
lemma ex1_eqvt:
+ − 463
shows "p \<bullet> (\<exists>!x. P x) = (\<exists>!x. (p \<bullet> P) x)"
+ − 464
unfolding Ex1_def
+ − 465
apply(simp add: ex_eqvt)
+ − 466
unfolding permute_fun_def
+ − 467
apply(simp add: conj_eqvt all_eqvt)
+ − 468
unfolding permute_fun_def
+ − 469
apply(simp add: imp_eqvt permute_bool_def)
+ − 470
done
+ − 471
1557
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 472
lemma permute_boolE:
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 473
fixes P::"bool"
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 474
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
+ − 475
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
+ − 476
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 477
lemma permute_boolI:
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 478
fixes P::"bool"
fee2389789ad
moved infinite_Un into mainstream Isabelle; moved permute_boolI/E lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 479
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
+ − 480
by(simp add: permute_bool_def)
1062
+ − 481
+ − 482
subsection {* Permutations for sets *}
+ − 483
+ − 484
lemma permute_set_eq:
+ − 485
fixes x::"'a::pt"
+ − 486
shows "(p \<bullet> X) = {p \<bullet> x | x. x \<in> X}"
1879
+ − 487
unfolding permute_fun_def
+ − 488
unfolding permute_bool_def
+ − 489
apply(auto simp add: mem_def)
1062
+ − 490
apply(rule_tac x="- p \<bullet> x" in exI)
+ − 491
apply(simp)
+ − 492
done
+ − 493
+ − 494
lemma permute_set_eq_image:
+ − 495
shows "p \<bullet> X = permute p ` X"
1879
+ − 496
unfolding permute_set_eq by auto
1062
+ − 497
+ − 498
lemma permute_set_eq_vimage:
+ − 499
shows "p \<bullet> X = permute (- p) -` X"
1879
+ − 500
unfolding permute_fun_def permute_bool_def
+ − 501
unfolding vimage_def Collect_def mem_def ..
1062
+ − 502
2588
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 503
lemma permute_finite [simp]:
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 504
shows "finite (p \<bullet> X) = finite X"
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 505
apply(simp add: permute_set_eq_image)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 506
apply(rule iffI)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 507
apply(drule finite_imageD)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 508
using inj_permute[where p="p"]
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 509
apply(simp add: inj_on_def)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 510
apply(assumption)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 511
apply(rule finite_imageI)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 512
apply(assumption)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 513
done
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 514
1062
+ − 515
lemma swap_set_not_in:
+ − 516
assumes a: "a \<notin> S" "b \<notin> S"
+ − 517
shows "(a \<rightleftharpoons> b) \<bullet> S = S"
1879
+ − 518
unfolding permute_set_eq
+ − 519
using a by (auto simp add: swap_atom)
1062
+ − 520
+ − 521
lemma swap_set_in:
+ − 522
assumes a: "a \<in> S" "b \<notin> S" "sort_of a = sort_of b"
+ − 523
shows "(a \<rightleftharpoons> b) \<bullet> S \<noteq> S"
1879
+ − 524
unfolding permute_set_eq
+ − 525
using a by (auto simp add: swap_atom)
1062
+ − 526
2669
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 527
lemma swap_set_in_eq:
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 528
assumes a: "a \<in> S" "b \<notin> S" "sort_of a = sort_of b"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 529
shows "(a \<rightleftharpoons> b) \<bullet> S = (S - {a}) \<union> {b}"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 530
unfolding permute_set_eq
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 531
using a by (auto simp add: swap_atom)
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 532
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 533
lemma swap_set_both_in:
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 534
assumes a: "a \<in> S" "b \<in> S"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 535
shows "(a \<rightleftharpoons> b) \<bullet> S = S"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 536
unfolding permute_set_eq
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 537
using a by (auto simp add: swap_atom)
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 538
2470
+ − 539
lemma mem_permute_iff:
+ − 540
shows "(p \<bullet> x) \<in> (p \<bullet> X) \<longleftrightarrow> x \<in> X"
+ − 541
unfolding mem_def permute_fun_def permute_bool_def
+ − 542
by simp
+ − 543
+ − 544
lemma mem_eqvt:
+ − 545
shows "p \<bullet> (x \<in> A) \<longleftrightarrow> (p \<bullet> x) \<in> (p \<bullet> A)"
+ − 546
unfolding mem_def
+ − 547
by (simp add: permute_fun_app_eq)
+ − 548
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 549
lemma empty_eqvt:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 550
shows "p \<bullet> {} = {}"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 551
unfolding empty_def Collect_def
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 552
by (simp add: permute_fun_def permute_bool_def)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 553
2470
+ − 554
lemma insert_eqvt:
+ − 555
shows "p \<bullet> (insert x A) = insert (p \<bullet> x) (p \<bullet> A)"
+ − 556
unfolding permute_set_eq_image image_insert ..
+ − 557
2672
+ − 558
lemma Collect_eqvt:
+ − 559
shows "p \<bullet> {x. P x} = {x. (p \<bullet> P) x}"
+ − 560
unfolding Collect_def permute_fun_def ..
+ − 561
+ − 562
lemma inter_eqvt:
+ − 563
shows "p \<bullet> (A \<inter> B) = (p \<bullet> A) \<inter> (p \<bullet> B)"
+ − 564
unfolding Int_def
+ − 565
apply(simp add: Collect_eqvt)
+ − 566
apply(simp add: permute_fun_def)
+ − 567
apply(simp add: conj_eqvt)
+ − 568
apply(simp add: mem_eqvt)
+ − 569
apply(simp add: permute_fun_def)
+ − 570
done
+ − 571
+ − 572
2470
+ − 573
1062
+ − 574
subsection {* Permutations for units *}
+ − 575
+ − 576
instantiation unit :: pt
+ − 577
begin
+ − 578
+ − 579
definition "p \<bullet> (u::unit) = u"
+ − 580
1879
+ − 581
instance
+ − 582
by (default) (simp_all add: permute_unit_def)
1062
+ − 583
+ − 584
end
+ − 585
+ − 586
+ − 587
subsection {* Permutations for products *}
+ − 588
2378
+ − 589
instantiation prod :: (pt, pt) pt
1062
+ − 590
begin
+ − 591
+ − 592
primrec
+ − 593
permute_prod
+ − 594
where
+ − 595
Pair_eqvt: "p \<bullet> (x, y) = (p \<bullet> x, p \<bullet> y)"
+ − 596
+ − 597
instance
+ − 598
by default auto
+ − 599
+ − 600
end
+ − 601
+ − 602
subsection {* Permutations for sums *}
+ − 603
2378
+ − 604
instantiation sum :: (pt, pt) pt
1062
+ − 605
begin
+ − 606
+ − 607
primrec
+ − 608
permute_sum
+ − 609
where
+ − 610
"p \<bullet> (Inl x) = Inl (p \<bullet> x)"
+ − 611
| "p \<bullet> (Inr y) = Inr (p \<bullet> y)"
+ − 612
1879
+ − 613
instance
+ − 614
by (default) (case_tac [!] x, simp_all)
1062
+ − 615
+ − 616
end
+ − 617
+ − 618
subsection {* Permutations for lists *}
+ − 619
+ − 620
instantiation list :: (pt) pt
+ − 621
begin
+ − 622
+ − 623
primrec
+ − 624
permute_list
+ − 625
where
+ − 626
"p \<bullet> [] = []"
+ − 627
| "p \<bullet> (x # xs) = p \<bullet> x # p \<bullet> xs"
+ − 628
1879
+ − 629
instance
+ − 630
by (default) (induct_tac [!] x, simp_all)
1062
+ − 631
+ − 632
end
+ − 633
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 634
lemma set_eqvt:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 635
shows "p \<bullet> (set xs) = set (p \<bullet> xs)"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 636
by (induct xs) (simp_all add: empty_eqvt insert_eqvt)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 637
1062
+ − 638
subsection {* Permutations for options *}
+ − 639
+ − 640
instantiation option :: (pt) pt
+ − 641
begin
+ − 642
+ − 643
primrec
+ − 644
permute_option
+ − 645
where
+ − 646
"p \<bullet> None = None"
+ − 647
| "p \<bullet> (Some x) = Some (p \<bullet> x)"
+ − 648
1879
+ − 649
instance
+ − 650
by (default) (induct_tac [!] x, simp_all)
1062
+ − 651
+ − 652
end
+ − 653
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 654
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 655
subsection {* Permutations for fsets *}
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 656
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 657
lemma permute_fset_rsp[quot_respect]:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 658
shows "(op = ===> list_eq ===> list_eq) permute permute"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 659
unfolding fun_rel_def
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 660
by (simp add: set_eqvt[symmetric])
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 661
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 662
instantiation fset :: (pt) pt
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 663
begin
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 664
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 665
quotient_definition
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 666
"permute_fset :: perm \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 667
is
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 668
"permute :: perm \<Rightarrow> 'a list \<Rightarrow> 'a list"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 669
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 670
instance
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 671
proof
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 672
fix x :: "'a fset" and p q :: "perm"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 673
show "0 \<bullet> x = x" by (descending) (simp)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 674
show "(p + q) \<bullet> x = p \<bullet> q \<bullet> x" by (descending) (simp)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 675
qed
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 676
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 677
end
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 678
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 679
lemma permute_fset [simp]:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 680
fixes S::"('a::pt) fset"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 681
shows "(p \<bullet> {||}) = ({||} ::('a::pt) fset)"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 682
and "(p \<bullet> insert_fset x S) = insert_fset (p \<bullet> x) (p \<bullet> S)"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 683
by (lifting permute_list.simps)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 684
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 685
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 686
1062
+ − 687
subsection {* Permutations for @{typ char}, @{typ nat}, and @{typ int} *}
+ − 688
+ − 689
instantiation char :: pt
+ − 690
begin
+ − 691
+ − 692
definition "p \<bullet> (c::char) = c"
+ − 693
1879
+ − 694
instance
+ − 695
by (default) (simp_all add: permute_char_def)
1062
+ − 696
+ − 697
end
+ − 698
+ − 699
instantiation nat :: pt
+ − 700
begin
+ − 701
+ − 702
definition "p \<bullet> (n::nat) = n"
+ − 703
1879
+ − 704
instance
+ − 705
by (default) (simp_all add: permute_nat_def)
1062
+ − 706
+ − 707
end
+ − 708
+ − 709
instantiation int :: pt
+ − 710
begin
+ − 711
+ − 712
definition "p \<bullet> (i::int) = i"
+ − 713
1879
+ − 714
instance
+ − 715
by (default) (simp_all add: permute_int_def)
1062
+ − 716
+ − 717
end
+ − 718
+ − 719
+ − 720
section {* Pure types *}
+ − 721
+ − 722
text {* Pure types will have always empty support. *}
+ − 723
+ − 724
class pure = pt +
+ − 725
assumes permute_pure: "p \<bullet> x = x"
+ − 726
+ − 727
text {* Types @{typ unit} and @{typ bool} are pure. *}
+ − 728
+ − 729
instance unit :: pure
+ − 730
proof qed (rule permute_unit_def)
+ − 731
+ − 732
instance bool :: pure
+ − 733
proof qed (rule permute_bool_def)
+ − 734
2635
+ − 735
1062
+ − 736
text {* Other type constructors preserve purity. *}
+ − 737
+ − 738
instance "fun" :: (pure, pure) pure
+ − 739
by default (simp add: permute_fun_def permute_pure)
+ − 740
2378
+ − 741
instance prod :: (pure, pure) pure
1062
+ − 742
by default (induct_tac x, simp add: permute_pure)
+ − 743
2378
+ − 744
instance sum :: (pure, pure) pure
1062
+ − 745
by default (induct_tac x, simp_all add: permute_pure)
+ − 746
+ − 747
instance list :: (pure) pure
+ − 748
by default (induct_tac x, simp_all add: permute_pure)
+ − 749
+ − 750
instance option :: (pure) pure
+ − 751
by default (induct_tac x, simp_all add: permute_pure)
+ − 752
+ − 753
+ − 754
subsection {* Types @{typ char}, @{typ nat}, and @{typ int} *}
+ − 755
+ − 756
instance char :: pure
+ − 757
proof qed (rule permute_char_def)
+ − 758
+ − 759
instance nat :: pure
+ − 760
proof qed (rule permute_nat_def)
+ − 761
+ − 762
instance int :: pure
+ − 763
proof qed (rule permute_int_def)
+ − 764
+ − 765
subsection {* Supp, Freshness and Supports *}
+ − 766
+ − 767
context pt
+ − 768
begin
+ − 769
+ − 770
definition
+ − 771
supp :: "'a \<Rightarrow> atom set"
+ − 772
where
+ − 773
"supp x = {a. infinite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}}"
+ − 774
+ − 775
definition
2732
+ − 776
fresh :: "atom \<Rightarrow> 'a \<Rightarrow> bool" ("_ \<sharp> _" [55, 55] 55)
1062
+ − 777
where
+ − 778
"a \<sharp> x \<equiv> a \<notin> supp x"
+ − 779
2732
+ − 780
end
+ − 781
1062
+ − 782
lemma supp_conv_fresh:
+ − 783
shows "supp x = {a. \<not> a \<sharp> x}"
+ − 784
unfolding fresh_def by simp
+ − 785
+ − 786
lemma swap_rel_trans:
+ − 787
assumes "sort_of a = sort_of b"
+ − 788
assumes "sort_of b = sort_of c"
+ − 789
assumes "(a \<rightleftharpoons> c) \<bullet> x = x"
+ − 790
assumes "(b \<rightleftharpoons> c) \<bullet> x = x"
+ − 791
shows "(a \<rightleftharpoons> b) \<bullet> x = x"
+ − 792
proof (cases)
+ − 793
assume "a = b \<or> c = b"
+ − 794
with assms show "(a \<rightleftharpoons> b) \<bullet> x = x" by auto
+ − 795
next
+ − 796
assume *: "\<not> (a = b \<or> c = b)"
+ − 797
have "((a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c)) \<bullet> x = x"
+ − 798
using assms by simp
+ − 799
also have "(a \<rightleftharpoons> c) + (b \<rightleftharpoons> c) + (a \<rightleftharpoons> c) = (a \<rightleftharpoons> b)"
+ − 800
using assms * by (simp add: swap_triple)
+ − 801
finally show "(a \<rightleftharpoons> b) \<bullet> x = x" .
+ − 802
qed
+ − 803
+ − 804
lemma swap_fresh_fresh:
+ − 805
assumes a: "a \<sharp> x"
+ − 806
and b: "b \<sharp> x"
+ − 807
shows "(a \<rightleftharpoons> b) \<bullet> x = x"
+ − 808
proof (cases)
+ − 809
assume asm: "sort_of a = sort_of b"
+ − 810
have "finite {c. (a \<rightleftharpoons> c) \<bullet> x \<noteq> x}" "finite {c. (b \<rightleftharpoons> c) \<bullet> x \<noteq> x}"
+ − 811
using a b unfolding fresh_def supp_def by simp_all
+ − 812
then have "finite ({c. (a \<rightleftharpoons> c) \<bullet> x \<noteq> x} \<union> {c. (b \<rightleftharpoons> c) \<bullet> x \<noteq> x})" by simp
+ − 813
then obtain c
+ − 814
where "(a \<rightleftharpoons> c) \<bullet> x = x" "(b \<rightleftharpoons> c) \<bullet> x = x" "sort_of c = sort_of b"
+ − 815
by (rule obtain_atom) (auto)
+ − 816
then show "(a \<rightleftharpoons> b) \<bullet> x = x" using asm by (rule_tac swap_rel_trans) (simp_all)
+ − 817
next
+ − 818
assume "sort_of a \<noteq> sort_of b"
+ − 819
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by simp
+ − 820
qed
+ − 821
+ − 822
+ − 823
subsection {* supp and fresh are equivariant *}
+ − 824
+ − 825
lemma finite_Collect_bij:
+ − 826
assumes a: "bij f"
+ − 827
shows "finite {x. P (f x)} = finite {x. P x}"
+ − 828
by (metis a finite_vimage_iff vimage_Collect_eq)
+ − 829
+ − 830
lemma fresh_permute_iff:
+ − 831
shows "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> a \<sharp> x"
+ − 832
proof -
+ − 833
have "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}"
+ − 834
unfolding fresh_def supp_def by simp
+ − 835
also have "\<dots> \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> p \<bullet> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}"
1879
+ − 836
using bij_permute by (rule finite_Collect_bij[symmetric])
1062
+ − 837
also have "\<dots> \<longleftrightarrow> finite {b. p \<bullet> (a \<rightleftharpoons> b) \<bullet> x \<noteq> p \<bullet> x}"
+ − 838
by (simp only: permute_eqvt [of p] swap_eqvt)
+ − 839
also have "\<dots> \<longleftrightarrow> finite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}"
+ − 840
by (simp only: permute_eq_iff)
+ − 841
also have "\<dots> \<longleftrightarrow> a \<sharp> x"
+ − 842
unfolding fresh_def supp_def by simp
1879
+ − 843
finally show "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> a \<sharp> x" .
1062
+ − 844
qed
+ − 845
+ − 846
lemma fresh_eqvt:
+ − 847
shows "p \<bullet> (a \<sharp> x) = (p \<bullet> a) \<sharp> (p \<bullet> x)"
1879
+ − 848
unfolding permute_bool_def
+ − 849
by (simp add: fresh_permute_iff)
1062
+ − 850
+ − 851
lemma supp_eqvt:
+ − 852
shows "p \<bullet> (supp x) = supp (p \<bullet> x)"
+ − 853
unfolding supp_conv_fresh
1879
+ − 854
unfolding Collect_def
+ − 855
unfolding permute_fun_def
1062
+ − 856
by (simp add: Not_eqvt fresh_eqvt)
+ − 857
2683
+ − 858
lemma fresh_permute_left:
+ − 859
shows "a \<sharp> p \<bullet> x \<longleftrightarrow> - p \<bullet> a \<sharp> x"
+ − 860
proof
+ − 861
assume "a \<sharp> p \<bullet> x"
+ − 862
then have "- p \<bullet> a \<sharp> - p \<bullet> p \<bullet> x" by (simp only: fresh_permute_iff)
+ − 863
then show "- p \<bullet> a \<sharp> x" by simp
+ − 864
next
+ − 865
assume "- p \<bullet> a \<sharp> x"
+ − 866
then have "p \<bullet> - p \<bullet> a \<sharp> p \<bullet> x" by (simp only: fresh_permute_iff)
+ − 867
then show "a \<sharp> p \<bullet> x" by simp
+ − 868
qed
+ − 869
+ − 870
1062
+ − 871
subsection {* supports *}
+ − 872
+ − 873
definition
+ − 874
supports :: "atom set \<Rightarrow> 'a::pt \<Rightarrow> bool" (infixl "supports" 80)
+ − 875
where
+ − 876
"S supports x \<equiv> \<forall>a b. (a \<notin> S \<and> b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x)"
+ − 877
+ − 878
lemma supp_is_subset:
+ − 879
fixes S :: "atom set"
+ − 880
and x :: "'a::pt"
+ − 881
assumes a1: "S supports x"
+ − 882
and a2: "finite S"
+ − 883
shows "(supp x) \<subseteq> S"
+ − 884
proof (rule ccontr)
1879
+ − 885
assume "\<not> (supp x \<subseteq> S)"
1062
+ − 886
then obtain a where b1: "a \<in> supp x" and b2: "a \<notin> S" by auto
1879
+ − 887
from a1 b2 have "\<forall>b. b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x" unfolding supports_def by auto
+ − 888
then have "{b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x} \<subseteq> S" by auto
2732
+ − 889
with a2 have "finite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}" by (simp add: finite_subset)
1062
+ − 890
then have "a \<notin> (supp x)" unfolding supp_def by simp
+ − 891
with b1 show False by simp
+ − 892
qed
+ − 893
+ − 894
lemma supports_finite:
+ − 895
fixes S :: "atom set"
+ − 896
and x :: "'a::pt"
+ − 897
assumes a1: "S supports x"
+ − 898
and a2: "finite S"
+ − 899
shows "finite (supp x)"
+ − 900
proof -
+ − 901
have "(supp x) \<subseteq> S" using a1 a2 by (rule supp_is_subset)
+ − 902
then show "finite (supp x)" using a2 by (simp add: finite_subset)
+ − 903
qed
+ − 904
+ − 905
lemma supp_supports:
+ − 906
fixes x :: "'a::pt"
+ − 907
shows "(supp x) supports x"
1879
+ − 908
unfolding supports_def
+ − 909
proof (intro strip)
1062
+ − 910
fix a b
+ − 911
assume "a \<notin> (supp x) \<and> b \<notin> (supp x)"
+ − 912
then have "a \<sharp> x" and "b \<sharp> x" by (simp_all add: fresh_def)
1879
+ − 913
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by (simp add: swap_fresh_fresh)
1062
+ − 914
qed
+ − 915
+ − 916
lemma supp_is_least_supports:
+ − 917
fixes S :: "atom set"
+ − 918
and x :: "'a::pt"
+ − 919
assumes a1: "S supports x"
+ − 920
and a2: "finite S"
+ − 921
and a3: "\<And>S'. finite S' \<Longrightarrow> (S' supports x) \<Longrightarrow> S \<subseteq> S'"
+ − 922
shows "(supp x) = S"
+ − 923
proof (rule equalityI)
+ − 924
show "(supp x) \<subseteq> S" using a1 a2 by (rule supp_is_subset)
+ − 925
with a2 have fin: "finite (supp x)" by (rule rev_finite_subset)
+ − 926
have "(supp x) supports x" by (rule supp_supports)
+ − 927
with fin a3 show "S \<subseteq> supp x" by blast
+ − 928
qed
+ − 929
+ − 930
lemma subsetCI:
+ − 931
shows "(\<And>x. x \<in> A \<Longrightarrow> x \<notin> B \<Longrightarrow> False) \<Longrightarrow> A \<subseteq> B"
+ − 932
by auto
+ − 933
+ − 934
lemma finite_supp_unique:
+ − 935
assumes a1: "S supports x"
+ − 936
assumes a2: "finite S"
+ − 937
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"
+ − 938
shows "(supp x) = S"
+ − 939
using a1 a2
+ − 940
proof (rule supp_is_least_supports)
+ − 941
fix S'
+ − 942
assume "finite S'" and "S' supports x"
+ − 943
show "S \<subseteq> S'"
+ − 944
proof (rule subsetCI)
+ − 945
fix a
+ − 946
assume "a \<in> S" and "a \<notin> S'"
+ − 947
have "finite (S \<union> S')"
+ − 948
using `finite S` `finite S'` by simp
+ − 949
then obtain b where "b \<notin> S \<union> S'" and "sort_of b = sort_of a"
+ − 950
by (rule obtain_atom)
+ − 951
then have "b \<notin> S" and "b \<notin> S'" and "sort_of a = sort_of b"
+ − 952
by simp_all
+ − 953
then have "(a \<rightleftharpoons> b) \<bullet> x = x"
+ − 954
using `a \<notin> S'` `S' supports x` by (simp add: supports_def)
+ − 955
moreover have "(a \<rightleftharpoons> b) \<bullet> x \<noteq> x"
+ − 956
using `a \<in> S` `b \<notin> S` `sort_of a = sort_of b`
+ − 957
by (rule a3)
+ − 958
ultimately show "False" by simp
+ − 959
qed
+ − 960
qed
+ − 961
2475
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 962
section {* Support w.r.t. relations *}
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 963
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 964
text {*
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 965
This definition is used for unquotient types, where
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 966
alpha-equivalence does not coincide with equality.
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 967
*}
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 968
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 969
definition
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 970
"supp_rel R x = {a. infinite {b. \<not>(R ((a \<rightleftharpoons> b) \<bullet> x) x)}}"
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 971
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 972
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 973
1062
+ − 974
section {* Finitely-supported types *}
+ − 975
+ − 976
class fs = pt +
+ − 977
assumes finite_supp: "finite (supp x)"
+ − 978
+ − 979
lemma pure_supp:
+ − 980
shows "supp (x::'a::pure) = {}"
+ − 981
unfolding supp_def by (simp add: permute_pure)
+ − 982
+ − 983
lemma pure_fresh:
+ − 984
fixes x::"'a::pure"
+ − 985
shows "a \<sharp> x"
+ − 986
unfolding fresh_def by (simp add: pure_supp)
+ − 987
+ − 988
instance pure < fs
+ − 989
by default (simp add: pure_supp)
+ − 990
+ − 991
+ − 992
subsection {* Type @{typ atom} is finitely-supported. *}
+ − 993
+ − 994
lemma supp_atom:
+ − 995
shows "supp a = {a}"
+ − 996
apply (rule finite_supp_unique)
+ − 997
apply (clarsimp simp add: supports_def)
+ − 998
apply simp
+ − 999
apply simp
+ − 1000
done
+ − 1001
+ − 1002
lemma fresh_atom:
+ − 1003
shows "a \<sharp> b \<longleftrightarrow> a \<noteq> b"
+ − 1004
unfolding fresh_def supp_atom by simp
+ − 1005
+ − 1006
instance atom :: fs
+ − 1007
by default (simp add: supp_atom)
+ − 1008
1933
9eab1dfc14d2
moved lemmas from FSet.thy to do with atom to Nominal2_Base, and to do with 'a::at set to Nominal2_Atoms; moved Nominal2_Eqvt.thy one up to be loaded before Nominal2_Atoms
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1009
1062
+ − 1010
section {* Type @{typ perm} is finitely-supported. *}
+ − 1011
+ − 1012
lemma perm_swap_eq:
+ − 1013
shows "(a \<rightleftharpoons> b) \<bullet> p = p \<longleftrightarrow> (p \<bullet> (a \<rightleftharpoons> b)) = (a \<rightleftharpoons> b)"
+ − 1014
unfolding permute_perm_def
+ − 1015
by (metis add_diff_cancel minus_perm_def)
+ − 1016
+ − 1017
lemma supports_perm:
+ − 1018
shows "{a. p \<bullet> a \<noteq> a} supports p"
+ − 1019
unfolding supports_def
1879
+ − 1020
unfolding perm_swap_eq
+ − 1021
by (simp add: swap_eqvt)
1062
+ − 1022
+ − 1023
lemma finite_perm_lemma:
+ − 1024
shows "finite {a::atom. p \<bullet> a \<noteq> a}"
+ − 1025
using finite_Rep_perm [of p]
+ − 1026
unfolding permute_atom_def .
+ − 1027
+ − 1028
lemma supp_perm:
+ − 1029
shows "supp p = {a. p \<bullet> a \<noteq> a}"
+ − 1030
apply (rule finite_supp_unique)
+ − 1031
apply (rule supports_perm)
+ − 1032
apply (rule finite_perm_lemma)
+ − 1033
apply (simp add: perm_swap_eq swap_eqvt)
2732
+ − 1034
apply (auto simp add: perm_eq_iff swap_atom)
1062
+ − 1035
done
+ − 1036
+ − 1037
lemma fresh_perm:
+ − 1038
shows "a \<sharp> p \<longleftrightarrow> p \<bullet> a = a"
1879
+ − 1039
unfolding fresh_def
+ − 1040
by (simp add: supp_perm)
1062
+ − 1041
+ − 1042
lemma supp_swap:
+ − 1043
shows "supp (a \<rightleftharpoons> b) = (if a = b \<or> sort_of a \<noteq> sort_of b then {} else {a, b})"
+ − 1044
by (auto simp add: supp_perm swap_atom)
+ − 1045
+ − 1046
lemma fresh_zero_perm:
+ − 1047
shows "a \<sharp> (0::perm)"
+ − 1048
unfolding fresh_perm by simp
+ − 1049
+ − 1050
lemma supp_zero_perm:
+ − 1051
shows "supp (0::perm) = {}"
+ − 1052
unfolding supp_perm by simp
+ − 1053
1087
+ − 1054
lemma fresh_plus_perm:
+ − 1055
fixes p q::perm
+ − 1056
assumes "a \<sharp> p" "a \<sharp> q"
+ − 1057
shows "a \<sharp> (p + q)"
+ − 1058
using assms
+ − 1059
unfolding fresh_def
+ − 1060
by (auto simp add: supp_perm)
+ − 1061
1062
+ − 1062
lemma supp_plus_perm:
+ − 1063
fixes p q::perm
+ − 1064
shows "supp (p + q) \<subseteq> supp p \<union> supp q"
+ − 1065
by (auto simp add: supp_perm)
+ − 1066
1087
+ − 1067
lemma fresh_minus_perm:
+ − 1068
fixes p::perm
+ − 1069
shows "a \<sharp> (- p) \<longleftrightarrow> a \<sharp> p"
+ − 1070
unfolding fresh_def
1879
+ − 1071
unfolding supp_perm
+ − 1072
apply(simp)
+ − 1073
apply(metis permute_minus_cancel)
1087
+ − 1074
done
+ − 1075
1062
+ − 1076
lemma supp_minus_perm:
+ − 1077
fixes p::perm
+ − 1078
shows "supp (- p) = supp p"
1087
+ − 1079
unfolding supp_conv_fresh
+ − 1080
by (simp add: fresh_minus_perm)
1062
+ − 1081
+ − 1082
instance perm :: fs
+ − 1083
by default (simp add: supp_perm finite_perm_lemma)
+ − 1084
1305
+ − 1085
lemma plus_perm_eq:
+ − 1086
fixes p q::"perm"
1879
+ − 1087
assumes asm: "supp p \<inter> supp q = {}"
1305
+ − 1088
shows "p + q = q + p"
2732
+ − 1089
unfolding perm_eq_iff
1305
+ − 1090
proof
+ − 1091
fix a::"atom"
+ − 1092
show "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 1093
proof -
+ − 1094
{ assume "a \<notin> supp p" "a \<notin> supp q"
+ − 1095
then have "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 1096
by (simp add: supp_perm)
+ − 1097
}
+ − 1098
moreover
+ − 1099
{ assume a: "a \<in> supp p" "a \<notin> supp q"
+ − 1100
then have "p \<bullet> a \<in> supp p" by (simp add: supp_perm)
+ − 1101
then have "p \<bullet> a \<notin> supp q" using asm by auto
+ − 1102
with a have "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 1103
by (simp add: supp_perm)
+ − 1104
}
+ − 1105
moreover
+ − 1106
{ assume a: "a \<notin> supp p" "a \<in> supp q"
+ − 1107
then have "q \<bullet> a \<in> supp q" by (simp add: supp_perm)
+ − 1108
then have "q \<bullet> a \<notin> supp p" using asm by auto
+ − 1109
with a have "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 1110
by (simp add: supp_perm)
+ − 1111
}
+ − 1112
ultimately show "(p + q) \<bullet> a = (q + p) \<bullet> a"
+ − 1113
using asm by blast
+ − 1114
qed
+ − 1115
qed
1062
+ − 1116
2614
+ − 1117
lemma supp_plus_perm_eq:
+ − 1118
fixes p q::perm
+ − 1119
assumes asm: "supp p \<inter> supp q = {}"
+ − 1120
shows "supp (p + q) = supp p \<union> supp q"
+ − 1121
proof -
+ − 1122
{ fix a::"atom"
+ − 1123
assume "a \<in> supp p"
+ − 1124
then have "a \<notin> supp q" using asm by auto
+ − 1125
then have "a \<in> supp (p + q)" using `a \<in> supp p`
+ − 1126
by (simp add: supp_perm)
+ − 1127
}
+ − 1128
moreover
+ − 1129
{ fix a::"atom"
+ − 1130
assume "a \<in> supp q"
+ − 1131
then have "a \<notin> supp p" using asm by auto
+ − 1132
then have "a \<in> supp (q + p)" using `a \<in> supp q`
+ − 1133
by (simp add: supp_perm)
+ − 1134
then have "a \<in> supp (p + q)" using asm plus_perm_eq
+ − 1135
by metis
+ − 1136
}
+ − 1137
ultimately have "supp p \<union> supp q \<subseteq> supp (p + q)"
+ − 1138
by blast
+ − 1139
then show "supp (p + q) = supp p \<union> supp q" using supp_plus_perm
+ − 1140
by blast
+ − 1141
qed
+ − 1142
+ − 1143
1062
+ − 1144
section {* Finite Support instances for other types *}
+ − 1145
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1146
1062
+ − 1147
subsection {* Type @{typ "'a \<times> 'b"} is finitely-supported. *}
+ − 1148
+ − 1149
lemma supp_Pair:
+ − 1150
shows "supp (x, y) = supp x \<union> supp y"
+ − 1151
by (simp add: supp_def Collect_imp_eq Collect_neg_eq)
+ − 1152
+ − 1153
lemma fresh_Pair:
+ − 1154
shows "a \<sharp> (x, y) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> y"
+ − 1155
by (simp add: fresh_def supp_Pair)
+ − 1156
2470
+ − 1157
lemma supp_Unit:
+ − 1158
shows "supp () = {}"
+ − 1159
by (simp add: supp_def)
+ − 1160
+ − 1161
lemma fresh_Unit:
+ − 1162
shows "a \<sharp> ()"
+ − 1163
by (simp add: fresh_def supp_Unit)
+ − 1164
2378
+ − 1165
instance prod :: (fs, fs) fs
1062
+ − 1166
apply default
+ − 1167
apply (induct_tac x)
+ − 1168
apply (simp add: supp_Pair finite_supp)
+ − 1169
done
+ − 1170
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1171
1062
+ − 1172
subsection {* Type @{typ "'a + 'b"} is finitely supported *}
+ − 1173
+ − 1174
lemma supp_Inl:
+ − 1175
shows "supp (Inl x) = supp x"
+ − 1176
by (simp add: supp_def)
+ − 1177
+ − 1178
lemma supp_Inr:
+ − 1179
shows "supp (Inr x) = supp x"
+ − 1180
by (simp add: supp_def)
+ − 1181
+ − 1182
lemma fresh_Inl:
+ − 1183
shows "a \<sharp> Inl x \<longleftrightarrow> a \<sharp> x"
+ − 1184
by (simp add: fresh_def supp_Inl)
+ − 1185
+ − 1186
lemma fresh_Inr:
+ − 1187
shows "a \<sharp> Inr y \<longleftrightarrow> a \<sharp> y"
+ − 1188
by (simp add: fresh_def supp_Inr)
+ − 1189
2378
+ − 1190
instance sum :: (fs, fs) fs
1062
+ − 1191
apply default
+ − 1192
apply (induct_tac x)
+ − 1193
apply (simp_all add: supp_Inl supp_Inr finite_supp)
+ − 1194
done
+ − 1195
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1196
1062
+ − 1197
subsection {* Type @{typ "'a option"} is finitely supported *}
+ − 1198
+ − 1199
lemma supp_None:
+ − 1200
shows "supp None = {}"
+ − 1201
by (simp add: supp_def)
+ − 1202
+ − 1203
lemma supp_Some:
+ − 1204
shows "supp (Some x) = supp x"
+ − 1205
by (simp add: supp_def)
+ − 1206
+ − 1207
lemma fresh_None:
+ − 1208
shows "a \<sharp> None"
+ − 1209
by (simp add: fresh_def supp_None)
+ − 1210
+ − 1211
lemma fresh_Some:
+ − 1212
shows "a \<sharp> Some x \<longleftrightarrow> a \<sharp> x"
+ − 1213
by (simp add: fresh_def supp_Some)
+ − 1214
+ − 1215
instance option :: (fs) fs
+ − 1216
apply default
+ − 1217
apply (induct_tac x)
+ − 1218
apply (simp_all add: supp_None supp_Some finite_supp)
+ − 1219
done
+ − 1220
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1221
1062
+ − 1222
subsubsection {* Type @{typ "'a list"} is finitely supported *}
+ − 1223
+ − 1224
lemma supp_Nil:
+ − 1225
shows "supp [] = {}"
+ − 1226
by (simp add: supp_def)
+ − 1227
+ − 1228
lemma supp_Cons:
+ − 1229
shows "supp (x # xs) = supp x \<union> supp xs"
+ − 1230
by (simp add: supp_def Collect_imp_eq Collect_neg_eq)
+ − 1231
2591
+ − 1232
lemma supp_append:
+ − 1233
shows "supp (xs @ ys) = supp xs \<union> supp ys"
+ − 1234
by (induct xs) (auto simp add: supp_Nil supp_Cons)
+ − 1235
1062
+ − 1236
lemma fresh_Nil:
+ − 1237
shows "a \<sharp> []"
+ − 1238
by (simp add: fresh_def supp_Nil)
+ − 1239
+ − 1240
lemma fresh_Cons:
+ − 1241
shows "a \<sharp> (x # xs) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> xs"
+ − 1242
by (simp add: fresh_def supp_Cons)
+ − 1243
2591
+ − 1244
lemma fresh_append:
+ − 1245
shows "a \<sharp> (xs @ ys) \<longleftrightarrow> a \<sharp> xs \<and> a \<sharp> ys"
+ − 1246
by (induct xs) (simp_all add: fresh_Nil fresh_Cons)
+ − 1247
+ − 1248
1062
+ − 1249
instance list :: (fs) fs
+ − 1250
apply default
+ − 1251
apply (induct_tac x)
+ − 1252
apply (simp_all add: supp_Nil supp_Cons finite_supp)
+ − 1253
done
+ − 1254
2588
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1255
lemma supp_of_atom_list:
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1256
fixes as::"atom list"
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1257
shows "supp as = set as"
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1258
by (induct as)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1259
(simp_all add: supp_Nil supp_Cons supp_atom)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1260
2466
+ − 1261
2470
+ − 1262
section {* Support and Freshness for Applications *}
1062
+ − 1263
1879
+ − 1264
lemma fresh_conv_MOST:
+ − 1265
shows "a \<sharp> x \<longleftrightarrow> (MOST b. (a \<rightleftharpoons> b) \<bullet> x = x)"
+ − 1266
unfolding fresh_def supp_def
+ − 1267
unfolding MOST_iff_cofinite by simp
+ − 1268
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1269
lemma supp_subset_fresh:
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1270
assumes a: "\<And>a. a \<sharp> x \<Longrightarrow> a \<sharp> y"
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1271
shows "supp y \<subseteq> supp x"
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1272
using a
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1273
unfolding fresh_def
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1274
by blast
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1275
1879
+ − 1276
lemma fresh_fun_app:
+ − 1277
assumes "a \<sharp> f" and "a \<sharp> x"
+ − 1278
shows "a \<sharp> f x"
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1279
using assms
1879
+ − 1280
unfolding fresh_conv_MOST
2732
+ − 1281
unfolding permute_fun_app_eq
1879
+ − 1282
by (elim MOST_rev_mp, simp)
+ − 1283
1062
+ − 1284
lemma supp_fun_app:
+ − 1285
shows "supp (f x) \<subseteq> (supp f) \<union> (supp x)"
1879
+ − 1286
using fresh_fun_app
+ − 1287
unfolding fresh_def
+ − 1288
by auto
+ − 1289
2732
+ − 1290
+ − 1291
subsection {* Equivariance *}
2663
+ − 1292
+ − 1293
definition
+ − 1294
"eqvt f \<equiv> \<forall>p. p \<bullet> f = f"
+ − 1295
+ − 1296
lemma eqvtI:
+ − 1297
shows "(\<And>p. p \<bullet> f \<equiv> f) \<Longrightarrow> eqvt f"
+ − 1298
unfolding eqvt_def
+ − 1299
by simp
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1300
1941
+ − 1301
lemma supp_fun_eqvt:
2663
+ − 1302
assumes a: "eqvt f"
1941
+ − 1303
shows "supp f = {}"
2663
+ − 1304
using a
+ − 1305
unfolding eqvt_def
1941
+ − 1306
unfolding supp_def
2663
+ − 1307
by simp
1941
+ − 1308
1062
+ − 1309
lemma fresh_fun_eqvt_app:
2663
+ − 1310
assumes a: "eqvt f"
1062
+ − 1311
shows "a \<sharp> x \<Longrightarrow> a \<sharp> f x"
+ − 1312
proof -
1941
+ − 1313
from a have "supp f = {}" by (simp add: supp_fun_eqvt)
1879
+ − 1314
then show "a \<sharp> x \<Longrightarrow> a \<sharp> f x"
1062
+ − 1315
unfolding fresh_def
2003
b53e98bfb298
added lemmas establishing the support of finite sets of finitely supported elements
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1316
using supp_fun_app by auto
1062
+ − 1317
qed
+ − 1318
2663
+ − 1319
text {* equivariance of a function at a given argument *}
2732
+ − 1320
2663
+ − 1321
definition
+ − 1322
"eqvt_at f x \<equiv> \<forall>p. p \<bullet> (f x) = f (p \<bullet> x)"
+ − 1323
+ − 1324
lemma supp_eqvt_at:
+ − 1325
assumes asm: "eqvt_at f x"
+ − 1326
and fin: "finite (supp x)"
+ − 1327
shows "supp (f x) \<subseteq> supp x"
+ − 1328
apply(rule supp_is_subset)
+ − 1329
unfolding supports_def
+ − 1330
unfolding fresh_def[symmetric]
+ − 1331
using asm
+ − 1332
apply(simp add: eqvt_at_def)
+ − 1333
apply(simp add: swap_fresh_fresh)
+ − 1334
apply(rule fin)
+ − 1335
done
+ − 1336
+ − 1337
lemma finite_supp_eqvt_at:
+ − 1338
assumes asm: "eqvt_at f x"
+ − 1339
and fin: "finite (supp x)"
+ − 1340
shows "finite (supp (f x))"
+ − 1341
apply(rule finite_subset)
+ − 1342
apply(rule supp_eqvt_at[OF asm fin])
+ − 1343
apply(rule fin)
+ − 1344
done
+ − 1345
+ − 1346
lemma fresh_eqvt_at:
+ − 1347
assumes asm: "eqvt_at f x"
+ − 1348
and fin: "finite (supp x)"
+ − 1349
and fresh: "a \<sharp> x"
+ − 1350
shows "a \<sharp> f x"
+ − 1351
using fresh
+ − 1352
unfolding fresh_def
+ − 1353
using supp_eqvt_at[OF asm fin]
+ − 1354
by auto
+ − 1355
+ − 1356
text {* helper functions for nominal_functions *}
+ − 1357
+ − 1358
lemma the_default_eqvt:
+ − 1359
assumes unique: "\<exists>!x. P x"
+ − 1360
shows "(p \<bullet> (THE_default d P)) = (THE_default d (p \<bullet> P))"
+ − 1361
apply(rule THE_default1_equality [symmetric])
+ − 1362
apply(rule_tac p="-p" in permute_boolE)
+ − 1363
apply(simp add: ex1_eqvt)
+ − 1364
apply(rule unique)
+ − 1365
apply(rule_tac p="-p" in permute_boolE)
+ − 1366
apply(rule subst[OF permute_fun_app_eq])
+ − 1367
apply(simp)
+ − 1368
apply(rule THE_defaultI'[OF unique])
+ − 1369
done
+ − 1370
2708
+ − 1371
lemma fundef_ex1_eqvt2:
+ − 1372
fixes x::"'a::pt"
+ − 1373
assumes f_def: "f == (\<lambda>x::'a. THE_default d (G x))"
+ − 1374
assumes eqvt: "eqvt_at G x"
+ − 1375
assumes ex1: "\<exists>!y. G x y"
+ − 1376
shows "(p \<bullet> (f x)) = f (p \<bullet> x)"
+ − 1377
apply(simp only: f_def)
+ − 1378
apply(subst the_default_eqvt)
+ − 1379
apply(rule ex1)
+ − 1380
using eqvt
+ − 1381
unfolding eqvt_at_def
+ − 1382
apply(simp)
+ − 1383
done
+ − 1384
2663
+ − 1385
lemma fundef_ex1_eqvt:
+ − 1386
fixes x::"'a::pt"
+ − 1387
assumes f_def: "f == (\<lambda>x::'a. THE_default d (G x))"
+ − 1388
assumes eqvt: "eqvt G"
+ − 1389
assumes ex1: "\<exists>!y. G x y"
+ − 1390
shows "(p \<bullet> (f x)) = f (p \<bullet> x)"
+ − 1391
apply(simp only: f_def)
+ − 1392
apply(subst the_default_eqvt)
+ − 1393
apply(rule ex1)
+ − 1394
using eqvt
+ − 1395
unfolding eqvt_def
+ − 1396
apply(simp add: permute_fun_app_eq)
+ − 1397
done
+ − 1398
2708
+ − 1399
lemma fundef_ex1_eqvt_at2:
+ − 1400
fixes x::"'a::pt"
+ − 1401
assumes f_def: "f == (\<lambda>x::'a. THE_default d (G x))"
+ − 1402
assumes eqvt: "eqvt_at G x"
+ − 1403
assumes ex1: "\<exists>!y. G x y"
+ − 1404
shows "eqvt_at f x"
+ − 1405
unfolding eqvt_at_def
+ − 1406
using assms
+ − 1407
by (auto intro: fundef_ex1_eqvt2)
+ − 1408
2663
+ − 1409
lemma fundef_ex1_eqvt_at:
+ − 1410
fixes x::"'a::pt"
+ − 1411
assumes f_def: "f == (\<lambda>x::'a. THE_default d (G x))"
+ − 1412
assumes eqvt: "eqvt G"
+ − 1413
assumes ex1: "\<exists>!y. G x y"
+ − 1414
shows "eqvt_at f x"
+ − 1415
unfolding eqvt_at_def
+ − 1416
using assms
+ − 1417
by (auto intro: fundef_ex1_eqvt)
+ − 1418
2466
+ − 1419
section {* Support of Finite Sets of Finitely Supported Elements *}
+ − 1420
2657
+ − 1421
text {* support and freshness for atom sets *}
+ − 1422
+ − 1423
lemma supp_finite_atom_set:
+ − 1424
fixes S::"atom set"
+ − 1425
assumes "finite S"
+ − 1426
shows "supp S = S"
+ − 1427
apply(rule finite_supp_unique)
+ − 1428
apply(simp add: supports_def)
+ − 1429
apply(simp add: swap_set_not_in)
+ − 1430
apply(rule assms)
+ − 1431
apply(simp add: swap_set_in)
+ − 1432
done
+ − 1433
+ − 1434
lemma fresh_finite_atom_set:
+ − 1435
fixes S::"atom set"
+ − 1436
assumes "finite S"
+ − 1437
shows "a \<sharp> S \<longleftrightarrow> a \<notin> S"
+ − 1438
unfolding fresh_def
+ − 1439
by (simp add: supp_finite_atom_set[OF assms])
+ − 1440
2679
+ − 1441
lemma fresh_minus_atom_set:
+ − 1442
fixes S::"atom set"
+ − 1443
assumes "finite S"
+ − 1444
shows "a \<sharp> S - T \<longleftrightarrow> (a \<notin> T \<longrightarrow> a \<sharp> S)"
+ − 1445
unfolding fresh_def
+ − 1446
by (auto simp add: supp_finite_atom_set assms)
+ − 1447
+ − 1448
2466
+ − 1449
lemma Union_fresh:
+ − 1450
shows "a \<sharp> S \<Longrightarrow> a \<sharp> (\<Union>x \<in> S. supp x)"
+ − 1451
unfolding Union_image_eq[symmetric]
+ − 1452
apply(rule_tac f="\<lambda>S. \<Union> supp ` S" in fresh_fun_eqvt_app)
2663
+ − 1453
unfolding eqvt_def
+ − 1454
unfolding permute_fun_def
+ − 1455
apply(simp)
+ − 1456
unfolding UNION_def
+ − 1457
unfolding Collect_def
+ − 1458
unfolding Bex_def
+ − 1459
apply(simp add: ex_eqvt)
+ − 1460
unfolding permute_fun_def
+ − 1461
apply(simp add: conj_eqvt)
+ − 1462
apply(simp add: mem_eqvt)
+ − 1463
apply(simp add: supp_eqvt)
+ − 1464
unfolding permute_fun_def
+ − 1465
apply(simp)
2466
+ − 1466
apply(assumption)
+ − 1467
done
+ − 1468
+ − 1469
lemma Union_supports_set:
+ − 1470
shows "(\<Union>x \<in> S. supp x) supports S"
+ − 1471
proof -
+ − 1472
{ fix a b
+ − 1473
have "\<forall>x \<in> S. (a \<rightleftharpoons> b) \<bullet> x = x \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> S = S"
+ − 1474
unfolding permute_set_eq by force
+ − 1475
}
+ − 1476
then show "(\<Union>x \<in> S. supp x) supports S"
+ − 1477
unfolding supports_def
+ − 1478
by (simp add: fresh_def[symmetric] swap_fresh_fresh)
+ − 1479
qed
+ − 1480
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1481
lemma Union_of_finite_supp_sets:
2466
+ − 1482
fixes S::"('a::fs set)"
+ − 1483
assumes fin: "finite S"
+ − 1484
shows "finite (\<Union>x\<in>S. supp x)"
+ − 1485
using fin by (induct) (auto simp add: finite_supp)
+ − 1486
+ − 1487
lemma Union_included_in_supp:
+ − 1488
fixes S::"('a::fs set)"
+ − 1489
assumes fin: "finite S"
+ − 1490
shows "(\<Union>x\<in>S. supp x) \<subseteq> supp S"
+ − 1491
proof -
+ − 1492
have "(\<Union>x\<in>S. supp x) = supp (\<Union>x\<in>S. supp x)"
+ − 1493
by (rule supp_finite_atom_set[symmetric])
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1494
(rule Union_of_finite_supp_sets[OF fin])
2466
+ − 1495
also have "\<dots> \<subseteq> supp S"
+ − 1496
by (rule supp_subset_fresh)
+ − 1497
(simp add: Union_fresh)
+ − 1498
finally show "(\<Union>x\<in>S. supp x) \<subseteq> supp S" .
+ − 1499
qed
+ − 1500
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1501
lemma supp_of_finite_sets:
2466
+ − 1502
fixes S::"('a::fs set)"
+ − 1503
assumes fin: "finite S"
+ − 1504
shows "(supp S) = (\<Union>x\<in>S. supp x)"
+ − 1505
apply(rule subset_antisym)
+ − 1506
apply(rule supp_is_subset)
+ − 1507
apply(rule Union_supports_set)
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1508
apply(rule Union_of_finite_supp_sets[OF fin])
2466
+ − 1509
apply(rule Union_included_in_supp[OF fin])
+ − 1510
done
+ − 1511
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1512
lemma finite_sets_supp:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1513
fixes S::"('a::fs set)"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1514
assumes "finite S"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1515
shows "finite (supp S)"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1516
using assms
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1517
by (simp only: supp_of_finite_sets Union_of_finite_supp_sets)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1518
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1519
lemma supp_of_finite_union:
2466
+ − 1520
fixes S T::"('a::fs) set"
+ − 1521
assumes fin1: "finite S"
+ − 1522
and fin2: "finite T"
+ − 1523
shows "supp (S \<union> T) = supp S \<union> supp T"
+ − 1524
using fin1 fin2
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1525
by (simp add: supp_of_finite_sets)
2466
+ − 1526
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1527
lemma supp_of_finite_insert:
2466
+ − 1528
fixes S::"('a::fs) set"
+ − 1529
assumes fin: "finite S"
+ − 1530
shows "supp (insert x S) = supp x \<union> supp S"
+ − 1531
using fin
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1532
by (simp add: supp_of_finite_sets)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1533
2588
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1534
lemma fresh_finite_insert:
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1535
fixes S::"('a::fs) set"
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1536
assumes fin: "finite S"
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1537
shows "a \<sharp> (insert x S) \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> S"
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1538
using fin unfolding fresh_def
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1539
by (simp add: supp_of_finite_insert)
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1540
2591
+ − 1541
lemma supp_set_empty:
+ − 1542
shows "supp {} = {}"
+ − 1543
unfolding supp_def
+ − 1544
by (simp add: empty_eqvt)
+ − 1545
+ − 1546
lemma fresh_set_empty:
+ − 1547
shows "a \<sharp> {}"
+ − 1548
by (simp add: fresh_def supp_set_empty)
+ − 1549
+ − 1550
lemma supp_set:
+ − 1551
fixes xs :: "('a::fs) list"
+ − 1552
shows "supp (set xs) = supp xs"
+ − 1553
apply(induct xs)
+ − 1554
apply(simp add: supp_set_empty supp_Nil)
+ − 1555
apply(simp add: supp_Cons supp_of_finite_insert)
+ − 1556
done
+ − 1557
+ − 1558
lemma fresh_set:
+ − 1559
fixes xs :: "('a::fs) list"
+ − 1560
shows "a \<sharp> (set xs) \<longleftrightarrow> a \<sharp> xs"
+ − 1561
unfolding fresh_def
+ − 1562
by (simp add: supp_set)
+ − 1563
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1564
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1565
subsection {* Type @{typ "'a fset"} is finitely supported *}
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1566
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1567
lemma fset_eqvt:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1568
shows "p \<bullet> (fset S) = fset (p \<bullet> S)"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1569
by (lifting set_eqvt)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1570
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1571
lemma supp_fset [simp]:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1572
shows "supp (fset S) = supp S"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1573
unfolding supp_def
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1574
by (simp add: fset_eqvt fset_cong)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1575
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1576
lemma supp_empty_fset [simp]:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1577
shows "supp {||} = {}"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1578
unfolding supp_def
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1579
by simp
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1580
2641
+ − 1581
lemma fresh_empty_fset:
+ − 1582
shows "a \<sharp> {||}"
+ − 1583
unfolding fresh_def
+ − 1584
by (simp)
+ − 1585
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1586
lemma supp_insert_fset [simp]:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1587
fixes x::"'a::fs"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1588
and S::"'a fset"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1589
shows "supp (insert_fset x S) = supp x \<union> supp S"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1590
apply(subst supp_fset[symmetric])
2587
+ − 1591
apply(simp add: supp_of_finite_insert)
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1592
done
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1593
2641
+ − 1594
lemma fresh_insert_fset:
+ − 1595
fixes x::"'a::fs"
+ − 1596
and S::"'a fset"
+ − 1597
shows "a \<sharp> insert_fset x S \<longleftrightarrow> a \<sharp> x \<and> a \<sharp> S"
+ − 1598
unfolding fresh_def
+ − 1599
by (simp)
+ − 1600
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1601
lemma fset_finite_supp:
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1602
fixes S::"('a::fs) fset"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1603
shows "finite (supp S)"
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1604
by (induct S) (simp_all add: finite_supp)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1605
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1606
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1607
instance fset :: (fs) fs
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1608
apply (default)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1609
apply (rule fset_finite_supp)
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1610
done
2466
+ − 1611
+ − 1612
2632
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1613
section {* Freshness and Fresh-Star *}
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1614
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1615
lemma fresh_Unit_elim:
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1616
shows "(a \<sharp> () \<Longrightarrow> PROP C) \<equiv> PROP C"
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1617
by (simp add: fresh_Unit)
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1618
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1619
lemma fresh_Pair_elim:
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1620
shows "(a \<sharp> (x, y) \<Longrightarrow> PROP C) \<equiv> (a \<sharp> x \<Longrightarrow> a \<sharp> y \<Longrightarrow> PROP C)"
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1621
by rule (simp_all add: fresh_Pair)
2470
+ − 1622
2632
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1623
(* this rule needs to be added before the fresh_prodD is *)
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1624
(* added to the simplifier with mksimps *)
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1625
lemma [simp]:
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1626
shows "a \<sharp> x1 \<Longrightarrow> a \<sharp> x2 \<Longrightarrow> a \<sharp> (x1, x2)"
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1627
by (simp add: fresh_Pair)
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1628
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1629
lemma fresh_PairD:
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1630
shows "a \<sharp> (x, y) \<Longrightarrow> a \<sharp> x"
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1631
and "a \<sharp> (x, y) \<Longrightarrow> a \<sharp> y"
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1632
by (simp_all add: fresh_Pair)
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1633
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1634
ML {*
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1635
val mksimps_pairs = (@{const_name Nominal2_Base.fresh}, @{thms fresh_PairD}) :: mksimps_pairs;
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1636
*}
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1637
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1638
declaration {* fn _ =>
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1639
Simplifier.map_ss (fn ss => ss setmksimps (mksimps mksimps_pairs))
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1640
*}
2470
+ − 1641
+ − 1642
text {* The fresh-star generalisation of fresh is used in strong
+ − 1643
induction principles. *}
+ − 1644
+ − 1645
definition
+ − 1646
fresh_star :: "atom set \<Rightarrow> 'a::pt \<Rightarrow> bool" ("_ \<sharp>* _" [80,80] 80)
+ − 1647
where
+ − 1648
"as \<sharp>* x \<equiv> \<forall>a \<in> as. a \<sharp> x"
+ − 1649
2507
+ − 1650
lemma fresh_star_supp_conv:
+ − 1651
shows "supp x \<sharp>* y \<Longrightarrow> supp y \<sharp>* x"
+ − 1652
by (auto simp add: fresh_star_def fresh_def)
+ − 1653
2675
+ − 1654
lemma fresh_star_perm_set_conv:
+ − 1655
fixes p::"perm"
+ − 1656
assumes fresh: "as \<sharp>* p"
+ − 1657
and fin: "finite as"
+ − 1658
shows "supp p \<sharp>* as"
+ − 1659
apply(rule fresh_star_supp_conv)
+ − 1660
apply(simp add: supp_finite_atom_set fin fresh)
+ − 1661
done
+ − 1662
2679
+ − 1663
lemma fresh_star_atom_set_conv:
+ − 1664
assumes fresh: "as \<sharp>* bs"
+ − 1665
and fin: "finite as" "finite bs"
+ − 1666
shows "bs \<sharp>* as"
+ − 1667
using fresh
+ − 1668
unfolding fresh_star_def fresh_def
+ − 1669
by (auto simp add: supp_finite_atom_set fin)
+ − 1670
2730
+ − 1671
lemma atom_fresh_star_disjoint:
+ − 1672
assumes fin: "finite bs"
+ − 1673
shows "as \<sharp>* bs \<longleftrightarrow> (as \<inter> bs = {})"
+ − 1674
+ − 1675
unfolding fresh_star_def fresh_def
+ − 1676
by (auto simp add: supp_finite_atom_set fin)
+ − 1677
2675
+ − 1678
2591
+ − 1679
lemma fresh_star_Pair:
2470
+ − 1680
shows "as \<sharp>* (x, y) = (as \<sharp>* x \<and> as \<sharp>* y)"
+ − 1681
by (auto simp add: fresh_star_def fresh_Pair)
+ − 1682
2591
+ − 1683
lemma fresh_star_list:
+ − 1684
shows "as \<sharp>* (xs @ ys) \<longleftrightarrow> as \<sharp>* xs \<and> as \<sharp>* ys"
+ − 1685
and "as \<sharp>* (x # xs) \<longleftrightarrow> as \<sharp>* x \<and> as \<sharp>* xs"
+ − 1686
and "as \<sharp>* []"
+ − 1687
by (auto simp add: fresh_star_def fresh_Nil fresh_Cons fresh_append)
+ − 1688
+ − 1689
lemma fresh_star_set:
+ − 1690
fixes xs::"('a::fs) list"
+ − 1691
shows "as \<sharp>* set xs \<longleftrightarrow> as \<sharp>* xs"
+ − 1692
unfolding fresh_star_def
+ − 1693
by (simp add: fresh_set)
+ − 1694
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1695
lemma fresh_star_singleton:
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1696
fixes a::"atom"
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1697
shows "as \<sharp>* {a} \<longleftrightarrow> as \<sharp>* a"
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1698
by (simp add: fresh_star_def fresh_finite_insert fresh_set_empty)
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1699
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1700
lemma fresh_star_fset:
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1701
fixes xs::"('a::fs) list"
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1702
shows "as \<sharp>* fset S \<longleftrightarrow> as \<sharp>* S"
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1703
by (simp add: fresh_star_def fresh_def)
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1704
2591
+ − 1705
lemma fresh_star_Un:
2470
+ − 1706
shows "(as \<union> bs) \<sharp>* x = (as \<sharp>* x \<and> bs \<sharp>* x)"
+ − 1707
by (auto simp add: fresh_star_def)
+ − 1708
+ − 1709
lemma fresh_star_insert:
+ − 1710
shows "(insert a as) \<sharp>* x = (a \<sharp> x \<and> as \<sharp>* x)"
+ − 1711
by (auto simp add: fresh_star_def)
+ − 1712
+ − 1713
lemma fresh_star_Un_elim:
+ − 1714
"((as \<union> bs) \<sharp>* x \<Longrightarrow> PROP C) \<equiv> (as \<sharp>* x \<Longrightarrow> bs \<sharp>* x \<Longrightarrow> PROP C)"
+ − 1715
unfolding fresh_star_def
+ − 1716
apply(rule)
+ − 1717
apply(erule meta_mp)
+ − 1718
apply(auto)
+ − 1719
done
+ − 1720
+ − 1721
lemma fresh_star_insert_elim:
+ − 1722
"(insert a as \<sharp>* x \<Longrightarrow> PROP C) \<equiv> (a \<sharp> x \<Longrightarrow> as \<sharp>* x \<Longrightarrow> PROP C)"
+ − 1723
unfolding fresh_star_def
+ − 1724
by rule (simp_all add: fresh_star_def)
+ − 1725
+ − 1726
lemma fresh_star_empty_elim:
+ − 1727
"({} \<sharp>* x \<Longrightarrow> PROP C) \<equiv> PROP C"
+ − 1728
by (simp add: fresh_star_def)
+ − 1729
2632
e8732350a29f
added small example for strong inductions; functions still need a sorry
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1730
lemma fresh_star_Unit_elim:
2470
+ − 1731
shows "(a \<sharp>* () \<Longrightarrow> PROP C) \<equiv> PROP C"
+ − 1732
by (simp add: fresh_star_def fresh_Unit)
+ − 1733
2591
+ − 1734
lemma fresh_star_Pair_elim:
2470
+ − 1735
shows "(a \<sharp>* (x, y) \<Longrightarrow> PROP C) \<equiv> (a \<sharp>* x \<Longrightarrow> a \<sharp>* y \<Longrightarrow> PROP C)"
2591
+ − 1736
by (rule, simp_all add: fresh_star_Pair)
2470
+ − 1737
+ − 1738
lemma fresh_star_zero:
+ − 1739
shows "as \<sharp>* (0::perm)"
+ − 1740
unfolding fresh_star_def
+ − 1741
by (simp add: fresh_zero_perm)
+ − 1742
+ − 1743
lemma fresh_star_plus:
+ − 1744
fixes p q::perm
+ − 1745
shows "\<lbrakk>a \<sharp>* p; a \<sharp>* q\<rbrakk> \<Longrightarrow> a \<sharp>* (p + q)"
+ − 1746
unfolding fresh_star_def
+ − 1747
by (simp add: fresh_plus_perm)
+ − 1748
+ − 1749
lemma fresh_star_permute_iff:
+ − 1750
shows "(p \<bullet> a) \<sharp>* (p \<bullet> x) \<longleftrightarrow> a \<sharp>* x"
+ − 1751
unfolding fresh_star_def
+ − 1752
by (metis mem_permute_iff permute_minus_cancel(1) fresh_permute_iff)
+ − 1753
+ − 1754
lemma fresh_star_eqvt:
2663
+ − 1755
shows "p \<bullet> (as \<sharp>* x) \<longleftrightarrow> (p \<bullet> as) \<sharp>* (p \<bullet> x)"
2470
+ − 1756
unfolding fresh_star_def
+ − 1757
unfolding Ball_def
+ − 1758
apply(simp add: all_eqvt)
+ − 1759
apply(subst permute_fun_def)
+ − 1760
apply(simp add: imp_eqvt fresh_eqvt mem_eqvt)
+ − 1761
done
+ − 1762
2591
+ − 1763
2470
+ − 1764
+ − 1765
section {* Induction principle for permutations *}
+ − 1766
+ − 1767
+ − 1768
lemma perm_struct_induct[consumes 1, case_names zero swap]:
+ − 1769
assumes S: "supp p \<subseteq> S"
+ − 1770
and zero: "P 0"
+ − 1771
and swap: "\<And>p a b. \<lbrakk>P p; supp p \<subseteq> S; a \<in> S; b \<in> S; a \<noteq> b; sort_of a = sort_of b\<rbrakk> \<Longrightarrow> P ((a \<rightleftharpoons> b) + p)"
+ − 1772
shows "P p"
+ − 1773
proof -
+ − 1774
have "finite (supp p)" by (simp add: finite_supp)
+ − 1775
then show "P p" using S
+ − 1776
proof(induct A\<equiv>"supp p" arbitrary: p rule: finite_psubset_induct)
+ − 1777
case (psubset p)
+ − 1778
then have ih: "\<And>q. supp q \<subset> supp p \<Longrightarrow> P q" by auto
+ − 1779
have as: "supp p \<subseteq> S" by fact
+ − 1780
{ assume "supp p = {}"
2732
+ − 1781
then have "p = 0" by (simp add: supp_perm perm_eq_iff)
2470
+ − 1782
then have "P p" using zero by simp
+ − 1783
}
+ − 1784
moreover
+ − 1785
{ assume "supp p \<noteq> {}"
+ − 1786
then obtain a where a0: "a \<in> supp p" by blast
+ − 1787
then have a1: "p \<bullet> a \<in> S" "a \<in> S" "sort_of (p \<bullet> a) = sort_of a" "p \<bullet> a \<noteq> a"
+ − 1788
using as by (auto simp add: supp_atom supp_perm swap_atom)
+ − 1789
let ?q = "(p \<bullet> a \<rightleftharpoons> a) + p"
+ − 1790
have a2: "supp ?q \<subseteq> supp p" unfolding supp_perm by (auto simp add: swap_atom)
+ − 1791
moreover
+ − 1792
have "a \<notin> supp ?q" by (simp add: supp_perm)
+ − 1793
then have "supp ?q \<noteq> supp p" using a0 by auto
+ − 1794
ultimately have "supp ?q \<subset> supp p" using a2 by auto
+ − 1795
then have "P ?q" using ih by simp
+ − 1796
moreover
+ − 1797
have "supp ?q \<subseteq> S" using as a2 by simp
+ − 1798
ultimately have "P ((p \<bullet> a \<rightleftharpoons> a) + ?q)" using as a1 swap by simp
+ − 1799
moreover
2732
+ − 1800
have "p = (p \<bullet> a \<rightleftharpoons> a) + ?q" by (simp add: perm_eq_iff)
2470
+ − 1801
ultimately have "P p" by simp
+ − 1802
}
+ − 1803
ultimately show "P p" by blast
+ − 1804
qed
+ − 1805
qed
+ − 1806
+ − 1807
lemma perm_simple_struct_induct[case_names zero swap]:
+ − 1808
assumes zero: "P 0"
+ − 1809
and swap: "\<And>p a b. \<lbrakk>P p; a \<noteq> b; sort_of a = sort_of b\<rbrakk> \<Longrightarrow> P ((a \<rightleftharpoons> b) + p)"
+ − 1810
shows "P p"
+ − 1811
by (rule_tac S="supp p" in perm_struct_induct)
+ − 1812
(auto intro: zero swap)
+ − 1813
2669
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1814
lemma perm_struct_induct2[consumes 1, case_names zero swap plus]:
2470
+ − 1815
assumes S: "supp p \<subseteq> S"
+ − 1816
assumes zero: "P 0"
+ − 1817
assumes swap: "\<And>a b. \<lbrakk>sort_of a = sort_of b; a \<noteq> b; a \<in> S; b \<in> S\<rbrakk> \<Longrightarrow> P (a \<rightleftharpoons> b)"
+ − 1818
assumes plus: "\<And>p1 p2. \<lbrakk>P p1; P p2; supp p1 \<subseteq> S; supp p2 \<subseteq> S\<rbrakk> \<Longrightarrow> P (p1 + p2)"
+ − 1819
shows "P p"
+ − 1820
using S
+ − 1821
by (induct p rule: perm_struct_induct)
+ − 1822
(auto intro: zero plus swap simp add: supp_swap)
+ − 1823
2669
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1824
lemma perm_simple_struct_induct2[case_names zero swap plus]:
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1825
assumes zero: "P 0"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1826
assumes swap: "\<And>a b. \<lbrakk>sort_of a = sort_of b; a \<noteq> b\<rbrakk> \<Longrightarrow> P (a \<rightleftharpoons> b)"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1827
assumes plus: "\<And>p1 p2. \<lbrakk>P p1; P p2\<rbrakk> \<Longrightarrow> P (p1 + p2)"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1828
shows "P p"
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1829
by (rule_tac S="supp p" in perm_struct_induct2)
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1830
(auto intro: zero swap plus)
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1831
2679
+ − 1832
lemma supp_perm_singleton:
+ − 1833
fixes p::"perm"
+ − 1834
shows "supp p \<subseteq> {b} \<longleftrightarrow> p = 0"
+ − 1835
proof -
+ − 1836
{ assume "supp p \<subseteq> {b}"
+ − 1837
then have "p = 0"
+ − 1838
by (induct p rule: perm_struct_induct) (simp_all)
+ − 1839
}
+ − 1840
then show "supp p \<subseteq> {b} \<longleftrightarrow> p = 0" by (auto simp add: supp_zero_perm)
+ − 1841
qed
+ − 1842
+ − 1843
lemma supp_perm_pair:
+ − 1844
fixes p::"perm"
+ − 1845
shows "supp p \<subseteq> {a, b} \<longleftrightarrow> p = 0 \<or> p = (b \<rightleftharpoons> a)"
+ − 1846
proof -
+ − 1847
{ assume "supp p \<subseteq> {a, b}"
+ − 1848
then have "p = 0 \<or> p = (b \<rightleftharpoons> a)"
+ − 1849
apply (induct p rule: perm_struct_induct)
+ − 1850
apply (auto simp add: swap_cancel supp_zero_perm supp_swap)
+ − 1851
apply (simp add: swap_commute)
+ − 1852
done
+ − 1853
}
+ − 1854
then show "supp p \<subseteq> {a, b} \<longleftrightarrow> p = 0 \<or> p = (b \<rightleftharpoons> a)"
+ − 1855
by (auto simp add: supp_zero_perm supp_swap split: if_splits)
+ − 1856
qed
+ − 1857
2470
+ − 1858
lemma supp_perm_eq:
+ − 1859
assumes "(supp x) \<sharp>* p"
+ − 1860
shows "p \<bullet> x = x"
+ − 1861
proof -
+ − 1862
from assms have "supp p \<subseteq> {a. a \<sharp> x}"
+ − 1863
unfolding supp_perm fresh_star_def fresh_def by auto
+ − 1864
then show "p \<bullet> x = x"
+ − 1865
proof (induct p rule: perm_struct_induct)
+ − 1866
case zero
+ − 1867
show "0 \<bullet> x = x" by simp
+ − 1868
next
+ − 1869
case (swap p a b)
+ − 1870
then have "a \<sharp> x" "b \<sharp> x" "p \<bullet> x = x" by simp_all
+ − 1871
then show "((a \<rightleftharpoons> b) + p) \<bullet> x = x" by (simp add: swap_fresh_fresh)
+ − 1872
qed
+ − 1873
qed
+ − 1874
+ − 1875
lemma supp_perm_eq_test:
+ − 1876
assumes "(supp x) \<sharp>* p"
+ − 1877
shows "p \<bullet> x = x"
+ − 1878
proof -
+ − 1879
from assms have "supp p \<subseteq> {a. a \<sharp> x}"
+ − 1880
unfolding supp_perm fresh_star_def fresh_def by auto
+ − 1881
then show "p \<bullet> x = x"
2669
1d1772a89026
the function translating lambda terms to locally nameless lambda terms; still needs a stronger abs_eq_iff lemma...at the moment only proved for restrictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1882
proof (induct p rule: perm_struct_induct2)
2470
+ − 1883
case zero
+ − 1884
show "0 \<bullet> x = x" by simp
+ − 1885
next
+ − 1886
case (swap a b)
+ − 1887
then have "a \<sharp> x" "b \<sharp> x" by simp_all
+ − 1888
then show "(a \<rightleftharpoons> b) \<bullet> x = x" by (simp add: swap_fresh_fresh)
+ − 1889
next
+ − 1890
case (plus p1 p2)
+ − 1891
have "p1 \<bullet> x = x" "p2 \<bullet> x = x" by fact+
+ − 1892
then show "(p1 + p2) \<bullet> x = x" by simp
+ − 1893
qed
+ − 1894
qed
+ − 1895
2591
+ − 1896
lemma perm_supp_eq:
+ − 1897
assumes a: "(supp p) \<sharp>* x"
+ − 1898
shows "p \<bullet> x = x"
+ − 1899
by (rule supp_perm_eq)
+ − 1900
(simp add: fresh_star_supp_conv a)
+ − 1901
2659
+ − 1902
lemma supp_perm_perm_eq:
+ − 1903
assumes a: "\<forall>a \<in> supp x. p \<bullet> a = q \<bullet> a"
+ − 1904
shows "p \<bullet> x = q \<bullet> x"
+ − 1905
proof -
+ − 1906
from a have "\<forall>a \<in> supp x. (-q + p) \<bullet> a = a" by simp
+ − 1907
then have "\<forall>a \<in> supp x. a \<notin> supp (-q + p)"
+ − 1908
unfolding supp_perm by simp
+ − 1909
then have "supp x \<sharp>* (-q + p)"
+ − 1910
unfolding fresh_star_def fresh_def by simp
+ − 1911
then have "(-q + p) \<bullet> x = x" by (simp only: supp_perm_eq)
+ − 1912
then show "p \<bullet> x = q \<bullet> x"
+ − 1913
by (metis permute_minus_cancel permute_plus)
+ − 1914
qed
+ − 1915
2668
+ − 1916
lemma atom_set_perm_eq:
+ − 1917
assumes a: "as \<sharp>* p"
+ − 1918
shows "p \<bullet> as = as"
+ − 1919
proof -
+ − 1920
from a have "supp p \<subseteq> {a. a \<notin> as}"
+ − 1921
unfolding supp_perm fresh_star_def fresh_def by auto
+ − 1922
then show "p \<bullet> as = as"
+ − 1923
proof (induct p rule: perm_struct_induct)
+ − 1924
case zero
+ − 1925
show "0 \<bullet> as = as" by simp
+ − 1926
next
+ − 1927
case (swap p a b)
+ − 1928
then have "a \<notin> as" "b \<notin> as" "p \<bullet> as = as" by simp_all
+ − 1929
then show "((a \<rightleftharpoons> b) + p) \<bullet> as = as" by (simp add: swap_set_not_in)
+ − 1930
qed
+ − 1931
qed
2470
+ − 1932
+ − 1933
section {* Avoiding of atom sets *}
+ − 1934
+ − 1935
text {*
+ − 1936
For every set of atoms, there is another set of atoms
+ − 1937
avoiding a finitely supported c and there is a permutation
+ − 1938
which 'translates' between both sets.
+ − 1939
*}
+ − 1940
+ − 1941
lemma at_set_avoiding_aux:
+ − 1942
fixes Xs::"atom set"
+ − 1943
and As::"atom set"
+ − 1944
assumes b: "Xs \<subseteq> As"
+ − 1945
and c: "finite As"
2614
+ − 1946
shows "\<exists>p. (p \<bullet> Xs) \<inter> As = {} \<and> (supp p) = (Xs \<union> (p \<bullet> Xs))"
2470
+ − 1947
proof -
+ − 1948
from b c have "finite Xs" by (rule finite_subset)
+ − 1949
then show ?thesis using b
+ − 1950
proof (induct rule: finite_subset_induct)
+ − 1951
case empty
+ − 1952
have "0 \<bullet> {} \<inter> As = {}" by simp
+ − 1953
moreover
2614
+ − 1954
have "supp (0::perm) = {} \<union> 0 \<bullet> {}" by (simp add: supp_zero_perm)
2470
+ − 1955
ultimately show ?case by blast
+ − 1956
next
+ − 1957
case (insert x Xs)
+ − 1958
then obtain p where
+ − 1959
p1: "(p \<bullet> Xs) \<inter> As = {}" and
2614
+ − 1960
p2: "supp p = (Xs \<union> (p \<bullet> Xs))" by blast
2470
+ − 1961
from `x \<in> As` p1 have "x \<notin> p \<bullet> Xs" by fast
+ − 1962
with `x \<notin> Xs` p2 have "x \<notin> supp p" by fast
+ − 1963
hence px: "p \<bullet> x = x" unfolding supp_perm by simp
2614
+ − 1964
have "finite (As \<union> p \<bullet> Xs \<union> supp p)"
2470
+ − 1965
using `finite As` `finite Xs`
2614
+ − 1966
by (simp add: permute_set_eq_image finite_supp)
+ − 1967
then obtain y where "y \<notin> (As \<union> p \<bullet> Xs \<union> supp p)" "sort_of y = sort_of x"
2470
+ − 1968
by (rule obtain_atom)
2614
+ − 1969
hence y: "y \<notin> As" "y \<notin> p \<bullet> Xs" "y \<notin> supp p" "sort_of y = sort_of x"
2470
+ − 1970
by simp_all
2614
+ − 1971
hence py: "p \<bullet> y = y" "x \<noteq> y" using `x \<in> As`
+ − 1972
by (auto simp add: supp_perm)
2470
+ − 1973
let ?q = "(x \<rightleftharpoons> y) + p"
+ − 1974
have q: "?q \<bullet> insert x Xs = insert y (p \<bullet> Xs)"
+ − 1975
unfolding insert_eqvt
+ − 1976
using `p \<bullet> x = x` `sort_of y = sort_of x`
+ − 1977
using `x \<notin> p \<bullet> Xs` `y \<notin> p \<bullet> Xs`
+ − 1978
by (simp add: swap_atom swap_set_not_in)
+ − 1979
have "?q \<bullet> insert x Xs \<inter> As = {}"
+ − 1980
using `y \<notin> As` `p \<bullet> Xs \<inter> As = {}`
+ − 1981
unfolding q by simp
+ − 1982
moreover
2614
+ − 1983
have "supp (x \<rightleftharpoons> y) \<inter> supp p = {}" using px py `sort_of y = sort_of x`
+ − 1984
unfolding supp_swap by (simp add: supp_perm)
+ − 1985
then have "supp ?q = (supp (x \<rightleftharpoons> y) \<union> supp p)"
+ − 1986
by (simp add: supp_plus_perm_eq)
+ − 1987
then have "supp ?q = insert x Xs \<union> ?q \<bullet> insert x Xs"
+ − 1988
using p2 `sort_of y = sort_of x` `x \<noteq> y` unfolding q supp_swap
+ − 1989
by auto
2470
+ − 1990
ultimately show ?case by blast
+ − 1991
qed
+ − 1992
qed
+ − 1993
+ − 1994
lemma at_set_avoiding:
+ − 1995
assumes a: "finite Xs"
+ − 1996
and b: "finite (supp c)"
2614
+ − 1997
obtains p::"perm" where "(p \<bullet> Xs)\<sharp>*c" and "(supp p) = (Xs \<union> (p \<bullet> Xs))"
2470
+ − 1998
using a b at_set_avoiding_aux [where Xs="Xs" and As="Xs \<union> supp c"]
+ − 1999
unfolding fresh_star_def fresh_def by blast
+ − 2000
2589
+ − 2001
lemma at_set_avoiding1:
+ − 2002
assumes "finite xs"
+ − 2003
and "finite (supp c)"
+ − 2004
shows "\<exists>p. (p \<bullet> xs) \<sharp>* c"
+ − 2005
using assms
+ − 2006
apply(erule_tac c="c" in at_set_avoiding)
+ − 2007
apply(auto)
+ − 2008
done
+ − 2009
2470
+ − 2010
lemma at_set_avoiding2:
+ − 2011
assumes "finite xs"
+ − 2012
and "finite (supp c)" "finite (supp x)"
+ − 2013
and "xs \<sharp>* x"
+ − 2014
shows "\<exists>p. (p \<bullet> xs) \<sharp>* c \<and> supp x \<sharp>* p"
+ − 2015
using assms
+ − 2016
apply(erule_tac c="(c, x)" in at_set_avoiding)
+ − 2017
apply(simp add: supp_Pair)
+ − 2018
apply(rule_tac x="p" in exI)
2591
+ − 2019
apply(simp add: fresh_star_Pair)
2507
+ − 2020
apply(rule fresh_star_supp_conv)
+ − 2021
apply(auto simp add: fresh_star_def)
2470
+ − 2022
done
+ − 2023
2573
+ − 2024
lemma at_set_avoiding3:
+ − 2025
assumes "finite xs"
+ − 2026
and "finite (supp c)" "finite (supp x)"
+ − 2027
and "xs \<sharp>* x"
2614
+ − 2028
shows "\<exists>p. (p \<bullet> xs) \<sharp>* c \<and> supp x \<sharp>* p \<and> supp p = xs \<union> (p \<bullet> xs)"
2586
+ − 2029
using assms
+ − 2030
apply(erule_tac c="(c, x)" in at_set_avoiding)
+ − 2031
apply(simp add: supp_Pair)
+ − 2032
apply(rule_tac x="p" in exI)
2591
+ − 2033
apply(simp add: fresh_star_Pair)
2586
+ − 2034
apply(rule fresh_star_supp_conv)
+ − 2035
apply(auto simp add: fresh_star_def)
+ − 2036
done
2573
+ − 2037
2470
+ − 2038
lemma at_set_avoiding2_atom:
+ − 2039
assumes "finite (supp c)" "finite (supp x)"
+ − 2040
and b: "a \<sharp> x"
+ − 2041
shows "\<exists>p. (p \<bullet> a) \<sharp> c \<and> supp x \<sharp>* p"
+ − 2042
proof -
+ − 2043
have a: "{a} \<sharp>* x" unfolding fresh_star_def by (simp add: b)
+ − 2044
obtain p where p1: "(p \<bullet> {a}) \<sharp>* c" and p2: "supp x \<sharp>* p"
+ − 2045
using at_set_avoiding2[of "{a}" "c" "x"] assms a by blast
+ − 2046
have c: "(p \<bullet> a) \<sharp> c" using p1
+ − 2047
unfolding fresh_star_def Ball_def
+ − 2048
by(erule_tac x="p \<bullet> a" in allE) (simp add: permute_set_eq)
+ − 2049
hence "p \<bullet> a \<sharp> c \<and> supp x \<sharp>* p" using p2 by blast
+ − 2050
then show "\<exists>p. (p \<bullet> a) \<sharp> c \<and> supp x \<sharp>* p" by blast
+ − 2051
qed
+ − 2052
2614
+ − 2053
2599
+ − 2054
section {* Renaming permutations *}
+ − 2055
+ − 2056
lemma set_renaming_perm:
2659
+ − 2057
assumes b: "finite bs"
2668
+ − 2058
shows "\<exists>q. (\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> (p \<bullet> bs)"
2659
+ − 2059
using b
2599
+ − 2060
proof (induct)
+ − 2061
case empty
2668
+ − 2062
have "(\<forall>b \<in> {}. 0 \<bullet> b = p \<bullet> b) \<and> supp (0::perm) \<subseteq> {} \<union> p \<bullet> {}"
2599
+ − 2063
by (simp add: permute_set_eq supp_perm)
2668
+ − 2064
then show "\<exists>q. (\<forall>b \<in> {}. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> {} \<union> p \<bullet> {}" by blast
2599
+ − 2065
next
+ − 2066
case (insert a bs)
2668
+ − 2067
then have " \<exists>q. (\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> p \<bullet> bs" by simp
+ − 2068
then obtain q where *: "\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b" and **: "supp q \<subseteq> bs \<union> p \<bullet> bs"
+ − 2069
by (metis empty_subsetI insert(3) supp_swap)
2599
+ − 2070
{ assume 1: "q \<bullet> a = p \<bullet> a"
2668
+ − 2071
have "\<forall>b \<in> (insert a bs). q \<bullet> b = p \<bullet> b" using 1 * by simp
2599
+ − 2072
moreover
+ − 2073
have "supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
+ − 2074
using ** by (auto simp add: insert_eqvt)
+ − 2075
ultimately
2668
+ − 2076
have "\<exists>q. (\<forall>b \<in> insert a bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs" by blast
2599
+ − 2077
}
+ − 2078
moreover
+ − 2079
{ assume 2: "q \<bullet> a \<noteq> p \<bullet> a"
+ − 2080
def q' \<equiv> "((q \<bullet> a) \<rightleftharpoons> (p \<bullet> a)) + q"
2668
+ − 2081
have "\<forall>b \<in> insert a bs. q' \<bullet> b = p \<bullet> b" using 2 * `a \<notin> bs` unfolding q'_def
+ − 2082
by (auto simp add: swap_atom)
2599
+ − 2083
moreover
+ − 2084
{ have "{q \<bullet> a, p \<bullet> a} \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
2659
+ − 2085
using **
+ − 2086
apply (auto simp add: supp_perm insert_eqvt)
+ − 2087
apply (subgoal_tac "q \<bullet> a \<in> bs \<union> p \<bullet> bs")
+ − 2088
apply(auto)[1]
+ − 2089
apply(subgoal_tac "q \<bullet> a \<in> {a. q \<bullet> a \<noteq> a}")
+ − 2090
apply(blast)
+ − 2091
apply(simp)
+ − 2092
done
2599
+ − 2093
then have "supp (q \<bullet> a \<rightleftharpoons> p \<bullet> a) \<subseteq> insert a bs \<union> p \<bullet> insert a bs" by (simp add: supp_swap)
+ − 2094
moreover
+ − 2095
have "supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
+ − 2096
using ** by (auto simp add: insert_eqvt)
+ − 2097
ultimately
+ − 2098
have "supp q' \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
+ − 2099
unfolding q'_def using supp_plus_perm by blast
+ − 2100
}
+ − 2101
ultimately
2668
+ − 2102
have "\<exists>q. (\<forall>b \<in> insert a bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs" by blast
2599
+ − 2103
}
2668
+ − 2104
ultimately show "\<exists>q. (\<forall>b \<in> insert a bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> insert a bs \<union> p \<bullet> insert a bs"
2599
+ − 2105
by blast
+ − 2106
qed
+ − 2107
2672
+ − 2108
lemma set_renaming_perm2:
+ − 2109
shows "\<exists>q. (\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> (p \<bullet> bs)"
+ − 2110
proof -
+ − 2111
have "finite (bs \<inter> supp p)" by (simp add: finite_supp)
+ − 2112
then obtain q
+ − 2113
where *: "\<forall>b \<in> bs \<inter> supp p. q \<bullet> b = p \<bullet> b" and **: "supp q \<subseteq> (bs \<inter> supp p) \<union> (p \<bullet> (bs \<inter> supp p))"
+ − 2114
using set_renaming_perm by blast
+ − 2115
from ** have "supp q \<subseteq> bs \<union> (p \<bullet> bs)" by (auto simp add: inter_eqvt)
+ − 2116
moreover
+ − 2117
have "\<forall>b \<in> bs - supp p. q \<bullet> b = p \<bullet> b"
+ − 2118
apply(auto)
+ − 2119
apply(subgoal_tac "b \<notin> supp q")
+ − 2120
apply(simp add: fresh_def[symmetric])
+ − 2121
apply(simp add: fresh_perm)
+ − 2122
apply(clarify)
+ − 2123
apply(rotate_tac 2)
+ − 2124
apply(drule subsetD[OF **])
+ − 2125
apply(simp add: inter_eqvt supp_eqvt permute_self)
+ − 2126
done
+ − 2127
ultimately have "(\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> (p \<bullet> bs)" using * by auto
+ − 2128
then show "\<exists>q. (\<forall>b \<in> bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> bs \<union> (p \<bullet> bs)" by blast
+ − 2129
qed
+ − 2130
2599
+ − 2131
lemma list_renaming_perm:
2668
+ − 2132
shows "\<exists>q. (\<forall>b \<in> set bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set bs \<union> (p \<bullet> set bs)"
2599
+ − 2133
proof (induct bs)
+ − 2134
case Nil
2668
+ − 2135
have "(\<forall>b \<in> set []. 0 \<bullet> b = p \<bullet> b) \<and> supp (0::perm) \<subseteq> set [] \<union> p \<bullet> set []"
+ − 2136
by (simp add: supp_zero_perm)
+ − 2137
then show "\<exists>q. (\<forall>b \<in> set []. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set [] \<union> p \<bullet> (set [])" by blast
2599
+ − 2138
next
+ − 2139
case (Cons a bs)
2668
+ − 2140
then have " \<exists>q. (\<forall>b \<in> set bs. q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set bs \<union> p \<bullet> (set bs)" by simp
+ − 2141
then obtain q where *: "\<forall>b \<in> set bs. q \<bullet> b = p \<bullet> b" and **: "supp q \<subseteq> set bs \<union> p \<bullet> (set bs)"
+ − 2142
by (blast)
2599
+ − 2143
{ assume 1: "a \<in> set bs"
+ − 2144
have "q \<bullet> a = p \<bullet> a" using * 1 by (induct bs) (auto)
2668
+ − 2145
then have "\<forall>b \<in> set (a # bs). q \<bullet> b = p \<bullet> b" using * by simp
2599
+ − 2146
moreover
+ − 2147
have "supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))" using ** by (auto simp add: insert_eqvt)
+ − 2148
ultimately
2668
+ − 2149
have "\<exists>q. (\<forall>b \<in> set (a # bs). q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))" by blast
2599
+ − 2150
}
+ − 2151
moreover
+ − 2152
{ assume 2: "a \<notin> set bs"
+ − 2153
def q' \<equiv> "((q \<bullet> a) \<rightleftharpoons> (p \<bullet> a)) + q"
2668
+ − 2154
have "\<forall>b \<in> set (a # bs). q' \<bullet> b = p \<bullet> b"
+ − 2155
unfolding q'_def using 2 * `a \<notin> set bs` by (auto simp add: swap_atom)
2599
+ − 2156
moreover
+ − 2157
{ have "{q \<bullet> a, p \<bullet> a} \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))"
2659
+ − 2158
using **
+ − 2159
apply (auto simp add: supp_perm insert_eqvt)
+ − 2160
apply (subgoal_tac "q \<bullet> a \<in> set bs \<union> p \<bullet> set bs")
+ − 2161
apply(auto)[1]
+ − 2162
apply(subgoal_tac "q \<bullet> a \<in> {a. q \<bullet> a \<noteq> a}")
+ − 2163
apply(blast)
+ − 2164
apply(simp)
+ − 2165
done
2599
+ − 2166
then have "supp (q \<bullet> a \<rightleftharpoons> p \<bullet> a) \<subseteq> set (a # bs) \<union> p \<bullet> set (a # bs)" by (simp add: supp_swap)
+ − 2167
moreover
+ − 2168
have "supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))"
+ − 2169
using ** by (auto simp add: insert_eqvt)
+ − 2170
ultimately
+ − 2171
have "supp q' \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))"
+ − 2172
unfolding q'_def using supp_plus_perm by blast
+ − 2173
}
+ − 2174
ultimately
2668
+ − 2175
have "\<exists>q. (\<forall>b \<in> set (a # bs). q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))" by blast
2599
+ − 2176
}
2668
+ − 2177
ultimately show "\<exists>q. (\<forall>b \<in> set (a # bs). q \<bullet> b = p \<bullet> b) \<and> supp q \<subseteq> set (a # bs) \<union> p \<bullet> (set (a # bs))"
2599
+ − 2178
by blast
+ − 2179
qed
+ − 2180
+ − 2181
2470
+ − 2182
section {* Concrete Atoms Types *}
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2183
1972
+ − 2184
text {*
+ − 2185
Class @{text at_base} allows types containing multiple sorts of atoms.
+ − 2186
Class @{text at} only allows types with a single sort.
+ − 2187
*}
+ − 2188
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2189
class at_base = pt +
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2190
fixes atom :: "'a \<Rightarrow> atom"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2191
assumes atom_eq_iff [simp]: "atom a = atom b \<longleftrightarrow> a = b"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2192
assumes atom_eqvt: "p \<bullet> (atom a) = atom (p \<bullet> a)"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2193
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2194
class at = at_base +
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2195
assumes sort_of_atom_eq [simp]: "sort_of (atom a) = sort_of (atom b)"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2196
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2197
lemma supp_at_base:
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2198
fixes a::"'a::at_base"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2199
shows "supp a = {atom a}"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2200
by (simp add: supp_atom [symmetric] supp_def atom_eqvt)
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2201
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2202
lemma fresh_at_base:
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2203
shows "a \<sharp> b \<longleftrightarrow> a \<noteq> atom b"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2204
unfolding fresh_def by (simp add: supp_at_base)
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2205
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2206
lemma fresh_atom_at_base:
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2207
fixes b::"'a::at_base"
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2208
shows "a \<sharp> atom b \<longleftrightarrow> a \<sharp> b"
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2209
by (simp add: fresh_def supp_at_base supp_atom)
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2210
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2211
lemma fresh_star_atom_at_base:
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2212
fixes b::"'a::at_base"
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2213
shows "as \<sharp>* atom b \<longleftrightarrow> as \<sharp>* b"
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2214
by (simp add: fresh_star_def fresh_atom_at_base)
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2215
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2216
instance at_base < fs
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2217
proof qed (simp add: supp_at_base)
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2218
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2219
lemma at_base_infinite [simp]:
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2220
shows "infinite (UNIV :: 'a::at_base set)" (is "infinite ?U")
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2221
proof
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2222
obtain a :: 'a where "True" by auto
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2223
assume "finite ?U"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2224
hence "finite (atom ` ?U)"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2225
by (rule finite_imageI)
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2226
then obtain b where b: "b \<notin> atom ` ?U" "sort_of b = sort_of (atom a)"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2227
by (rule obtain_atom)
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2228
from b(2) have "b = atom ((atom a \<rightleftharpoons> b) \<bullet> a)"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2229
unfolding atom_eqvt [symmetric]
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2230
by (simp add: swap_atom)
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2231
hence "b \<in> atom ` ?U" by simp
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2232
with b(1) show "False" by simp
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2233
qed
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2234
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2235
lemma swap_at_base_simps [simp]:
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2236
fixes x y::"'a::at_base"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2237
shows "sort_of (atom x) = sort_of (atom y) \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> x = y"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2238
and "sort_of (atom x) = sort_of (atom y) \<Longrightarrow> (atom x \<rightleftharpoons> atom y) \<bullet> y = x"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2239
and "atom x \<noteq> a \<Longrightarrow> atom x \<noteq> b \<Longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2240
unfolding atom_eq_iff [symmetric]
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2241
unfolding atom_eqvt [symmetric]
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2242
by simp_all
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2243
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2244
lemma obtain_at_base:
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2245
assumes X: "finite X"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2246
obtains a::"'a::at_base" where "atom a \<notin> X"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2247
proof -
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2248
have "inj (atom :: 'a \<Rightarrow> atom)"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2249
by (simp add: inj_on_def)
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2250
with X have "finite (atom -` X :: 'a set)"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2251
by (rule finite_vimageI)
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2252
with at_base_infinite have "atom -` X \<noteq> (UNIV :: 'a set)"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2253
by auto
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2254
then obtain a :: 'a where "atom a \<notin> X"
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2255
by auto
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2256
thus ?thesis ..
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2257
qed
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2258
2685
+ − 2259
lemma obtain_fresh':
+ − 2260
assumes fin: "finite (supp x)"
+ − 2261
obtains a::"'a::at_base" where "atom a \<sharp> x"
+ − 2262
using obtain_at_base[where X="supp x"]
+ − 2263
by (auto simp add: fresh_def fin)
+ − 2264
+ − 2265
lemma obtain_fresh:
+ − 2266
fixes x::"'b::fs"
+ − 2267
obtains a::"'a::at_base" where "atom a \<sharp> x"
+ − 2268
by (rule obtain_fresh') (auto simp add: finite_supp)
+ − 2269
1973
+ − 2270
lemma supp_finite_set_at_base:
1971
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2271
assumes a: "finite S"
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2272
shows "supp S = atom ` S"
2565
6bf332360510
moved most material fron Nominal2_FSet into the Nominal_Base theory
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2273
apply(simp add: supp_of_finite_sets[OF a])
2466
+ − 2274
apply(simp add: supp_at_base)
+ − 2275
apply(auto)
+ − 2276
done
1971
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2277
2657
+ − 2278
lemma fresh_finite_set_at_base:
+ − 2279
fixes a::"'a::at_base"
+ − 2280
assumes a: "finite S"
+ − 2281
shows "atom a \<sharp> S \<longleftrightarrow> a \<notin> S"
+ − 2282
unfolding fresh_def
+ − 2283
apply(simp add: supp_finite_set_at_base[OF a])
+ − 2284
apply(subst inj_image_mem_iff)
+ − 2285
apply(simp add: inj_on_def)
+ − 2286
apply(simp)
+ − 2287
done
+ − 2288
2683
+ − 2289
lemma fresh_at_base_permute_iff[simp]:
+ − 2290
fixes a::"'a::at_base"
+ − 2291
shows "atom (p \<bullet> a) \<sharp> p \<bullet> x \<longleftrightarrow> atom a \<sharp> x"
+ − 2292
unfolding atom_eqvt[symmetric]
+ − 2293
by (simp add: fresh_permute_iff)
+ − 2294
2657
+ − 2295
2467
+ − 2296
section {* Infrastructure for concrete atom types *}
1971
8daf6ff5e11a
simpliied and moved the remaining lemmas about the atom-function to Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2297
2467
+ − 2298
definition
+ − 2299
flip :: "'a::at_base \<Rightarrow> 'a \<Rightarrow> perm" ("'(_ \<leftrightarrow> _')")
+ − 2300
where
+ − 2301
"(a \<leftrightarrow> b) = (atom a \<rightleftharpoons> atom b)"
+ − 2302
+ − 2303
lemma flip_self [simp]: "(a \<leftrightarrow> a) = 0"
+ − 2304
unfolding flip_def by (rule swap_self)
+ − 2305
+ − 2306
lemma flip_commute: "(a \<leftrightarrow> b) = (b \<leftrightarrow> a)"
+ − 2307
unfolding flip_def by (rule swap_commute)
+ − 2308
+ − 2309
lemma minus_flip [simp]: "- (a \<leftrightarrow> b) = (a \<leftrightarrow> b)"
+ − 2310
unfolding flip_def by (rule minus_swap)
+ − 2311
+ − 2312
lemma add_flip_cancel: "(a \<leftrightarrow> b) + (a \<leftrightarrow> b) = 0"
+ − 2313
unfolding flip_def by (rule swap_cancel)
+ − 2314
+ − 2315
lemma permute_flip_cancel [simp]: "(a \<leftrightarrow> b) \<bullet> (a \<leftrightarrow> b) \<bullet> x = x"
+ − 2316
unfolding permute_plus [symmetric] add_flip_cancel by simp
+ − 2317
+ − 2318
lemma permute_flip_cancel2 [simp]: "(a \<leftrightarrow> b) \<bullet> (b \<leftrightarrow> a) \<bullet> x = x"
+ − 2319
by (simp add: flip_commute)
+ − 2320
+ − 2321
lemma flip_eqvt:
+ − 2322
fixes a b c::"'a::at_base"
+ − 2323
shows "p \<bullet> (a \<leftrightarrow> b) = (p \<bullet> a \<leftrightarrow> p \<bullet> b)"
+ − 2324
unfolding flip_def
+ − 2325
by (simp add: swap_eqvt atom_eqvt)
+ − 2326
+ − 2327
lemma flip_at_base_simps [simp]:
+ − 2328
shows "sort_of (atom a) = sort_of (atom b) \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> a = b"
+ − 2329
and "sort_of (atom a) = sort_of (atom b) \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> b = a"
+ − 2330
and "\<lbrakk>a \<noteq> c; b \<noteq> c\<rbrakk> \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> c = c"
+ − 2331
and "sort_of (atom a) \<noteq> sort_of (atom b) \<Longrightarrow> (a \<leftrightarrow> b) \<bullet> x = x"
+ − 2332
unfolding flip_def
+ − 2333
unfolding atom_eq_iff [symmetric]
+ − 2334
unfolding atom_eqvt [symmetric]
+ − 2335
by simp_all
+ − 2336
+ − 2337
text {* the following two lemmas do not hold for at_base,
+ − 2338
only for single sort atoms from at *}
+ − 2339
+ − 2340
lemma permute_flip_at:
+ − 2341
fixes a b c::"'a::at"
+ − 2342
shows "(a \<leftrightarrow> b) \<bullet> c = (if c = a then b else if c = b then a else c)"
+ − 2343
unfolding flip_def
+ − 2344
apply (rule atom_eq_iff [THEN iffD1])
+ − 2345
apply (subst atom_eqvt [symmetric])
+ − 2346
apply (simp add: swap_atom)
+ − 2347
done
+ − 2348
+ − 2349
lemma flip_at_simps [simp]:
+ − 2350
fixes a b::"'a::at"
+ − 2351
shows "(a \<leftrightarrow> b) \<bullet> a = b"
+ − 2352
and "(a \<leftrightarrow> b) \<bullet> b = a"
+ − 2353
unfolding permute_flip_at by simp_all
+ − 2354
+ − 2355
lemma flip_fresh_fresh:
+ − 2356
fixes a b::"'a::at_base"
+ − 2357
assumes "atom a \<sharp> x" "atom b \<sharp> x"
+ − 2358
shows "(a \<leftrightarrow> b) \<bullet> x = x"
+ − 2359
using assms
+ − 2360
by (simp add: flip_def swap_fresh_fresh)
+ − 2361
2683
+ − 2362
+ − 2363
2467
+ − 2364
subsection {* Syntax for coercing at-elements to the atom-type *}
+ − 2365
+ − 2366
syntax
+ − 2367
"_atom_constrain" :: "logic \<Rightarrow> type \<Rightarrow> logic" ("_:::_" [4, 0] 3)
+ − 2368
+ − 2369
translations
+ − 2370
"_atom_constrain a t" => "CONST atom (_constrain a t)"
+ − 2371
+ − 2372
+ − 2373
subsection {* A lemma for proving instances of class @{text at}. *}
+ − 2374
+ − 2375
setup {* Sign.add_const_constraint (@{const_name "permute"}, NONE) *}
+ − 2376
setup {* Sign.add_const_constraint (@{const_name "atom"}, NONE) *}
+ − 2377
+ − 2378
text {*
+ − 2379
New atom types are defined as subtypes of @{typ atom}.
+ − 2380
*}
+ − 2381
+ − 2382
lemma exists_eq_simple_sort:
+ − 2383
shows "\<exists>a. a \<in> {a. sort_of a = s}"
+ − 2384
by (rule_tac x="Atom s 0" in exI, simp)
+ − 2385
+ − 2386
lemma exists_eq_sort:
+ − 2387
shows "\<exists>a. a \<in> {a. sort_of a \<in> range sort_fun}"
+ − 2388
by (rule_tac x="Atom (sort_fun x) y" in exI, simp)
+ − 2389
+ − 2390
lemma at_base_class:
+ − 2391
fixes sort_fun :: "'b \<Rightarrow>atom_sort"
+ − 2392
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a"
+ − 2393
assumes type: "type_definition Rep Abs {a. sort_of a \<in> range sort_fun}"
+ − 2394
assumes atom_def: "\<And>a. atom a = Rep a"
+ − 2395
assumes permute_def: "\<And>p a. p \<bullet> a = Abs (p \<bullet> Rep a)"
+ − 2396
shows "OFCLASS('a, at_base_class)"
+ − 2397
proof
+ − 2398
interpret type_definition Rep Abs "{a. sort_of a \<in> range sort_fun}" by (rule type)
+ − 2399
have sort_of_Rep: "\<And>a. sort_of (Rep a) \<in> range sort_fun" using Rep by simp
+ − 2400
fix a b :: 'a and p p1 p2 :: perm
+ − 2401
show "0 \<bullet> a = a"
+ − 2402
unfolding permute_def by (simp add: Rep_inverse)
+ − 2403
show "(p1 + p2) \<bullet> a = p1 \<bullet> p2 \<bullet> a"
+ − 2404
unfolding permute_def by (simp add: Abs_inverse sort_of_Rep)
+ − 2405
show "atom a = atom b \<longleftrightarrow> a = b"
+ − 2406
unfolding atom_def by (simp add: Rep_inject)
+ − 2407
show "p \<bullet> atom a = atom (p \<bullet> a)"
+ − 2408
unfolding permute_def atom_def by (simp add: Abs_inverse sort_of_Rep)
+ − 2409
qed
+ − 2410
+ − 2411
(*
+ − 2412
lemma at_class:
+ − 2413
fixes s :: atom_sort
+ − 2414
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a"
+ − 2415
assumes type: "type_definition Rep Abs {a. sort_of a \<in> range (\<lambda>x::unit. s)}"
+ − 2416
assumes atom_def: "\<And>a. atom a = Rep a"
+ − 2417
assumes permute_def: "\<And>p a. p \<bullet> a = Abs (p \<bullet> Rep a)"
+ − 2418
shows "OFCLASS('a, at_class)"
+ − 2419
proof
+ − 2420
interpret type_definition Rep Abs "{a. sort_of a \<in> range (\<lambda>x::unit. s)}" by (rule type)
+ − 2421
have sort_of_Rep: "\<And>a. sort_of (Rep a) = s" using Rep by (simp add: image_def)
+ − 2422
fix a b :: 'a and p p1 p2 :: perm
+ − 2423
show "0 \<bullet> a = a"
+ − 2424
unfolding permute_def by (simp add: Rep_inverse)
+ − 2425
show "(p1 + p2) \<bullet> a = p1 \<bullet> p2 \<bullet> a"
+ − 2426
unfolding permute_def by (simp add: Abs_inverse sort_of_Rep)
+ − 2427
show "sort_of (atom a) = sort_of (atom b)"
+ − 2428
unfolding atom_def by (simp add: sort_of_Rep)
+ − 2429
show "atom a = atom b \<longleftrightarrow> a = b"
+ − 2430
unfolding atom_def by (simp add: Rep_inject)
+ − 2431
show "p \<bullet> atom a = atom (p \<bullet> a)"
+ − 2432
unfolding permute_def atom_def by (simp add: Abs_inverse sort_of_Rep)
+ − 2433
qed
+ − 2434
*)
+ − 2435
+ − 2436
lemma at_class:
+ − 2437
fixes s :: atom_sort
+ − 2438
fixes Rep :: "'a \<Rightarrow> atom" and Abs :: "atom \<Rightarrow> 'a"
+ − 2439
assumes type: "type_definition Rep Abs {a. sort_of a = s}"
+ − 2440
assumes atom_def: "\<And>a. atom a = Rep a"
+ − 2441
assumes permute_def: "\<And>p a. p \<bullet> a = Abs (p \<bullet> Rep a)"
+ − 2442
shows "OFCLASS('a, at_class)"
+ − 2443
proof
+ − 2444
interpret type_definition Rep Abs "{a. sort_of a = s}" by (rule type)
+ − 2445
have sort_of_Rep: "\<And>a. sort_of (Rep a) = s" using Rep by (simp add: image_def)
+ − 2446
fix a b :: 'a and p p1 p2 :: perm
+ − 2447
show "0 \<bullet> a = a"
+ − 2448
unfolding permute_def by (simp add: Rep_inverse)
+ − 2449
show "(p1 + p2) \<bullet> a = p1 \<bullet> p2 \<bullet> a"
+ − 2450
unfolding permute_def by (simp add: Abs_inverse sort_of_Rep)
+ − 2451
show "sort_of (atom a) = sort_of (atom b)"
+ − 2452
unfolding atom_def by (simp add: sort_of_Rep)
+ − 2453
show "atom a = atom b \<longleftrightarrow> a = b"
+ − 2454
unfolding atom_def by (simp add: Rep_inject)
+ − 2455
show "p \<bullet> atom a = atom (p \<bullet> a)"
+ − 2456
unfolding permute_def atom_def by (simp add: Abs_inverse sort_of_Rep)
+ − 2457
qed
+ − 2458
+ − 2459
setup {* Sign.add_const_constraint
+ − 2460
(@{const_name "permute"}, SOME @{typ "perm \<Rightarrow> 'a::pt \<Rightarrow> 'a"}) *}
+ − 2461
setup {* Sign.add_const_constraint
+ − 2462
(@{const_name "atom"}, SOME @{typ "'a::at_base \<Rightarrow> atom"}) *}
+ − 2463
+ − 2464
2470
+ − 2465
+ − 2466
section {* The freshness lemma according to Andy Pitts *}
+ − 2467
+ − 2468
lemma freshness_lemma:
+ − 2469
fixes h :: "'a::at \<Rightarrow> 'b::pt"
+ − 2470
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
+ − 2471
shows "\<exists>x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
+ − 2472
proof -
+ − 2473
from a obtain b where a1: "atom b \<sharp> h" and a2: "atom b \<sharp> h b"
+ − 2474
by (auto simp add: fresh_Pair)
+ − 2475
show "\<exists>x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
+ − 2476
proof (intro exI allI impI)
+ − 2477
fix a :: 'a
+ − 2478
assume a3: "atom a \<sharp> h"
+ − 2479
show "h a = h b"
+ − 2480
proof (cases "a = b")
+ − 2481
assume "a = b"
+ − 2482
thus "h a = h b" by simp
+ − 2483
next
+ − 2484
assume "a \<noteq> b"
+ − 2485
hence "atom a \<sharp> b" by (simp add: fresh_at_base)
+ − 2486
with a3 have "atom a \<sharp> h b"
+ − 2487
by (rule fresh_fun_app)
+ − 2488
with a2 have d1: "(atom b \<rightleftharpoons> atom a) \<bullet> (h b) = (h b)"
+ − 2489
by (rule swap_fresh_fresh)
+ − 2490
from a1 a3 have d2: "(atom b \<rightleftharpoons> atom a) \<bullet> h = h"
+ − 2491
by (rule swap_fresh_fresh)
+ − 2492
from d1 have "h b = (atom b \<rightleftharpoons> atom a) \<bullet> (h b)" by simp
+ − 2493
also have "\<dots> = ((atom b \<rightleftharpoons> atom a) \<bullet> h) ((atom b \<rightleftharpoons> atom a) \<bullet> b)"
+ − 2494
by (rule permute_fun_app_eq)
+ − 2495
also have "\<dots> = h a"
+ − 2496
using d2 by simp
+ − 2497
finally show "h a = h b" by simp
+ − 2498
qed
+ − 2499
qed
+ − 2500
qed
+ − 2501
+ − 2502
lemma freshness_lemma_unique:
+ − 2503
fixes h :: "'a::at \<Rightarrow> 'b::pt"
+ − 2504
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
+ − 2505
shows "\<exists>!x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
+ − 2506
proof (rule ex_ex1I)
+ − 2507
from a show "\<exists>x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
+ − 2508
by (rule freshness_lemma)
+ − 2509
next
+ − 2510
fix x y
+ − 2511
assume x: "\<forall>a. atom a \<sharp> h \<longrightarrow> h a = x"
+ − 2512
assume y: "\<forall>a. atom a \<sharp> h \<longrightarrow> h a = y"
+ − 2513
from a x y show "x = y"
+ − 2514
by (auto simp add: fresh_Pair)
+ − 2515
qed
+ − 2516
+ − 2517
text {* packaging the freshness lemma into a function *}
+ − 2518
+ − 2519
definition
+ − 2520
fresh_fun :: "('a::at \<Rightarrow> 'b::pt) \<Rightarrow> 'b"
+ − 2521
where
+ − 2522
"fresh_fun h = (THE x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x)"
+ − 2523
+ − 2524
lemma fresh_fun_apply:
+ − 2525
fixes h :: "'a::at \<Rightarrow> 'b::pt"
+ − 2526
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
+ − 2527
assumes b: "atom a \<sharp> h"
+ − 2528
shows "fresh_fun h = h a"
+ − 2529
unfolding fresh_fun_def
+ − 2530
proof (rule the_equality)
+ − 2531
show "\<forall>a'. atom a' \<sharp> h \<longrightarrow> h a' = h a"
+ − 2532
proof (intro strip)
+ − 2533
fix a':: 'a
+ − 2534
assume c: "atom a' \<sharp> h"
+ − 2535
from a have "\<exists>x. \<forall>a. atom a \<sharp> h \<longrightarrow> h a = x" by (rule freshness_lemma)
+ − 2536
with b c show "h a' = h a" by auto
+ − 2537
qed
+ − 2538
next
+ − 2539
fix fr :: 'b
+ − 2540
assume "\<forall>a. atom a \<sharp> h \<longrightarrow> h a = fr"
+ − 2541
with b show "fr = h a" by auto
+ − 2542
qed
+ − 2543
+ − 2544
lemma fresh_fun_apply':
+ − 2545
fixes h :: "'a::at \<Rightarrow> 'b::pt"
+ − 2546
assumes a: "atom a \<sharp> h" "atom a \<sharp> h a"
+ − 2547
shows "fresh_fun h = h a"
+ − 2548
apply (rule fresh_fun_apply)
+ − 2549
apply (auto simp add: fresh_Pair intro: a)
+ − 2550
done
+ − 2551
+ − 2552
lemma fresh_fun_eqvt:
+ − 2553
fixes h :: "'a::at \<Rightarrow> 'b::pt"
+ − 2554
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
+ − 2555
shows "p \<bullet> (fresh_fun h) = fresh_fun (p \<bullet> h)"
+ − 2556
using a
+ − 2557
apply (clarsimp simp add: fresh_Pair)
+ − 2558
apply (subst fresh_fun_apply', assumption+)
+ − 2559
apply (drule fresh_permute_iff [where p=p, THEN iffD2])
+ − 2560
apply (drule fresh_permute_iff [where p=p, THEN iffD2])
2683
+ − 2561
apply (simp only: atom_eqvt permute_fun_app_eq [where f=h])
2470
+ − 2562
apply (erule (1) fresh_fun_apply' [symmetric])
+ − 2563
done
+ − 2564
+ − 2565
lemma fresh_fun_supports:
+ − 2566
fixes h :: "'a::at \<Rightarrow> 'b::pt"
+ − 2567
assumes a: "\<exists>a. atom a \<sharp> (h, h a)"
+ − 2568
shows "(supp h) supports (fresh_fun h)"
+ − 2569
apply (simp add: supports_def fresh_def [symmetric])
+ − 2570
apply (simp add: fresh_fun_eqvt [OF a] swap_fresh_fresh)
+ − 2571
done
+ − 2572
+ − 2573
notation fresh_fun (binder "FRESH " 10)
+ − 2574
+ − 2575
lemma FRESH_f_iff:
+ − 2576
fixes P :: "'a::at \<Rightarrow> 'b::pure"
+ − 2577
fixes f :: "'b \<Rightarrow> 'c::pure"
+ − 2578
assumes P: "finite (supp P)"
+ − 2579
shows "(FRESH x. f (P x)) = f (FRESH x. P x)"
+ − 2580
proof -
2685
+ − 2581
obtain a::'a where "atom a \<sharp> P" using P by (rule obtain_fresh')
2470
+ − 2582
show "(FRESH x. f (P x)) = f (FRESH x. P x)"
+ − 2583
apply (subst fresh_fun_apply' [where a=a, OF _ pure_fresh])
+ − 2584
apply (cut_tac `atom a \<sharp> P`)
+ − 2585
apply (simp add: fresh_conv_MOST)
+ − 2586
apply (elim MOST_rev_mp, rule MOST_I, clarify)
2479
+ − 2587
apply (simp add: permute_fun_def permute_pure fun_eq_iff)
2470
+ − 2588
apply (subst fresh_fun_apply' [where a=a, OF `atom a \<sharp> P` pure_fresh])
+ − 2589
apply (rule refl)
+ − 2590
done
+ − 2591
qed
+ − 2592
+ − 2593
lemma FRESH_binop_iff:
+ − 2594
fixes P :: "'a::at \<Rightarrow> 'b::pure"
+ − 2595
fixes Q :: "'a::at \<Rightarrow> 'c::pure"
+ − 2596
fixes binop :: "'b \<Rightarrow> 'c \<Rightarrow> 'd::pure"
+ − 2597
assumes P: "finite (supp P)"
+ − 2598
and Q: "finite (supp Q)"
+ − 2599
shows "(FRESH x. binop (P x) (Q x)) = binop (FRESH x. P x) (FRESH x. Q x)"
+ − 2600
proof -
2685
+ − 2601
from assms have "finite (supp (P, Q))" by (simp add: supp_Pair)
+ − 2602
then obtain a::'a where "atom a \<sharp> (P, Q)" by (rule obtain_fresh')
+ − 2603
then have "atom a \<sharp> P" and "atom a \<sharp> Q" by (simp_all add: fresh_Pair)
2470
+ − 2604
show ?thesis
+ − 2605
apply (subst fresh_fun_apply' [where a=a, OF _ pure_fresh])
+ − 2606
apply (cut_tac `atom a \<sharp> P` `atom a \<sharp> Q`)
+ − 2607
apply (simp add: fresh_conv_MOST)
+ − 2608
apply (elim MOST_rev_mp, rule MOST_I, clarify)
2479
+ − 2609
apply (simp add: permute_fun_def permute_pure fun_eq_iff)
2470
+ − 2610
apply (subst fresh_fun_apply' [where a=a, OF `atom a \<sharp> P` pure_fresh])
+ − 2611
apply (subst fresh_fun_apply' [where a=a, OF `atom a \<sharp> Q` pure_fresh])
+ − 2612
apply (rule refl)
+ − 2613
done
+ − 2614
qed
+ − 2615
+ − 2616
lemma FRESH_conj_iff:
+ − 2617
fixes P Q :: "'a::at \<Rightarrow> bool"
+ − 2618
assumes P: "finite (supp P)" and Q: "finite (supp Q)"
+ − 2619
shows "(FRESH x. P x \<and> Q x) \<longleftrightarrow> (FRESH x. P x) \<and> (FRESH x. Q x)"
+ − 2620
using P Q by (rule FRESH_binop_iff)
+ − 2621
+ − 2622
lemma FRESH_disj_iff:
+ − 2623
fixes P Q :: "'a::at \<Rightarrow> bool"
+ − 2624
assumes P: "finite (supp P)" and Q: "finite (supp Q)"
+ − 2625
shows "(FRESH x. P x \<or> Q x) \<longleftrightarrow> (FRESH x. P x) \<or> (FRESH x. Q x)"
+ − 2626
using P Q by (rule FRESH_binop_iff)
+ − 2627
+ − 2628
2467
+ − 2629
section {* Library functions for the nominal infrastructure *}
+ − 2630
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2631
use "nominal_library.ML"
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2632
2466
+ − 2633
2467
+ − 2634
section {* Automation for creating concrete atom types *}
+ − 2635
+ − 2636
text {* at the moment only single-sort concrete atoms are supported *}
+ − 2637
+ − 2638
use "nominal_atoms.ML"
+ − 2639
+ − 2640
2466
+ − 2641
1062
+ − 2642
end