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