2084
+ − 1
(* Title: HOL/Quotient_Examples/FSet.thy
+ − 2
Author: Cezary Kaliszyk, TU Munich
+ − 3
Author: Christian Urban, TU Munich
1823
+ − 4
2533
+ − 5
Type of finite sets.
1823
+ − 6
*)
2084
+ − 7
1518
+ − 8
theory FSet
2528
+ − 9
imports Quotient_List
1518
+ − 10
begin
+ − 11
2546
+ − 12
text {*
+ − 13
The type of finite sets is created by a quotient construction
+ − 14
over lists. The definition of the equivalence:
+ − 15
*}
1909
+ − 16
1518
+ − 17
fun
+ − 18
list_eq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "\<approx>" 50)
+ − 19
where
2546
+ − 20
"list_eq xs ys \<longleftrightarrow> set xs = set ys"
1518
+ − 21
+ − 22
lemma list_eq_equivp:
+ − 23
shows "equivp list_eq"
1909
+ − 24
unfolding equivp_reflp_symp_transp
1889
+ − 25
unfolding reflp_def symp_def transp_def
+ − 26
by auto
+ − 27
2533
+ − 28
text {* Fset type *}
+ − 29
1909
+ − 30
quotient_type
+ − 31
'a fset = "'a list" / "list_eq"
+ − 32
by (rule list_eq_equivp)
+ − 33
2533
+ − 34
text {*
2540
+ − 35
Definitions for membership, sublist, cardinality,
+ − 36
intersection, difference and respectful fold over
+ − 37
lists.
2372
+ − 38
*}
1909
+ − 39
2546
+ − 40
fun
+ − 41
memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool"
+ − 42
where
+ − 43
"memb x xs \<longleftrightarrow> x \<in> set xs"
1889
+ − 44
2546
+ − 45
fun
+ − 46
sub_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool"
+ − 47
where
+ − 48
"sub_list xs ys \<longleftrightarrow> set xs \<subseteq> set ys"
1889
+ − 49
2546
+ − 50
fun
+ − 51
card_list :: "'a list \<Rightarrow> nat"
+ − 52
where
2536
+ − 53
"card_list xs = card (set xs)"
1518
+ − 54
2546
+ − 55
fun
+ − 56
inter_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
+ − 57
where
2538
+ − 58
"inter_list xs ys = [x \<leftarrow> xs. x \<in> set xs \<and> x \<in> set ys]"
2534
+ − 59
2546
+ − 60
fun
+ − 61
diff_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
+ − 62
where
+ − 63
"diff_list xs ys = [x \<leftarrow> xs. x \<notin> set ys]"
2534
+ − 64
1909
+ − 65
definition
+ − 66
rsp_fold
+ − 67
where
2538
+ − 68
"rsp_fold f \<equiv> \<forall>u v w. (f u (f v w) = f v (f u w))"
1893
+ − 69
1909
+ − 70
primrec
2540
+ − 71
fold_list :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b"
1909
+ − 72
where
2540
+ − 73
"fold_list f z [] = z"
+ − 74
| "fold_list f z (a # xs) =
1909
+ − 75
(if (rsp_fold f) then
2540
+ − 76
if a \<in> set xs then fold_list f z xs
+ − 77
else f a (fold_list f z xs)
1909
+ − 78
else z)"
+ − 79
2533
+ − 80
2540
+ − 81
2533
+ − 82
section {* Quotient composition lemmas *}
1935
+ − 83
2540
+ − 84
lemma list_all2_refl':
2544
+ − 85
assumes q: "equivp R"
+ − 86
shows "(list_all2 R) r r"
+ − 87
by (rule list_all2_refl) (metis equivp_def q)
1938
+ − 88
1935
+ − 89
lemma compose_list_refl:
2544
+ − 90
assumes q: "equivp R"
+ − 91
shows "(list_all2 R OOO op \<approx>) r r"
1935
+ − 92
proof
2084
+ − 93
have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
2544
+ − 94
show "list_all2 R r r" by (rule list_all2_refl'[OF q])
+ − 95
with * show "(op \<approx> OO list_all2 R) r r" ..
1935
+ − 96
qed
+ − 97
2540
+ − 98
lemma map_list_eq_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba"
1935
+ − 99
unfolding list_eq.simps
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 100
by (simp only: set_map)
1935
+ − 101
2544
+ − 102
lemma quotient_compose_list_g:
+ − 103
assumes q: "Quotient R Abs Rep"
+ − 104
and e: "equivp R"
+ − 105
shows "Quotient ((list_all2 R) OOO (op \<approx>))
+ − 106
(abs_fset \<circ> (map Abs)) ((map Rep) \<circ> rep_fset)"
1935
+ − 107
unfolding Quotient_def comp_def
+ − 108
proof (intro conjI allI)
+ − 109
fix a r s
2544
+ − 110
show "abs_fset (map Abs (map Rep (rep_fset a))) = a"
+ − 111
by (simp add: abs_o_rep[OF q] Quotient_abs_rep[OF Quotient_fset] map_id)
+ − 112
have b: "list_all2 R (map Rep (rep_fset a)) (map Rep (rep_fset a))"
+ − 113
by (rule list_all2_refl'[OF e])
+ − 114
have c: "(op \<approx> OO list_all2 R) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
1935
+ − 115
by (rule, rule equivp_reflp[OF fset_equivp]) (rule b)
2544
+ − 116
show "(list_all2 R OOO op \<approx>) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
+ − 117
by (rule, rule list_all2_refl'[OF e]) (rule c)
+ − 118
show "(list_all2 R OOO op \<approx>) r s = ((list_all2 R OOO op \<approx>) r r \<and>
+ − 119
(list_all2 R OOO op \<approx>) s s \<and> abs_fset (map Abs r) = abs_fset (map Abs s))"
1935
+ − 120
proof (intro iffI conjI)
2544
+ − 121
show "(list_all2 R OOO op \<approx>) r r" by (rule compose_list_refl[OF e])
+ − 122
show "(list_all2 R OOO op \<approx>) s s" by (rule compose_list_refl[OF e])
1935
+ − 123
next
2544
+ − 124
assume a: "(list_all2 R OOO op \<approx>) r s"
+ − 125
then have b: "map Abs r \<approx> map Abs s"
2084
+ − 126
proof (elim pred_compE)
1935
+ − 127
fix b ba
2544
+ − 128
assume c: "list_all2 R r b"
1935
+ − 129
assume d: "b \<approx> ba"
2544
+ − 130
assume e: "list_all2 R ba s"
+ − 131
have f: "map Abs r = map Abs b"
+ − 132
using Quotient_rel[OF list_quotient[OF q]] c by blast
+ − 133
have "map Abs ba = map Abs s"
+ − 134
using Quotient_rel[OF list_quotient[OF q]] e by blast
+ − 135
then have g: "map Abs s = map Abs ba" by simp
+ − 136
then show "map Abs r \<approx> map Abs s" using d f map_list_eq_cong by simp
1935
+ − 137
qed
2544
+ − 138
then show "abs_fset (map Abs r) = abs_fset (map Abs s)"
1938
+ − 139
using Quotient_rel[OF Quotient_fset] by blast
1935
+ − 140
next
2544
+ − 141
assume a: "(list_all2 R OOO op \<approx>) r r \<and> (list_all2 R OOO op \<approx>) s s
+ − 142
\<and> abs_fset (map Abs r) = abs_fset (map Abs s)"
+ − 143
then have s: "(list_all2 R OOO op \<approx>) s s" by simp
+ − 144
have d: "map Abs r \<approx> map Abs s"
1935
+ − 145
by (subst Quotient_rel[OF Quotient_fset]) (simp add: a)
2544
+ − 146
have b: "map Rep (map Abs r) \<approx> map Rep (map Abs s)"
2540
+ − 147
by (rule map_list_eq_cong[OF d])
2544
+ − 148
have y: "list_all2 R (map Rep (map Abs s)) s"
+ − 149
by (fact rep_abs_rsp_left[OF list_quotient[OF q], OF list_all2_refl'[OF e, of s]])
+ − 150
have c: "(op \<approx> OO list_all2 R) (map Rep (map Abs r)) s"
1935
+ − 151
by (rule pred_compI) (rule b, rule y)
2544
+ − 152
have z: "list_all2 R r (map Rep (map Abs r))"
+ − 153
by (fact rep_abs_rsp[OF list_quotient[OF q], OF list_all2_refl'[OF e, of r]])
+ − 154
then show "(list_all2 R OOO op \<approx>) r s"
1935
+ − 155
using a c pred_compI by simp
+ − 156
qed
+ − 157
qed
+ − 158
2544
+ − 159
lemma quotient_compose_list[quot_thm]:
+ − 160
shows "Quotient ((list_all2 op \<approx>) OOO (op \<approx>))
+ − 161
(abs_fset \<circ> (map abs_fset)) ((map rep_fset) \<circ> rep_fset)"
+ − 162
by (rule quotient_compose_list_g, rule Quotient_fset, rule list_eq_equivp)
2525
+ − 163
2538
+ − 164
subsection {* Respectfulness lemmas for list operations *}
1893
+ − 165
2538
+ − 166
lemma list_equiv_rsp [quot_respect]:
+ − 167
shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>"
+ − 168
by auto
+ − 169
+ − 170
lemma append_rsp [quot_respect]:
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 171
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) append append"
2533
+ − 172
by simp
1895
+ − 173
2538
+ − 174
lemma sub_list_rsp [quot_respect]:
1909
+ − 175
shows "(op \<approx> ===> op \<approx> ===> op =) sub_list sub_list"
2546
+ − 176
by simp
1909
+ − 177
2538
+ − 178
lemma memb_rsp [quot_respect]:
1909
+ − 179
shows "(op = ===> op \<approx> ===> op =) memb memb"
2546
+ − 180
by simp
1909
+ − 181
2538
+ − 182
lemma nil_rsp [quot_respect]:
2525
+ − 183
shows "(op \<approx>) Nil Nil"
1909
+ − 184
by simp
+ − 185
2538
+ − 186
lemma cons_rsp [quot_respect]:
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 187
shows "(op = ===> op \<approx> ===> op \<approx>) Cons Cons"
1909
+ − 188
by simp
+ − 189
2538
+ − 190
lemma map_rsp [quot_respect]:
1909
+ − 191
shows "(op = ===> op \<approx> ===> op \<approx>) map map"
+ − 192
by auto
+ − 193
2538
+ − 194
lemma set_rsp [quot_respect]:
1909
+ − 195
"(op \<approx> ===> op =) set set"
+ − 196
by auto
+ − 197
2538
+ − 198
lemma inter_list_rsp [quot_respect]:
+ − 199
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) inter_list inter_list"
2546
+ − 200
by simp
1909
+ − 201
2538
+ − 202
lemma removeAll_rsp [quot_respect]:
2525
+ − 203
shows "(op = ===> op \<approx> ===> op \<approx>) removeAll removeAll"
+ − 204
by simp
+ − 205
2538
+ − 206
lemma diff_list_rsp [quot_respect]:
2537
+ − 207
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) diff_list diff_list"
2546
+ − 208
by simp
2525
+ − 209
2538
+ − 210
lemma card_list_rsp [quot_respect]:
2536
+ − 211
shows "(op \<approx> ===> op =) card_list card_list"
2546
+ − 212
by simp
2525
+ − 213
2538
+ − 214
lemma filter_rsp [quot_respect]:
+ − 215
shows "(op = ===> op \<approx> ===> op \<approx>) filter filter"
+ − 216
by simp
2525
+ − 217
2540
+ − 218
lemma memb_commute_fold_list:
+ − 219
assumes a: "rsp_fold f"
+ − 220
and b: "x \<in> set xs"
+ − 221
shows "fold_list f y xs = f x (fold_list f y (removeAll x xs))"
+ − 222
using a b by (induct xs) (auto simp add: rsp_fold_def)
1909
+ − 223
2540
+ − 224
lemma fold_list_rsp_pre:
+ − 225
assumes a: "set xs = set ys"
+ − 226
shows "fold_list f z xs = fold_list f z ys"
+ − 227
using a
+ − 228
apply (induct xs arbitrary: ys)
1909
+ − 229
apply (simp)
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 230
apply (simp (no_asm_use))
1909
+ − 231
apply (rule conjI)
+ − 232
apply (rule_tac [!] impI)
+ − 233
apply (rule_tac [!] conjI)
+ − 234
apply (rule_tac [!] impI)
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 235
apply (metis insert_absorb)
2540
+ − 236
apply (metis List.insert_def List.set.simps(2) List.set_insert fold_list.simps(2))
+ − 237
apply (metis Diff_insert_absorb insertI1 memb_commute_fold_list set_removeAll)
+ − 238
apply(drule_tac x="removeAll a ys" in meta_spec)
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 239
apply(auto)
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 240
apply(drule meta_mp)
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 241
apply(blast)
2540
+ − 242
by (metis List.set.simps(2) emptyE fold_list.simps(2) in_listsp_conv_set listsp.simps mem_def)
1909
+ − 243
2540
+ − 244
lemma fold_list_rsp [quot_respect]:
+ − 245
shows "(op = ===> op = ===> op \<approx> ===> op =) fold_list fold_list"
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 246
unfolding fun_rel_def
2540
+ − 247
by(auto intro: fold_list_rsp_pre)
1909
+ − 248
1935
+ − 249
lemma concat_rsp_pre:
2326
+ − 250
assumes a: "list_all2 op \<approx> x x'"
1935
+ − 251
and b: "x' \<approx> y'"
2326
+ − 252
and c: "list_all2 op \<approx> y' y"
1935
+ − 253
and d: "\<exists>x\<in>set x. xa \<in> set x"
+ − 254
shows "\<exists>x\<in>set y. xa \<in> set x"
+ − 255
proof -
+ − 256
obtain xb where e: "xb \<in> set x" and f: "xa \<in> set xb" using d by auto
2326
+ − 257
have "\<exists>y. y \<in> set x' \<and> xb \<approx> y" by (rule list_all2_find_element[OF e a])
1935
+ − 258
then obtain ya where h: "ya \<in> set x'" and i: "xb \<approx> ya" by auto
2084
+ − 259
have "ya \<in> set y'" using b h by simp
2326
+ − 260
then have "\<exists>yb. yb \<in> set y \<and> ya \<approx> yb" using c by (rule list_all2_find_element)
1935
+ − 261
then show ?thesis using f i by auto
+ − 262
qed
+ − 263
2538
+ − 264
lemma concat_rsp [quot_respect]:
2326
+ − 265
shows "(list_all2 op \<approx> OOO op \<approx> ===> op \<approx>) concat concat"
1935
+ − 266
proof (rule fun_relI, elim pred_compE)
+ − 267
fix a b ba bb
2326
+ − 268
assume a: "list_all2 op \<approx> a ba"
1935
+ − 269
assume b: "ba \<approx> bb"
2326
+ − 270
assume c: "list_all2 op \<approx> bb b"
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 271
have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)"
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 272
proof
1935
+ − 273
fix x
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 274
show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)"
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 275
proof
1935
+ − 276
assume d: "\<exists>xa\<in>set a. x \<in> set xa"
+ − 277
show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d])
+ − 278
next
+ − 279
assume e: "\<exists>xa\<in>set b. x \<in> set xa"
2326
+ − 280
have a': "list_all2 op \<approx> ba a" by (rule list_all2_symp[OF list_eq_equivp, OF a])
1935
+ − 281
have b': "bb \<approx> ba" by (rule equivp_symp[OF list_eq_equivp, OF b])
2326
+ − 282
have c': "list_all2 op \<approx> b bb" by (rule list_all2_symp[OF list_eq_equivp, OF c])
1935
+ − 283
show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e])
+ − 284
qed
+ − 285
qed
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 286
then show "concat a \<approx> concat b" by auto
1935
+ − 287
qed
+ − 288
2084
+ − 289
2539
+ − 290
+ − 291
section {* Quotient definitions for fsets *}
+ − 292
+ − 293
2538
+ − 294
subsection {* Finite sets are a bounded, distributive lattice with minus *}
1905
+ − 295
2528
+ − 296
instantiation fset :: (type) "{bounded_lattice_bot, distrib_lattice, minus}"
1893
+ − 297
begin
+ − 298
+ − 299
quotient_definition
2538
+ − 300
"bot :: 'a fset"
+ − 301
is "Nil :: 'a list"
1893
+ − 302
+ − 303
abbreviation
2540
+ − 304
empty_fset ("{||}")
1893
+ − 305
where
+ − 306
"{||} \<equiv> bot :: 'a fset"
+ − 307
+ − 308
quotient_definition
2538
+ − 309
"less_eq_fset :: ('a fset \<Rightarrow> 'a fset \<Rightarrow> bool)"
+ − 310
is "sub_list :: ('a list \<Rightarrow> 'a list \<Rightarrow> bool)"
1893
+ − 311
+ − 312
abbreviation
2540
+ − 313
subset_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subseteq>|" 50)
1893
+ − 314
where
+ − 315
"xs |\<subseteq>| ys \<equiv> xs \<le> ys"
+ − 316
+ − 317
definition
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 318
less_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool"
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 319
where
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 320
"xs < ys \<equiv> xs \<le> ys \<and> xs \<noteq> (ys::'a fset)"
1893
+ − 321
+ − 322
abbreviation
2540
+ − 323
psubset_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50)
1893
+ − 324
where
+ − 325
"xs |\<subset>| ys \<equiv> xs < ys"
+ − 326
1895
+ − 327
quotient_definition
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 328
"sup :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2538
+ − 329
is "append :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
1895
+ − 330
+ − 331
abbreviation
2540
+ − 332
union_fset (infixl "|\<union>|" 65)
1895
+ − 333
where
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 334
"xs |\<union>| ys \<equiv> sup xs (ys::'a fset)"
1895
+ − 335
1905
+ − 336
quotient_definition
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 337
"inf :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2538
+ − 338
is "inter_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
1905
+ − 339
+ − 340
abbreviation
2540
+ − 341
inter_fset (infixl "|\<inter>|" 65)
1905
+ − 342
where
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 343
"xs |\<inter>| ys \<equiv> inf xs (ys::'a fset)"
1905
+ − 344
2084
+ − 345
quotient_definition
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 346
"minus :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2538
+ − 347
is "diff_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
2084
+ − 348
2533
+ − 349
1895
+ − 350
instance
+ − 351
proof
1905
+ − 352
fix x y z :: "'a fset"
2528
+ − 353
show "x |\<subset>| y \<longleftrightarrow> x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x"
2530
+ − 354
unfolding less_fset_def
2546
+ − 355
by (descending) (auto)
+ − 356
show "x |\<subseteq>| x" by (descending) (simp)
+ − 357
show "{||} |\<subseteq>| x" by (descending) (simp)
+ − 358
show "x |\<subseteq>| x |\<union>| y" by (descending) (simp)
+ − 359
show "y |\<subseteq>| x |\<union>| y" by (descending) (simp)
+ − 360
show "x |\<inter>| y |\<subseteq>| x" by (descending) (auto)
+ − 361
show "x |\<inter>| y |\<subseteq>| y" by (descending) (auto)
2528
+ − 362
show "x |\<union>| (y |\<inter>| z) = x |\<union>| y |\<inter>| (x |\<union>| z)"
2546
+ − 363
by (descending) (auto)
1905
+ − 364
next
+ − 365
fix x y z :: "'a fset"
+ − 366
assume a: "x |\<subseteq>| y"
+ − 367
assume b: "y |\<subseteq>| z"
2546
+ − 368
show "x |\<subseteq>| z" using a b by (descending) (simp)
1895
+ − 369
next
+ − 370
fix x y :: "'a fset"
+ − 371
assume a: "x |\<subseteq>| y"
+ − 372
assume b: "y |\<subseteq>| x"
2546
+ − 373
show "x = y" using a b by (descending) (auto)
1895
+ − 374
next
+ − 375
fix x y z :: "'a fset"
+ − 376
assume a: "y |\<subseteq>| x"
+ − 377
assume b: "z |\<subseteq>| x"
2546
+ − 378
show "y |\<union>| z |\<subseteq>| x" using a b by (descending) (simp)
1905
+ − 379
next
+ − 380
fix x y z :: "'a fset"
+ − 381
assume a: "x |\<subseteq>| y"
+ − 382
assume b: "x |\<subseteq>| z"
2546
+ − 383
show "x |\<subseteq>| y |\<inter>| z" using a b by (descending) (auto)
1895
+ − 384
qed
1905
+ − 385
1893
+ − 386
end
+ − 387
2540
+ − 388
+ − 389
subsection {* Other constants for fsets *}
+ − 390
1518
+ − 391
quotient_definition
2540
+ − 392
"insert_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2534
+ − 393
is "Cons"
1518
+ − 394
+ − 395
syntax
2540
+ − 396
"@Insert_fset" :: "args => 'a fset" ("{|(_)|}")
1518
+ − 397
+ − 398
translations
2540
+ − 399
"{|x, xs|}" == "CONST insert_fset x {|xs|}"
+ − 400
"{|x|}" == "CONST insert_fset x {||}"
1518
+ − 401
+ − 402
quotient_definition
2540
+ − 403
in_fset (infix "|\<in>|" 50)
1518
+ − 404
where
2540
+ − 405
"in_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> bool" is "memb"
1518
+ − 406
+ − 407
abbreviation
2540
+ − 408
notin_fset :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50)
1518
+ − 409
where
1860
+ − 410
"x |\<notin>| S \<equiv> \<not> (x |\<in>| S)"
1518
+ − 411
2540
+ − 412
+ − 413
subsection {* Other constants on the Quotient Type *}
1935
+ − 414
+ − 415
quotient_definition
2540
+ − 416
"card_fset :: 'a fset \<Rightarrow> nat"
2536
+ − 417
is card_list
1935
+ − 418
+ − 419
quotient_definition
2540
+ − 420
"map_fset :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
2534
+ − 421
is map
1935
+ − 422
+ − 423
quotient_definition
2540
+ − 424
"remove_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 425
is removeAll
1935
+ − 426
+ − 427
quotient_definition
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 428
"fset :: 'a fset \<Rightarrow> 'a set"
1935
+ − 429
is "set"
+ − 430
+ − 431
quotient_definition
2540
+ − 432
"fold_fset :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b"
+ − 433
is fold_list
1935
+ − 434
+ − 435
quotient_definition
2540
+ − 436
"concat_fset :: ('a fset) fset \<Rightarrow> 'a fset"
2534
+ − 437
is concat
1935
+ − 438
2084
+ − 439
quotient_definition
2540
+ − 440
"filter_fset :: ('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2534
+ − 441
is filter
2084
+ − 442
2534
+ − 443
2540
+ − 444
subsection {* Compositional respectfulness and preservation lemmas *}
1935
+ − 445
2539
+ − 446
lemma Nil_rsp2 [quot_respect]:
+ − 447
shows "(list_all2 op \<approx> OOO op \<approx>) Nil Nil"
2544
+ − 448
by (rule compose_list_refl, rule list_eq_equivp)
1935
+ − 449
2539
+ − 450
lemma Cons_rsp2 [quot_respect]:
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 451
shows "(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) Cons Cons"
1935
+ − 452
apply auto
+ − 453
apply (rule_tac b="x # b" in pred_compI)
+ − 454
apply auto
+ − 455
apply (rule_tac b="x # ba" in pred_compI)
+ − 456
apply auto
+ − 457
done
+ − 458
2539
+ − 459
lemma map_prs [quot_preserve]:
+ − 460
shows "(abs_fset \<circ> map f) [] = abs_fset []"
+ − 461
by simp
+ − 462
2540
+ − 463
lemma insert_fset_rsp [quot_preserve]:
2541
+ − 464
"(rep_fset ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) Cons = insert_fset"
2479
+ − 465
by (simp add: fun_eq_iff Quotient_abs_rep[OF Quotient_fset]
2540
+ − 466
abs_o_rep[OF Quotient_fset] map_id insert_fset_def)
1935
+ − 467
2540
+ − 468
lemma union_fset_rsp [quot_preserve]:
2541
+ − 469
"((map rep_fset \<circ> rep_fset) ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset))
+ − 470
append = union_fset"
2479
+ − 471
by (simp add: fun_eq_iff Quotient_abs_rep[OF Quotient_fset]
1935
+ − 472
abs_o_rep[OF Quotient_fset] map_id sup_fset_def)
+ − 473
2326
+ − 474
lemma list_all2_app_l:
1935
+ − 475
assumes a: "reflp R"
2326
+ − 476
and b: "list_all2 R l r"
+ − 477
shows "list_all2 R (z @ l) (z @ r)"
1938
+ − 478
by (induct z) (simp_all add: b rev_iffD1[OF a meta_eq_to_obj_eq[OF reflp_def]])
1935
+ − 479
+ − 480
lemma append_rsp2_pre0:
2326
+ − 481
assumes a:"list_all2 op \<approx> x x'"
+ − 482
shows "list_all2 op \<approx> (x @ z) (x' @ z)"
1935
+ − 483
using a apply (induct x x' rule: list_induct2')
2544
+ − 484
by simp_all (rule list_all2_refl'[OF list_eq_equivp])
1935
+ − 485
+ − 486
lemma append_rsp2_pre1:
2326
+ − 487
assumes a:"list_all2 op \<approx> x x'"
+ − 488
shows "list_all2 op \<approx> (z @ x) (z @ x')"
1935
+ − 489
using a apply (induct x x' arbitrary: z rule: list_induct2')
2544
+ − 490
apply (rule list_all2_refl'[OF list_eq_equivp])
1935
+ − 491
apply (simp_all del: list_eq.simps)
2326
+ − 492
apply (rule list_all2_app_l)
1935
+ − 493
apply (simp_all add: reflp_def)
+ − 494
done
+ − 495
+ − 496
lemma append_rsp2_pre:
2326
+ − 497
assumes a:"list_all2 op \<approx> x x'"
+ − 498
and b: "list_all2 op \<approx> z z'"
+ − 499
shows "list_all2 op \<approx> (x @ z) (x' @ z')"
+ − 500
apply (rule list_all2_transp[OF fset_equivp])
1935
+ − 501
apply (rule append_rsp2_pre0)
+ − 502
apply (rule a)
+ − 503
using b apply (induct z z' rule: list_induct2')
+ − 504
apply (simp_all only: append_Nil2)
2544
+ − 505
apply (rule list_all2_refl'[OF list_eq_equivp])
1935
+ − 506
apply simp_all
+ − 507
apply (rule append_rsp2_pre1)
+ − 508
apply simp
+ − 509
done
+ − 510
+ − 511
lemma [quot_respect]:
2539
+ − 512
"(list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) append append"
1935
+ − 513
proof (intro fun_relI, elim pred_compE)
+ − 514
fix x y z w x' z' y' w' :: "'a list list"
2326
+ − 515
assume a:"list_all2 op \<approx> x x'"
1935
+ − 516
and b: "x' \<approx> y'"
2326
+ − 517
and c: "list_all2 op \<approx> y' y"
+ − 518
assume aa: "list_all2 op \<approx> z z'"
1935
+ − 519
and bb: "z' \<approx> w'"
2326
+ − 520
and cc: "list_all2 op \<approx> w' w"
+ − 521
have a': "list_all2 op \<approx> (x @ z) (x' @ z')" using a aa append_rsp2_pre by auto
1935
+ − 522
have b': "x' @ z' \<approx> y' @ w'" using b bb by simp
2326
+ − 523
have c': "list_all2 op \<approx> (y' @ w') (y @ w)" using c cc append_rsp2_pre by auto
+ − 524
have d': "(op \<approx> OO list_all2 op \<approx>) (x' @ z') (y @ w)"
1935
+ − 525
by (rule pred_compI) (rule b', rule c')
2326
+ − 526
show "(list_all2 op \<approx> OOO op \<approx>) (x @ z) (y @ w)"
1935
+ − 527
by (rule pred_compI) (rule a', rule d')
+ − 528
qed
+ − 529
1878
+ − 530
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 531
2534
+ − 532
section {* Lifted theorems *}
+ − 533
+ − 534
subsection {* fset *}
1518
+ − 535
2540
+ − 536
lemma fset_simps [simp]:
2543
+ − 537
shows "fset {||} = {}"
+ − 538
and "fset (insert_fset x S) = insert x (fset S)"
+ − 539
by (descending, simp)+
1518
+ − 540
2534
+ − 541
lemma finite_fset [simp]:
+ − 542
shows "finite (fset S)"
+ − 543
by (descending) (simp)
+ − 544
+ − 545
lemma fset_cong:
+ − 546
shows "fset S = fset T \<longleftrightarrow> S = T"
+ − 547
by (descending) (simp)
+ − 548
2540
+ − 549
lemma filter_fset [simp]:
+ − 550
shows "fset (filter_fset P xs) = P \<inter> fset xs"
2534
+ − 551
by (descending) (auto simp add: mem_def)
+ − 552
2540
+ − 553
lemma remove_fset [simp]:
+ − 554
shows "fset (remove_fset x xs) = fset xs - {x}"
2534
+ − 555
by (descending) (simp)
+ − 556
2540
+ − 557
lemma inter_fset [simp]:
2534
+ − 558
shows "fset (xs |\<inter>| ys) = fset xs \<inter> fset ys"
2546
+ − 559
by (descending) (auto)
2534
+ − 560
2540
+ − 561
lemma union_fset [simp]:
2534
+ − 562
shows "fset (xs |\<union>| ys) = fset xs \<union> fset ys"
+ − 563
by (lifting set_append)
+ − 564
2540
+ − 565
lemma minus_fset [simp]:
2534
+ − 566
shows "fset (xs - ys) = fset xs - fset ys"
2546
+ − 567
by (descending) (auto)
2534
+ − 568
+ − 569
2541
+ − 570
subsection {* in_fset *}
+ − 571
+ − 572
lemma in_fset:
+ − 573
shows "x |\<in>| S \<longleftrightarrow> x \<in> fset S"
2546
+ − 574
by (descending) (simp)
2541
+ − 575
+ − 576
lemma notin_fset:
+ − 577
shows "x |\<notin>| S \<longleftrightarrow> x \<notin> fset S"
+ − 578
by (simp add: in_fset)
+ − 579
+ − 580
lemma notin_empty_fset:
+ − 581
shows "x |\<notin>| {||}"
+ − 582
by (simp add: in_fset)
+ − 583
+ − 584
lemma fset_eq_iff:
+ − 585
shows "S = T \<longleftrightarrow> (\<forall>x. (x |\<in>| S) = (x |\<in>| T))"
2546
+ − 586
by (descending) (auto)
2541
+ − 587
+ − 588
lemma none_in_empty_fset:
+ − 589
shows "(\<forall>x. x |\<notin>| S) \<longleftrightarrow> S = {||}"
2546
+ − 590
by (descending) (simp)
2541
+ − 591
+ − 592
+ − 593
subsection {* insert_fset *}
+ − 594
+ − 595
lemma in_insert_fset_iff [simp]:
+ − 596
shows "x |\<in>| insert_fset y S \<longleftrightarrow> x = y \<or> x |\<in>| S"
2546
+ − 597
by (descending) (simp)
2541
+ − 598
+ − 599
lemma
+ − 600
shows insert_fsetI1: "x |\<in>| insert_fset x S"
+ − 601
and insert_fsetI2: "x |\<in>| S \<Longrightarrow> x |\<in>| insert_fset y S"
+ − 602
by simp_all
+ − 603
+ − 604
lemma insert_absorb_fset [simp]:
+ − 605
shows "x |\<in>| S \<Longrightarrow> insert_fset x S = S"
2546
+ − 606
by (descending) (auto)
2541
+ − 607
+ − 608
lemma empty_not_insert_fset[simp]:
+ − 609
shows "{||} \<noteq> insert_fset x S"
+ − 610
and "insert_fset x S \<noteq> {||}"
+ − 611
by (descending, simp)+
+ − 612
+ − 613
lemma insert_fset_left_comm:
+ − 614
shows "insert_fset x (insert_fset y S) = insert_fset y (insert_fset x S)"
+ − 615
by (descending) (auto)
+ − 616
+ − 617
lemma insert_fset_left_idem:
+ − 618
shows "insert_fset x (insert_fset x S) = insert_fset x S"
+ − 619
by (descending) (auto)
+ − 620
+ − 621
lemma singleton_fset_eq[simp]:
+ − 622
shows "{|x|} = {|y|} \<longleftrightarrow> x = y"
+ − 623
by (descending) (auto)
+ − 624
+ − 625
+ − 626
(* FIXME: is this a useful lemma ? *)
+ − 627
lemma in_fset_mdef:
+ − 628
shows "x |\<in>| F \<longleftrightarrow> x |\<notin>| (F - {|x|}) \<and> F = insert_fset x (F - {|x|})"
2546
+ − 629
by (descending) (auto)
2541
+ − 630
+ − 631
2540
+ − 632
subsection {* union_fset *}
2534
+ − 633
+ − 634
lemmas [simp] =
+ − 635
sup_bot_left[where 'a="'a fset", standard]
+ − 636
sup_bot_right[where 'a="'a fset", standard]
+ − 637
2540
+ − 638
lemma union_insert_fset [simp]:
+ − 639
shows "insert_fset x S |\<union>| T = insert_fset x (S |\<union>| T)"
2534
+ − 640
by (lifting append.simps(2))
+ − 641
2540
+ − 642
lemma singleton_union_fset_left:
+ − 643
shows "{|a|} |\<union>| S = insert_fset a S"
2534
+ − 644
by simp
1518
+ − 645
2540
+ − 646
lemma singleton_union_fset_right:
+ − 647
shows "S |\<union>| {|a|} = insert_fset a S"
2534
+ − 648
by (subst sup.commute) simp
+ − 649
2540
+ − 650
lemma in_union_fset:
2534
+ − 651
shows "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T"
2546
+ − 652
by (descending) (simp)
2534
+ − 653
+ − 654
2540
+ − 655
subsection {* minus_fset *}
2534
+ − 656
2540
+ − 657
lemma minus_in_fset:
2534
+ − 658
shows "x |\<in>| (xs - ys) \<longleftrightarrow> x |\<in>| xs \<and> x |\<notin>| ys"
2546
+ − 659
by (descending) (simp)
2534
+ − 660
2540
+ − 661
lemma minus_insert_fset:
+ − 662
shows "insert_fset x xs - ys = (if x |\<in>| ys then xs - ys else insert_fset x (xs - ys))"
2546
+ − 663
by (descending) (auto)
2534
+ − 664
2540
+ − 665
lemma minus_insert_in_fset[simp]:
+ − 666
shows "x |\<in>| ys \<Longrightarrow> insert_fset x xs - ys = xs - ys"
+ − 667
by (simp add: minus_insert_fset)
2534
+ − 668
2540
+ − 669
lemma minus_insert_notin_fset[simp]:
+ − 670
shows "x |\<notin>| ys \<Longrightarrow> insert_fset x xs - ys = insert_fset x (xs - ys)"
+ − 671
by (simp add: minus_insert_fset)
2534
+ − 672
2541
+ − 673
lemma in_minus_fset:
2534
+ − 674
shows "x |\<in>| F - S \<Longrightarrow> x |\<notin>| S"
2540
+ − 675
unfolding in_fset minus_fset
2534
+ − 676
by blast
+ − 677
2541
+ − 678
lemma notin_minus_fset:
2534
+ − 679
shows "x |\<in>| S \<Longrightarrow> x |\<notin>| F - S"
2540
+ − 680
unfolding in_fset minus_fset
2534
+ − 681
by blast
+ − 682
+ − 683
2540
+ − 684
subsection {* remove_fset *}
2534
+ − 685
2540
+ − 686
lemma in_remove_fset:
+ − 687
shows "x |\<in>| remove_fset y S \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
2546
+ − 688
by (descending) (simp)
1518
+ − 689
2540
+ − 690
lemma notin_remove_fset:
+ − 691
shows "x |\<notin>| remove_fset x S"
2546
+ − 692
by (descending) (simp)
2534
+ − 693
2540
+ − 694
lemma notin_remove_ident_fset:
+ − 695
shows "x |\<notin>| S \<Longrightarrow> remove_fset x S = S"
2546
+ − 696
by (descending) (simp)
2534
+ − 697
2540
+ − 698
lemma remove_fset_cases:
+ − 699
shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = insert_fset x (remove_fset x S))"
2546
+ − 700
by (descending) (auto simp add: insert_absorb)
2534
+ − 701
+ − 702
2540
+ − 703
subsection {* inter_fset *}
2534
+ − 704
2540
+ − 705
lemma inter_empty_fset_l:
2534
+ − 706
shows "{||} |\<inter>| S = {||}"
+ − 707
by simp
+ − 708
2540
+ − 709
lemma inter_empty_fset_r:
2534
+ − 710
shows "S |\<inter>| {||} = {||}"
+ − 711
by simp
+ − 712
2540
+ − 713
lemma inter_insert_fset:
+ − 714
shows "insert_fset x S |\<inter>| T = (if x |\<in>| T then insert_fset x (S |\<inter>| T) else S |\<inter>| T)"
2546
+ − 715
by (descending) (auto)
2534
+ − 716
2540
+ − 717
lemma in_inter_fset:
2534
+ − 718
shows "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
2546
+ − 719
by (descending) (simp)
1533
+ − 720
1518
+ − 721
2540
+ − 722
subsection {* subset_fset and psubset_fset *}
2534
+ − 723
2540
+ − 724
lemma subset_fset:
2534
+ − 725
shows "xs |\<subseteq>| ys \<longleftrightarrow> fset xs \<subseteq> fset ys"
2546
+ − 726
by (descending) (simp)
2534
+ − 727
2540
+ − 728
lemma psubset_fset:
2534
+ − 729
shows "xs |\<subset>| ys \<longleftrightarrow> fset xs \<subset> fset ys"
+ − 730
unfolding less_fset_def
2546
+ − 731
by (descending) (auto)
2534
+ − 732
2540
+ − 733
lemma subset_insert_fset:
+ − 734
shows "(insert_fset x xs) |\<subseteq>| ys \<longleftrightarrow> x |\<in>| ys \<and> xs |\<subseteq>| ys"
2546
+ − 735
by (descending) (simp)
2534
+ − 736
2540
+ − 737
lemma subset_in_fset:
2534
+ − 738
shows "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)"
2546
+ − 739
by (descending) (auto)
2534
+ − 740
2540
+ − 741
lemma subset_empty_fset:
2534
+ − 742
shows "xs |\<subseteq>| {||} \<longleftrightarrow> xs = {||}"
2546
+ − 743
by (descending) (simp)
2534
+ − 744
2541
+ − 745
lemma not_psubset_empty_fset:
2534
+ − 746
shows "\<not> xs |\<subset>| {||}"
2540
+ − 747
by (metis fset_simps(1) psubset_fset not_psubset_empty)
2534
+ − 748
+ − 749
2540
+ − 750
subsection {* map_fset *}
2534
+ − 751
2540
+ − 752
lemma map_fset_simps [simp]:
+ − 753
shows "map_fset f {||} = {||}"
+ − 754
and "map_fset f (insert_fset x S) = insert_fset (f x) (map_fset f S)"
2534
+ − 755
by (descending, simp)+
+ − 756
2540
+ − 757
lemma map_fset_image [simp]:
+ − 758
shows "fset (map_fset f S) = f ` (fset S)"
2534
+ − 759
by (descending) (simp)
+ − 760
2542
+ − 761
lemma inj_map_fset_cong:
2540
+ − 762
shows "inj f \<Longrightarrow> map_fset f S = map_fset f T \<longleftrightarrow> S = T"
2534
+ − 763
by (descending) (metis inj_vimage_image_eq list_eq.simps set_map)
+ − 764
2540
+ − 765
lemma map_union_fset:
+ − 766
shows "map_fset f (S |\<union>| T) = map_fset f S |\<union>| map_fset f T"
2534
+ − 767
by (descending) (simp)
+ − 768
+ − 769
2540
+ − 770
subsection {* card_fset *}
2534
+ − 771
2540
+ − 772
lemma card_fset:
+ − 773
shows "card_fset xs = card (fset xs)"
2546
+ − 774
by (descending) (simp)
1518
+ − 775
2541
+ − 776
lemma card_insert_fset_iff [simp]:
2540
+ − 777
shows "card_fset (insert_fset x S) = (if x |\<in>| S then card_fset S else Suc (card_fset S))"
2546
+ − 778
by (descending) (simp add: insert_absorb)
1518
+ − 779
2540
+ − 780
lemma card_fset_0[simp]:
+ − 781
shows "card_fset S = 0 \<longleftrightarrow> S = {||}"
2546
+ − 782
by (descending) (simp)
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 783
2540
+ − 784
lemma card_empty_fset[simp]:
+ − 785
shows "card_fset {||} = 0"
2541
+ − 786
by (simp add: card_fset)
1813
+ − 787
2540
+ − 788
lemma card_fset_1:
+ − 789
shows "card_fset S = 1 \<longleftrightarrow> (\<exists>x. S = {|x|})"
2546
+ − 790
by (descending) (auto simp add: card_Suc_eq)
1819
+ − 791
2540
+ − 792
lemma card_fset_gt_0:
+ − 793
shows "x \<in> fset S \<Longrightarrow> 0 < card_fset S"
2546
+ − 794
by (descending) (auto simp add: card_gt_0_iff)
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 795
2540
+ − 796
lemma card_notin_fset:
+ − 797
shows "(x |\<notin>| S) = (card_fset (insert_fset x S) = Suc (card_fset S))"
2541
+ − 798
by simp
1813
+ − 799
2540
+ − 800
lemma card_fset_Suc:
+ − 801
shows "card_fset S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = insert_fset x T \<and> card_fset T = n"
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 802
apply(descending)
2546
+ − 803
apply(auto dest!: card_eq_SucD)
2540
+ − 804
by (metis Diff_insert_absorb set_removeAll)
1813
+ − 805
2541
+ − 806
lemma card_remove_fset_iff [simp]:
2540
+ − 807
shows "card_fset (remove_fset y S) = (if y |\<in>| S then card_fset S - 1 else card_fset S)"
2546
+ − 808
by (descending) (simp)
1819
+ − 809
2541
+ − 810
lemma card_Suc_exists_in_fset:
+ − 811
shows "card_fset S = Suc n \<Longrightarrow> \<exists>a. a |\<in>| S"
+ − 812
by (drule card_fset_Suc) (auto)
1878
+ − 813
2541
+ − 814
lemma in_card_fset_not_0:
2540
+ − 815
shows "a |\<in>| A \<Longrightarrow> card_fset A \<noteq> 0"
2546
+ − 816
by (descending) (auto)
1878
+ − 817
2540
+ − 818
lemma card_fset_mono:
+ − 819
shows "xs |\<subseteq>| ys \<Longrightarrow> card_fset xs \<le> card_fset ys"
+ − 820
unfolding card_fset psubset_fset
2546
+ − 821
by (simp add: card_mono subset_fset)
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 822
2540
+ − 823
lemma card_subset_fset_eq:
+ − 824
shows "xs |\<subseteq>| ys \<Longrightarrow> card_fset ys \<le> card_fset xs \<Longrightarrow> xs = ys"
+ − 825
unfolding card_fset subset_fset
2534
+ − 826
by (auto dest: card_seteq[OF finite_fset] simp add: fset_cong)
+ − 827
2540
+ − 828
lemma psubset_card_fset_mono:
+ − 829
shows "xs |\<subset>| ys \<Longrightarrow> card_fset xs < card_fset ys"
+ − 830
unfolding card_fset subset_fset
+ − 831
by (metis finite_fset psubset_fset psubset_card_mono)
2534
+ − 832
2540
+ − 833
lemma card_union_inter_fset:
+ − 834
shows "card_fset xs + card_fset ys = card_fset (xs |\<union>| ys) + card_fset (xs |\<inter>| ys)"
+ − 835
unfolding card_fset union_fset inter_fset
2534
+ − 836
by (rule card_Un_Int[OF finite_fset finite_fset])
+ − 837
2540
+ − 838
lemma card_union_disjoint_fset:
+ − 839
shows "xs |\<inter>| ys = {||} \<Longrightarrow> card_fset (xs |\<union>| ys) = card_fset xs + card_fset ys"
+ − 840
unfolding card_fset union_fset
2534
+ − 841
apply (rule card_Un_disjoint[OF finite_fset finite_fset])
2540
+ − 842
by (metis inter_fset fset_simps(1))
2534
+ − 843
2540
+ − 844
lemma card_remove_fset_less1:
+ − 845
shows "x |\<in>| xs \<Longrightarrow> card_fset (remove_fset x xs) < card_fset xs"
+ − 846
unfolding card_fset in_fset remove_fset
2534
+ − 847
by (rule card_Diff1_less[OF finite_fset])
1518
+ − 848
2541
+ − 849
lemma card_remove_fset_less2:
2540
+ − 850
shows "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> card_fset (remove_fset y (remove_fset x xs)) < card_fset xs"
+ − 851
unfolding card_fset remove_fset in_fset
2534
+ − 852
by (rule card_Diff2_less[OF finite_fset])
+ − 853
2541
+ − 854
lemma card_remove_fset_le1:
2540
+ − 855
shows "card_fset (remove_fset x xs) \<le> card_fset xs"
+ − 856
unfolding remove_fset card_fset
2534
+ − 857
by (rule card_Diff1_le[OF finite_fset])
+ − 858
2540
+ − 859
lemma card_psubset_fset:
+ − 860
shows "ys |\<subseteq>| xs \<Longrightarrow> card_fset ys < card_fset xs \<Longrightarrow> ys |\<subset>| xs"
+ − 861
unfolding card_fset psubset_fset subset_fset
2534
+ − 862
by (rule card_psubset[OF finite_fset])
+ − 863
2540
+ − 864
lemma card_map_fset_le:
+ − 865
shows "card_fset (map_fset f xs) \<le> card_fset xs"
+ − 866
unfolding card_fset map_fset_image
2534
+ − 867
by (rule card_image_le[OF finite_fset])
+ − 868
2540
+ − 869
lemma card_minus_insert_fset[simp]:
2534
+ − 870
assumes "a |\<in>| A" and "a |\<notin>| B"
2540
+ − 871
shows "card_fset (A - insert_fset a B) = card_fset (A - B) - 1"
2534
+ − 872
using assms
2540
+ − 873
unfolding in_fset card_fset minus_fset
2534
+ − 874
by (simp add: card_Diff_insert[OF finite_fset])
+ − 875
2540
+ − 876
lemma card_minus_subset_fset:
2534
+ − 877
assumes "B |\<subseteq>| A"
2540
+ − 878
shows "card_fset (A - B) = card_fset A - card_fset B"
2534
+ − 879
using assms
2540
+ − 880
unfolding subset_fset card_fset minus_fset
2534
+ − 881
by (rule card_Diff_subset[OF finite_fset])
1518
+ − 882
2541
+ − 883
lemma card_minus_fset:
2540
+ − 884
shows "card_fset (A - B) = card_fset A - card_fset (A |\<inter>| B)"
+ − 885
unfolding inter_fset card_fset minus_fset
2534
+ − 886
by (rule card_Diff_subset_Int) (simp)
+ − 887
+ − 888
2540
+ − 889
subsection {* concat_fset *}
2534
+ − 890
2541
+ − 891
lemma concat_empty_fset [simp]:
2540
+ − 892
shows "concat_fset {||} = {||}"
2534
+ − 893
by (lifting concat.simps(1))
+ − 894
2541
+ − 895
lemma concat_insert_fset [simp]:
2540
+ − 896
shows "concat_fset (insert_fset x S) = x |\<union>| concat_fset S"
2534
+ − 897
by (lifting concat.simps(2))
+ − 898
2541
+ − 899
lemma concat_inter_fset [simp]:
2540
+ − 900
shows "concat_fset (xs |\<union>| ys) = concat_fset xs |\<union>| concat_fset ys"
2534
+ − 901
by (lifting concat_append)
+ − 902
+ − 903
2540
+ − 904
subsection {* filter_fset *}
2534
+ − 905
2540
+ − 906
lemma subset_filter_fset:
+ − 907
shows "filter_fset P xs |\<subseteq>| filter_fset Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)"
2546
+ − 908
by (descending) (auto)
2534
+ − 909
2540
+ − 910
lemma eq_filter_fset:
+ − 911
shows "(filter_fset P xs = filter_fset Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)"
2546
+ − 912
by (descending) (auto)
1887
+ − 913
2540
+ − 914
lemma psubset_filter_fset:
+ − 915
shows "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow>
+ − 916
filter_fset P xs |\<subset>| filter_fset Q xs"
+ − 917
unfolding less_fset_def by (auto simp add: subset_filter_fset eq_filter_fset)
2534
+ − 918
+ − 919
2540
+ − 920
subsection {* fold_fset *}
2534
+ − 921
2540
+ − 922
lemma fold_empty_fset:
+ − 923
shows "fold_fset f z {||} = z"
2534
+ − 924
by (descending) (simp)
+ − 925
2540
+ − 926
lemma fold_insert_fset: "fold_fset f z (insert_fset a A) =
+ − 927
(if rsp_fold f then if a |\<in>| A then fold_fset f z A else f a (fold_fset f z A) else z)"
2546
+ − 928
by (descending) (simp)
1887
+ − 929
2540
+ − 930
lemma in_commute_fold_fset:
+ − 931
"\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> fold_fset f z b = f h (fold_fset f z (remove_fset h b))"
2546
+ − 932
by (descending) (simp add: memb_commute_fold_list)
2534
+ − 933
+ − 934
+ − 935
subsection {* Choice in fsets *}
+ − 936
+ − 937
lemma fset_choice:
+ − 938
assumes a: "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y)"
+ − 939
shows "\<exists>f. \<forall>x. x |\<in>| A \<longrightarrow> P x (f x)"
+ − 940
using a
+ − 941
apply(descending)
+ − 942
using finite_set_choice
2546
+ − 943
by (auto simp add: Ball_def)
2534
+ − 944
+ − 945
2539
+ − 946
section {* Induction and Cases rules for fsets *}
+ − 947
2540
+ − 948
lemma fset_exhaust [case_names empty_fset insert_fset, cases type: fset]:
+ − 949
assumes empty_fset_case: "S = {||} \<Longrightarrow> P"
+ − 950
and insert_fset_case: "\<And>x S'. S = insert_fset x S' \<Longrightarrow> P"
2539
+ − 951
shows "P"
+ − 952
using assms by (lifting list.exhaust)
2534
+ − 953
2540
+ − 954
lemma fset_induct [case_names empty_fset insert_fset]:
+ − 955
assumes empty_fset_case: "P {||}"
+ − 956
and insert_fset_case: "\<And>x S. P S \<Longrightarrow> P (insert_fset x S)"
2539
+ − 957
shows "P S"
+ − 958
using assms
+ − 959
by (descending) (blast intro: list.induct)
+ − 960
2540
+ − 961
lemma fset_induct_stronger [case_names empty_fset insert_fset, induct type: fset]:
+ − 962
assumes empty_fset_case: "P {||}"
+ − 963
and insert_fset_case: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (insert_fset x S)"
2539
+ − 964
shows "P S"
+ − 965
proof(induct S rule: fset_induct)
2540
+ − 966
case empty_fset
+ − 967
show "P {||}" using empty_fset_case by simp
2539
+ − 968
next
2540
+ − 969
case (insert_fset x S)
2539
+ − 970
have "P S" by fact
2540
+ − 971
then show "P (insert_fset x S)" using insert_fset_case
2539
+ − 972
by (cases "x |\<in>| S") (simp_all)
+ − 973
qed
1887
+ − 974
2540
+ − 975
lemma fset_card_induct:
+ − 976
assumes empty_fset_case: "P {||}"
+ − 977
and card_fset_Suc_case: "\<And>S T. Suc (card_fset S) = (card_fset T) \<Longrightarrow> P S \<Longrightarrow> P T"
2539
+ − 978
shows "P S"
+ − 979
proof (induct S)
2540
+ − 980
case empty_fset
+ − 981
show "P {||}" by (rule empty_fset_case)
2539
+ − 982
next
2540
+ − 983
case (insert_fset x S)
2539
+ − 984
have h: "P S" by fact
+ − 985
have "x |\<notin>| S" by fact
2540
+ − 986
then have "Suc (card_fset S) = card_fset (insert_fset x S)"
+ − 987
using card_fset_Suc by auto
+ − 988
then show "P (insert_fset x S)"
+ − 989
using h card_fset_Suc_case by simp
2539
+ − 990
qed
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 991
2539
+ − 992
lemma fset_raw_strong_cases:
+ − 993
obtains "xs = []"
+ − 994
| x ys where "\<not> memb x ys" and "xs \<approx> x # ys"
+ − 995
proof (induct xs arbitrary: x ys)
+ − 996
case Nil
+ − 997
then show thesis by simp
+ − 998
next
+ − 999
case (Cons a xs)
+ − 1000
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
+ − 1001
have b: "\<And>x' ys'. \<lbrakk>\<not> memb x' ys'; a # xs \<approx> x' # ys'\<rbrakk> \<Longrightarrow> thesis" by fact
2546
+ − 1002
have c: "xs = [] \<Longrightarrow> thesis" using b
+ − 1003
apply(simp)
+ − 1004
by (metis List.set.simps(1) emptyE empty_subsetI)
2539
+ − 1005
have "\<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis"
+ − 1006
proof -
+ − 1007
fix x :: 'a
+ − 1008
fix ys :: "'a list"
+ − 1009
assume d:"\<not> memb x ys"
+ − 1010
assume e:"xs \<approx> x # ys"
+ − 1011
show thesis
+ − 1012
proof (cases "x = a")
+ − 1013
assume h: "x = a"
+ − 1014
then have f: "\<not> memb a ys" using d by simp
+ − 1015
have g: "a # xs \<approx> a # ys" using e h by auto
+ − 1016
show thesis using b f g by simp
+ − 1017
next
+ − 1018
assume h: "x \<noteq> a"
2546
+ − 1019
then have f: "\<not> memb x (a # ys)" using d by auto
2539
+ − 1020
have g: "a # xs \<approx> x # (a # ys)" using e h by auto
2546
+ − 1021
show thesis using b f g by (simp del: memb.simps)
2539
+ − 1022
qed
+ − 1023
qed
+ − 1024
then show thesis using a c by blast
+ − 1025
qed
+ − 1026
1518
+ − 1027
+ − 1028
lemma fset_strong_cases:
2084
+ − 1029
obtains "xs = {||}"
2540
+ − 1030
| x ys where "x |\<notin>| ys" and "xs = insert_fset x ys"
1819
+ − 1031
by (lifting fset_raw_strong_cases)
1518
+ − 1032
+ − 1033
1533
+ − 1034
lemma fset_induct2:
+ − 1035
"P {||} {||} \<Longrightarrow>
2540
+ − 1036
(\<And>x xs. x |\<notin>| xs \<Longrightarrow> P (insert_fset x xs) {||}) \<Longrightarrow>
+ − 1037
(\<And>y ys. y |\<notin>| ys \<Longrightarrow> P {||} (insert_fset y ys)) \<Longrightarrow>
+ − 1038
(\<And>x xs y ys. \<lbrakk>P xs ys; x |\<notin>| xs; y |\<notin>| ys\<rbrakk> \<Longrightarrow> P (insert_fset x xs) (insert_fset y ys)) \<Longrightarrow>
1533
+ − 1039
P xsa ysa"
+ − 1040
apply (induct xsa arbitrary: ysa)
2539
+ − 1041
apply (induct_tac x rule: fset_induct_stronger)
1533
+ − 1042
apply simp_all
2539
+ − 1043
apply (induct_tac xa rule: fset_induct_stronger)
1533
+ − 1044
apply simp_all
+ − 1045
done
1518
+ − 1046
2539
+ − 1047
+ − 1048
+ − 1049
subsection {* alternate formulation with a different decomposition principle
+ − 1050
and a proof of equivalence *}
+ − 1051
+ − 1052
inductive
+ − 1053
list_eq2 ("_ \<approx>2 _")
+ − 1054
where
+ − 1055
"(a # b # xs) \<approx>2 (b # a # xs)"
+ − 1056
| "[] \<approx>2 []"
+ − 1057
| "xs \<approx>2 ys \<Longrightarrow> ys \<approx>2 xs"
+ − 1058
| "(a # a # xs) \<approx>2 (a # xs)"
+ − 1059
| "xs \<approx>2 ys \<Longrightarrow> (a # xs) \<approx>2 (a # ys)"
+ − 1060
| "\<lbrakk>xs1 \<approx>2 xs2; xs2 \<approx>2 xs3\<rbrakk> \<Longrightarrow> xs1 \<approx>2 xs3"
+ − 1061
+ − 1062
lemma list_eq2_refl:
+ − 1063
shows "xs \<approx>2 xs"
+ − 1064
by (induct xs) (auto intro: list_eq2.intros)
+ − 1065
+ − 1066
lemma cons_delete_list_eq2:
+ − 1067
shows "(a # (removeAll a A)) \<approx>2 (if memb a A then A else a # A)"
+ − 1068
apply (induct A)
2546
+ − 1069
apply (simp add: list_eq2_refl)
2539
+ − 1070
apply (case_tac "memb a (aa # A)")
2546
+ − 1071
apply (simp_all)
2539
+ − 1072
apply (case_tac [!] "a = aa")
+ − 1073
apply (simp_all)
+ − 1074
apply (case_tac "memb a A")
2546
+ − 1075
apply (auto)[2]
2539
+ − 1076
apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6))
+ − 1077
apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6))
+ − 1078
apply (auto simp add: list_eq2_refl memb_def)
+ − 1079
done
+ − 1080
+ − 1081
lemma memb_delete_list_eq2:
+ − 1082
assumes a: "memb e r"
+ − 1083
shows "(e # removeAll e r) \<approx>2 r"
+ − 1084
using a cons_delete_list_eq2[of e r]
+ − 1085
by simp
+ − 1086
+ − 1087
lemma list_eq2_equiv:
+ − 1088
"(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)"
+ − 1089
proof
+ − 1090
show "list_eq2 l r \<Longrightarrow> l \<approx> r" by (induct rule: list_eq2.induct) auto
2084
+ − 1091
next
2539
+ − 1092
{
+ − 1093
fix n
+ − 1094
assume a: "card_list l = n" and b: "l \<approx> r"
+ − 1095
have "l \<approx>2 r"
+ − 1096
using a b
+ − 1097
proof (induct n arbitrary: l r)
+ − 1098
case 0
+ − 1099
have "card_list l = 0" by fact
2546
+ − 1100
then have "\<forall>x. \<not> memb x l" by auto
+ − 1101
then have z: "l = []" by auto
2539
+ − 1102
then have "r = []" using `l \<approx> r` by simp
+ − 1103
then show ?case using z list_eq2_refl by simp
+ − 1104
next
+ − 1105
case (Suc m)
+ − 1106
have b: "l \<approx> r" by fact
+ − 1107
have d: "card_list l = Suc m" by fact
+ − 1108
then have "\<exists>a. memb a l"
2546
+ − 1109
apply(simp)
2539
+ − 1110
apply(drule card_eq_SucD)
+ − 1111
apply(blast)
+ − 1112
done
+ − 1113
then obtain a where e: "memb a l" by auto
+ − 1114
then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b
2546
+ − 1115
by auto
+ − 1116
have f: "card_list (removeAll a l) = m" using e d by (simp)
2539
+ − 1117
have g: "removeAll a l \<approx> removeAll a r" using removeAll_rsp b by simp
2540
+ − 1118
have "(removeAll a l) \<approx>2 (removeAll a r)" by (rule Suc.hyps[OF f g])
+ − 1119
then have h: "(a # removeAll a l) \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(5))
+ − 1120
have i: "l \<approx>2 (a # removeAll a l)"
2539
+ − 1121
by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]])
2540
+ − 1122
have "l \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(6)[OF i h])
2539
+ − 1123
then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp
+ − 1124
qed
+ − 1125
}
2540
+ − 1126
then show "l \<approx> r \<Longrightarrow> l \<approx>2 r" by blast
2084
+ − 1127
qed
+ − 1128
2524
693562f03eee
major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1129
1888
+ − 1130
(* We cannot write it as "assumes .. shows" since Isabelle changes
+ − 1131
the quantifiers to schematic variables and reintroduces them in
+ − 1132
a different order *)
+ − 1133
lemma fset_eq_cases:
+ − 1134
"\<lbrakk>a1 = a2;
2540
+ − 1135
\<And>a b xs. \<lbrakk>a1 = insert_fset a (insert_fset b xs); a2 = insert_fset b (insert_fset a xs)\<rbrakk> \<Longrightarrow> P;
1888
+ − 1136
\<lbrakk>a1 = {||}; a2 = {||}\<rbrakk> \<Longrightarrow> P; \<And>xs ys. \<lbrakk>a1 = ys; a2 = xs; xs = ys\<rbrakk> \<Longrightarrow> P;
2540
+ − 1137
\<And>a xs. \<lbrakk>a1 = insert_fset a (insert_fset a xs); a2 = insert_fset a xs\<rbrakk> \<Longrightarrow> P;
+ − 1138
\<And>xs ys a. \<lbrakk>a1 = insert_fset a xs; a2 = insert_fset a ys; xs = ys\<rbrakk> \<Longrightarrow> P;
1888
+ − 1139
\<And>xs1 xs2 xs3. \<lbrakk>a1 = xs1; a2 = xs3; xs1 = xs2; xs2 = xs3\<rbrakk> \<Longrightarrow> P\<rbrakk>
+ − 1140
\<Longrightarrow> P"
+ − 1141
by (lifting list_eq2.cases[simplified list_eq2_equiv[symmetric]])
+ − 1142
+ − 1143
lemma fset_eq_induct:
+ − 1144
assumes "x1 = x2"
2540
+ − 1145
and "\<And>a b xs. P (insert_fset a (insert_fset b xs)) (insert_fset b (insert_fset a xs))"
1888
+ − 1146
and "P {||} {||}"
+ − 1147
and "\<And>xs ys. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P ys xs"
2540
+ − 1148
and "\<And>a xs. P (insert_fset a (insert_fset a xs)) (insert_fset a xs)"
+ − 1149
and "\<And>xs ys a. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P (insert_fset a xs) (insert_fset a ys)"
1888
+ − 1150
and "\<And>xs1 xs2 xs3. \<lbrakk>xs1 = xs2; P xs1 xs2; xs2 = xs3; P xs2 xs3\<rbrakk> \<Longrightarrow> P xs1 xs3"
+ − 1151
shows "P x1 x2"
+ − 1152
using assms
+ − 1153
by (lifting list_eq2.induct[simplified list_eq2_equiv[symmetric]])
1820
+ − 1154
2528
+ − 1155
ML {*
+ − 1156
fun dest_fsetT (Type (@{type_name fset}, [T])) = T
+ − 1157
| dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []);
+ − 1158
*}
+ − 1159
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1160
no_notation
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1161
list_eq (infix "\<approx>" 50)
2539
+ − 1162
and list_eq2 (infix "\<approx>2" 50)
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1163
2234
+ − 1164
end