author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Tue, 13 Apr 2010 15:59:53 +0200 | |
changeset 1820 | de28a91eaca3 |
parent 1819 | 63dd459dbc0d |
child 1821 | 509a0ccc4f32 |
permissions | -rw-r--r-- |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
1 |
theory FSet |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
2 |
imports Quotient Quotient_List List |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
3 |
begin |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
4 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
5 |
fun |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
6 |
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
|
7 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
8 |
"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
|
9 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
10 |
lemma list_eq_equivp: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
11 |
shows "equivp list_eq" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
12 |
unfolding equivp_reflp_symp_transp reflp_def symp_def transp_def |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
13 |
by auto |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
14 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
15 |
quotient_type |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
16 |
'a fset = "'a list" / "list_eq" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
17 |
by (rule list_eq_equivp) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
18 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
19 |
section {* empty fset, finsert and membership *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
20 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
21 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
22 |
fempty ("{||}") |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
23 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
24 |
"fempty :: 'a fset" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
25 |
is "[]::'a list" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
26 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
27 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
28 |
"finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
29 |
is "op #" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
30 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
31 |
syntax |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
32 |
"@Finset" :: "args => 'a fset" ("{|(_)|}") |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
33 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
34 |
translations |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
35 |
"{|x, xs|}" == "CONST finsert x {|xs|}" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
36 |
"{|x|}" == "CONST finsert x {||}" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
37 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
38 |
definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
39 |
memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
40 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
41 |
"memb x xs \<equiv> x \<in> set xs" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
42 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
43 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
44 |
fin ("_ |\<in>| _" [50, 51] 50) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
45 |
where |
1816
56cebe7f8e24
some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents:
1682
diff
changeset
|
46 |
"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
|
47 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
48 |
abbreviation |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
49 |
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
|
50 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
51 |
"a |\<notin>| S \<equiv> \<not>(a |\<in>| S)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
52 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
53 |
lemma memb_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
54 |
shows "(op = ===> op \<approx> ===> op =) memb memb" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
55 |
by (auto simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
56 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
57 |
lemma nil_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
58 |
shows "[] \<approx> []" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
59 |
by simp |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
60 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
61 |
lemma cons_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
62 |
shows "(op = ===> op \<approx> ===> op \<approx>) op # op #" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
63 |
by simp |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
64 |
|
1816
56cebe7f8e24
some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents:
1682
diff
changeset
|
65 |
section {* Augmenting an fset -- @{const finsert} *} |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
66 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
67 |
lemma nil_not_cons: |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
68 |
shows |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
69 |
"\<not>[] \<approx> x # xs" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
70 |
"\<not>x # xs \<approx> []" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
71 |
by auto |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
72 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
73 |
lemma not_memb_nil: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
74 |
"\<not>memb x []" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
75 |
by (simp add: memb_def) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
76 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
77 |
lemma memb_cons_iff: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
78 |
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
|
79 |
by (induct xs) (auto simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
80 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
81 |
lemma memb_consI1: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
82 |
shows "memb x (x # xs)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
83 |
by (simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
84 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
85 |
lemma memb_consI2: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
86 |
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
|
87 |
by (simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
88 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
89 |
lemma memb_absorb: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
90 |
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
|
91 |
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
|
92 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
93 |
section {* Singletons *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
94 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
95 |
lemma singleton_list_eq: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
96 |
shows "[x] \<approx> [y] \<longleftrightarrow> x = y" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
97 |
by (simp add: id_simps) auto |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
98 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
99 |
section {* Union *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
100 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
101 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
102 |
funion (infixl "|\<union>|" 65) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
103 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
104 |
"funion :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
105 |
is |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
106 |
"op @" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
107 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
108 |
section {* Cardinality of finite sets *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
109 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
110 |
fun |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
111 |
fcard_raw :: "'a list \<Rightarrow> nat" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
112 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
113 |
fcard_raw_nil: "fcard_raw [] = 0" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
114 |
| 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
|
115 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
116 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
117 |
"fcard :: 'a fset \<Rightarrow> nat" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
118 |
is |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
119 |
"fcard_raw" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
120 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
121 |
lemma fcard_raw_0: |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
122 |
fixes a :: "'a list" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
123 |
shows "(fcard_raw a = 0) = (a \<approx> [])" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
124 |
apply (induct a) |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
125 |
apply auto |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
126 |
apply (drule memb_absorb) |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
127 |
apply (auto simp add: nil_not_cons) |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
128 |
done |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
129 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
130 |
lemma fcard_raw_gt_0: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
131 |
assumes a: "x \<in> set xs" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
132 |
shows "0 < fcard_raw xs" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
133 |
using a |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
134 |
by (induct xs) (auto simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
135 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
136 |
lemma fcard_raw_not_memb: |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
137 |
fixes x :: "'a" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
138 |
fixes xs :: "'a list" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
139 |
shows "(~(memb x xs)) = (fcard_raw (x # xs) = Suc (fcard_raw xs))" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
140 |
by auto |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
141 |
|
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
142 |
lemma fcard_raw_suc: |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
143 |
fixes xs :: "'a list" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
144 |
fixes n :: "nat" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
145 |
assumes c: "fcard_raw xs = Suc n" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
146 |
shows "\<exists>a ys. ~(memb a ys) \<and> xs \<approx> (a # ys) \<and> fcard_raw ys = n" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
147 |
unfolding memb_def |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
148 |
using c |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
149 |
proof (induct xs) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
150 |
case Nil |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
151 |
then show ?case by simp |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
152 |
next |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
153 |
case (Cons a xs) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
154 |
have f1: "fcard_raw xs = Suc n \<Longrightarrow> \<exists>a ys. a \<notin> set ys \<and> xs \<approx> a # ys \<and> fcard_raw ys = n" by fact |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
155 |
have f2: "fcard_raw (a # xs) = Suc n" by fact |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
156 |
then show ?case proof (cases "a \<in> set xs") |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
157 |
case True |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
158 |
then show ?thesis using f1 f2 apply - |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
159 |
apply (simp add: memb_def) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
160 |
apply clarify |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
161 |
by metis |
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
162 |
next |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
163 |
case False |
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
164 |
then show ?thesis using f1 f2 apply - |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
165 |
apply (rule_tac x="a" in exI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
166 |
apply (rule_tac x="xs" in exI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
167 |
apply (simp add: memb_def) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
168 |
done |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
169 |
qed |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
170 |
qed |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
171 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
172 |
lemma singleton_fcard_1: "set a = {b} \<Longrightarrow> fcard_raw a = Suc 0" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
173 |
apply (induct a) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
174 |
apply simp_all |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
175 |
apply auto |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
176 |
apply (subgoal_tac "set a2 = {b}") |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
177 |
apply simp |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
178 |
apply (simp add: memb_def) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
179 |
apply auto |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
180 |
apply (subgoal_tac "set a2 = {}") |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
181 |
apply simp |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
182 |
by (metis memb_def subset_empty subset_insert) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
183 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
184 |
lemma fcard_raw_1: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
185 |
fixes a :: "'a list" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
186 |
shows "(fcard_raw a = 1) = (\<exists>b. a \<approx> [b])" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
187 |
apply auto |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
188 |
apply (drule fcard_raw_suc) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
189 |
apply clarify |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
190 |
apply (simp add: fcard_raw_0) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
191 |
apply (rule_tac x="aa" in exI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
192 |
apply simp |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
193 |
apply (subgoal_tac "set a = {b}") |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
194 |
apply (erule singleton_fcard_1) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
195 |
apply auto |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
196 |
done |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
197 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
198 |
lemma fcard_raw_delete_one: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
199 |
"fcard_raw ([x \<leftarrow> xs. x \<noteq> y]) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
200 |
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
|
201 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
202 |
lemma fcard_raw_rsp_aux: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
203 |
assumes a: "a \<approx> b" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
204 |
shows "fcard_raw a = fcard_raw b" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
205 |
using a |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
206 |
apply(induct a arbitrary: b) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
207 |
apply(auto simp add: memb_def) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
208 |
apply(metis) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
209 |
apply(drule_tac x="[x \<leftarrow> b. x \<noteq> a1]" in meta_spec) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
210 |
apply(simp add: fcard_raw_delete_one) |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
211 |
apply(metis Suc_pred'[OF fcard_raw_gt_0] fcard_raw_delete_one memb_def) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
212 |
done |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
213 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
214 |
lemma fcard_raw_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
215 |
"(op \<approx> ===> op =) fcard_raw fcard_raw" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
216 |
by (simp add: fcard_raw_rsp_aux) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
217 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
218 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
219 |
section {* fmap and fset comprehension *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
220 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
221 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
222 |
"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
|
223 |
is |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
224 |
"map" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
225 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
226 |
lemma map_append: |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
227 |
"(map f (a @ b)) \<approx> (map f a) @ (map f b)" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
228 |
by simp |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
229 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
230 |
lemma memb_append: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
231 |
"memb e (append l r) = (memb e l \<or> memb e r)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
232 |
by (induct l) (simp_all add: not_memb_nil memb_cons_iff) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
233 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
234 |
text {* raw section *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
235 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
236 |
lemma map_rsp_aux: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
237 |
assumes a: "a \<approx> b" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
238 |
shows "map f a \<approx> map f b" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
239 |
using a |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
240 |
apply(induct a arbitrary: b) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
241 |
apply(auto) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
242 |
apply(metis rev_image_eqI) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
243 |
done |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
244 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
245 |
lemma map_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
246 |
shows "(op = ===> op \<approx> ===> op \<approx>) map map" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
247 |
by (auto simp add: map_rsp_aux) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
248 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
249 |
lemma cons_left_comm: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
250 |
"x # y # A \<approx> y # x # A" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
251 |
by (auto simp add: id_simps) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
252 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
253 |
lemma cons_left_idem: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
254 |
"x # x # A \<approx> x # A" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
255 |
by (auto simp add: id_simps) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
256 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
257 |
lemma none_mem_nil: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
258 |
"(\<forall>a. a \<notin> set A) = (A \<approx> [])" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
259 |
by simp |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
260 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
261 |
lemma fset_raw_strong_cases: |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
262 |
"(X = []) \<or> (\<exists>a Y. ((a \<notin> set Y) \<and> (X \<approx> a # Y)))" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
263 |
apply (induct X) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
264 |
apply (simp) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
265 |
apply (rule disjI2) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
266 |
apply (erule disjE) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
267 |
apply (rule_tac x="a" in exI) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
268 |
apply (rule_tac x="[]" in exI) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
269 |
apply (simp) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
270 |
apply (erule exE)+ |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
271 |
apply (case_tac "a = aa") |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
272 |
apply (rule_tac x="a" in exI) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
273 |
apply (rule_tac x="Y" in exI) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
274 |
apply (simp) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
275 |
apply (rule_tac x="aa" in exI) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
276 |
apply (rule_tac x="a # Y" in exI) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
277 |
apply (auto) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
278 |
done |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
279 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
280 |
fun |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
281 |
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
|
282 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
283 |
"delete_raw [] x = []" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
284 |
| "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
|
285 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
286 |
lemma memb_delete_raw: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
287 |
"memb x (delete_raw A a) = (memb x A \<and> x \<noteq> a)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
288 |
by (induct A arbitrary: x a) (auto simp add: memb_def) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
289 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
290 |
lemma [quot_respect]: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
291 |
"(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
|
292 |
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
|
293 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
294 |
lemma memb_delete_raw_ident: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
295 |
"\<not> memb a (delete_raw A a)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
296 |
by (induct A) (auto simp add: memb_def) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
297 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
298 |
lemma not_memb_delete_raw_ident: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
299 |
"\<not> memb b A \<Longrightarrow> delete_raw A b = A" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
300 |
by (induct A) (auto simp add: memb_def) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
301 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
302 |
lemma fset_raw_delete_raw_cases: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
303 |
"X = [] \<or> (\<exists>a. memb a X \<and> X \<approx> a # delete_raw X a)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
304 |
by (induct X) (auto simp add: memb_def) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
305 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
306 |
lemma fdelete_raw_filter: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
307 |
"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
|
308 |
by (induct xs) simp_all |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
309 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
310 |
lemma fcard_raw_delete: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
311 |
"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
|
312 |
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
|
313 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
314 |
lemma set_rsp[quot_respect]: |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
315 |
"(op \<approx> ===> op =) set set" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
316 |
by auto |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
317 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
318 |
definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
319 |
rsp_fold |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
320 |
where |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
321 |
"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
|
322 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
323 |
primrec |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
324 |
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
|
325 |
where |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
326 |
"ffold_raw f z [] = z" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
327 |
| "ffold_raw f z (a # A) = |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
328 |
(if (rsp_fold f) then |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
329 |
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
|
330 |
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
|
331 |
else z)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
332 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
333 |
lemma memb_commute_ffold_raw: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
334 |
"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
|
335 |
apply (induct b) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
336 |
apply (simp add: not_memb_nil) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
337 |
apply (simp add: ffold_raw.simps) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
338 |
apply (rule conjI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
339 |
apply (rule_tac [!] impI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
340 |
apply (rule_tac [!] conjI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
341 |
apply (rule_tac [!] impI) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
342 |
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
|
343 |
apply (simp add: memb_cons_iff) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
344 |
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
|
345 |
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
|
346 |
done |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
347 |
|
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
348 |
lemma ffold_raw_rsp_pre: |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
349 |
"\<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
|
350 |
apply (induct a arbitrary: b) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
351 |
apply (simp add: hd_in_set memb_absorb memb_def none_mem_nil) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
352 |
apply (simp add: ffold_raw.simps) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
353 |
apply (rule conjI) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
354 |
apply (rule_tac [!] impI) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
355 |
apply (rule_tac [!] conjI) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
356 |
apply (rule_tac [!] impI) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
357 |
apply (simp add: in_set_code memb_cons_iff memb_def) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
358 |
apply (metis) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
359 |
apply (metis Nitpick.list_size_simp(2) ffold_raw.simps(2) length_Suc_conv memb_absorb memb_cons_iff nil_not_cons(2)) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
360 |
defer |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
361 |
apply (metis Nitpick.list_size_simp(2) ffold_raw.simps(2) length_Suc_conv memb_absorb memb_cons_iff nil_not_cons(2)) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
362 |
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
|
363 |
apply (simp only:) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
364 |
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
|
365 |
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
|
366 |
apply simp |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
367 |
apply (simp add: memb_delete_raw) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
368 |
apply (metis memb_cons_iff) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
369 |
apply (erule memb_commute_ffold_raw) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
370 |
apply (drule_tac x="a1" in spec) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
371 |
apply (simp add: memb_cons_iff) |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
372 |
done |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
373 |
|
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
374 |
lemma [quot_respect]: |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
375 |
"(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
|
376 |
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
|
377 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
378 |
primrec |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
379 |
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
|
380 |
where |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
381 |
"finter_raw [] l = []" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
382 |
| "finter_raw (h # t) l = |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
383 |
(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
|
384 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
385 |
lemma finter_raw_empty: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
386 |
"finter_raw l [] = []" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
387 |
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
|
388 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
389 |
lemma memb_finter_raw: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
390 |
"memb e (finter_raw l r) = (memb e l \<and> memb e r)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
391 |
apply (induct l) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
392 |
apply (simp add: not_memb_nil) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
393 |
apply (simp add: finter_raw.simps) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
394 |
apply (simp add: memb_cons_iff) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
395 |
apply auto |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
396 |
done |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
397 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
398 |
lemma [quot_respect]: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
399 |
"(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
|
400 |
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
|
401 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
402 |
section {* Constants on the Quotient Type *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
403 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
404 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
405 |
"fdelete :: 'a fset \<Rightarrow> 'a \<Rightarrow> 'a fset" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
406 |
is "delete_raw" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
407 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
408 |
quotient_definition |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
409 |
"fset_to_set :: 'a fset \<Rightarrow> 'a set" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
410 |
is "set" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
411 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
412 |
quotient_definition |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
413 |
"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
|
414 |
is "ffold_raw" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
415 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
416 |
quotient_definition |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
417 |
finter (infix "|\<inter>|" 50) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
418 |
where |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
419 |
"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
|
420 |
is "finter_raw" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
421 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
422 |
lemma funion_sym_pre: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
423 |
"a @ b \<approx> b @ a" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
424 |
by auto |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
425 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
426 |
lemma append_rsp[quot_respect]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
427 |
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
428 |
by (auto) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
429 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
430 |
lemma set_cong: "(set x = set y) = (x \<approx> y)" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
431 |
apply rule |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
432 |
apply simp_all |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
433 |
apply (induct x y rule: list_induct2') |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
434 |
apply simp_all |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
435 |
apply auto |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
436 |
done |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
437 |
|
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
438 |
lemma inj_map_eq_iff: |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
439 |
"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
|
440 |
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
|
441 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
442 |
quotient_definition |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
443 |
"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
|
444 |
is |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
445 |
"concat" |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
446 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
447 |
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
|
448 |
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
|
449 |
by auto |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
450 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
451 |
section {* lifted part *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
452 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
453 |
lemma not_fin_fnil: "x |\<notin>| {||}" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
454 |
by (lifting not_memb_nil) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
455 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
456 |
lemma fin_finsert_iff[simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
457 |
"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
|
458 |
by (lifting memb_cons_iff) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
459 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
460 |
lemma |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
461 |
shows finsertI1: "x |\<in>| finsert x S" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
462 |
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
|
463 |
by (lifting memb_consI1, lifting memb_consI2) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
464 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
465 |
lemma finsert_absorb[simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
466 |
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
|
467 |
by (lifting memb_absorb) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
468 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
469 |
lemma fempty_not_finsert[simp]: |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
470 |
"{||} \<noteq> finsert x S" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
471 |
"finsert x S \<noteq> {||}" |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
472 |
by (lifting nil_not_cons) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
473 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
474 |
lemma finsert_left_comm: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
475 |
"finsert a (finsert b S) = finsert b (finsert a S)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
476 |
by (lifting cons_left_comm) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
477 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
478 |
lemma finsert_left_idem: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
479 |
"finsert a (finsert a S) = finsert a S" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
480 |
by (lifting cons_left_idem) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
481 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
482 |
lemma fsingleton_eq[simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
483 |
shows "{|x|} = {|y|} \<longleftrightarrow> x = y" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
484 |
by (lifting singleton_list_eq) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
485 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
486 |
text {* fset_to_set *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
487 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
488 |
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
|
489 |
"fset_to_set {||} = ({} :: 'a set)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
490 |
"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
|
491 |
by (lifting set.simps) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
492 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
493 |
lemma in_fset_to_set: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
494 |
"x \<in> fset_to_set xs \<equiv> x |\<in>| xs" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
495 |
by (lifting memb_def[symmetric]) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
496 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
497 |
lemma none_fin_fempty: |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
498 |
"(\<forall>a. a \<notin> fset_to_set A) = (A = {||})" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
499 |
by (lifting none_mem_nil) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
500 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
501 |
lemma fset_cong: |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
502 |
"(fset_to_set x = fset_to_set y) = (x = y)" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
503 |
by (lifting set_cong) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
504 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
505 |
text {* fcard *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
506 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
507 |
lemma fcard_fempty [simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
508 |
shows "fcard {||} = 0" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
509 |
by (lifting fcard_raw_nil) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
510 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
511 |
lemma fcard_finsert_if [simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
512 |
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
|
513 |
by (lifting fcard_raw_cons) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
514 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
515 |
lemma fcard_0: "(fcard a = 0) = (a = {||})" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
516 |
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
|
517 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
518 |
lemma fcard_1: "(fcard a = 1) = (\<exists>b. a = {|b|})" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
519 |
by (lifting fcard_raw_1) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
520 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
521 |
lemma fcard_gt_0: "x \<in> fset_to_set xs \<Longrightarrow> 0 < fcard xs" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
522 |
by (lifting fcard_raw_gt_0) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
523 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
524 |
lemma fcard_not_fin: "(x |\<notin>| xs) = (fcard (finsert x xs) = Suc (fcard xs))" |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
525 |
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
|
526 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
527 |
lemma fcard_suc: "fcard xs = Suc n \<Longrightarrow> \<exists>a ys. a |\<notin>| ys \<and> xs = finsert a ys \<and> fcard ys = n" |
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
528 |
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
|
529 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
530 |
lemma fcard_delete: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
531 |
"fcard (fdelete xs y) = (if y |\<in>| xs then fcard xs - 1 else fcard xs)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
532 |
by (lifting fcard_raw_delete) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
533 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
534 |
text {* funion *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
535 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
536 |
lemma funion_simps[simp]: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
537 |
"{||} |\<union>| ys = ys" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
538 |
"finsert x xs |\<union>| ys = finsert x (xs |\<union>| ys)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
539 |
by (lifting append.simps) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
540 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
541 |
lemma funion_sym: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
542 |
"a |\<union>| b = b |\<union>| a" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
543 |
by (lifting funion_sym_pre) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
544 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
545 |
lemma funion_assoc: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
546 |
"x |\<union>| xa |\<union>| xb = x |\<union>| (xa |\<union>| xb)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
547 |
by (lifting append_assoc) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
548 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
549 |
section {* Induction and Cases rules for finite sets *} |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
550 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
551 |
lemma fset_strong_cases: |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
552 |
"X = {||} \<or> (\<exists>a Y. a \<notin> fset_to_set Y \<and> X = finsert a Y)" |
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
553 |
by (lifting fset_raw_strong_cases) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
554 |
|
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
555 |
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
|
556 |
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
|
557 |
by (lifting list.exhaust) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
558 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
559 |
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
|
560 |
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
|
561 |
by (lifting list.induct) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
562 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
563 |
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
|
564 |
assumes prem1: "P {||}" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
565 |
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
|
566 |
shows "P S" |
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
567 |
proof(induct S rule: fset_induct_weak) |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
568 |
case fempty |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
569 |
show "P {||}" by (rule prem1) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
570 |
next |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
571 |
case (finsert x S) |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
572 |
have asm: "P S" by fact |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
573 |
show "P (finsert x S)" |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
574 |
proof(cases "x |\<in>| S") |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
575 |
case True |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
576 |
have "x |\<in>| S" by fact |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
577 |
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
|
578 |
next |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
579 |
case False |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
580 |
have "x |\<notin>| S" by fact |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
581 |
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
|
582 |
qed |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
583 |
qed |
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
584 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
585 |
lemma fset_induct2: |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
586 |
"P {||} {||} \<Longrightarrow> |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
587 |
(\<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
|
588 |
(\<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
|
589 |
(\<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
|
590 |
P xsa ysa" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
591 |
apply (induct xsa arbitrary: ysa) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
592 |
apply (induct_tac x rule: fset_induct) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
593 |
apply simp_all |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
594 |
apply (induct_tac xa rule: fset_induct) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
595 |
apply simp_all |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
596 |
done |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
597 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
598 |
text {* fmap *} |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
599 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
600 |
lemma fmap_simps[simp]: |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
601 |
"fmap (f :: 'a \<Rightarrow> 'b) {||} = {||}" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
602 |
"fmap f (finsert x xs) = finsert (f x) (fmap f xs)" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
603 |
by (lifting map.simps) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
604 |
|
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
605 |
lemma fmap_set_image: |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
606 |
"fset_to_set (fmap f fs) = f ` (fset_to_set fs)" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
607 |
apply (induct fs) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
608 |
apply (simp_all) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
609 |
done |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
610 |
|
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
611 |
lemma inj_fmap_eq_iff: |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
612 |
"inj f \<Longrightarrow> (fmap f l = fmap f m) = (l = m)" |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
613 |
by (lifting inj_map_eq_iff) |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
614 |
|
1813
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
615 |
lemma fmap_funion: "fmap f (a |\<union>| b) = fmap f a |\<union>| fmap f b" |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
616 |
by (lifting map_append) |
69fff336dd18
Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1682
diff
changeset
|
617 |
|
1819
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
618 |
lemma fin_funion: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
619 |
"(e |\<in>| l |\<union>| r) = (e |\<in>| l \<or> e |\<in>| r)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
620 |
by (lifting memb_append) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
621 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
622 |
text {* ffold *} |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
623 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
624 |
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
|
625 |
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
|
626 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
627 |
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
|
628 |
(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
|
629 |
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
|
630 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
631 |
lemma fin_commute_ffold: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
632 |
"\<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
|
633 |
by (lifting memb_commute_ffold_raw) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
634 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
635 |
text {* fdelete *} |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
636 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
637 |
lemma fin_fdelete: "(x |\<in>| fdelete A a) = (x |\<in>| A \<and> x \<noteq> a)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
638 |
by (lifting memb_delete_raw) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
639 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
640 |
lemma fin_fdelete_ident: "a |\<notin>| fdelete A a" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
641 |
by (lifting memb_delete_raw_ident) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
642 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
643 |
lemma not_memb_fdelete_ident: "b |\<notin>| A \<Longrightarrow> fdelete A b = A" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
644 |
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
|
645 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
646 |
lemma fset_fdelete_cases: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
647 |
"X = {||} \<or> (\<exists>a. a |\<in>| X \<and> X = finsert a (fdelete X a))" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
648 |
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
|
649 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
650 |
text {* inter *} |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
651 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
652 |
lemma finter_empty_l: "({||} |\<inter>| r) = {||}" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
653 |
by (lifting finter_raw.simps(1)) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
654 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
655 |
lemma finter_empty_r: "(l |\<inter>| {||}) = {||}" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
656 |
by (lifting finter_raw_empty) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
657 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
658 |
lemma finter_finsert: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
659 |
"(finsert h t |\<inter>| l) = (if h |\<in>| l then finsert h (t |\<inter>| l) else t |\<inter>| l)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
660 |
by (lifting finter_raw.simps(2)) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
661 |
|
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
662 |
lemma fin_finter: |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
663 |
"(e |\<in>| (l |\<inter>| r)) = (e |\<in>| l \<and> e |\<in>| r)" |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
664 |
by (lifting memb_finter_raw) |
63dd459dbc0d
Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1817
diff
changeset
|
665 |
|
1820
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
666 |
lemma expand_fset_eq: |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
667 |
"(xs = ys) = (\<forall>x. (x |\<in>| xs) = (x |\<in>| ys))" |
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
668 |
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
|
669 |
|
de28a91eaca3
Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1819
diff
changeset
|
670 |
|
1533
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
671 |
ML {* |
5f5e99a11f66
A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1518
diff
changeset
|
672 |
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
|
673 |
| 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
|
674 |
*} |
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
675 |
|
1682
ae54ce4cde54
Remove list_eq notation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1533
diff
changeset
|
676 |
no_notation |
ae54ce4cde54
Remove list_eq notation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1533
diff
changeset
|
677 |
list_eq (infix "\<approx>" 50) |
ae54ce4cde54
Remove list_eq notation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1533
diff
changeset
|
678 |
|
1518
212629c90971
Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
679 |
end |