2084
+ − 1
(* Title: HOL/Quotient_Examples/FSet.thy
+ − 2
Author: Cezary Kaliszyk, TU Munich
+ − 3
Author: Christian Urban, TU Munich
1823
+ − 4
2084
+ − 5
A reasoning infrastructure for the type of finite sets.
1823
+ − 6
*)
2084
+ − 7
1518
+ − 8
theory FSet
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 9
imports Quotient_List Quotient_Product
1518
+ − 10
begin
+ − 11
1909
+ − 12
text {* Definiton of List relation and the quotient type *}
+ − 13
1518
+ − 14
fun
+ − 15
list_eq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "\<approx>" 50)
+ − 16
where
+ − 17
"list_eq xs ys = (\<forall>x. x \<in> set xs \<longleftrightarrow> x \<in> set ys)"
+ − 18
+ − 19
lemma list_eq_equivp:
+ − 20
shows "equivp list_eq"
1909
+ − 21
unfolding equivp_reflp_symp_transp
1889
+ − 22
unfolding reflp_def symp_def transp_def
+ − 23
by auto
+ − 24
1909
+ − 25
quotient_type
+ − 26
'a fset = "'a list" / "list_eq"
+ − 27
by (rule list_eq_equivp)
+ − 28
+ − 29
text {* Raw definitions *}
+ − 30
1889
+ − 31
definition
+ − 32
memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool"
+ − 33
where
+ − 34
"memb x xs \<equiv> x \<in> set xs"
+ − 35
+ − 36
definition
+ − 37
sub_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool"
+ − 38
where
+ − 39
"sub_list xs ys \<equiv> (\<forall>x. x \<in> set xs \<longrightarrow> x \<in> set ys)"
+ − 40
1909
+ − 41
fun
+ − 42
fcard_raw :: "'a list \<Rightarrow> nat"
+ − 43
where
+ − 44
fcard_raw_nil: "fcard_raw [] = 0"
+ − 45
| fcard_raw_cons: "fcard_raw (x # xs) = (if memb x xs then fcard_raw xs else Suc (fcard_raw xs))"
1518
+ − 46
1909
+ − 47
primrec
+ − 48
finter_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
+ − 49
where
+ − 50
"finter_raw [] l = []"
+ − 51
| "finter_raw (h # t) l =
+ − 52
(if memb h l then h # (finter_raw t l) else finter_raw t l)"
1893
+ − 53
2084
+ − 54
primrec
1909
+ − 55
delete_raw :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list"
+ − 56
where
+ − 57
"delete_raw [] x = []"
2084
+ − 58
| "delete_raw (a # xs) x = (if (a = x) then delete_raw xs x else a # (delete_raw xs x))"
+ − 59
+ − 60
primrec
+ − 61
fminus_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
+ − 62
where
+ − 63
"fminus_raw l [] = l"
+ − 64
| "fminus_raw l (h # t) = fminus_raw (delete_raw l h) t"
1909
+ − 65
+ − 66
definition
+ − 67
rsp_fold
+ − 68
where
+ − 69
"rsp_fold f = (\<forall>u v w. (f u (f v w) = f v (f u w)))"
1893
+ − 70
1909
+ − 71
primrec
+ − 72
ffold_raw :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b"
+ − 73
where
+ − 74
"ffold_raw f z [] = z"
2084
+ − 75
| "ffold_raw f z (a # xs) =
1909
+ − 76
(if (rsp_fold f) then
2084
+ − 77
if memb a xs then ffold_raw f z xs
+ − 78
else f a (ffold_raw f z xs)
1909
+ − 79
else z)"
+ − 80
1935
+ − 81
text {* Composition Quotient *}
+ − 82
2326
+ − 83
lemma list_all2_refl1:
+ − 84
shows "(list_all2 op \<approx>) r r"
+ − 85
by (rule list_all2_refl) (metis equivp_def fset_equivp)
1938
+ − 86
1935
+ − 87
lemma compose_list_refl:
2326
+ − 88
shows "(list_all2 op \<approx> OOO op \<approx>) r r"
1935
+ − 89
proof
2084
+ − 90
have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
2326
+ − 91
show "list_all2 op \<approx> r r" by (rule list_all2_refl1)
+ − 92
with * show "(op \<approx> OO list_all2 op \<approx>) r r" ..
1935
+ − 93
qed
+ − 94
+ − 95
lemma Quotient_fset_list:
2326
+ − 96
shows "Quotient (list_all2 op \<approx>) (map abs_fset) (map rep_fset)"
1935
+ − 97
by (fact list_quotient[OF Quotient_fset])
+ − 98
2084
+ − 99
lemma set_in_eq: "(\<forall>e. ((e \<in> xs) \<longleftrightarrow> (e \<in> ys))) \<equiv> xs = ys"
1935
+ − 100
by (rule eq_reflection) auto
+ − 101
+ − 102
lemma map_rel_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba"
+ − 103
unfolding list_eq.simps
+ − 104
by (simp only: set_map set_in_eq)
+ − 105
2368
+ − 106
text {* Peter *}
+ − 107
ML {* Quotient_Info.quotient_rules_get @{context} *}
+ − 108
+ − 109
lemma
+ − 110
assumes "Quotient R1 abs1 rep1"
+ − 111
and "Quotient R2 abs2 rep2"
+ − 112
shows "Quotient (R1 OOO R2) (abs1 o ab2) (rep1 o rep2)"
+ − 113
using assms
+ − 114
sorry
+ − 115
+ − 116
lemma
+ − 117
assumes "Quotient R1 abs1 rep1"
+ − 118
and "Quotient R2 abs2 rep2"
+ − 119
shows "Quotient (R3) (abs1 o ab2) (rep1 o rep2)"
+ − 120
using assms
+ − 121
sorry
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 122
1935
+ − 123
lemma quotient_compose_list[quot_thm]:
2326
+ − 124
shows "Quotient ((list_all2 op \<approx>) OOO (op \<approx>))
1935
+ − 125
(abs_fset \<circ> (map abs_fset)) ((map rep_fset) \<circ> rep_fset)"
+ − 126
unfolding Quotient_def comp_def
+ − 127
proof (intro conjI allI)
+ − 128
fix a r s
+ − 129
show "abs_fset (map abs_fset (map rep_fset (rep_fset a))) = a"
+ − 130
by (simp add: abs_o_rep[OF Quotient_fset] Quotient_abs_rep[OF Quotient_fset] map_id)
2326
+ − 131
have b: "list_all2 op \<approx> (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
+ − 132
by (rule list_all2_refl1)
+ − 133
have c: "(op \<approx> OO list_all2 op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
1935
+ − 134
by (rule, rule equivp_reflp[OF fset_equivp]) (rule b)
2326
+ − 135
show "(list_all2 op \<approx> OOO op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
+ − 136
by (rule, rule list_all2_refl1) (rule c)
+ − 137
show "(list_all2 op \<approx> OOO op \<approx>) r s = ((list_all2 op \<approx> OOO op \<approx>) r r \<and>
+ − 138
(list_all2 op \<approx> OOO op \<approx>) s s \<and> abs_fset (map abs_fset r) = abs_fset (map abs_fset s))"
1935
+ − 139
proof (intro iffI conjI)
2326
+ − 140
show "(list_all2 op \<approx> OOO op \<approx>) r r" by (rule compose_list_refl)
+ − 141
show "(list_all2 op \<approx> OOO op \<approx>) s s" by (rule compose_list_refl)
1935
+ − 142
next
2326
+ − 143
assume a: "(list_all2 op \<approx> OOO op \<approx>) r s"
2084
+ − 144
then have b: "map abs_fset r \<approx> map abs_fset s"
+ − 145
proof (elim pred_compE)
1935
+ − 146
fix b ba
2326
+ − 147
assume c: "list_all2 op \<approx> r b"
1935
+ − 148
assume d: "b \<approx> ba"
2326
+ − 149
assume e: "list_all2 op \<approx> ba s"
1935
+ − 150
have f: "map abs_fset r = map abs_fset b"
1938
+ − 151
using Quotient_rel[OF Quotient_fset_list] c by blast
+ − 152
have "map abs_fset ba = map abs_fset s"
+ − 153
using Quotient_rel[OF Quotient_fset_list] e by blast
+ − 154
then have g: "map abs_fset s = map abs_fset ba" by simp
+ − 155
then show "map abs_fset r \<approx> map abs_fset s" using d f map_rel_cong by simp
1935
+ − 156
qed
+ − 157
then show "abs_fset (map abs_fset r) = abs_fset (map abs_fset s)"
1938
+ − 158
using Quotient_rel[OF Quotient_fset] by blast
1935
+ − 159
next
2326
+ − 160
assume a: "(list_all2 op \<approx> OOO op \<approx>) r r \<and> (list_all2 op \<approx> OOO op \<approx>) s s
1935
+ − 161
\<and> abs_fset (map abs_fset r) = abs_fset (map abs_fset s)"
2326
+ − 162
then have s: "(list_all2 op \<approx> OOO op \<approx>) s s" by simp
1935
+ − 163
have d: "map abs_fset r \<approx> map abs_fset s"
+ − 164
by (subst Quotient_rel[OF Quotient_fset]) (simp add: a)
+ − 165
have b: "map rep_fset (map abs_fset r) \<approx> map rep_fset (map abs_fset s)"
+ − 166
by (rule map_rel_cong[OF d])
2326
+ − 167
have y: "list_all2 op \<approx> (map rep_fset (map abs_fset s)) s"
+ − 168
by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl1[of s]])
+ − 169
have c: "(op \<approx> OO list_all2 op \<approx>) (map rep_fset (map abs_fset r)) s"
1935
+ − 170
by (rule pred_compI) (rule b, rule y)
2326
+ − 171
have z: "list_all2 op \<approx> r (map rep_fset (map abs_fset r))"
+ − 172
by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl1[of r]])
+ − 173
then show "(list_all2 op \<approx> OOO op \<approx>) r s"
1935
+ − 174
using a c pred_compI by simp
+ − 175
qed
+ − 176
qed
+ − 177
1909
+ − 178
text {* Respectfullness *}
1893
+ − 179
2187
+ − 180
lemma append_rsp[quot_respect]:
1895
+ − 181
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @"
2278
+ − 182
apply(simp del: list_eq.simps)
2368
+ − 183
by auto
1895
+ − 184
2190
+ − 185
lemma append_rsp_unfolded:
+ − 186
"\<lbrakk>x \<approx> y; v \<approx> w\<rbrakk> \<Longrightarrow> x @ v \<approx> y @ w"
+ − 187
by auto
+ − 188
1909
+ − 189
lemma [quot_respect]:
+ − 190
shows "(op \<approx> ===> op \<approx> ===> op =) sub_list sub_list"
+ − 191
by (auto simp add: sub_list_def)
+ − 192
+ − 193
lemma memb_rsp[quot_respect]:
+ − 194
shows "(op = ===> op \<approx> ===> op =) memb memb"
+ − 195
by (auto simp add: memb_def)
+ − 196
+ − 197
lemma nil_rsp[quot_respect]:
+ − 198
shows "[] \<approx> []"
+ − 199
by simp
+ − 200
+ − 201
lemma cons_rsp[quot_respect]:
+ − 202
shows "(op = ===> op \<approx> ===> op \<approx>) op # op #"
+ − 203
by simp
+ − 204
+ − 205
lemma map_rsp[quot_respect]:
+ − 206
shows "(op = ===> op \<approx> ===> op \<approx>) map map"
+ − 207
by auto
+ − 208
+ − 209
lemma set_rsp[quot_respect]:
+ − 210
"(op \<approx> ===> op =) set set"
+ − 211
by auto
+ − 212
+ − 213
lemma list_equiv_rsp[quot_respect]:
+ − 214
shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>"
+ − 215
by auto
+ − 216
+ − 217
lemma not_memb_nil:
+ − 218
shows "\<not> memb x []"
+ − 219
by (simp add: memb_def)
+ − 220
+ − 221
lemma memb_cons_iff:
+ − 222
shows "memb x (y # xs) = (x = y \<or> memb x xs)"
+ − 223
by (induct xs) (auto simp add: memb_def)
+ − 224
+ − 225
lemma memb_finter_raw:
+ − 226
"memb x (finter_raw xs ys) \<longleftrightarrow> memb x xs \<and> memb x ys"
+ − 227
by (induct xs) (auto simp add: not_memb_nil memb_cons_iff)
+ − 228
+ − 229
lemma [quot_respect]:
+ − 230
"(op \<approx> ===> op \<approx> ===> op \<approx>) finter_raw finter_raw"
+ − 231
by (simp add: memb_def[symmetric] memb_finter_raw)
+ − 232
+ − 233
lemma memb_delete_raw:
+ − 234
"memb x (delete_raw xs y) = (memb x xs \<and> x \<noteq> y)"
+ − 235
by (induct xs arbitrary: x y) (auto simp add: memb_def)
+ − 236
+ − 237
lemma [quot_respect]:
+ − 238
"(op \<approx> ===> op = ===> op \<approx>) delete_raw delete_raw"
+ − 239
by (simp add: memb_def[symmetric] memb_delete_raw)
+ − 240
2084
+ − 241
lemma fminus_raw_memb: "memb x (fminus_raw xs ys) = (memb x xs \<and> \<not> memb x ys)"
+ − 242
by (induct ys arbitrary: xs)
+ − 243
(simp_all add: not_memb_nil memb_delete_raw memb_cons_iff)
+ − 244
+ − 245
lemma [quot_respect]:
+ − 246
"(op \<approx> ===> op \<approx> ===> op \<approx>) fminus_raw fminus_raw"
+ − 247
by (simp add: memb_def[symmetric] fminus_raw_memb)
+ − 248
1909
+ − 249
lemma fcard_raw_gt_0:
+ − 250
assumes a: "x \<in> set xs"
+ − 251
shows "0 < fcard_raw xs"
+ − 252
using a by (induct xs) (auto simp add: memb_def)
+ − 253
+ − 254
lemma fcard_raw_delete_one:
+ − 255
shows "fcard_raw ([x \<leftarrow> xs. x \<noteq> y]) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
+ − 256
by (induct xs) (auto dest: fcard_raw_gt_0 simp add: memb_def)
+ − 257
+ − 258
lemma fcard_raw_rsp_aux:
+ − 259
assumes a: "xs \<approx> ys"
+ − 260
shows "fcard_raw xs = fcard_raw ys"
+ − 261
using a
2084
+ − 262
proof (induct xs arbitrary: ys)
+ − 263
case Nil
+ − 264
show ?case using Nil.prems by simp
+ − 265
next
+ − 266
case (Cons a xs)
+ − 267
have a: "a # xs \<approx> ys" by fact
+ − 268
have b: "\<And>ys. xs \<approx> ys \<Longrightarrow> fcard_raw xs = fcard_raw ys" by fact
+ − 269
show ?case proof (cases "a \<in> set xs")
+ − 270
assume c: "a \<in> set xs"
+ − 271
have "\<forall>x. (x \<in> set xs) = (x \<in> set ys)"
+ − 272
proof (intro allI iffI)
+ − 273
fix x
+ − 274
assume "x \<in> set xs"
+ − 275
then show "x \<in> set ys" using a by auto
+ − 276
next
+ − 277
fix x
+ − 278
assume d: "x \<in> set ys"
+ − 279
have e: "(x \<in> set (a # xs)) = (x \<in> set ys)" using a by simp
+ − 280
show "x \<in> set xs" using c d e unfolding list_eq.simps by simp blast
+ − 281
qed
+ − 282
then show ?thesis using b c by (simp add: memb_def)
+ − 283
next
+ − 284
assume c: "a \<notin> set xs"
+ − 285
have d: "xs \<approx> [x\<leftarrow>ys . x \<noteq> a] \<Longrightarrow> fcard_raw xs = fcard_raw [x\<leftarrow>ys . x \<noteq> a]" using b by simp
+ − 286
have "Suc (fcard_raw xs) = fcard_raw ys"
+ − 287
proof (cases "a \<in> set ys")
+ − 288
assume e: "a \<in> set ys"
+ − 289
have f: "\<forall>x. (x \<in> set xs) = (x \<in> set ys \<and> x \<noteq> a)" using a c
+ − 290
by (auto simp add: fcard_raw_delete_one)
+ − 291
have "fcard_raw ys = Suc (fcard_raw ys - 1)" by (rule Suc_pred'[OF fcard_raw_gt_0]) (rule e)
+ − 292
then show ?thesis using d e f by (simp_all add: fcard_raw_delete_one memb_def)
+ − 293
next
+ − 294
case False then show ?thesis using a c d by auto
+ − 295
qed
+ − 296
then show ?thesis using a c d by (simp add: memb_def)
+ − 297
qed
+ − 298
qed
1909
+ − 299
+ − 300
lemma fcard_raw_rsp[quot_respect]:
+ − 301
shows "(op \<approx> ===> op =) fcard_raw fcard_raw"
+ − 302
by (simp add: fcard_raw_rsp_aux)
+ − 303
+ − 304
lemma memb_absorb:
+ − 305
shows "memb x xs \<Longrightarrow> x # xs \<approx> xs"
+ − 306
by (induct xs) (auto simp add: memb_def)
+ − 307
+ − 308
lemma none_memb_nil:
+ − 309
"(\<forall>x. \<not> memb x xs) = (xs \<approx> [])"
+ − 310
by (simp add: memb_def)
+ − 311
+ − 312
lemma not_memb_delete_raw_ident:
+ − 313
shows "\<not> memb x xs \<Longrightarrow> delete_raw xs x = xs"
+ − 314
by (induct xs) (auto simp add: memb_def)
+ − 315
+ − 316
lemma memb_commute_ffold_raw:
+ − 317
"rsp_fold f \<Longrightarrow> memb h b \<Longrightarrow> ffold_raw f z b = f h (ffold_raw f z (delete_raw b h))"
+ − 318
apply (induct b)
+ − 319
apply (simp_all add: not_memb_nil)
+ − 320
apply (auto)
1938
+ − 321
apply (simp_all add: memb_delete_raw not_memb_delete_raw_ident rsp_fold_def memb_cons_iff)
1909
+ − 322
done
+ − 323
+ − 324
lemma ffold_raw_rsp_pre:
+ − 325
"\<forall>e. memb e a = memb e b \<Longrightarrow> ffold_raw f z a = ffold_raw f z b"
+ − 326
apply (induct a arbitrary: b)
+ − 327
apply (simp add: memb_absorb memb_def none_memb_nil)
+ − 328
apply (simp)
+ − 329
apply (rule conjI)
+ − 330
apply (rule_tac [!] impI)
+ − 331
apply (rule_tac [!] conjI)
+ − 332
apply (rule_tac [!] impI)
+ − 333
apply (subgoal_tac "\<forall>e. memb e a2 = memb e b")
+ − 334
apply (simp)
+ − 335
apply (simp add: memb_cons_iff memb_def)
+ − 336
apply (auto)[1]
+ − 337
apply (drule_tac x="e" in spec)
+ − 338
apply (blast)
+ − 339
apply (case_tac b)
+ − 340
apply (simp_all)
+ − 341
apply (subgoal_tac "ffold_raw f z b = f a1 (ffold_raw f z (delete_raw b a1))")
+ − 342
apply (simp only:)
+ − 343
apply (rule_tac f="f a1" in arg_cong)
+ − 344
apply (subgoal_tac "\<forall>e. memb e a2 = memb e (delete_raw b a1)")
+ − 345
apply (simp)
+ − 346
apply (simp add: memb_delete_raw)
+ − 347
apply (auto simp add: memb_cons_iff)[1]
+ − 348
apply (erule memb_commute_ffold_raw)
+ − 349
apply (drule_tac x="a1" in spec)
+ − 350
apply (simp add: memb_cons_iff)
+ − 351
apply (simp add: memb_cons_iff)
+ − 352
apply (case_tac b)
+ − 353
apply (simp_all)
+ − 354
done
+ − 355
+ − 356
lemma [quot_respect]:
+ − 357
"(op = ===> op = ===> op \<approx> ===> op =) ffold_raw ffold_raw"
+ − 358
by (simp add: memb_def[symmetric] ffold_raw_rsp_pre)
+ − 359
1935
+ − 360
lemma concat_rsp_pre:
2326
+ − 361
assumes a: "list_all2 op \<approx> x x'"
1935
+ − 362
and b: "x' \<approx> y'"
2326
+ − 363
and c: "list_all2 op \<approx> y' y"
1935
+ − 364
and d: "\<exists>x\<in>set x. xa \<in> set x"
+ − 365
shows "\<exists>x\<in>set y. xa \<in> set x"
+ − 366
proof -
+ − 367
obtain xb where e: "xb \<in> set x" and f: "xa \<in> set xb" using d by auto
2326
+ − 368
have "\<exists>y. y \<in> set x' \<and> xb \<approx> y" by (rule list_all2_find_element[OF e a])
1935
+ − 369
then obtain ya where h: "ya \<in> set x'" and i: "xb \<approx> ya" by auto
2084
+ − 370
have "ya \<in> set y'" using b h by simp
2326
+ − 371
then have "\<exists>yb. yb \<in> set y \<and> ya \<approx> yb" using c by (rule list_all2_find_element)
1935
+ − 372
then show ?thesis using f i by auto
+ − 373
qed
+ − 374
2187
+ − 375
lemma concat_rsp[quot_respect]:
2326
+ − 376
shows "(list_all2 op \<approx> OOO op \<approx> ===> op \<approx>) concat concat"
1935
+ − 377
proof (rule fun_relI, elim pred_compE)
+ − 378
fix a b ba bb
2326
+ − 379
assume a: "list_all2 op \<approx> a ba"
1935
+ − 380
assume b: "ba \<approx> bb"
2326
+ − 381
assume c: "list_all2 op \<approx> bb b"
1935
+ − 382
have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
+ − 383
fix x
+ − 384
show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
+ − 385
assume d: "\<exists>xa\<in>set a. x \<in> set xa"
+ − 386
show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d])
+ − 387
next
+ − 388
assume e: "\<exists>xa\<in>set b. x \<in> set xa"
2326
+ − 389
have a': "list_all2 op \<approx> ba a" by (rule list_all2_symp[OF list_eq_equivp, OF a])
1935
+ − 390
have b': "bb \<approx> ba" by (rule equivp_symp[OF list_eq_equivp, OF b])
2326
+ − 391
have c': "list_all2 op \<approx> b bb" by (rule list_all2_symp[OF list_eq_equivp, OF c])
1935
+ − 392
show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e])
+ − 393
qed
+ − 394
qed
+ − 395
then show "concat a \<approx> concat b" by simp
+ − 396
qed
+ − 397
2190
+ − 398
+ − 399
+ − 400
lemma concat_rsp_unfolded:
2326
+ − 401
"\<lbrakk>list_all2 op \<approx> a ba; ba \<approx> bb; list_all2 op \<approx> bb b\<rbrakk> \<Longrightarrow> concat a \<approx> concat b"
2190
+ − 402
proof -
+ − 403
fix a b ba bb
2326
+ − 404
assume a: "list_all2 op \<approx> a ba"
2190
+ − 405
assume b: "ba \<approx> bb"
2326
+ − 406
assume c: "list_all2 op \<approx> bb b"
2190
+ − 407
have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
+ − 408
fix x
+ − 409
show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
+ − 410
assume d: "\<exists>xa\<in>set a. x \<in> set xa"
+ − 411
show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d])
+ − 412
next
+ − 413
assume e: "\<exists>xa\<in>set b. x \<in> set xa"
2326
+ − 414
have a': "list_all2 op \<approx> ba a" by (rule list_all2_symp[OF list_eq_equivp, OF a])
2190
+ − 415
have b': "bb \<approx> ba" by (rule equivp_symp[OF list_eq_equivp, OF b])
2326
+ − 416
have c': "list_all2 op \<approx> b bb" by (rule list_all2_symp[OF list_eq_equivp, OF c])
2190
+ − 417
show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e])
+ − 418
qed
+ − 419
qed
+ − 420
then show "concat a \<approx> concat b" by simp
+ − 421
qed
+ − 422
2084
+ − 423
lemma [quot_respect]:
+ − 424
"((op =) ===> op \<approx> ===> op \<approx>) filter filter"
+ − 425
by auto
+ − 426
1909
+ − 427
text {* Distributive lattice with bot *}
+ − 428
1893
+ − 429
lemma sub_list_not_eq:
+ − 430
"(sub_list x y \<and> \<not> list_eq x y) = (sub_list x y \<and> \<not> sub_list y x)"
+ − 431
by (auto simp add: sub_list_def)
+ − 432
+ − 433
lemma sub_list_refl:
+ − 434
"sub_list x x"
+ − 435
by (simp add: sub_list_def)
+ − 436
+ − 437
lemma sub_list_trans:
+ − 438
"sub_list x y \<Longrightarrow> sub_list y z \<Longrightarrow> sub_list x z"
+ − 439
by (simp add: sub_list_def)
+ − 440
+ − 441
lemma sub_list_empty:
+ − 442
"sub_list [] x"
+ − 443
by (simp add: sub_list_def)
+ − 444
1905
+ − 445
lemma sub_list_append_left:
+ − 446
"sub_list x (x @ y)"
+ − 447
by (simp add: sub_list_def)
+ − 448
+ − 449
lemma sub_list_append_right:
+ − 450
"sub_list y (x @ y)"
+ − 451
by (simp add: sub_list_def)
+ − 452
+ − 453
lemma sub_list_inter_left:
+ − 454
shows "sub_list (finter_raw x y) x"
+ − 455
by (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
+ − 456
+ − 457
lemma sub_list_inter_right:
+ − 458
shows "sub_list (finter_raw x y) y"
+ − 459
by (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
+ − 460
+ − 461
lemma sub_list_list_eq:
+ − 462
"sub_list x y \<Longrightarrow> sub_list y x \<Longrightarrow> list_eq x y"
+ − 463
unfolding sub_list_def list_eq.simps by blast
+ − 464
+ − 465
lemma sub_list_append:
+ − 466
"sub_list y x \<Longrightarrow> sub_list z x \<Longrightarrow> sub_list (y @ z) x"
+ − 467
unfolding sub_list_def by auto
+ − 468
+ − 469
lemma sub_list_inter:
+ − 470
"sub_list x y \<Longrightarrow> sub_list x z \<Longrightarrow> sub_list x (finter_raw y z)"
+ − 471
by (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
+ − 472
+ − 473
lemma append_inter_distrib:
+ − 474
"x @ (finter_raw y z) \<approx> finter_raw (x @ y) (x @ z)"
+ − 475
apply (induct x)
+ − 476
apply (simp_all add: memb_def)
+ − 477
apply (simp add: memb_def[symmetric] memb_finter_raw)
2084
+ − 478
apply (auto simp add: memb_def)
+ − 479
done
1905
+ − 480
2084
+ − 481
instantiation fset :: (type) "{bounded_lattice_bot,distrib_lattice,minus}"
1893
+ − 482
begin
+ − 483
+ − 484
quotient_definition
+ − 485
"bot :: 'a fset" is "[] :: 'a list"
+ − 486
+ − 487
abbreviation
+ − 488
fempty ("{||}")
+ − 489
where
+ − 490
"{||} \<equiv> bot :: 'a fset"
+ − 491
+ − 492
quotient_definition
+ − 493
"less_eq_fset \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> bool)"
+ − 494
is
+ − 495
"sub_list \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> bool)"
+ − 496
+ − 497
abbreviation
+ − 498
f_subset_eq :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subseteq>|" 50)
+ − 499
where
+ − 500
"xs |\<subseteq>| ys \<equiv> xs \<le> ys"
+ − 501
+ − 502
definition
+ − 503
less_fset:
+ − 504
"(xs :: 'a fset) < ys \<equiv> xs \<le> ys \<and> xs \<noteq> ys"
+ − 505
+ − 506
abbreviation
+ − 507
f_subset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50)
+ − 508
where
+ − 509
"xs |\<subset>| ys \<equiv> xs < ys"
+ − 510
1895
+ − 511
quotient_definition
+ − 512
"sup \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
+ − 513
is
+ − 514
"(op @) \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
+ − 515
+ − 516
abbreviation
2084
+ − 517
funion (infixl "|\<union>|" 65)
1895
+ − 518
where
+ − 519
"xs |\<union>| ys \<equiv> sup (xs :: 'a fset) ys"
+ − 520
1905
+ − 521
quotient_definition
2084
+ − 522
"inf \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
1905
+ − 523
is
+ − 524
"finter_raw \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
+ − 525
+ − 526
abbreviation
+ − 527
finter (infixl "|\<inter>|" 65)
+ − 528
where
+ − 529
"xs |\<inter>| ys \<equiv> inf (xs :: 'a fset) ys"
+ − 530
2084
+ − 531
quotient_definition
+ − 532
"minus \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
+ − 533
is
+ − 534
"fminus_raw \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
+ − 535
1895
+ − 536
instance
+ − 537
proof
1905
+ − 538
fix x y z :: "'a fset"
+ − 539
show "(x |\<subset>| y) = (x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x)"
+ − 540
unfolding less_fset by (lifting sub_list_not_eq)
+ − 541
show "x |\<subseteq>| x" by (lifting sub_list_refl)
+ − 542
show "{||} |\<subseteq>| x" by (lifting sub_list_empty)
1895
+ − 543
show "x |\<subseteq>| x |\<union>| y" by (lifting sub_list_append_left)
+ − 544
show "y |\<subseteq>| x |\<union>| y" by (lifting sub_list_append_right)
1905
+ − 545
show "x |\<inter>| y |\<subseteq>| x" by (lifting sub_list_inter_left)
+ − 546
show "x |\<inter>| y |\<subseteq>| y" by (lifting sub_list_inter_right)
+ − 547
show "x |\<union>| (y |\<inter>| z) = x |\<union>| y |\<inter>| (x |\<union>| z)" by (lifting append_inter_distrib)
+ − 548
next
+ − 549
fix x y z :: "'a fset"
+ − 550
assume a: "x |\<subseteq>| y"
+ − 551
assume b: "y |\<subseteq>| z"
+ − 552
show "x |\<subseteq>| z" using a b by (lifting sub_list_trans)
1895
+ − 553
next
+ − 554
fix x y :: "'a fset"
+ − 555
assume a: "x |\<subseteq>| y"
+ − 556
assume b: "y |\<subseteq>| x"
+ − 557
show "x = y" using a b by (lifting sub_list_list_eq)
+ − 558
next
+ − 559
fix x y z :: "'a fset"
+ − 560
assume a: "y |\<subseteq>| x"
+ − 561
assume b: "z |\<subseteq>| x"
+ − 562
show "y |\<union>| z |\<subseteq>| x" using a b by (lifting sub_list_append)
1905
+ − 563
next
+ − 564
fix x y z :: "'a fset"
+ − 565
assume a: "x |\<subseteq>| y"
+ − 566
assume b: "x |\<subseteq>| z"
+ − 567
show "x |\<subseteq>| y |\<inter>| z" using a b by (lifting sub_list_inter)
1895
+ − 568
qed
1905
+ − 569
1893
+ − 570
end
+ − 571
1909
+ − 572
section {* Finsert and Membership *}
1518
+ − 573
+ − 574
quotient_definition
1893
+ − 575
"finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
1518
+ − 576
is "op #"
+ − 577
+ − 578
syntax
+ − 579
"@Finset" :: "args => 'a fset" ("{|(_)|}")
+ − 580
+ − 581
translations
+ − 582
"{|x, xs|}" == "CONST finsert x {|xs|}"
+ − 583
"{|x|}" == "CONST finsert x {||}"
+ − 584
+ − 585
quotient_definition
1938
+ − 586
fin (infix "|\<in>|" 50)
1518
+ − 587
where
1816
+ − 588
"fin :: 'a \<Rightarrow> 'a fset \<Rightarrow> bool" is "memb"
1518
+ − 589
+ − 590
abbreviation
1938
+ − 591
fnotin :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50)
1518
+ − 592
where
1860
+ − 593
"x |\<notin>| S \<equiv> \<not> (x |\<in>| S)"
1518
+ − 594
2084
+ − 595
section {* Other constants on the Quotient Type *}
1935
+ − 596
+ − 597
quotient_definition
2084
+ − 598
"fcard :: 'a fset \<Rightarrow> nat"
1935
+ − 599
is
+ − 600
"fcard_raw"
+ − 601
+ − 602
quotient_definition
+ − 603
"fmap :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
+ − 604
is
+ − 605
"map"
+ − 606
+ − 607
quotient_definition
2084
+ − 608
"fdelete :: 'a fset \<Rightarrow> 'a \<Rightarrow> 'a fset"
1935
+ − 609
is "delete_raw"
+ − 610
+ − 611
quotient_definition
2084
+ − 612
"fset_to_set :: 'a fset \<Rightarrow> 'a set"
1935
+ − 613
is "set"
+ − 614
+ − 615
quotient_definition
+ − 616
"ffold :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b"
+ − 617
is "ffold_raw"
+ − 618
+ − 619
quotient_definition
+ − 620
"fconcat :: ('a fset) fset \<Rightarrow> 'a fset"
+ − 621
is
+ − 622
"concat"
+ − 623
2084
+ − 624
quotient_definition
+ − 625
"ffilter :: ('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
+ − 626
is
+ − 627
"filter"
+ − 628
1935
+ − 629
text {* Compositional Respectfullness and Preservation *}
+ − 630
2326
+ − 631
lemma [quot_respect]: "(list_all2 op \<approx> OOO op \<approx>) [] []"
1938
+ − 632
by (fact compose_list_refl)
1935
+ − 633
+ − 634
lemma [quot_preserve]: "(abs_fset \<circ> map f) [] = abs_fset []"
+ − 635
by simp
+ − 636
+ − 637
lemma [quot_respect]:
2326
+ − 638
"(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) op # op #"
1935
+ − 639
apply auto
+ − 640
apply (simp add: set_in_eq)
+ − 641
apply (rule_tac b="x # b" in pred_compI)
+ − 642
apply auto
+ − 643
apply (rule_tac b="x # ba" in pred_compI)
+ − 644
apply auto
+ − 645
done
+ − 646
2196
+ − 647
lemma insert_preserve2:
+ − 648
shows "((rep_fset ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) op #) =
+ − 649
(id ---> rep_fset ---> abs_fset) op #"
+ − 650
by (simp add: expand_fun_eq abs_o_rep[OF Quotient_fset] map_id Quotient_abs_rep[OF Quotient_fset])
+ − 651
1935
+ − 652
lemma [quot_preserve]:
+ − 653
"(rep_fset ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) op # = finsert"
+ − 654
by (simp add: expand_fun_eq Quotient_abs_rep[OF Quotient_fset]
+ − 655
abs_o_rep[OF Quotient_fset] map_id finsert_def)
+ − 656
+ − 657
lemma [quot_preserve]:
1938
+ − 658
"((map rep_fset \<circ> rep_fset) ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) op @ = funion"
1935
+ − 659
by (simp add: expand_fun_eq Quotient_abs_rep[OF Quotient_fset]
+ − 660
abs_o_rep[OF Quotient_fset] map_id sup_fset_def)
+ − 661
2326
+ − 662
lemma list_all2_app_l:
1935
+ − 663
assumes a: "reflp R"
2326
+ − 664
and b: "list_all2 R l r"
+ − 665
shows "list_all2 R (z @ l) (z @ r)"
1938
+ − 666
by (induct z) (simp_all add: b rev_iffD1[OF a meta_eq_to_obj_eq[OF reflp_def]])
1935
+ − 667
+ − 668
lemma append_rsp2_pre0:
2326
+ − 669
assumes a:"list_all2 op \<approx> x x'"
+ − 670
shows "list_all2 op \<approx> (x @ z) (x' @ z)"
1935
+ − 671
using a apply (induct x x' rule: list_induct2')
2326
+ − 672
by simp_all (rule list_all2_refl1)
1935
+ − 673
+ − 674
lemma append_rsp2_pre1:
2326
+ − 675
assumes a:"list_all2 op \<approx> x x'"
+ − 676
shows "list_all2 op \<approx> (z @ x) (z @ x')"
1935
+ − 677
using a apply (induct x x' arbitrary: z rule: list_induct2')
2326
+ − 678
apply (rule list_all2_refl1)
1935
+ − 679
apply (simp_all del: list_eq.simps)
2326
+ − 680
apply (rule list_all2_app_l)
1935
+ − 681
apply (simp_all add: reflp_def)
+ − 682
done
+ − 683
+ − 684
lemma append_rsp2_pre:
2326
+ − 685
assumes a:"list_all2 op \<approx> x x'"
+ − 686
and b: "list_all2 op \<approx> z z'"
+ − 687
shows "list_all2 op \<approx> (x @ z) (x' @ z')"
+ − 688
apply (rule list_all2_transp[OF fset_equivp])
1935
+ − 689
apply (rule append_rsp2_pre0)
+ − 690
apply (rule a)
+ − 691
using b apply (induct z z' rule: list_induct2')
+ − 692
apply (simp_all only: append_Nil2)
2326
+ − 693
apply (rule list_all2_refl1)
1935
+ − 694
apply simp_all
+ − 695
apply (rule append_rsp2_pre1)
+ − 696
apply simp
+ − 697
done
+ − 698
+ − 699
lemma [quot_respect]:
2326
+ − 700
"(list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) op @ op @"
1935
+ − 701
proof (intro fun_relI, elim pred_compE)
+ − 702
fix x y z w x' z' y' w' :: "'a list list"
2326
+ − 703
assume a:"list_all2 op \<approx> x x'"
1935
+ − 704
and b: "x' \<approx> y'"
2326
+ − 705
and c: "list_all2 op \<approx> y' y"
+ − 706
assume aa: "list_all2 op \<approx> z z'"
1935
+ − 707
and bb: "z' \<approx> w'"
2326
+ − 708
and cc: "list_all2 op \<approx> w' w"
+ − 709
have a': "list_all2 op \<approx> (x @ z) (x' @ z')" using a aa append_rsp2_pre by auto
1935
+ − 710
have b': "x' @ z' \<approx> y' @ w'" using b bb by simp
2326
+ − 711
have c': "list_all2 op \<approx> (y' @ w') (y @ w)" using c cc append_rsp2_pre by auto
+ − 712
have d': "(op \<approx> OO list_all2 op \<approx>) (x' @ z') (y @ w)"
1935
+ − 713
by (rule pred_compI) (rule b', rule c')
2326
+ − 714
show "(list_all2 op \<approx> OOO op \<approx>) (x @ z) (y @ w)"
1935
+ − 715
by (rule pred_compI) (rule a', rule d')
+ − 716
qed
+ − 717
+ − 718
text {* Raw theorems. Finsert, memb, singleron, sub_list *}
1518
+ − 719
1892
+ − 720
lemma nil_not_cons:
+ − 721
shows "\<not> ([] \<approx> x # xs)"
+ − 722
and "\<not> (x # xs \<approx> [])"
+ − 723
by auto
+ − 724
1878
+ − 725
lemma no_memb_nil:
+ − 726
"(\<forall>x. \<not> memb x xs) = (xs = [])"
+ − 727
by (simp add: memb_def)
+ − 728
1518
+ − 729
lemma memb_consI1:
+ − 730
shows "memb x (x # xs)"
+ − 731
by (simp add: memb_def)
+ − 732
+ − 733
lemma memb_consI2:
+ − 734
shows "memb x xs \<Longrightarrow> memb x (y # xs)"
+ − 735
by (simp add: memb_def)
+ − 736
+ − 737
lemma singleton_list_eq:
+ − 738
shows "[x] \<approx> [y] \<longleftrightarrow> x = y"
+ − 739
by (simp add: id_simps) auto
+ − 740
1892
+ − 741
lemma sub_list_cons:
+ − 742
"sub_list (x # xs) ys = (memb x ys \<and> sub_list xs ys)"
+ − 743
by (auto simp add: memb_def sub_list_def)
+ − 744
2084
+ − 745
lemma fminus_raw_red: "fminus_raw (x # xs) ys = (if memb x ys then fminus_raw xs ys else x # (fminus_raw xs ys))"
+ − 746
by (induct ys arbitrary: xs x)
+ − 747
(simp_all add: not_memb_nil memb_delete_raw memb_cons_iff)
+ − 748
1935
+ − 749
text {* Cardinality of finite sets *}
1518
+ − 750
1813
+ − 751
lemma fcard_raw_0:
1860
+ − 752
shows "fcard_raw xs = 0 \<longleftrightarrow> xs \<approx> []"
1821
+ − 753
by (induct xs) (auto simp add: memb_def)
1813
+ − 754
+ − 755
lemma fcard_raw_not_memb:
1860
+ − 756
shows "\<not> memb x xs \<longleftrightarrow> fcard_raw (x # xs) = Suc (fcard_raw xs)"
1813
+ − 757
by auto
+ − 758
+ − 759
lemma fcard_raw_suc:
1860
+ − 760
assumes a: "fcard_raw xs = Suc n"
+ − 761
shows "\<exists>x ys. \<not> (memb x ys) \<and> xs \<approx> (x # ys) \<and> fcard_raw ys = n"
+ − 762
using a
+ − 763
by (induct xs) (auto simp add: memb_def split: if_splits)
1819
+ − 764
1935
+ − 765
lemma singleton_fcard_1:
1860
+ − 766
shows "set xs = {x} \<Longrightarrow> fcard_raw xs = 1"
+ − 767
by (induct xs) (auto simp add: memb_def subset_insert)
1819
+ − 768
+ − 769
lemma fcard_raw_1:
1823
+ − 770
shows "fcard_raw xs = 1 \<longleftrightarrow> (\<exists>x. xs \<approx> [x])"
+ − 771
apply (auto dest!: fcard_raw_suc)
1819
+ − 772
apply (simp add: fcard_raw_0)
1821
+ − 773
apply (rule_tac x="x" in exI)
1819
+ − 774
apply simp
1821
+ − 775
apply (subgoal_tac "set xs = {x}")
1860
+ − 776
apply (drule singleton_fcard_1)
1819
+ − 777
apply auto
1813
+ − 778
done
+ − 779
1878
+ − 780
lemma fcard_raw_suc_memb:
+ − 781
assumes a: "fcard_raw A = Suc n"
+ − 782
shows "\<exists>a. memb a A"
+ − 783
using a
1938
+ − 784
by (induct A) (auto simp add: memb_def)
1878
+ − 785
1884
+ − 786
lemma memb_card_not_0:
1878
+ − 787
assumes a: "memb a A"
+ − 788
shows "\<not>(fcard_raw A = 0)"
1883
+ − 789
proof -
+ − 790
have "\<not>(\<forall>x. \<not> memb x A)" using a by auto
+ − 791
then have "\<not>A \<approx> []" using none_memb_nil[of A] by simp
+ − 792
then show ?thesis using fcard_raw_0[of A] by simp
+ − 793
qed
1878
+ − 794
1935
+ − 795
text {* fmap *}
1518
+ − 796
1813
+ − 797
lemma map_append:
1821
+ − 798
"map f (xs @ ys) \<approx> (map f xs) @ (map f ys)"
1813
+ − 799
by simp
+ − 800
1819
+ − 801
lemma memb_append:
1823
+ − 802
"memb x (xs @ ys) \<longleftrightarrow> memb x xs \<or> memb x ys"
1821
+ − 803
by (induct xs) (simp_all add: not_memb_nil memb_cons_iff)
1819
+ − 804
1518
+ − 805
lemma cons_left_comm:
1821
+ − 806
"x # y # xs \<approx> y # x # xs"
+ − 807
by auto
1518
+ − 808
+ − 809
lemma cons_left_idem:
1821
+ − 810
"x # x # xs \<approx> x # xs"
+ − 811
by auto
1518
+ − 812
1819
+ − 813
lemma fset_raw_strong_cases:
2084
+ − 814
obtains "xs = []"
+ − 815
| x ys where "\<not> memb x ys" and "xs \<approx> x # ys"
+ − 816
proof (induct xs arbitrary: x ys)
+ − 817
case Nil
+ − 818
then show thesis by simp
+ − 819
next
+ − 820
case (Cons a xs)
+ − 821
have a: "\<lbrakk>xs = [] \<Longrightarrow> thesis; \<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis" by fact
+ − 822
have b: "\<And>x' ys'. \<lbrakk>\<not> memb x' ys'; a # xs \<approx> x' # ys'\<rbrakk> \<Longrightarrow> thesis" by fact
+ − 823
have c: "xs = [] \<Longrightarrow> thesis" by (metis no_memb_nil singleton_list_eq b)
+ − 824
have "\<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis"
+ − 825
proof -
+ − 826
fix x :: 'a
+ − 827
fix ys :: "'a list"
+ − 828
assume d:"\<not> memb x ys"
+ − 829
assume e:"xs \<approx> x # ys"
+ − 830
show thesis
+ − 831
proof (cases "x = a")
+ − 832
assume h: "x = a"
+ − 833
then have f: "\<not> memb a ys" using d by simp
+ − 834
have g: "a # xs \<approx> a # ys" using e h by auto
+ − 835
show thesis using b f g by simp
+ − 836
next
+ − 837
assume h: "x \<noteq> a"
+ − 838
then have f: "\<not> memb x (a # ys)" using d unfolding memb_def by auto
+ − 839
have g: "a # xs \<approx> x # (a # ys)" using e h by auto
+ − 840
show thesis using b f g by simp
+ − 841
qed
+ − 842
qed
+ − 843
then show thesis using a c by blast
+ − 844
qed
1518
+ − 845
1860
+ − 846
section {* deletion *}
+ − 847
1819
+ − 848
lemma memb_delete_raw_ident:
1860
+ − 849
shows "\<not> memb x (delete_raw xs x)"
1821
+ − 850
by (induct xs) (auto simp add: memb_def)
1518
+ − 851
1819
+ − 852
lemma fset_raw_delete_raw_cases:
1821
+ − 853
"xs = [] \<or> (\<exists>x. memb x xs \<and> xs \<approx> x # delete_raw xs x)"
+ − 854
by (induct xs) (auto simp add: memb_def)
1518
+ − 855
1819
+ − 856
lemma fdelete_raw_filter:
+ − 857
"delete_raw xs y = [x \<leftarrow> xs. x \<noteq> y]"
+ − 858
by (induct xs) simp_all
1518
+ − 859
1819
+ − 860
lemma fcard_raw_delete:
+ − 861
"fcard_raw (delete_raw xs y) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
+ − 862
by (simp add: fdelete_raw_filter fcard_raw_delete_one)
1518
+ − 863
1819
+ − 864
lemma finter_raw_empty:
+ − 865
"finter_raw l [] = []"
+ − 866
by (induct l) (simp_all add: not_memb_nil)
+ − 867
2084
+ − 868
lemma set_cong:
+ − 869
shows "(x \<approx> y) = (set x = set y)"
1821
+ − 870
by auto
1533
+ − 871
+ − 872
lemma inj_map_eq_iff:
+ − 873
"inj f \<Longrightarrow> (map f l \<approx> map f m) = (l \<approx> m)"
+ − 874
by (simp add: expand_set_eq[symmetric] inj_image_eq_iff)
+ − 875
1888
+ − 876
text {* alternate formulation with a different decomposition principle
+ − 877
and a proof of equivalence *}
+ − 878
+ − 879
inductive
+ − 880
list_eq2
+ − 881
where
+ − 882
"list_eq2 (a # b # xs) (b # a # xs)"
+ − 883
| "list_eq2 [] []"
+ − 884
| "list_eq2 xs ys \<Longrightarrow> list_eq2 ys xs"
+ − 885
| "list_eq2 (a # a # xs) (a # xs)"
+ − 886
| "list_eq2 xs ys \<Longrightarrow> list_eq2 (a # xs) (a # ys)"
+ − 887
| "\<lbrakk>list_eq2 xs1 xs2; list_eq2 xs2 xs3\<rbrakk> \<Longrightarrow> list_eq2 xs1 xs3"
+ − 888
+ − 889
lemma list_eq2_refl:
+ − 890
shows "list_eq2 xs xs"
+ − 891
by (induct xs) (auto intro: list_eq2.intros)
+ − 892
+ − 893
lemma cons_delete_list_eq2:
+ − 894
shows "list_eq2 (a # (delete_raw A a)) (if memb a A then A else a # A)"
+ − 895
apply (induct A)
+ − 896
apply (simp add: memb_def list_eq2_refl)
+ − 897
apply (case_tac "memb a (aa # A)")
+ − 898
apply (simp_all only: memb_cons_iff)
+ − 899
apply (case_tac [!] "a = aa")
1909
+ − 900
apply (simp_all)
1888
+ − 901
apply (case_tac "memb a A")
+ − 902
apply (auto simp add: memb_def)[2]
+ − 903
apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6))
1895
+ − 904
apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6))
1888
+ − 905
apply (auto simp add: list_eq2_refl not_memb_delete_raw_ident)
+ − 906
done
+ − 907
+ − 908
lemma memb_delete_list_eq2:
+ − 909
assumes a: "memb e r"
+ − 910
shows "list_eq2 (e # delete_raw r e) r"
+ − 911
using a cons_delete_list_eq2[of e r]
+ − 912
by simp
+ − 913
1909
+ − 914
lemma delete_raw_rsp:
+ − 915
"xs \<approx> ys \<Longrightarrow> delete_raw xs x \<approx> delete_raw ys x"
+ − 916
by (simp add: memb_def[symmetric] memb_delete_raw)
+ − 917
1888
+ − 918
lemma list_eq2_equiv:
+ − 919
"(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)"
+ − 920
proof
+ − 921
show "list_eq2 l r \<Longrightarrow> l \<approx> r" by (induct rule: list_eq2.induct) auto
1938
+ − 922
next
+ − 923
{
+ − 924
fix n
+ − 925
assume a: "fcard_raw l = n" and b: "l \<approx> r"
+ − 926
have "list_eq2 l r"
+ − 927
using a b
+ − 928
proof (induct n arbitrary: l r)
+ − 929
case 0
+ − 930
have "fcard_raw l = 0" by fact
+ − 931
then have "\<forall>x. \<not> memb x l" using memb_card_not_0[of _ l] by auto
+ − 932
then have z: "l = []" using no_memb_nil by auto
+ − 933
then have "r = []" using `l \<approx> r` by simp
+ − 934
then show ?case using z list_eq2_refl by simp
+ − 935
next
+ − 936
case (Suc m)
+ − 937
have b: "l \<approx> r" by fact
+ − 938
have d: "fcard_raw l = Suc m" by fact
2084
+ − 939
then have "\<exists>a. memb a l" by (rule fcard_raw_suc_memb)
1938
+ − 940
then obtain a where e: "memb a l" by auto
+ − 941
then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b by auto
+ − 942
have f: "fcard_raw (delete_raw l a) = m" using fcard_raw_delete[of l a] e d by simp
+ − 943
have g: "delete_raw l a \<approx> delete_raw r a" using delete_raw_rsp[OF b] by simp
2084
+ − 944
have "list_eq2 (delete_raw l a) (delete_raw r a)" by (rule Suc.hyps[OF f g])
+ − 945
then have h: "list_eq2 (a # delete_raw l a) (a # delete_raw r a)" by (rule list_eq2.intros(5))
1938
+ − 946
have i: "list_eq2 l (a # delete_raw l a)"
+ − 947
by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]])
+ − 948
have "list_eq2 l (a # delete_raw r a)" by (rule list_eq2.intros(6)[OF i h])
+ − 949
then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp
+ − 950
qed
+ − 951
}
+ − 952
then show "l \<approx> r \<Longrightarrow> list_eq2 l r" by blast
1888
+ − 953
qed
+ − 954
2084
+ − 955
text {* Set *}
+ − 956
+ − 957
lemma sub_list_set: "sub_list xs ys = (set xs \<subseteq> set ys)"
+ − 958
by (metis rev_append set_append set_cong set_rev sub_list_append sub_list_append_left sub_list_def sub_list_not_eq subset_Un_eq)
+ − 959
+ − 960
lemma sub_list_neq_set: "(sub_list xs ys \<and> \<not> list_eq xs ys) = (set xs \<subset> set ys)"
+ − 961
by (auto simp add: sub_list_set)
+ − 962
+ − 963
lemma fcard_raw_set: "fcard_raw xs = card (set xs)"
+ − 964
by (induct xs) (auto simp add: insert_absorb memb_def card_insert_disjoint finite_set)
+ − 965
+ − 966
lemma memb_set: "memb x xs = (x \<in> set xs)"
+ − 967
by (simp only: memb_def)
+ − 968
+ − 969
lemma filter_set: "set (filter P xs) = P \<inter> (set xs)"
+ − 970
by (induct xs, simp)
+ − 971
(metis Int_insert_right_if0 Int_insert_right_if1 List.set.simps(2) filter.simps(2) mem_def)
+ − 972
+ − 973
lemma delete_raw_set: "set (delete_raw xs x) = set xs - {x}"
+ − 974
by (induct xs) auto
+ − 975
+ − 976
lemma inter_raw_set: "set (finter_raw xs ys) = set xs \<inter> set ys"
+ − 977
by (induct xs) (simp_all add: memb_def)
+ − 978
+ − 979
lemma fminus_raw_set: "set (fminus_raw xs ys) = set xs - set ys"
+ − 980
by (induct ys arbitrary: xs)
+ − 981
(simp_all add: fminus_raw.simps delete_raw_set, blast)
+ − 982
+ − 983
text {* Raw theorems of ffilter *}
+ − 984
+ − 985
lemma sub_list_filter: "sub_list (filter P xs) (filter Q xs) = (\<forall> x. memb x xs \<longrightarrow> P x \<longrightarrow> Q x)"
+ − 986
unfolding sub_list_def memb_def by auto
+ − 987
+ − 988
lemma list_eq_filter: "list_eq (filter P xs) (filter Q xs) = (\<forall>x. memb x xs \<longrightarrow> P x = Q x)"
+ − 989
unfolding memb_def by auto
+ − 990
1935
+ − 991
text {* Lifted theorems *}
1518
+ − 992
1819
+ − 993
lemma not_fin_fnil: "x |\<notin>| {||}"
+ − 994
by (lifting not_memb_nil)
1518
+ − 995
+ − 996
lemma fin_finsert_iff[simp]:
+ − 997
"x |\<in>| finsert y S = (x = y \<or> x |\<in>| S)"
+ − 998
by (lifting memb_cons_iff)
+ − 999
+ − 1000
lemma
+ − 1001
shows finsertI1: "x |\<in>| finsert x S"
+ − 1002
and finsertI2: "x |\<in>| S \<Longrightarrow> x |\<in>| finsert y S"
+ − 1003
by (lifting memb_consI1, lifting memb_consI2)
+ − 1004
+ − 1005
lemma finsert_absorb[simp]:
+ − 1006
shows "x |\<in>| S \<Longrightarrow> finsert x S = S"
+ − 1007
by (lifting memb_absorb)
+ − 1008
+ − 1009
lemma fempty_not_finsert[simp]:
1533
+ − 1010
"{||} \<noteq> finsert x S"
+ − 1011
"finsert x S \<noteq> {||}"
1518
+ − 1012
by (lifting nil_not_cons)
+ − 1013
+ − 1014
lemma finsert_left_comm:
1822
+ − 1015
"finsert x (finsert y S) = finsert y (finsert x S)"
1518
+ − 1016
by (lifting cons_left_comm)
+ − 1017
+ − 1018
lemma finsert_left_idem:
1822
+ − 1019
"finsert x (finsert x S) = finsert x S"
1518
+ − 1020
by (lifting cons_left_idem)
+ − 1021
+ − 1022
lemma fsingleton_eq[simp]:
+ − 1023
shows "{|x|} = {|y|} \<longleftrightarrow> x = y"
+ − 1024
by (lifting singleton_list_eq)
+ − 1025
+ − 1026
text {* fset_to_set *}
+ − 1027
1533
+ − 1028
lemma fset_to_set_simps[simp]:
1819
+ − 1029
"fset_to_set {||} = ({} :: 'a set)"
+ − 1030
"fset_to_set (finsert (h :: 'a) t) = insert h (fset_to_set t)"
+ − 1031
by (lifting set.simps)
1518
+ − 1032
+ − 1033
lemma in_fset_to_set:
1822
+ − 1034
"x \<in> fset_to_set S \<equiv> x |\<in>| S"
1518
+ − 1035
by (lifting memb_def[symmetric])
+ − 1036
1819
+ − 1037
lemma none_fin_fempty:
1824
+ − 1038
"(\<forall>x. x |\<notin>| S) = (S = {||})"
+ − 1039
by (lifting none_memb_nil)
1518
+ − 1040
1533
+ − 1041
lemma fset_cong:
2084
+ − 1042
"(S = T) = (fset_to_set S = fset_to_set T)"
1533
+ − 1043
by (lifting set_cong)
+ − 1044
1518
+ − 1045
text {* fcard *}
+ − 1046
+ − 1047
lemma fcard_fempty [simp]:
+ − 1048
shows "fcard {||} = 0"
+ − 1049
by (lifting fcard_raw_nil)
+ − 1050
+ − 1051
lemma fcard_finsert_if [simp]:
+ − 1052
shows "fcard (finsert x S) = (if x |\<in>| S then fcard S else Suc (fcard S))"
+ − 1053
by (lifting fcard_raw_cons)
+ − 1054
1822
+ − 1055
lemma fcard_0: "(fcard S = 0) = (S = {||})"
1813
+ − 1056
by (lifting fcard_raw_0)
+ − 1057
1821
+ − 1058
lemma fcard_1:
1822
+ − 1059
shows "(fcard S = 1) = (\<exists>x. S = {|x|})"
1819
+ − 1060
by (lifting fcard_raw_1)
+ − 1061
2084
+ − 1062
lemma fcard_gt_0:
1860
+ − 1063
shows "x \<in> fset_to_set S \<Longrightarrow> 0 < fcard S"
1518
+ − 1064
by (lifting fcard_raw_gt_0)
+ − 1065
2084
+ − 1066
lemma fcard_not_fin:
1860
+ − 1067
shows "(x |\<notin>| S) = (fcard (finsert x S) = Suc (fcard S))"
1813
+ − 1068
by (lifting fcard_raw_not_memb)
+ − 1069
1822
+ − 1070
lemma fcard_suc: "fcard S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = finsert x T \<and> fcard T = n"
1813
+ − 1071
by (lifting fcard_raw_suc)
+ − 1072
1819
+ − 1073
lemma fcard_delete:
1822
+ − 1074
"fcard (fdelete S y) = (if y |\<in>| S then fcard S - 1 else fcard S)"
1819
+ − 1075
by (lifting fcard_raw_delete)
+ − 1076
1878
+ − 1077
lemma fcard_suc_memb: "fcard A = Suc n \<Longrightarrow> \<exists>a. a |\<in>| A"
+ − 1078
by (lifting fcard_raw_suc_memb)
+ − 1079
+ − 1080
lemma fin_fcard_not_0: "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0"
1887
+ − 1081
by (lifting memb_card_not_0)
1878
+ − 1082
1518
+ − 1083
text {* funion *}
+ − 1084
2084
+ − 1085
lemmas [simp] =
+ − 1086
sup_bot_left[where 'a="'a fset", standard]
+ − 1087
sup_bot_right[where 'a="'a fset", standard]
1518
+ − 1088
2084
+ − 1089
lemma funion_finsert[simp]:
+ − 1090
shows "finsert x S |\<union>| T = finsert x (S |\<union>| T)"
+ − 1091
by (lifting append.simps(2))
1887
+ − 1092
+ − 1093
lemma singleton_union_left:
+ − 1094
"{|a|} |\<union>| S = finsert a S"
+ − 1095
by simp
+ − 1096
+ − 1097
lemma singleton_union_right:
+ − 1098
"S |\<union>| {|a|} = finsert a S"
1907
+ − 1099
by (subst sup.commute) simp
1887
+ − 1100
1518
+ − 1101
section {* Induction and Cases rules for finite sets *}
+ − 1102
+ − 1103
lemma fset_strong_cases:
2084
+ − 1104
obtains "xs = {||}"
+ − 1105
| x ys where "x |\<notin>| ys" and "xs = finsert x ys"
1819
+ − 1106
by (lifting fset_raw_strong_cases)
1518
+ − 1107
+ − 1108
lemma fset_exhaust[case_names fempty finsert, cases type: fset]:
+ − 1109
shows "\<lbrakk>S = {||} \<Longrightarrow> P; \<And>x S'. S = finsert x S' \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
+ − 1110
by (lifting list.exhaust)
+ − 1111
1533
+ − 1112
lemma fset_induct_weak[case_names fempty finsert]:
1518
+ − 1113
shows "\<lbrakk>P {||}; \<And>x S. P S \<Longrightarrow> P (finsert x S)\<rbrakk> \<Longrightarrow> P S"
+ − 1114
by (lifting list.induct)
+ − 1115
1533
+ − 1116
lemma fset_induct[case_names fempty finsert, induct type: fset]:
2084
+ − 1117
assumes prem1: "P {||}"
1518
+ − 1118
and prem2: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (finsert x S)"
+ − 1119
shows "P S"
1533
+ − 1120
proof(induct S rule: fset_induct_weak)
1518
+ − 1121
case fempty
+ − 1122
show "P {||}" by (rule prem1)
+ − 1123
next
+ − 1124
case (finsert x S)
+ − 1125
have asm: "P S" by fact
+ − 1126
show "P (finsert x S)"
1938
+ − 1127
by (cases "x |\<in>| S") (simp_all add: asm prem2)
1518
+ − 1128
qed
+ − 1129
1533
+ − 1130
lemma fset_induct2:
+ − 1131
"P {||} {||} \<Longrightarrow>
+ − 1132
(\<And>x xs. x |\<notin>| xs \<Longrightarrow> P (finsert x xs) {||}) \<Longrightarrow>
+ − 1133
(\<And>y ys. y |\<notin>| ys \<Longrightarrow> P {||} (finsert y ys)) \<Longrightarrow>
+ − 1134
(\<And>x xs y ys. \<lbrakk>P xs ys; x |\<notin>| xs; y |\<notin>| ys\<rbrakk> \<Longrightarrow> P (finsert x xs) (finsert y ys)) \<Longrightarrow>
+ − 1135
P xsa ysa"
+ − 1136
apply (induct xsa arbitrary: ysa)
+ − 1137
apply (induct_tac x rule: fset_induct)
+ − 1138
apply simp_all
+ − 1139
apply (induct_tac xa rule: fset_induct)
+ − 1140
apply simp_all
+ − 1141
done
1518
+ − 1142
2084
+ − 1143
lemma fset_fcard_induct:
+ − 1144
assumes a: "P {||}"
+ − 1145
and b: "\<And>xs ys. Suc (fcard xs) = (fcard ys) \<Longrightarrow> P xs \<Longrightarrow> P ys"
+ − 1146
shows "P zs"
+ − 1147
proof (induct zs)
+ − 1148
show "P {||}" by (rule a)
+ − 1149
next
+ − 1150
fix x :: 'a and zs :: "'a fset"
+ − 1151
assume h: "P zs"
+ − 1152
assume "x |\<notin>| zs"
+ − 1153
then have H1: "Suc (fcard zs) = fcard (finsert x zs)" using fcard_suc by auto
+ − 1154
then show "P (finsert x zs)" using b h by simp
+ − 1155
qed
+ − 1156
1819
+ − 1157
text {* fmap *}
+ − 1158
1533
+ − 1159
lemma fmap_simps[simp]:
+ − 1160
"fmap (f :: 'a \<Rightarrow> 'b) {||} = {||}"
1822
+ − 1161
"fmap f (finsert x S) = finsert (f x) (fmap f S)"
1533
+ − 1162
by (lifting map.simps)
+ − 1163
+ − 1164
lemma fmap_set_image:
1822
+ − 1165
"fset_to_set (fmap f S) = f ` (fset_to_set S)"
2084
+ − 1166
by (induct S) simp_all
1533
+ − 1167
+ − 1168
lemma inj_fmap_eq_iff:
1822
+ − 1169
"inj f \<Longrightarrow> (fmap f S = fmap f T) = (S = T)"
1533
+ − 1170
by (lifting inj_map_eq_iff)
+ − 1171
1822
+ − 1172
lemma fmap_funion: "fmap f (S |\<union>| T) = fmap f S |\<union>| fmap f T"
1813
+ − 1173
by (lifting map_append)
+ − 1174
1819
+ − 1175
lemma fin_funion:
1822
+ − 1176
"x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T"
1819
+ − 1177
by (lifting memb_append)
+ − 1178
2084
+ − 1179
text {* to_set *}
+ − 1180
+ − 1181
lemma fin_set: "(x |\<in>| xs) = (x \<in> fset_to_set xs)"
+ − 1182
by (lifting memb_set)
+ − 1183
+ − 1184
lemma fnotin_set: "(x |\<notin>| xs) = (x \<notin> fset_to_set xs)"
+ − 1185
by (simp add: fin_set)
+ − 1186
+ − 1187
lemma fcard_set: "fcard xs = card (fset_to_set xs)"
+ − 1188
by (lifting fcard_raw_set)
+ − 1189
+ − 1190
lemma fsubseteq_set: "(xs |\<subseteq>| ys) = (fset_to_set xs \<subseteq> fset_to_set ys)"
+ − 1191
by (lifting sub_list_set)
+ − 1192
+ − 1193
lemma fsubset_set: "(xs |\<subset>| ys) = (fset_to_set xs \<subset> fset_to_set ys)"
+ − 1194
unfolding less_fset by (lifting sub_list_neq_set)
+ − 1195
+ − 1196
lemma ffilter_set: "fset_to_set (ffilter P xs) = P \<inter> fset_to_set xs"
+ − 1197
by (lifting filter_set)
+ − 1198
+ − 1199
lemma fdelete_set: "fset_to_set (fdelete xs x) = fset_to_set xs - {x}"
+ − 1200
by (lifting delete_raw_set)
+ − 1201
+ − 1202
lemma inter_set: "fset_to_set (xs |\<inter>| ys) = fset_to_set xs \<inter> fset_to_set ys"
+ − 1203
by (lifting inter_raw_set)
+ − 1204
+ − 1205
lemma union_set: "fset_to_set (xs |\<union>| ys) = fset_to_set xs \<union> fset_to_set ys"
+ − 1206
by (lifting set_append)
+ − 1207
+ − 1208
lemma fminus_set: "fset_to_set (xs - ys) = fset_to_set xs - fset_to_set ys"
+ − 1209
by (lifting fminus_raw_set)
+ − 1210
+ − 1211
lemmas fset_to_set_trans =
+ − 1212
fin_set fnotin_set fcard_set fsubseteq_set fsubset_set
+ − 1213
inter_set union_set ffilter_set fset_to_set_simps
+ − 1214
fset_cong fdelete_set fmap_set_image fminus_set
+ − 1215
+ − 1216
1819
+ − 1217
text {* ffold *}
+ − 1218
+ − 1219
lemma ffold_nil: "ffold f z {||} = z"
+ − 1220
by (lifting ffold_raw.simps(1)[where 'a="'b" and 'b="'a"])
+ − 1221
+ − 1222
lemma ffold_finsert: "ffold f z (finsert a A) =
+ − 1223
(if rsp_fold f then if a |\<in>| A then ffold f z A else f a (ffold f z A) else z)"
+ − 1224
by (lifting ffold_raw.simps(2)[where 'a="'b" and 'b="'a"])
+ − 1225
+ − 1226
lemma fin_commute_ffold:
+ − 1227
"\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete b h))"
+ − 1228
by (lifting memb_commute_ffold_raw)
+ − 1229
+ − 1230
text {* fdelete *}
+ − 1231
2084
+ − 1232
lemma fin_fdelete:
1822
+ − 1233
shows "x |\<in>| fdelete S y \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
1819
+ − 1234
by (lifting memb_delete_raw)
+ − 1235
2084
+ − 1236
lemma fin_fdelete_ident:
1822
+ − 1237
shows "x |\<notin>| fdelete S x"
1819
+ − 1238
by (lifting memb_delete_raw_ident)
+ − 1239
2084
+ − 1240
lemma not_memb_fdelete_ident:
1822
+ − 1241
shows "x |\<notin>| S \<Longrightarrow> fdelete S x = S"
1819
+ − 1242
by (lifting not_memb_delete_raw_ident)
+ − 1243
+ − 1244
lemma fset_fdelete_cases:
1822
+ − 1245
shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete S x))"
1819
+ − 1246
by (lifting fset_raw_delete_raw_cases)
+ − 1247
+ − 1248
text {* inter *}
+ − 1249
1822
+ − 1250
lemma finter_empty_l: "({||} |\<inter>| S) = {||}"
1819
+ − 1251
by (lifting finter_raw.simps(1))
+ − 1252
1822
+ − 1253
lemma finter_empty_r: "(S |\<inter>| {||}) = {||}"
1819
+ − 1254
by (lifting finter_raw_empty)
+ − 1255
+ − 1256
lemma finter_finsert:
1822
+ − 1257
"finsert x S |\<inter>| T = (if x |\<in>| T then finsert x (S |\<inter>| T) else S |\<inter>| T)"
1819
+ − 1258
by (lifting finter_raw.simps(2))
+ − 1259
+ − 1260
lemma fin_finter:
1822
+ − 1261
"x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
1819
+ − 1262
by (lifting memb_finter_raw)
+ − 1263
1893
+ − 1264
lemma fsubset_finsert:
+ − 1265
"(finsert x xs |\<subseteq>| ys) = (x |\<in>| ys \<and> xs |\<subseteq>| ys)"
+ − 1266
by (lifting sub_list_cons)
+ − 1267
1936
+ − 1268
lemma "xs |\<subseteq>| ys \<equiv> \<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys"
+ − 1269
by (lifting sub_list_def[simplified memb_def[symmetric]])
1893
+ − 1270
+ − 1271
lemma fsubset_fin: "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)"
+ − 1272
by (rule meta_eq_to_obj_eq)
+ − 1273
(lifting sub_list_def[simplified memb_def[symmetric]])
+ − 1274
2084
+ − 1275
lemma fminus_fin: "(x |\<in>| xs - ys) = (x |\<in>| xs \<and> x |\<notin>| ys)"
+ − 1276
by (lifting fminus_raw_memb)
+ − 1277
+ − 1278
lemma fminus_red: "finsert x xs - ys = (if x |\<in>| ys then xs - ys else finsert x (xs - ys))"
+ − 1279
by (lifting fminus_raw_red)
+ − 1280
+ − 1281
lemma fminus_red_fin[simp]: "x |\<in>| ys \<Longrightarrow> finsert x xs - ys = xs - ys"
+ − 1282
by (simp add: fminus_red)
+ − 1283
+ − 1284
lemma fminus_red_fnotin[simp]: "x |\<notin>| ys \<Longrightarrow> finsert x xs - ys = finsert x (xs - ys)"
+ − 1285
by (simp add: fminus_red)
+ − 1286
1820
+ − 1287
lemma expand_fset_eq:
1822
+ − 1288
"(S = T) = (\<forall>x. (x |\<in>| S) = (x |\<in>| T))"
1820
+ − 1289
by (lifting list_eq.simps[simplified memb_def[symmetric]])
+ − 1290
1888
+ − 1291
(* We cannot write it as "assumes .. shows" since Isabelle changes
+ − 1292
the quantifiers to schematic variables and reintroduces them in
+ − 1293
a different order *)
+ − 1294
lemma fset_eq_cases:
+ − 1295
"\<lbrakk>a1 = a2;
+ − 1296
\<And>a b xs. \<lbrakk>a1 = finsert a (finsert b xs); a2 = finsert b (finsert a xs)\<rbrakk> \<Longrightarrow> P;
+ − 1297
\<lbrakk>a1 = {||}; a2 = {||}\<rbrakk> \<Longrightarrow> P; \<And>xs ys. \<lbrakk>a1 = ys; a2 = xs; xs = ys\<rbrakk> \<Longrightarrow> P;
+ − 1298
\<And>a xs. \<lbrakk>a1 = finsert a (finsert a xs); a2 = finsert a xs\<rbrakk> \<Longrightarrow> P;
+ − 1299
\<And>xs ys a. \<lbrakk>a1 = finsert a xs; a2 = finsert a ys; xs = ys\<rbrakk> \<Longrightarrow> P;
+ − 1300
\<And>xs1 xs2 xs3. \<lbrakk>a1 = xs1; a2 = xs3; xs1 = xs2; xs2 = xs3\<rbrakk> \<Longrightarrow> P\<rbrakk>
+ − 1301
\<Longrightarrow> P"
+ − 1302
by (lifting list_eq2.cases[simplified list_eq2_equiv[symmetric]])
+ − 1303
+ − 1304
lemma fset_eq_induct:
+ − 1305
assumes "x1 = x2"
+ − 1306
and "\<And>a b xs. P (finsert a (finsert b xs)) (finsert b (finsert a xs))"
+ − 1307
and "P {||} {||}"
+ − 1308
and "\<And>xs ys. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P ys xs"
+ − 1309
and "\<And>a xs. P (finsert a (finsert a xs)) (finsert a xs)"
+ − 1310
and "\<And>xs ys a. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P (finsert a xs) (finsert a ys)"
+ − 1311
and "\<And>xs1 xs2 xs3. \<lbrakk>xs1 = xs2; P xs1 xs2; xs2 = xs3; P xs2 xs3\<rbrakk> \<Longrightarrow> P xs1 xs3"
+ − 1312
shows "P x1 x2"
+ − 1313
using assms
+ − 1314
by (lifting list_eq2.induct[simplified list_eq2_equiv[symmetric]])
1820
+ − 1315
1935
+ − 1316
text {* concat *}
+ − 1317
+ − 1318
lemma fconcat_empty:
+ − 1319
shows "fconcat {||} = {||}"
+ − 1320
by (lifting concat.simps(1))
+ − 1321
2368
+ − 1322
text {* Peter *}
+ − 1323
lemma test: "equivp R ==> a = b --> R a b"
+ − 1324
by (simp add: equivp_def)
+ − 1325
+ − 1326
lemma
+ − 1327
shows "fconcat {||} = {||}"
+ − 1328
apply(lifting_setup concat.simps(1))
+ − 1329
apply(rule test)
+ − 1330
apply(tactic {* resolve_tac (Quotient_Info.equiv_rules_get @{context}) 1 *})
2371
+ − 1331
2368
+ − 1332
sorry
+ − 1333
1935
+ − 1334
lemma fconcat_insert:
+ − 1335
shows "fconcat (finsert x S) = x |\<union>| fconcat S"
+ − 1336
by (lifting concat.simps(2))
+ − 1337
+ − 1338
lemma "fconcat (xs |\<union>| ys) = fconcat xs |\<union>| fconcat ys"
+ − 1339
by (lifting concat_append)
+ − 1340
2084
+ − 1341
text {* ffilter *}
+ − 1342
+ − 1343
lemma subseteq_filter: "ffilter P xs <= ffilter Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)"
+ − 1344
by (lifting sub_list_filter)
+ − 1345
+ − 1346
lemma eq_ffilter: "(ffilter P xs = ffilter Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)"
+ − 1347
by (lifting list_eq_filter)
+ − 1348
+ − 1349
lemma subset_ffilter: "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow> ffilter P xs < ffilter Q xs"
+ − 1350
unfolding less_fset by (auto simp add: subseteq_filter eq_ffilter)
+ − 1351
+ − 1352
section {* lemmas transferred from Finite_Set theory *}
+ − 1353
+ − 1354
text {* finiteness for finite sets holds *}
+ − 1355
lemma finite_fset: "finite (fset_to_set S)"
+ − 1356
by (induct S) auto
+ − 1357
+ − 1358
lemma fset_choice: "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. x |\<in>| A \<longrightarrow> P x (f x)"
+ − 1359
unfolding fset_to_set_trans
+ − 1360
by (rule finite_set_choice[simplified Ball_def, OF finite_fset])
+ − 1361
+ − 1362
lemma fsubseteq_fnil: "xs |\<subseteq>| {||} = (xs = {||})"
+ − 1363
unfolding fset_to_set_trans
+ − 1364
by (rule subset_empty)
+ − 1365
+ − 1366
lemma not_fsubset_fnil: "\<not> xs |\<subset>| {||}"
+ − 1367
unfolding fset_to_set_trans
+ − 1368
by (rule not_psubset_empty)
+ − 1369
+ − 1370
lemma fcard_mono: "xs |\<subseteq>| ys \<Longrightarrow> fcard xs \<le> fcard ys"
+ − 1371
unfolding fset_to_set_trans
+ − 1372
by (rule card_mono[OF finite_fset])
+ − 1373
+ − 1374
lemma fcard_fseteq: "xs |\<subseteq>| ys \<Longrightarrow> fcard ys \<le> fcard xs \<Longrightarrow> xs = ys"
+ − 1375
unfolding fset_to_set_trans
+ − 1376
by (rule card_seteq[OF finite_fset])
+ − 1377
+ − 1378
lemma psubset_fcard_mono: "xs |\<subset>| ys \<Longrightarrow> fcard xs < fcard ys"
+ − 1379
unfolding fset_to_set_trans
+ − 1380
by (rule psubset_card_mono[OF finite_fset])
+ − 1381
+ − 1382
lemma fcard_funion_finter: "fcard xs + fcard ys = fcard (xs |\<union>| ys) + fcard (xs |\<inter>| ys)"
+ − 1383
unfolding fset_to_set_trans
+ − 1384
by (rule card_Un_Int[OF finite_fset finite_fset])
+ − 1385
+ − 1386
lemma fcard_funion_disjoint: "xs |\<inter>| ys = {||} \<Longrightarrow> fcard (xs |\<union>| ys) = fcard xs + fcard ys"
+ − 1387
unfolding fset_to_set_trans
+ − 1388
by (rule card_Un_disjoint[OF finite_fset finite_fset])
+ − 1389
+ − 1390
lemma fcard_delete1_less: "x |\<in>| xs \<Longrightarrow> fcard (fdelete xs x) < fcard xs"
+ − 1391
unfolding fset_to_set_trans
+ − 1392
by (rule card_Diff1_less[OF finite_fset])
+ − 1393
+ − 1394
lemma fcard_delete2_less: "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> fcard (fdelete (fdelete xs x) y) < fcard xs"
+ − 1395
unfolding fset_to_set_trans
+ − 1396
by (rule card_Diff2_less[OF finite_fset])
+ − 1397
+ − 1398
lemma fcard_delete1_le: "fcard (fdelete xs x) <= fcard xs"
+ − 1399
unfolding fset_to_set_trans
+ − 1400
by (rule card_Diff1_le[OF finite_fset])
+ − 1401
+ − 1402
lemma fcard_psubset: "ys |\<subseteq>| xs \<Longrightarrow> fcard ys < fcard xs \<Longrightarrow> ys |\<subset>| xs"
+ − 1403
unfolding fset_to_set_trans
+ − 1404
by (rule card_psubset[OF finite_fset])
+ − 1405
+ − 1406
lemma fcard_fmap_le: "fcard (fmap f xs) \<le> fcard xs"
+ − 1407
unfolding fset_to_set_trans
+ − 1408
by (rule card_image_le[OF finite_fset])
+ − 1409
+ − 1410
lemma fin_fminus_fnotin: "x |\<in>| F - S \<Longrightarrow> x |\<notin>| S"
+ − 1411
unfolding fset_to_set_trans
+ − 1412
by blast
+ − 1413
+ − 1414
lemma fin_fnotin_fminus: "x |\<in>| S \<Longrightarrow> x |\<notin>| F - S"
+ − 1415
unfolding fset_to_set_trans
+ − 1416
by blast
+ − 1417
+ − 1418
lemma fin_mdef: "x |\<in>| F = ((x |\<notin>| (F - {|x|})) & (F = finsert x (F - {|x|})))"
+ − 1419
unfolding fset_to_set_trans
+ − 1420
by blast
+ − 1421
+ − 1422
lemma fcard_fminus_finsert[simp]:
+ − 1423
assumes "a |\<in>| A" and "a |\<notin>| B"
+ − 1424
shows "fcard(A - finsert a B) = fcard(A - B) - 1"
+ − 1425
using assms unfolding fset_to_set_trans
+ − 1426
by (rule card_Diff_insert[OF finite_fset])
+ − 1427
+ − 1428
lemma fcard_fminus_fsubset:
+ − 1429
assumes "B |\<subseteq>| A"
+ − 1430
shows "fcard (A - B) = fcard A - fcard B"
+ − 1431
using assms unfolding fset_to_set_trans
+ − 1432
by (rule card_Diff_subset[OF finite_fset])
+ − 1433
+ − 1434
lemma fcard_fminus_subset_finter:
+ − 1435
"fcard (A - B) = fcard A - fcard (A |\<inter>| B)"
+ − 1436
unfolding fset_to_set_trans
+ − 1437
by (rule card_Diff_subset_Int) (fold inter_set, rule finite_fset)
+ − 1438
2249
+ − 1439
lemma ball_reg_right_unfolded: "(\<forall>x. R x \<longrightarrow> P x \<longrightarrow> Q x) \<longrightarrow> (All P \<longrightarrow> Ball R Q)"
+ − 1440
apply rule
+ − 1441
apply (rule ball_reg_right)
+ − 1442
apply auto
+ − 1443
done
2234
+ − 1444
2326
+ − 1445
lemma list_all2_refl:
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1446
assumes q: "equivp R"
2326
+ − 1447
shows "(list_all2 R) r r"
+ − 1448
by (rule list_all2_refl) (metis equivp_def fset_equivp q)
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1449
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1450
lemma compose_list_refl2:
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1451
assumes q: "equivp R"
2326
+ − 1452
shows "(list_all2 R OOO op \<approx>) r r"
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1453
proof
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1454
have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
2326
+ − 1455
show "list_all2 R r r" by (rule list_all2_refl[OF q])
+ − 1456
with * show "(op \<approx> OO list_all2 R) r r" ..
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1457
qed
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1458
2285
+ − 1459
lemma quotient_compose_list_g:
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1460
assumes q: "Quotient R Abs Rep"
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1461
and e: "equivp R"
2326
+ − 1462
shows "Quotient ((list_all2 R) OOO (op \<approx>))
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1463
(abs_fset \<circ> (map Abs)) ((map Rep) \<circ> rep_fset)"
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1464
unfolding Quotient_def comp_def
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1465
proof (intro conjI allI)
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1466
fix a r s
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1467
show "abs_fset (map Abs (map Rep (rep_fset a))) = a"
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1468
by (simp add: abs_o_rep[OF q] Quotient_abs_rep[OF Quotient_fset] map_id)
2326
+ − 1469
have b: "list_all2 R (map Rep (rep_fset a)) (map Rep (rep_fset a))"
+ − 1470
by (rule list_all2_refl[OF e])
+ − 1471
have c: "(op \<approx> OO list_all2 R) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1472
by (rule, rule equivp_reflp[OF fset_equivp]) (rule b)
2326
+ − 1473
show "(list_all2 R OOO op \<approx>) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
+ − 1474
by (rule, rule list_all2_refl[OF e]) (rule c)
+ − 1475
show "(list_all2 R OOO op \<approx>) r s = ((list_all2 R OOO op \<approx>) r r \<and>
+ − 1476
(list_all2 R OOO op \<approx>) s s \<and> abs_fset (map Abs r) = abs_fset (map Abs s))"
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1477
proof (intro iffI conjI)
2326
+ − 1478
show "(list_all2 R OOO op \<approx>) r r" by (rule compose_list_refl2[OF e])
+ − 1479
show "(list_all2 R OOO op \<approx>) s s" by (rule compose_list_refl2[OF e])
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1480
next
2326
+ − 1481
assume a: "(list_all2 R OOO op \<approx>) r s"
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1482
then have b: "map Abs r \<approx> map Abs s"
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1483
proof (elim pred_compE)
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1484
fix b ba
2326
+ − 1485
assume c: "list_all2 R r b"
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1486
assume d: "b \<approx> ba"
2326
+ − 1487
assume e: "list_all2 R ba s"
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1488
have f: "map Abs r = map Abs b"
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1489
using Quotient_rel[OF list_quotient[OF q]] c by blast
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1490
have "map Abs ba = map Abs s"
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1491
using Quotient_rel[OF list_quotient[OF q]] e by blast
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1492
then have g: "map Abs s = map Abs ba" by simp
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1493
then show "map Abs r \<approx> map Abs s" using d f map_rel_cong by simp
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1494
qed
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1495
then show "abs_fset (map Abs r) = abs_fset (map Abs s)"
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1496
using Quotient_rel[OF Quotient_fset] by blast
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1497
next
2326
+ − 1498
assume a: "(list_all2 R OOO op \<approx>) r r \<and> (list_all2 R OOO op \<approx>) s s
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1499
\<and> abs_fset (map Abs r) = abs_fset (map Abs s)"
2326
+ − 1500
then have s: "(list_all2 R OOO op \<approx>) s s" by simp
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1501
have d: "map Abs r \<approx> map Abs s"
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1502
by (subst Quotient_rel[OF Quotient_fset]) (simp add: a)
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1503
have b: "map Rep (map Abs r) \<approx> map Rep (map Abs s)"
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1504
by (rule map_rel_cong[OF d])
2326
+ − 1505
have y: "list_all2 R (map Rep (map Abs s)) s"
+ − 1506
by (fact rep_abs_rsp_left[OF list_quotient[OF q], OF list_all2_refl[OF e, of s]])
+ − 1507
have c: "(op \<approx> OO list_all2 R) (map Rep (map Abs r)) s"
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1508
by (rule pred_compI) (rule b, rule y)
2326
+ − 1509
have z: "list_all2 R r (map Rep (map Abs r))"
+ − 1510
by (fact rep_abs_rsp[OF list_quotient[OF q], OF list_all2_refl[OF e, of r]])
+ − 1511
then show "(list_all2 R OOO op \<approx>) r s"
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1512
using a c pred_compI by simp
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1513
qed
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1514
qed
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1515
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1516
no_notation
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1517
list_eq (infix "\<approx>" 50)
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1518
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1519
2234
+ − 1520
end