author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Mon, 19 Apr 2010 16:19:17 +0200 | |
changeset 1895 | 91d67240c9c1 |
parent 1893 | 464dd13efff6 |
child 1905 | dbc9e88c44da |
child 1912 | 0a857f662e4c |
permissions | -rw-r--r-- |
1823
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
1 |
(* Title: Quotient.thy |
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
2 |
Author: Cezary Kaliszyk |
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
3 |
Author: Christian Urban |
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
4 |
|
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
5 |
provides a reasoning infrastructure for the type of finite sets |
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
6 |
*) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
7 |
theory FSet |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
8 |
imports Quotient Quotient_List List |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
9 |
begin |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
10 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
11 |
fun |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
12 |
list_eq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "\<approx>" 50) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
13 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
14 |
"list_eq xs ys = (\<forall>x. x \<in> set xs \<longleftrightarrow> x \<in> set ys)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
15 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
16 |
lemma list_eq_equivp: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
17 |
shows "equivp list_eq" |
1889
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
18 |
unfolding equivp_reflp_symp_transp |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
19 |
unfolding reflp_def symp_def transp_def |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
20 |
by auto |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
21 |
|
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
22 |
definition |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
23 |
memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
24 |
where |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
25 |
"memb x xs \<equiv> x \<in> set xs" |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
26 |
|
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
27 |
definition |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
28 |
sub_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
29 |
where |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
30 |
"sub_list xs ys \<equiv> (\<forall>x. x \<in> set xs \<longrightarrow> x \<in> set ys)" |
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
31 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
32 |
quotient_type |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
33 |
'a fset = "'a list" / "list_eq" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
34 |
by (rule list_eq_equivp) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
35 |
|
1893
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
36 |
lemma sub_list_rsp1: "\<lbrakk>xs \<approx> ys\<rbrakk> \<Longrightarrow> sub_list xs zs = sub_list ys zs" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
37 |
by (simp add: sub_list_def) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
38 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
39 |
lemma sub_list_rsp2: "\<lbrakk>xs \<approx> ys\<rbrakk> \<Longrightarrow> sub_list zs xs = sub_list zs ys" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
40 |
by (simp add: sub_list_def) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
41 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
42 |
lemma [quot_respect]: |
1895
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
43 |
shows "(op \<approx> ===> op \<approx> ===> op =) sub_list sub_list" |
1893
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
44 |
by (auto simp only: fun_rel_def sub_list_rsp1 sub_list_rsp2) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
45 |
|
1895
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
46 |
lemma [quot_respect]: |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
47 |
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
48 |
by auto |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
49 |
|
1893
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
50 |
lemma sub_list_not_eq: |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
51 |
"(sub_list x y \<and> \<not> list_eq x y) = (sub_list x y \<and> \<not> sub_list y x)" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
52 |
by (auto simp add: sub_list_def) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
53 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
54 |
lemma sub_list_refl: |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
55 |
"sub_list x x" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
56 |
by (simp add: sub_list_def) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
57 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
58 |
lemma sub_list_trans: |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
59 |
"sub_list x y \<Longrightarrow> sub_list y z \<Longrightarrow> sub_list x z" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
60 |
by (simp add: sub_list_def) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
61 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
62 |
lemma sub_list_empty: |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
63 |
"sub_list [] x" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
64 |
by (simp add: sub_list_def) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
65 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
66 |
instantiation fset :: (type) bot |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
67 |
begin |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
68 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
69 |
quotient_definition |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
70 |
"bot :: 'a fset" is "[] :: 'a list" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
71 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
72 |
abbreviation |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
73 |
fempty ("{||}") |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
74 |
where |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
75 |
"{||} \<equiv> bot :: 'a fset" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
76 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
77 |
quotient_definition |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
78 |
"less_eq_fset \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> bool)" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
79 |
is |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
80 |
"sub_list \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> bool)" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
81 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
82 |
abbreviation |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
83 |
f_subset_eq :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subseteq>|" 50) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
84 |
where |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
85 |
"xs |\<subseteq>| ys \<equiv> xs \<le> ys" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
86 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
87 |
definition |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
88 |
less_fset: |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
89 |
"(xs :: 'a fset) < ys \<equiv> xs \<le> ys \<and> xs \<noteq> ys" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
90 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
91 |
abbreviation |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
92 |
f_subset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
93 |
where |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
94 |
"xs |\<subset>| ys \<equiv> xs < ys" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
95 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
96 |
instance |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
97 |
proof |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
98 |
fix x y z :: "'a fset" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
99 |
show "(x |\<subset>| y) = (x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x)" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
100 |
unfolding less_fset by (lifting sub_list_not_eq) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
101 |
show "x |\<subseteq>| x" by (lifting sub_list_refl) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
102 |
show "{||} |\<subseteq>| x" by (lifting sub_list_empty) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
103 |
next |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
104 |
fix x y z :: "'a fset" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
105 |
assume a: "x |\<subseteq>| y" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
106 |
assume b: "y |\<subseteq>| z" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
107 |
show "x |\<subseteq>| z" using a b by (lifting sub_list_trans) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
108 |
qed |
1895
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
109 |
end |
1893
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
110 |
|
1895
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
111 |
lemma sub_list_append_left: |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
112 |
"sub_list x (x @ y)" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
113 |
by (simp add: sub_list_def) |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
114 |
|
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
115 |
lemma sub_list_append_right: |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
116 |
"sub_list y (x @ y)" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
117 |
by (simp add: sub_list_def) |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
118 |
|
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
119 |
lemma sub_list_list_eq: |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
120 |
"sub_list x y \<Longrightarrow> sub_list y x \<Longrightarrow> list_eq x y" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
121 |
unfolding sub_list_def list_eq.simps by blast |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
122 |
|
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
123 |
lemma sub_list_append: |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
124 |
"sub_list y x \<Longrightarrow> sub_list z x \<Longrightarrow> sub_list (y @ z) x" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
125 |
unfolding sub_list_def by auto |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
126 |
|
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
127 |
instantiation fset :: (type) "semilattice_sup" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
128 |
begin |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
129 |
|
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
130 |
quotient_definition |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
131 |
"sup \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
132 |
is |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
133 |
"(op @) \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
134 |
|
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
135 |
abbreviation |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
136 |
funion (infixl "|\<union>|" 65) |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
137 |
where |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
138 |
"xs |\<union>| ys \<equiv> sup (xs :: 'a fset) ys" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
139 |
|
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
140 |
instance |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
141 |
proof |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
142 |
fix x y :: "'a fset" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
143 |
show "x |\<subseteq>| x |\<union>| y" by (lifting sub_list_append_left) |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
144 |
show "y |\<subseteq>| x |\<union>| y" by (lifting sub_list_append_right) |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
145 |
next |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
146 |
fix x y :: "'a fset" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
147 |
assume a: "x |\<subseteq>| y" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
148 |
assume b: "y |\<subseteq>| x" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
149 |
show "x = y" using a b by (lifting sub_list_list_eq) |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
150 |
next |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
151 |
fix x y z :: "'a fset" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
152 |
assume a: "y |\<subseteq>| x" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
153 |
assume b: "z |\<subseteq>| x" |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
154 |
show "y |\<union>| z |\<subseteq>| x" using a b by (lifting sub_list_append) |
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
155 |
qed |
1893
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
156 |
end |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
157 |
|
1860 | 158 |
section {* Empty fset, Finsert and Membership *} |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
159 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
160 |
quotient_definition |
1893
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
161 |
"finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
162 |
is "op #" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
163 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
164 |
syntax |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
165 |
"@Finset" :: "args => 'a fset" ("{|(_)|}") |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
166 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
167 |
translations |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
168 |
"{|x, xs|}" == "CONST finsert x {|xs|}" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
169 |
"{|x|}" == "CONST finsert x {||}" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
170 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
171 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
172 |
fin ("_ |\<in>| _" [50, 51] 50) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
173 |
where |
1816
56cebe7f8e24
some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents:
1682
diff
changeset
|
174 |
"fin :: 'a \<Rightarrow> 'a fset \<Rightarrow> bool" is "memb" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
175 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
176 |
abbreviation |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
177 |
fnotin :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" ("_ |\<notin>| _" [50, 51] 50) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
178 |
where |
1860 | 179 |
"x |\<notin>| S \<equiv> \<not> (x |\<in>| S)" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
180 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
181 |
lemma memb_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
182 |
shows "(op = ===> op \<approx> ===> op =) memb memb" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
183 |
by (auto simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
184 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
185 |
lemma nil_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
186 |
shows "[] \<approx> []" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
187 |
by simp |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
188 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
189 |
lemma cons_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
190 |
shows "(op = ===> op \<approx> ===> op \<approx>) op # op #" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
191 |
by simp |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
192 |
|
1816
56cebe7f8e24
some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents:
1682
diff
changeset
|
193 |
section {* Augmenting an fset -- @{const finsert} *} |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
194 |
|
1892 | 195 |
lemma nil_not_cons: |
196 |
shows "\<not> ([] \<approx> x # xs)" |
|
197 |
and "\<not> (x # xs \<approx> [])" |
|
198 |
by auto |
|
199 |
||
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
200 |
lemma not_memb_nil: |
1860 | 201 |
shows "\<not> memb x []" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
202 |
by (simp add: memb_def) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
203 |
|
1878
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
204 |
lemma no_memb_nil: |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
205 |
"(\<forall>x. \<not> memb x xs) = (xs = [])" |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
206 |
by (simp add: memb_def) |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
207 |
|
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
208 |
lemma none_memb_nil: |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
209 |
"(\<forall>x. \<not> memb x xs) = (xs \<approx> [])" |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
210 |
by (simp add: memb_def) |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
211 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
212 |
lemma memb_cons_iff: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
213 |
shows "memb x (y # xs) = (x = y \<or> memb x xs)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
214 |
by (induct xs) (auto simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
215 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
216 |
lemma memb_consI1: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
217 |
shows "memb x (x # xs)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
218 |
by (simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
219 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
220 |
lemma memb_consI2: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
221 |
shows "memb x xs \<Longrightarrow> memb x (y # xs)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
222 |
by (simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
223 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
224 |
lemma memb_absorb: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
225 |
shows "memb x xs \<Longrightarrow> x # xs \<approx> xs" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
226 |
by (induct xs) (auto simp add: memb_def id_simps) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
227 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
228 |
section {* Singletons *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
229 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
230 |
lemma singleton_list_eq: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
231 |
shows "[x] \<approx> [y] \<longleftrightarrow> x = y" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
232 |
by (simp add: id_simps) auto |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
233 |
|
1892 | 234 |
section {* sub_list *} |
235 |
||
236 |
lemma sub_list_cons: |
|
237 |
"sub_list (x # xs) ys = (memb x ys \<and> sub_list xs ys)" |
|
238 |
by (auto simp add: memb_def sub_list_def) |
|
239 |
||
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
240 |
section {* Cardinality of finite sets *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
241 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
242 |
fun |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
243 |
fcard_raw :: "'a list \<Rightarrow> nat" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
244 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
245 |
fcard_raw_nil: "fcard_raw [] = 0" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
246 |
| fcard_raw_cons: "fcard_raw (x # xs) = (if memb x xs then fcard_raw xs else Suc (fcard_raw xs))" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
247 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
248 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
249 |
"fcard :: 'a fset \<Rightarrow> nat" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
250 |
is |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
251 |
"fcard_raw" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
252 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
253 |
lemma fcard_raw_0: |
1860 | 254 |
shows "fcard_raw xs = 0 \<longleftrightarrow> xs \<approx> []" |
1821 | 255 |
by (induct xs) (auto simp add: memb_def) |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
256 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
257 |
lemma fcard_raw_gt_0: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
258 |
assumes a: "x \<in> set xs" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
259 |
shows "0 < fcard_raw xs" |
1860 | 260 |
using a by (induct xs) (auto simp add: memb_def) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
261 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
262 |
lemma fcard_raw_not_memb: |
1860 | 263 |
shows "\<not> memb x xs \<longleftrightarrow> fcard_raw (x # xs) = Suc (fcard_raw xs)" |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
264 |
by auto |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
265 |
|
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
266 |
lemma fcard_raw_suc: |
1860 | 267 |
assumes a: "fcard_raw xs = Suc n" |
268 |
shows "\<exists>x ys. \<not> (memb x ys) \<and> xs \<approx> (x # ys) \<and> fcard_raw ys = n" |
|
269 |
using a |
|
270 |
by (induct xs) (auto simp add: memb_def split: if_splits) |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
271 |
|
1821 | 272 |
lemma singleton_fcard_1: |
1860 | 273 |
shows "set xs = {x} \<Longrightarrow> fcard_raw xs = 1" |
274 |
by (induct xs) (auto simp add: memb_def subset_insert) |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
275 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
276 |
lemma fcard_raw_1: |
1823
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
277 |
shows "fcard_raw xs = 1 \<longleftrightarrow> (\<exists>x. xs \<approx> [x])" |
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
278 |
apply (auto dest!: fcard_raw_suc) |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
279 |
apply (simp add: fcard_raw_0) |
1821 | 280 |
apply (rule_tac x="x" in exI) |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
281 |
apply simp |
1821 | 282 |
apply (subgoal_tac "set xs = {x}") |
1860 | 283 |
apply (drule singleton_fcard_1) |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
284 |
apply auto |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
285 |
done |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
286 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
287 |
lemma fcard_raw_delete_one: |
1860 | 288 |
shows "fcard_raw ([x \<leftarrow> xs. x \<noteq> y]) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
289 |
by (induct xs) (auto dest: fcard_raw_gt_0 simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
290 |
|
1878
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
291 |
lemma fcard_raw_suc_memb: |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
292 |
assumes a: "fcard_raw A = Suc n" |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
293 |
shows "\<exists>a. memb a A" |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
294 |
using a |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
295 |
apply (induct A) |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
296 |
apply simp |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
297 |
apply (rule_tac x="a" in exI) |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
298 |
apply (simp add: memb_def) |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
299 |
done |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
300 |
|
1884 | 301 |
lemma memb_card_not_0: |
1878
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
302 |
assumes a: "memb a A" |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
303 |
shows "\<not>(fcard_raw A = 0)" |
1883
b2fa5de30a73
Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1881
diff
changeset
|
304 |
proof - |
b2fa5de30a73
Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1881
diff
changeset
|
305 |
have "\<not>(\<forall>x. \<not> memb x A)" using a by auto |
b2fa5de30a73
Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1881
diff
changeset
|
306 |
then have "\<not>A \<approx> []" using none_memb_nil[of A] by simp |
b2fa5de30a73
Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1881
diff
changeset
|
307 |
then show ?thesis using fcard_raw_0[of A] by simp |
b2fa5de30a73
Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1881
diff
changeset
|
308 |
qed |
1878
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
309 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
310 |
lemma fcard_raw_rsp_aux: |
1821 | 311 |
assumes a: "xs \<approx> ys" |
312 |
shows "fcard_raw xs = fcard_raw ys" |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
313 |
using a |
1821 | 314 |
apply(induct xs arbitrary: ys) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
315 |
apply(auto simp add: memb_def) |
1884 | 316 |
apply(subgoal_tac "\<forall>x. (x \<in> set xs) = (x \<in> set ys)") |
317 |
apply simp |
|
318 |
apply auto |
|
319 |
apply (drule_tac x="x" in spec) |
|
320 |
apply blast |
|
1821 | 321 |
apply(drule_tac x="[x \<leftarrow> ys. x \<noteq> a]" in meta_spec) |
1884 | 322 |
apply(simp add: fcard_raw_delete_one memb_def) |
1885 | 323 |
apply (case_tac "a \<in> set ys") |
324 |
apply (simp only: if_True) |
|
325 |
apply (subgoal_tac "\<forall>x. (x \<in> set xs) = (x \<in> set ys \<and> x \<noteq> a)") |
|
326 |
apply (drule Suc_pred'[OF fcard_raw_gt_0]) |
|
327 |
apply auto |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
328 |
done |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
329 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
330 |
lemma fcard_raw_rsp[quot_respect]: |
1860 | 331 |
shows "(op \<approx> ===> op =) fcard_raw fcard_raw" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
332 |
by (simp add: fcard_raw_rsp_aux) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
333 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
334 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
335 |
section {* fmap and fset comprehension *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
336 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
337 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
338 |
"fmap :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
339 |
is |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
340 |
"map" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
341 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
342 |
lemma map_append: |
1821 | 343 |
"map f (xs @ ys) \<approx> (map f xs) @ (map f ys)" |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
344 |
by simp |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
345 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
346 |
lemma memb_append: |
1823
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
347 |
"memb x (xs @ ys) \<longleftrightarrow> memb x xs \<or> memb x ys" |
1821 | 348 |
by (induct xs) (simp_all add: not_memb_nil memb_cons_iff) |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
349 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
350 |
text {* raw section *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
351 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
352 |
lemma map_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
353 |
shows "(op = ===> op \<approx> ===> op \<approx>) map map" |
1822 | 354 |
by auto |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
355 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
356 |
lemma cons_left_comm: |
1821 | 357 |
"x # y # xs \<approx> y # x # xs" |
358 |
by auto |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
359 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
360 |
lemma cons_left_idem: |
1821 | 361 |
"x # x # xs \<approx> x # xs" |
362 |
by auto |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
363 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
364 |
lemma fset_raw_strong_cases: |
1822 | 365 |
"(xs = []) \<or> (\<exists>x ys. ((\<not> memb x ys) \<and> (xs \<approx> x # ys)))" |
1821 | 366 |
apply (induct xs) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
367 |
apply (simp) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
368 |
apply (rule disjI2) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
369 |
apply (erule disjE) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
370 |
apply (rule_tac x="a" in exI) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
371 |
apply (rule_tac x="[]" in exI) |
1822 | 372 |
apply (simp add: memb_def) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
373 |
apply (erule exE)+ |
1821 | 374 |
apply (case_tac "x = a") |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
375 |
apply (rule_tac x="a" in exI) |
1821 | 376 |
apply (rule_tac x="ys" in exI) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
377 |
apply (simp) |
1821 | 378 |
apply (rule_tac x="x" in exI) |
379 |
apply (rule_tac x="a # ys" in exI) |
|
1822 | 380 |
apply (auto simp add: memb_def) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
381 |
done |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
382 |
|
1860 | 383 |
section {* deletion *} |
384 |
||
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
385 |
fun |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
386 |
delete_raw :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
387 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
388 |
"delete_raw [] x = []" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
389 |
| "delete_raw (a # A) x = (if (a = x) then delete_raw A x else a # (delete_raw A x))" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
390 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
391 |
lemma memb_delete_raw: |
1821 | 392 |
"memb x (delete_raw xs y) = (memb x xs \<and> x \<noteq> y)" |
393 |
by (induct xs arbitrary: x y) (auto simp add: memb_def) |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
394 |
|
1825
1d6a0aeef4a1
merge part: delete_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1824
diff
changeset
|
395 |
lemma delete_raw_rsp: |
1860 | 396 |
"xs \<approx> ys \<Longrightarrow> delete_raw xs x \<approx> delete_raw ys x" |
1825
1d6a0aeef4a1
merge part: delete_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1824
diff
changeset
|
397 |
by (simp add: memb_def[symmetric] memb_delete_raw) |
1d6a0aeef4a1
merge part: delete_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1824
diff
changeset
|
398 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
399 |
lemma [quot_respect]: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
400 |
"(op \<approx> ===> op = ===> op \<approx>) delete_raw delete_raw" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
401 |
by (simp add: memb_def[symmetric] memb_delete_raw) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
402 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
403 |
lemma memb_delete_raw_ident: |
1860 | 404 |
shows "\<not> memb x (delete_raw xs x)" |
1821 | 405 |
by (induct xs) (auto simp add: memb_def) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
406 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
407 |
lemma not_memb_delete_raw_ident: |
1860 | 408 |
shows "\<not> memb x xs \<Longrightarrow> delete_raw xs x = xs" |
1821 | 409 |
by (induct xs) (auto simp add: memb_def) |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
410 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
411 |
lemma fset_raw_delete_raw_cases: |
1821 | 412 |
"xs = [] \<or> (\<exists>x. memb x xs \<and> xs \<approx> x # delete_raw xs x)" |
413 |
by (induct xs) (auto simp add: memb_def) |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
414 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
415 |
lemma fdelete_raw_filter: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
416 |
"delete_raw xs y = [x \<leftarrow> xs. x \<noteq> y]" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
417 |
by (induct xs) simp_all |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
418 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
419 |
lemma fcard_raw_delete: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
420 |
"fcard_raw (delete_raw xs y) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
421 |
by (simp add: fdelete_raw_filter fcard_raw_delete_one) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
422 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
423 |
lemma set_rsp[quot_respect]: |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
424 |
"(op \<approx> ===> op =) set set" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
425 |
by auto |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
426 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
427 |
definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
428 |
rsp_fold |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
429 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
430 |
"rsp_fold f = (\<forall>u v w. (f u (f v w) = f v (f u w)))" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
431 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
432 |
primrec |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
433 |
ffold_raw :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
434 |
where |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
435 |
"ffold_raw f z [] = z" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
436 |
| "ffold_raw f z (a # A) = |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
437 |
(if (rsp_fold f) then |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
438 |
if memb a A then ffold_raw f z A |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
439 |
else f a (ffold_raw f z A) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
440 |
else z)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
441 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
442 |
lemma memb_commute_ffold_raw: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
443 |
"rsp_fold f \<Longrightarrow> memb h b \<Longrightarrow> ffold_raw f z b = f h (ffold_raw f z (delete_raw b h))" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
444 |
apply (induct b) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
445 |
apply (simp add: not_memb_nil) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
446 |
apply (simp add: ffold_raw.simps) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
447 |
apply (rule conjI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
448 |
apply (rule_tac [!] impI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
449 |
apply (rule_tac [!] conjI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
450 |
apply (rule_tac [!] impI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
451 |
apply (simp_all add: memb_delete_raw) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
452 |
apply (simp add: memb_cons_iff) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
453 |
apply (simp add: not_memb_delete_raw_ident) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
454 |
apply (simp add: memb_cons_iff rsp_fold_def) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
455 |
done |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
456 |
|
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
457 |
lemma ffold_raw_rsp_pre: |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
458 |
"\<forall>e. memb e a = memb e b \<Longrightarrow> ffold_raw f z a = ffold_raw f z b" |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
459 |
apply (induct a arbitrary: b) |
1824
2ccc1b00377c
merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1823
diff
changeset
|
460 |
apply (simp add: hd_in_set memb_absorb memb_def none_memb_nil) |
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
461 |
apply (simp add: ffold_raw.simps) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
462 |
apply (rule conjI) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
463 |
apply (rule_tac [!] impI) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
464 |
apply (rule_tac [!] conjI) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
465 |
apply (rule_tac [!] impI) |
1884 | 466 |
apply (subgoal_tac "\<forall>e. memb e a2 = memb e b") |
467 |
apply (simp) |
|
468 |
apply (simp add: memb_cons_iff memb_def) |
|
469 |
apply auto |
|
470 |
apply (drule_tac x="e" in spec) |
|
471 |
apply blast |
|
1886 | 472 |
apply (case_tac b) |
473 |
apply simp_all |
|
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
474 |
apply (subgoal_tac "ffold_raw f z b = f a1 (ffold_raw f z (delete_raw b a1))") |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
475 |
apply (simp only:) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
476 |
apply (rule_tac f="f a1" in arg_cong) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
477 |
apply (subgoal_tac "\<forall>e. memb e a2 = memb e (delete_raw b a1)") |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
478 |
apply simp |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
479 |
apply (simp add: memb_delete_raw) |
1883
b2fa5de30a73
Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1881
diff
changeset
|
480 |
apply (auto simp add: memb_cons_iff)[1] |
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
481 |
apply (erule memb_commute_ffold_raw) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
482 |
apply (drule_tac x="a1" in spec) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
483 |
apply (simp add: memb_cons_iff) |
1886 | 484 |
apply (simp add: memb_cons_iff) |
485 |
apply (case_tac b) |
|
486 |
apply simp_all |
|
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
487 |
done |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
488 |
|
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
489 |
lemma [quot_respect]: |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
490 |
"(op = ===> op = ===> op \<approx> ===> op =) ffold_raw ffold_raw" |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
491 |
by (simp add: memb_def[symmetric] ffold_raw_rsp_pre) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
492 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
493 |
primrec |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
494 |
finter_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
495 |
where |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
496 |
"finter_raw [] l = []" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
497 |
| "finter_raw (h # t) l = |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
498 |
(if memb h l then h # (finter_raw t l) else finter_raw t l)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
499 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
500 |
lemma finter_raw_empty: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
501 |
"finter_raw l [] = []" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
502 |
by (induct l) (simp_all add: not_memb_nil) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
503 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
504 |
lemma memb_finter_raw: |
1823
91ba55dba5e0
added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents:
1822
diff
changeset
|
505 |
"memb x (finter_raw xs ys) \<longleftrightarrow> memb x xs \<and> memb x ys" |
1822 | 506 |
apply (induct xs) |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
507 |
apply (simp add: not_memb_nil) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
508 |
apply (simp add: finter_raw.simps) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
509 |
apply (simp add: memb_cons_iff) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
510 |
apply auto |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
511 |
done |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
512 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
513 |
lemma [quot_respect]: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
514 |
"(op \<approx> ===> op \<approx> ===> op \<approx>) finter_raw finter_raw" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
515 |
by (simp add: memb_def[symmetric] memb_finter_raw) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
516 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
517 |
section {* Constants on the Quotient Type *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
518 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
519 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
520 |
"fdelete :: 'a fset \<Rightarrow> 'a \<Rightarrow> 'a fset" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
521 |
is "delete_raw" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
522 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
523 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
524 |
"fset_to_set :: 'a fset \<Rightarrow> 'a set" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
525 |
is "set" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
526 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
527 |
quotient_definition |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
528 |
"ffold :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
529 |
is "ffold_raw" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
530 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
531 |
quotient_definition |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
532 |
finter (infix "|\<inter>|" 50) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
533 |
where |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
534 |
"finter :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
535 |
is "finter_raw" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
536 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
537 |
lemma funion_sym_pre: |
1822 | 538 |
"xs @ ys \<approx> ys @ xs" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
539 |
by auto |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
540 |
|
1821 | 541 |
lemma set_cong: |
542 |
shows "(set x = set y) = (x \<approx> y)" |
|
543 |
by auto |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
544 |
|
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
545 |
lemma inj_map_eq_iff: |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
546 |
"inj f \<Longrightarrow> (map f l \<approx> map f m) = (l \<approx> m)" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
547 |
by (simp add: expand_set_eq[symmetric] inj_image_eq_iff) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
548 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
549 |
quotient_definition |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
550 |
"fconcat :: ('a fset) fset \<Rightarrow> 'a fset" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
551 |
is |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
552 |
"concat" |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
553 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
554 |
lemma list_equiv_rsp[quot_respect]: |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
555 |
shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
556 |
by auto |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
557 |
|
1888
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
558 |
text {* alternate formulation with a different decomposition principle |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
559 |
and a proof of equivalence *} |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
560 |
|
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
561 |
inductive |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
562 |
list_eq2 |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
563 |
where |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
564 |
"list_eq2 (a # b # xs) (b # a # xs)" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
565 |
| "list_eq2 [] []" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
566 |
| "list_eq2 xs ys \<Longrightarrow> list_eq2 ys xs" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
567 |
| "list_eq2 (a # a # xs) (a # xs)" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
568 |
| "list_eq2 xs ys \<Longrightarrow> list_eq2 (a # xs) (a # ys)" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
569 |
| "\<lbrakk>list_eq2 xs1 xs2; list_eq2 xs2 xs3\<rbrakk> \<Longrightarrow> list_eq2 xs1 xs3" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
570 |
|
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
571 |
lemma list_eq2_refl: |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
572 |
shows "list_eq2 xs xs" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
573 |
by (induct xs) (auto intro: list_eq2.intros) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
574 |
|
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
575 |
lemma cons_delete_list_eq2: |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
576 |
shows "list_eq2 (a # (delete_raw A a)) (if memb a A then A else a # A)" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
577 |
apply (induct A) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
578 |
apply (simp add: memb_def list_eq2_refl) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
579 |
apply (case_tac "memb a (aa # A)") |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
580 |
apply (simp_all only: memb_cons_iff) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
581 |
apply (case_tac [!] "a = aa") |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
582 |
apply (simp_all add: delete_raw.simps) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
583 |
apply (case_tac "memb a A") |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
584 |
apply (auto simp add: memb_def)[2] |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
585 |
apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6)) |
1895
91d67240c9c1
FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1893
diff
changeset
|
586 |
apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6)) |
1888
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
587 |
apply (auto simp add: list_eq2_refl not_memb_delete_raw_ident) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
588 |
done |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
589 |
|
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
590 |
lemma memb_delete_list_eq2: |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
591 |
assumes a: "memb e r" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
592 |
shows "list_eq2 (e # delete_raw r e) r" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
593 |
using a cons_delete_list_eq2[of e r] |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
594 |
by simp |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
595 |
|
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
596 |
lemma list_eq2_equiv_aux: |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
597 |
assumes a: "fcard_raw l = n" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
598 |
and b: "l \<approx> r" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
599 |
shows "list_eq2 l r" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
600 |
using a b |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
601 |
proof (induct n arbitrary: l r) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
602 |
case 0 |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
603 |
have "fcard_raw l = 0" by fact |
1889
6c5b5ec53a0b
sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1888
diff
changeset
|
604 |
then have "\<forall>x. \<not> memb x l" using memb_card_not_0[of _ l] by auto |
1888
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
605 |
then have z: "l = []" using no_memb_nil by auto |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
606 |
then have "r = []" sorry |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
607 |
then show ?case using z list_eq2_refl by simp |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
608 |
next |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
609 |
case (Suc m) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
610 |
have b: "l \<approx> r" by fact |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
611 |
have d: "fcard_raw l = Suc m" by fact |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
612 |
have "\<exists>a. memb a l" by (rule fcard_raw_suc_memb[OF d]) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
613 |
then obtain a where e: "memb a l" by auto |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
614 |
then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b by auto |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
615 |
have f: "fcard_raw (delete_raw l a) = m" using fcard_raw_delete[of l a] e d by simp |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
616 |
have g: "delete_raw l a \<approx> delete_raw r a" using delete_raw_rsp[OF b] by simp |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
617 |
have g': "list_eq2 (delete_raw l a) (delete_raw r a)" by (rule Suc.hyps[OF f g]) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
618 |
have h: "list_eq2 (a # delete_raw l a) (a # delete_raw r a)" by (rule list_eq2.intros(5)[OF g']) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
619 |
have i: "list_eq2 l (a # delete_raw l a)" by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]]) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
620 |
have "list_eq2 l (a # delete_raw r a)" by (rule list_eq2.intros(6)[OF i h]) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
621 |
then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
622 |
qed |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
623 |
|
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
624 |
lemma list_eq2_equiv: |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
625 |
"(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
626 |
proof |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
627 |
show "list_eq2 l r \<Longrightarrow> l \<approx> r" by (induct rule: list_eq2.induct) auto |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
628 |
show "l \<approx> r \<Longrightarrow> list_eq2 l r" using list_eq2_equiv_aux by blast |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
629 |
qed |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
630 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
631 |
section {* lifted part *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
632 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
633 |
lemma not_fin_fnil: "x |\<notin>| {||}" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
634 |
by (lifting not_memb_nil) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
635 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
636 |
lemma fin_finsert_iff[simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
637 |
"x |\<in>| finsert y S = (x = y \<or> x |\<in>| S)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
638 |
by (lifting memb_cons_iff) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
639 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
640 |
lemma |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
641 |
shows finsertI1: "x |\<in>| finsert x S" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
642 |
and finsertI2: "x |\<in>| S \<Longrightarrow> x |\<in>| finsert y S" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
643 |
by (lifting memb_consI1, lifting memb_consI2) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
644 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
645 |
lemma finsert_absorb[simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
646 |
shows "x |\<in>| S \<Longrightarrow> finsert x S = S" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
647 |
by (lifting memb_absorb) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
648 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
649 |
lemma fempty_not_finsert[simp]: |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
650 |
"{||} \<noteq> finsert x S" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
651 |
"finsert x S \<noteq> {||}" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
652 |
by (lifting nil_not_cons) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
653 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
654 |
lemma finsert_left_comm: |
1822 | 655 |
"finsert x (finsert y S) = finsert y (finsert x S)" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
656 |
by (lifting cons_left_comm) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
657 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
658 |
lemma finsert_left_idem: |
1822 | 659 |
"finsert x (finsert x S) = finsert x S" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
660 |
by (lifting cons_left_idem) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
661 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
662 |
lemma fsingleton_eq[simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
663 |
shows "{|x|} = {|y|} \<longleftrightarrow> x = y" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
664 |
by (lifting singleton_list_eq) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
665 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
666 |
text {* fset_to_set *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
667 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
668 |
lemma fset_to_set_simps[simp]: |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
669 |
"fset_to_set {||} = ({} :: 'a set)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
670 |
"fset_to_set (finsert (h :: 'a) t) = insert h (fset_to_set t)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
671 |
by (lifting set.simps) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
672 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
673 |
lemma in_fset_to_set: |
1822 | 674 |
"x \<in> fset_to_set S \<equiv> x |\<in>| S" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
675 |
by (lifting memb_def[symmetric]) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
676 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
677 |
lemma none_fin_fempty: |
1824
2ccc1b00377c
merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1823
diff
changeset
|
678 |
"(\<forall>x. x |\<notin>| S) = (S = {||})" |
2ccc1b00377c
merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1823
diff
changeset
|
679 |
by (lifting none_memb_nil) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
680 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
681 |
lemma fset_cong: |
1822 | 682 |
"(fset_to_set S = fset_to_set T) = (S = T)" |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
683 |
by (lifting set_cong) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
684 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
685 |
text {* fcard *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
686 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
687 |
lemma fcard_fempty [simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
688 |
shows "fcard {||} = 0" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
689 |
by (lifting fcard_raw_nil) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
690 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
691 |
lemma fcard_finsert_if [simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
692 |
shows "fcard (finsert x S) = (if x |\<in>| S then fcard S else Suc (fcard S))" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
693 |
by (lifting fcard_raw_cons) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
694 |
|
1822 | 695 |
lemma fcard_0: "(fcard S = 0) = (S = {||})" |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
696 |
by (lifting fcard_raw_0) |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
697 |
|
1821 | 698 |
lemma fcard_1: |
1822 | 699 |
shows "(fcard S = 1) = (\<exists>x. S = {|x|})" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
700 |
by (lifting fcard_raw_1) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
701 |
|
1860 | 702 |
lemma fcard_gt_0: |
703 |
shows "x \<in> fset_to_set S \<Longrightarrow> 0 < fcard S" |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
704 |
by (lifting fcard_raw_gt_0) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
705 |
|
1860 | 706 |
lemma fcard_not_fin: |
707 |
shows "(x |\<notin>| S) = (fcard (finsert x S) = Suc (fcard S))" |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
708 |
by (lifting fcard_raw_not_memb) |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
709 |
|
1822 | 710 |
lemma fcard_suc: "fcard S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = finsert x T \<and> fcard T = n" |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
711 |
by (lifting fcard_raw_suc) |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
712 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
713 |
lemma fcard_delete: |
1822 | 714 |
"fcard (fdelete S y) = (if y |\<in>| S then fcard S - 1 else fcard S)" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
715 |
by (lifting fcard_raw_delete) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
716 |
|
1878
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
717 |
lemma fcard_suc_memb: "fcard A = Suc n \<Longrightarrow> \<exists>a. a |\<in>| A" |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
718 |
by (lifting fcard_raw_suc_memb) |
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
719 |
|
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
720 |
lemma fin_fcard_not_0: "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0" |
1887 | 721 |
by (lifting memb_card_not_0) |
1878
c22947214948
2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1860
diff
changeset
|
722 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
723 |
text {* funion *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
724 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
725 |
lemma funion_simps[simp]: |
1860 | 726 |
shows "{||} |\<union>| S = S" |
727 |
and "finsert x S |\<union>| T = finsert x (S |\<union>| T)" |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
728 |
by (lifting append.simps) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
729 |
|
1887 | 730 |
lemma funion_empty[simp]: |
731 |
shows "S |\<union>| {||} = S" |
|
732 |
by (lifting append_Nil2) |
|
733 |
||
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
734 |
lemma funion_sym: |
1860 | 735 |
shows "S |\<union>| T = T |\<union>| S" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
736 |
by (lifting funion_sym_pre) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
737 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
738 |
lemma funion_assoc: |
1860 | 739 |
shows "S |\<union>| T |\<union>| U = S |\<union>| (T |\<union>| U)" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
740 |
by (lifting append_assoc) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
741 |
|
1887 | 742 |
lemma singleton_union_left: |
743 |
"{|a|} |\<union>| S = finsert a S" |
|
744 |
by simp |
|
745 |
||
746 |
lemma singleton_union_right: |
|
747 |
"S |\<union>| {|a|} = finsert a S" |
|
748 |
by (subst funion_sym) simp |
|
749 |
||
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
750 |
section {* Induction and Cases rules for finite sets *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
751 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
752 |
lemma fset_strong_cases: |
1822 | 753 |
"S = {||} \<or> (\<exists>x T. x |\<notin>| T \<and> S = finsert x T)" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
754 |
by (lifting fset_raw_strong_cases) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
755 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
756 |
lemma fset_exhaust[case_names fempty finsert, cases type: fset]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
757 |
shows "\<lbrakk>S = {||} \<Longrightarrow> P; \<And>x S'. S = finsert x S' \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
758 |
by (lifting list.exhaust) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
759 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
760 |
lemma fset_induct_weak[case_names fempty finsert]: |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
761 |
shows "\<lbrakk>P {||}; \<And>x S. P S \<Longrightarrow> P (finsert x S)\<rbrakk> \<Longrightarrow> P S" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
762 |
by (lifting list.induct) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
763 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
764 |
lemma fset_induct[case_names fempty finsert, induct type: fset]: |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
765 |
assumes prem1: "P {||}" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
766 |
and prem2: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (finsert x S)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
767 |
shows "P S" |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
768 |
proof(induct S rule: fset_induct_weak) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
769 |
case fempty |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
770 |
show "P {||}" by (rule prem1) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
771 |
next |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
772 |
case (finsert x S) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
773 |
have asm: "P S" by fact |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
774 |
show "P (finsert x S)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
775 |
proof(cases "x |\<in>| S") |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
776 |
case True |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
777 |
have "x |\<in>| S" by fact |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
778 |
then show "P (finsert x S)" using asm by simp |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
779 |
next |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
780 |
case False |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
781 |
have "x |\<notin>| S" by fact |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
782 |
then show "P (finsert x S)" using prem2 asm by simp |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
783 |
qed |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
784 |
qed |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
785 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
786 |
lemma fset_induct2: |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
787 |
"P {||} {||} \<Longrightarrow> |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
788 |
(\<And>x xs. x |\<notin>| xs \<Longrightarrow> P (finsert x xs) {||}) \<Longrightarrow> |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
789 |
(\<And>y ys. y |\<notin>| ys \<Longrightarrow> P {||} (finsert y ys)) \<Longrightarrow> |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
790 |
(\<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> |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
791 |
P xsa ysa" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
792 |
apply (induct xsa arbitrary: ysa) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
793 |
apply (induct_tac x rule: fset_induct) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
794 |
apply simp_all |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
795 |
apply (induct_tac xa rule: fset_induct) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
796 |
apply simp_all |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
797 |
done |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
798 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
799 |
text {* fmap *} |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
800 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
801 |
lemma fmap_simps[simp]: |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
802 |
"fmap (f :: 'a \<Rightarrow> 'b) {||} = {||}" |
1822 | 803 |
"fmap f (finsert x S) = finsert (f x) (fmap f S)" |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
804 |
by (lifting map.simps) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
805 |
|
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
806 |
lemma fmap_set_image: |
1822 | 807 |
"fset_to_set (fmap f S) = f ` (fset_to_set S)" |
808 |
by (induct S) (simp_all) |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
809 |
|
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
810 |
lemma inj_fmap_eq_iff: |
1822 | 811 |
"inj f \<Longrightarrow> (fmap f S = fmap f T) = (S = T)" |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
812 |
by (lifting inj_map_eq_iff) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
813 |
|
1822 | 814 |
lemma fmap_funion: "fmap f (S |\<union>| T) = fmap f S |\<union>| fmap f T" |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
815 |
by (lifting map_append) |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
816 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
817 |
lemma fin_funion: |
1822 | 818 |
"x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
819 |
by (lifting memb_append) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
820 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
821 |
text {* ffold *} |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
822 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
823 |
lemma ffold_nil: "ffold f z {||} = z" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
824 |
by (lifting ffold_raw.simps(1)[where 'a="'b" and 'b="'a"]) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
825 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
826 |
lemma ffold_finsert: "ffold f z (finsert a A) = |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
827 |
(if rsp_fold f then if a |\<in>| A then ffold f z A else f a (ffold f z A) else z)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
828 |
by (lifting ffold_raw.simps(2)[where 'a="'b" and 'b="'a"]) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
829 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
830 |
lemma fin_commute_ffold: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
831 |
"\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete b h))" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
832 |
by (lifting memb_commute_ffold_raw) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
833 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
834 |
text {* fdelete *} |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
835 |
|
1822 | 836 |
lemma fin_fdelete: |
837 |
shows "x |\<in>| fdelete S y \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y" |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
838 |
by (lifting memb_delete_raw) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
839 |
|
1822 | 840 |
lemma fin_fdelete_ident: |
841 |
shows "x |\<notin>| fdelete S x" |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
842 |
by (lifting memb_delete_raw_ident) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
843 |
|
1822 | 844 |
lemma not_memb_fdelete_ident: |
845 |
shows "x |\<notin>| S \<Longrightarrow> fdelete S x = S" |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
846 |
by (lifting not_memb_delete_raw_ident) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
847 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
848 |
lemma fset_fdelete_cases: |
1822 | 849 |
shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete S x))" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
850 |
by (lifting fset_raw_delete_raw_cases) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
851 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
852 |
text {* inter *} |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
853 |
|
1822 | 854 |
lemma finter_empty_l: "({||} |\<inter>| S) = {||}" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
855 |
by (lifting finter_raw.simps(1)) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
856 |
|
1822 | 857 |
lemma finter_empty_r: "(S |\<inter>| {||}) = {||}" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
858 |
by (lifting finter_raw_empty) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
859 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
860 |
lemma finter_finsert: |
1822 | 861 |
"finsert x S |\<inter>| T = (if x |\<in>| T then finsert x (S |\<inter>| T) else S |\<inter>| T)" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
862 |
by (lifting finter_raw.simps(2)) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
863 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
864 |
lemma fin_finter: |
1822 | 865 |
"x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
866 |
by (lifting memb_finter_raw) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
867 |
|
1893
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
868 |
lemma fsubset_finsert: |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
869 |
"(finsert x xs |\<subseteq>| ys) = (x |\<in>| ys \<and> xs |\<subseteq>| ys)" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
870 |
by (lifting sub_list_cons) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
871 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
872 |
thm sub_list_def[simplified memb_def[symmetric], quot_lifted, no_vars] |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
873 |
|
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
874 |
lemma fsubset_fin: "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)" |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
875 |
by (rule meta_eq_to_obj_eq) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
876 |
(lifting sub_list_def[simplified memb_def[symmetric]]) |
464dd13efff6
Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1892
diff
changeset
|
877 |
|
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
878 |
lemma expand_fset_eq: |
1822 | 879 |
"(S = T) = (\<forall>x. (x |\<in>| S) = (x |\<in>| T))" |
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
880 |
by (lifting list_eq.simps[simplified memb_def[symmetric]]) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
881 |
|
1888
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
882 |
(* We cannot write it as "assumes .. shows" since Isabelle changes |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
883 |
the quantifiers to schematic variables and reintroduces them in |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
884 |
a different order *) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
885 |
lemma fset_eq_cases: |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
886 |
"\<lbrakk>a1 = a2; |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
887 |
\<And>a b xs. \<lbrakk>a1 = finsert a (finsert b xs); a2 = finsert b (finsert a xs)\<rbrakk> \<Longrightarrow> P; |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
888 |
\<lbrakk>a1 = {||}; a2 = {||}\<rbrakk> \<Longrightarrow> P; \<And>xs ys. \<lbrakk>a1 = ys; a2 = xs; xs = ys\<rbrakk> \<Longrightarrow> P; |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
889 |
\<And>a xs. \<lbrakk>a1 = finsert a (finsert a xs); a2 = finsert a xs\<rbrakk> \<Longrightarrow> P; |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
890 |
\<And>xs ys a. \<lbrakk>a1 = finsert a xs; a2 = finsert a ys; xs = ys\<rbrakk> \<Longrightarrow> P; |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
891 |
\<And>xs1 xs2 xs3. \<lbrakk>a1 = xs1; a2 = xs3; xs1 = xs2; xs2 = xs3\<rbrakk> \<Longrightarrow> P\<rbrakk> |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
892 |
\<Longrightarrow> P" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
893 |
by (lifting list_eq2.cases[simplified list_eq2_equiv[symmetric]]) |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
894 |
|
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
895 |
lemma fset_eq_induct: |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
896 |
assumes "x1 = x2" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
897 |
and "\<And>a b xs. P (finsert a (finsert b xs)) (finsert b (finsert a xs))" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
898 |
and "P {||} {||}" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
899 |
and "\<And>xs ys. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P ys xs" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
900 |
and "\<And>a xs. P (finsert a (finsert a xs)) (finsert a xs)" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
901 |
and "\<And>xs ys a. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P (finsert a xs) (finsert a ys)" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
902 |
and "\<And>xs1 xs2 xs3. \<lbrakk>xs1 = xs2; P xs1 xs2; xs2 = xs3; P xs2 xs3\<rbrakk> \<Longrightarrow> P xs1 xs3" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
903 |
shows "P x1 x2" |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
904 |
using assms |
59f41804b3f8
Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1887
diff
changeset
|
905 |
by (lifting list_eq2.induct[simplified list_eq2_equiv[symmetric]]) |
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
906 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
907 |
ML {* |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
908 |
fun dest_fsetT (Type ("FSet.fset", [T])) = T |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
909 |
| dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []); |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
910 |
*} |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
911 |
|
1682
ae54ce4cde54
Remove list_eq notation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1533
diff
changeset
|
912 |
no_notation |
ae54ce4cde54
Remove list_eq notation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1533
diff
changeset
|
913 |
list_eq (infix "\<approx>" 50) |
ae54ce4cde54
Remove list_eq notation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1533
diff
changeset
|
914 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
915 |
end |