author | haftmann |
Thu, 23 Feb 2012 20:33:35 +0100 | |
changeset 46631 | 2c5c003cee35 |
parent 46557 | ae926869a311 |
child 46636 | 353731f11559 |
permissions | -rw-r--r-- |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
1 |
(* Title: HOL/Predicate.thy |
30328 | 2 |
Author: Stefan Berghofer and Lukas Bulwahn and Florian Haftmann, TU Muenchen |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
3 |
*) |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
4 |
|
30328 | 5 |
header {* Predicates as relations and enumerations *} |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
6 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
7 |
theory Predicate |
23708 | 8 |
imports Inductive Relation |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
9 |
begin |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
10 |
|
30328 | 11 |
notation |
41082 | 12 |
bot ("\<bottom>") and |
13 |
top ("\<top>") and |
|
30328 | 14 |
inf (infixl "\<sqinter>" 70) and |
15 |
sup (infixl "\<squnion>" 65) and |
|
16 |
Inf ("\<Sqinter>_" [900] 900) and |
|
41082 | 17 |
Sup ("\<Squnion>_" [900] 900) |
30328 | 18 |
|
41080 | 19 |
syntax (xsymbols) |
41082 | 20 |
"_INF1" :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sqinter>_./ _)" [0, 10] 10) |
21 |
"_INF" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10) |
|
41080 | 22 |
"_SUP1" :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Squnion>_./ _)" [0, 10] 10) |
23 |
"_SUP" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10) |
|
24 |
||
30328 | 25 |
|
46631
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
26 |
subsection {* Classical rules for reasoning on predicates *} |
46557
ae926869a311
reverting changesets from 5d33a3269029 on: change of order of declaration of classical rules makes serious problems
haftmann
parents:
46553
diff
changeset
|
27 |
|
46631
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
28 |
declare predicate1D [Pure.dest?, dest?] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
29 |
declare predicate2I [Pure.intro!, intro!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
30 |
declare predicate2D [Pure.dest, dest] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
31 |
declare bot1E [elim!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
32 |
declare bot2E [elim!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
33 |
declare top1I [intro!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
34 |
declare top2I [intro!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
35 |
declare inf1I [intro!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
36 |
declare inf2I [intro!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
37 |
declare inf1E [elim!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
38 |
declare inf2E [elim!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
39 |
declare sup1I1 [intro?] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
40 |
declare sup2I1 [intro?] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
41 |
declare sup1I2 [intro?] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
42 |
declare sup2I2 [intro?] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
43 |
declare sup1E [elim!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
44 |
declare sup2E [elim!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
45 |
declare sup1CI [intro!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
46 |
declare sup2CI [intro!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
47 |
declare INF1_I [intro!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
48 |
declare INF2_I [intro!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
49 |
declare INF1_D [elim] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
50 |
declare INF2_D [elim] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
51 |
declare INF1_E [elim] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
52 |
declare INF2_E [elim] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
53 |
declare SUP1_I [intro] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
54 |
declare SUP2_I [intro] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
55 |
declare SUP1_E [elim!] |
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
56 |
declare SUP2_E [elim!] |
46557
ae926869a311
reverting changesets from 5d33a3269029 on: change of order of declaration of classical rules makes serious problems
haftmann
parents:
46553
diff
changeset
|
57 |
|
ae926869a311
reverting changesets from 5d33a3269029 on: change of order of declaration of classical rules makes serious problems
haftmann
parents:
46553
diff
changeset
|
58 |
|
46631
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
59 |
subsection {* Conversion between set and predicate relations *} |
46557
ae926869a311
reverting changesets from 5d33a3269029 on: change of order of declaration of classical rules makes serious problems
haftmann
parents:
46553
diff
changeset
|
60 |
|
32779 | 61 |
subsubsection {* Equality *} |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
62 |
|
46175
48c534b22040
Declared pred_equals/subset_eq, sup_Un_eq and SUP_UN_eq(2) as pred_set_conv rules
berghofe
parents:
46038
diff
changeset
|
63 |
lemma pred_equals_eq [pred_set_conv]: "((\<lambda>x. x \<in> R) = (\<lambda>x. x \<in> S)) \<longleftrightarrow> (R = S)" |
45970
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
64 |
by (simp add: set_eq_iff fun_eq_iff) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
65 |
|
44415 | 66 |
lemma pred_equals_eq2 [pred_set_conv]: "((\<lambda>x y. (x, y) \<in> R) = (\<lambda>x y. (x, y) \<in> S)) \<longleftrightarrow> (R = S)" |
45970
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
67 |
by (simp add: set_eq_iff fun_eq_iff) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
68 |
|
32779 | 69 |
|
70 |
subsubsection {* Order relation *} |
|
71 |
||
46175
48c534b22040
Declared pred_equals/subset_eq, sup_Un_eq and SUP_UN_eq(2) as pred_set_conv rules
berghofe
parents:
46038
diff
changeset
|
72 |
lemma pred_subset_eq [pred_set_conv]: "((\<lambda>x. x \<in> R) \<le> (\<lambda>x. x \<in> S)) \<longleftrightarrow> (R \<subseteq> S)" |
45970
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
73 |
by (simp add: subset_iff le_fun_def) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
74 |
|
44415 | 75 |
lemma pred_subset_eq2 [pred_set_conv]: "((\<lambda>x y. (x, y) \<in> R) \<le> (\<lambda>x y. (x, y) \<in> S)) \<longleftrightarrow> (R \<subseteq> S)" |
45970
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
76 |
by (simp add: subset_iff le_fun_def) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
77 |
|
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
78 |
|
30328 | 79 |
subsubsection {* Top and bottom elements *} |
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
80 |
|
44414 | 81 |
lemma bot_empty_eq: "\<bottom> = (\<lambda>x. x \<in> {})" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
82 |
by (auto simp add: fun_eq_iff) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
83 |
|
44414 | 84 |
lemma bot_empty_eq2: "\<bottom> = (\<lambda>x y. (x, y) \<in> {})" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
85 |
by (auto simp add: fun_eq_iff) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
86 |
|
41082 | 87 |
|
88 |
subsubsection {* Binary intersection *} |
|
89 |
||
46191
a88546428c2a
Added inf_Int_eq to pred_set_conv database as well
berghofe
parents:
46175
diff
changeset
|
90 |
lemma inf_Int_eq [pred_set_conv]: "(\<lambda>x. x \<in> R) \<sqinter> (\<lambda>x. x \<in> S) = (\<lambda>x. x \<in> R \<inter> S)" |
45970
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
91 |
by (simp add: inf_fun_def) |
41082 | 92 |
|
44414 | 93 |
lemma inf_Int_eq2 [pred_set_conv]: "(\<lambda>x y. (x, y) \<in> R) \<sqinter> (\<lambda>x y. (x, y) \<in> S) = (\<lambda>x y. (x, y) \<in> R \<inter> S)" |
45970
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
94 |
by (simp add: inf_fun_def) |
41082 | 95 |
|
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
96 |
|
30328 | 97 |
subsubsection {* Binary union *} |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
98 |
|
46175
48c534b22040
Declared pred_equals/subset_eq, sup_Un_eq and SUP_UN_eq(2) as pred_set_conv rules
berghofe
parents:
46038
diff
changeset
|
99 |
lemma sup_Un_eq [pred_set_conv]: "(\<lambda>x. x \<in> R) \<squnion> (\<lambda>x. x \<in> S) = (\<lambda>x. x \<in> R \<union> S)" |
45970
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
100 |
by (simp add: sup_fun_def) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
101 |
|
44414 | 102 |
lemma sup_Un_eq2 [pred_set_conv]: "(\<lambda>x y. (x, y) \<in> R) \<squnion> (\<lambda>x y. (x, y) \<in> S) = (\<lambda>x y. (x, y) \<in> R \<union> S)" |
45970
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
103 |
by (simp add: sup_fun_def) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
104 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
105 |
|
30328 | 106 |
subsubsection {* Intersections of families *} |
22430
6a56bf1b3a64
Generalized version of SUP and INF (with index set).
berghofe
parents:
22422
diff
changeset
|
107 |
|
46631
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
108 |
lemma INF_INT_eq: "(\<Sqinter>i. (\<lambda>x. x \<in> r i)) = (\<lambda>x. x \<in> (\<Inter>i. r i))" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44415
diff
changeset
|
109 |
by (simp add: INF_apply fun_eq_iff) |
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
110 |
|
46631
2c5c003cee35
moved lemmas for orderings and lattices on predicates to corresponding theories, retaining declaration order of classical rules; tuned headings; tuned syntax
haftmann
parents:
46557
diff
changeset
|
111 |
lemma INF_INT_eq2: "(\<Sqinter>i. (\<lambda>x y. (x, y) \<in> r i)) = (\<lambda>x y. (x, y) \<in> (\<Inter>i. r i))" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44415
diff
changeset
|
112 |
by (simp add: INF_apply fun_eq_iff) |
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
113 |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
114 |
|
41082 | 115 |
subsubsection {* Unions of families *} |
116 |
||
46175
48c534b22040
Declared pred_equals/subset_eq, sup_Un_eq and SUP_UN_eq(2) as pred_set_conv rules
berghofe
parents:
46038
diff
changeset
|
117 |
lemma SUP_UN_eq [pred_set_conv]: "(\<Squnion>i. (\<lambda>x. x \<in> r i)) = (\<lambda>x. x \<in> (\<Union>i. r i))" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44415
diff
changeset
|
118 |
by (simp add: SUP_apply fun_eq_iff) |
41082 | 119 |
|
46175
48c534b22040
Declared pred_equals/subset_eq, sup_Un_eq and SUP_UN_eq(2) as pred_set_conv rules
berghofe
parents:
46038
diff
changeset
|
120 |
lemma SUP_UN_eq2 [pred_set_conv]: "(\<Squnion>i. (\<lambda>x y. (x, y) \<in> r i)) = (\<lambda>x y. (x, y) \<in> (\<Union>i. r i))" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44415
diff
changeset
|
121 |
by (simp add: SUP_apply fun_eq_iff) |
41082 | 122 |
|
123 |
||
30328 | 124 |
subsection {* Predicates as relations *} |
125 |
||
126 |
subsubsection {* Composition *} |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
127 |
|
44414 | 128 |
inductive pred_comp :: "['a \<Rightarrow> 'b \<Rightarrow> bool, 'b \<Rightarrow> 'c \<Rightarrow> bool] \<Rightarrow> 'a \<Rightarrow> 'c \<Rightarrow> bool" (infixr "OO" 75) |
129 |
for r :: "'a \<Rightarrow> 'b \<Rightarrow> bool" and s :: "'b \<Rightarrow> 'c \<Rightarrow> bool" where |
|
130 |
pred_compI [intro]: "r a b \<Longrightarrow> s b c \<Longrightarrow> (r OO s) a c" |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
131 |
|
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
132 |
inductive_cases pred_compE [elim!]: "(r OO s) a c" |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
133 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
134 |
lemma pred_comp_rel_comp_eq [pred_set_conv]: |
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
135 |
"((\<lambda>x y. (x, y) \<in> r) OO (\<lambda>x y. (x, y) \<in> s)) = (\<lambda>x y. (x, y) \<in> r O s)" |
41550 | 136 |
by (auto simp add: fun_eq_iff) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
137 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
138 |
|
30328 | 139 |
subsubsection {* Converse *} |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
140 |
|
44414 | 141 |
inductive conversep :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> bool" ("(_^--1)" [1000] 1000) |
142 |
for r :: "'a \<Rightarrow> 'b \<Rightarrow> bool" where |
|
143 |
conversepI: "r a b \<Longrightarrow> r^--1 b a" |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
144 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
145 |
notation (xsymbols) |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
146 |
conversep ("(_\<inverse>\<inverse>)" [1000] 1000) |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
147 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
148 |
lemma conversepD: |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
149 |
assumes ab: "r^--1 a b" |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
150 |
shows "r b a" using ab |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
151 |
by cases simp |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
152 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
153 |
lemma conversep_iff [iff]: "r^--1 a b = r b a" |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
154 |
by (iprover intro: conversepI dest: conversepD) |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
155 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
156 |
lemma conversep_converse_eq [pred_set_conv]: |
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
157 |
"(\<lambda>x y. (x, y) \<in> r)^--1 = (\<lambda>x y. (x, y) \<in> r^-1)" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
158 |
by (auto simp add: fun_eq_iff) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
159 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
160 |
lemma conversep_conversep [simp]: "(r^--1)^--1 = r" |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
161 |
by (iprover intro: order_antisym conversepI dest: conversepD) |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
162 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
163 |
lemma converse_pred_comp: "(r OO s)^--1 = s^--1 OO r^--1" |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
164 |
by (iprover intro: order_antisym conversepI pred_compI |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
165 |
elim: pred_compE dest: conversepD) |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
166 |
|
44414 | 167 |
lemma converse_meet: "(r \<sqinter> s)^--1 = r^--1 \<sqinter> s^--1" |
41550 | 168 |
by (simp add: inf_fun_def) (iprover intro: conversepI ext dest: conversepD) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
169 |
|
44414 | 170 |
lemma converse_join: "(r \<squnion> s)^--1 = r^--1 \<squnion> s^--1" |
41550 | 171 |
by (simp add: sup_fun_def) (iprover intro: conversepI ext dest: conversepD) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
172 |
|
44414 | 173 |
lemma conversep_noteq [simp]: "(op \<noteq>)^--1 = op \<noteq>" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
174 |
by (auto simp add: fun_eq_iff) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
175 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
176 |
lemma conversep_eq [simp]: "(op =)^--1 = op =" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
177 |
by (auto simp add: fun_eq_iff) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
178 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
179 |
|
30328 | 180 |
subsubsection {* Domain *} |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
181 |
|
44414 | 182 |
inductive DomainP :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> bool" |
183 |
for r :: "'a \<Rightarrow> 'b \<Rightarrow> bool" where |
|
184 |
DomainPI [intro]: "r a b \<Longrightarrow> DomainP r a" |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
185 |
|
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
186 |
inductive_cases DomainPE [elim!]: "DomainP r a" |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
187 |
|
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
188 |
lemma DomainP_Domain_eq [pred_set_conv]: "DomainP (\<lambda>x y. (x, y) \<in> r) = (\<lambda>x. x \<in> Domain r)" |
26797
a6cb51c314f2
- Added mem_def and predicate1I in some of the proofs
berghofe
parents:
24345
diff
changeset
|
189 |
by (blast intro!: Orderings.order_antisym predicate1I) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
190 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
191 |
|
30328 | 192 |
subsubsection {* Range *} |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
193 |
|
44414 | 194 |
inductive RangeP :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'b \<Rightarrow> bool" |
195 |
for r :: "'a \<Rightarrow> 'b \<Rightarrow> bool" where |
|
196 |
RangePI [intro]: "r a b \<Longrightarrow> RangeP r b" |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
197 |
|
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
198 |
inductive_cases RangePE [elim!]: "RangeP r b" |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
199 |
|
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
200 |
lemma RangeP_Range_eq [pred_set_conv]: "RangeP (\<lambda>x y. (x, y) \<in> r) = (\<lambda>x. x \<in> Range r)" |
26797
a6cb51c314f2
- Added mem_def and predicate1I in some of the proofs
berghofe
parents:
24345
diff
changeset
|
201 |
by (blast intro!: Orderings.order_antisym predicate1I) |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
202 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
203 |
|
30328 | 204 |
subsubsection {* Inverse image *} |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
205 |
|
44414 | 206 |
definition inv_imagep :: "('b \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" where |
207 |
"inv_imagep r f = (\<lambda>x y. r (f x) (f y))" |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
208 |
|
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
209 |
lemma [pred_set_conv]: "inv_imagep (\<lambda>x y. (x, y) \<in> r) f = (\<lambda>x y. (x, y) \<in> inv_image r f)" |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
210 |
by (simp add: inv_image_def inv_imagep_def) |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
211 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
212 |
lemma in_inv_imagep [simp]: "inv_imagep r f x y = r (f x) (f y)" |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
213 |
by (simp add: inv_imagep_def) |
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
214 |
|
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
215 |
|
30328 | 216 |
subsubsection {* Powerset *} |
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
217 |
|
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
218 |
definition Powp :: "('a \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> bool" where |
44414 | 219 |
"Powp A = (\<lambda>B. \<forall>x \<in> B. A x)" |
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
220 |
|
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
221 |
lemma Powp_Pow_eq [pred_set_conv]: "Powp (\<lambda>x. x \<in> A) = (\<lambda>x. x \<in> Pow A)" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
222 |
by (auto simp add: Powp_def fun_eq_iff) |
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
223 |
|
46175
48c534b22040
Declared pred_equals/subset_eq, sup_Un_eq and SUP_UN_eq(2) as pred_set_conv rules
berghofe
parents:
46038
diff
changeset
|
224 |
lemmas Powp_mono [mono] = Pow_mono [to_pred] |
26797
a6cb51c314f2
- Added mem_def and predicate1I in some of the proofs
berghofe
parents:
24345
diff
changeset
|
225 |
|
23741
1801a921df13
- Moved infrastructure for converting between sets and predicates
berghofe
parents:
23708
diff
changeset
|
226 |
|
30328 | 227 |
subsubsection {* Properties of relations *} |
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
228 |
|
44414 | 229 |
abbreviation antisymP :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where |
230 |
"antisymP r \<equiv> antisym {(x, y). r x y}" |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
231 |
|
44414 | 232 |
abbreviation transP :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where |
233 |
"transP r \<equiv> trans {(x, y). r x y}" |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
234 |
|
44414 | 235 |
abbreviation single_valuedP :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool" where |
236 |
"single_valuedP r \<equiv> single_valued {(x, y). r x y}" |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
237 |
|
40813
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
238 |
(*FIXME inconsistencies: abbreviations vs. definitions, suffix `P` vs. suffix `p`*) |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
239 |
|
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
240 |
definition reflp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
241 |
"reflp r \<longleftrightarrow> refl {(x, y). r x y}" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
242 |
|
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
243 |
definition symp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
244 |
"symp r \<longleftrightarrow> sym {(x, y). r x y}" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
245 |
|
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
246 |
definition transp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
247 |
"transp r \<longleftrightarrow> trans {(x, y). r x y}" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
248 |
|
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
249 |
lemma reflpI: |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
250 |
"(\<And>x. r x x) \<Longrightarrow> reflp r" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
251 |
by (auto intro: refl_onI simp add: reflp_def) |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
252 |
|
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
253 |
lemma reflpE: |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
254 |
assumes "reflp r" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
255 |
obtains "r x x" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
256 |
using assms by (auto dest: refl_onD simp add: reflp_def) |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
257 |
|
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
258 |
lemma sympI: |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
259 |
"(\<And>x y. r x y \<Longrightarrow> r y x) \<Longrightarrow> symp r" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
260 |
by (auto intro: symI simp add: symp_def) |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
261 |
|
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
262 |
lemma sympE: |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
263 |
assumes "symp r" and "r x y" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
264 |
obtains "r y x" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
265 |
using assms by (auto dest: symD simp add: symp_def) |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
266 |
|
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
267 |
lemma transpI: |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
268 |
"(\<And>x y z. r x y \<Longrightarrow> r y z \<Longrightarrow> r x z) \<Longrightarrow> transp r" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
269 |
by (auto intro: transI simp add: transp_def) |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
270 |
|
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
271 |
lemma transpE: |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
272 |
assumes "transp r" and "r x y" and "r y z" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
273 |
obtains "r x z" |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
274 |
using assms by (auto dest: transD simp add: transp_def) |
f1fc2a1547eb
moved generic definitions about relations from Quotient.thy to Predicate;
haftmann
parents:
40674
diff
changeset
|
275 |
|
30328 | 276 |
|
277 |
subsection {* Predicates as enumerations *} |
|
278 |
||
279 |
subsubsection {* The type of predicate enumerations (a monad) *} |
|
280 |
||
281 |
datatype 'a pred = Pred "'a \<Rightarrow> bool" |
|
282 |
||
283 |
primrec eval :: "'a pred \<Rightarrow> 'a \<Rightarrow> bool" where |
|
284 |
eval_pred: "eval (Pred f) = f" |
|
285 |
||
286 |
lemma Pred_eval [simp]: |
|
287 |
"Pred (eval x) = x" |
|
288 |
by (cases x) simp |
|
289 |
||
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
290 |
lemma pred_eqI: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
291 |
"(\<And>w. eval P w \<longleftrightarrow> eval Q w) \<Longrightarrow> P = Q" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
292 |
by (cases P, cases Q) (auto simp add: fun_eq_iff) |
30328 | 293 |
|
46038
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
294 |
lemma pred_eq_iff: |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
295 |
"P = Q \<Longrightarrow> (\<And>w. eval P w \<longleftrightarrow> eval Q w)" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
296 |
by (simp add: pred_eqI) |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
297 |
|
44033 | 298 |
instantiation pred :: (type) complete_lattice |
30328 | 299 |
begin |
300 |
||
301 |
definition |
|
302 |
"P \<le> Q \<longleftrightarrow> eval P \<le> eval Q" |
|
303 |
||
304 |
definition |
|
305 |
"P < Q \<longleftrightarrow> eval P < eval Q" |
|
306 |
||
307 |
definition |
|
308 |
"\<bottom> = Pred \<bottom>" |
|
309 |
||
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
310 |
lemma eval_bot [simp]: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
311 |
"eval \<bottom> = \<bottom>" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
312 |
by (simp add: bot_pred_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
313 |
|
30328 | 314 |
definition |
315 |
"\<top> = Pred \<top>" |
|
316 |
||
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
317 |
lemma eval_top [simp]: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
318 |
"eval \<top> = \<top>" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
319 |
by (simp add: top_pred_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
320 |
|
30328 | 321 |
definition |
322 |
"P \<sqinter> Q = Pred (eval P \<sqinter> eval Q)" |
|
323 |
||
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
324 |
lemma eval_inf [simp]: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
325 |
"eval (P \<sqinter> Q) = eval P \<sqinter> eval Q" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
326 |
by (simp add: inf_pred_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
327 |
|
30328 | 328 |
definition |
329 |
"P \<squnion> Q = Pred (eval P \<squnion> eval Q)" |
|
330 |
||
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
331 |
lemma eval_sup [simp]: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
332 |
"eval (P \<squnion> Q) = eval P \<squnion> eval Q" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
333 |
by (simp add: sup_pred_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
334 |
|
30328 | 335 |
definition |
37767 | 336 |
"\<Sqinter>A = Pred (INFI A eval)" |
30328 | 337 |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
338 |
lemma eval_Inf [simp]: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
339 |
"eval (\<Sqinter>A) = INFI A eval" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
340 |
by (simp add: Inf_pred_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
341 |
|
30328 | 342 |
definition |
37767 | 343 |
"\<Squnion>A = Pred (SUPR A eval)" |
30328 | 344 |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
345 |
lemma eval_Sup [simp]: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
346 |
"eval (\<Squnion>A) = SUPR A eval" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
347 |
by (simp add: Sup_pred_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
348 |
|
44033 | 349 |
instance proof |
44415 | 350 |
qed (auto intro!: pred_eqI simp add: less_eq_pred_def less_pred_def le_fun_def less_fun_def) |
44033 | 351 |
|
352 |
end |
|
353 |
||
354 |
lemma eval_INFI [simp]: |
|
355 |
"eval (INFI A f) = INFI A (eval \<circ> f)" |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44415
diff
changeset
|
356 |
by (simp only: INF_def eval_Inf image_compose) |
44033 | 357 |
|
358 |
lemma eval_SUPR [simp]: |
|
359 |
"eval (SUPR A f) = SUPR A (eval \<circ> f)" |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44415
diff
changeset
|
360 |
by (simp only: SUP_def eval_Sup image_compose) |
44033 | 361 |
|
362 |
instantiation pred :: (type) complete_boolean_algebra |
|
363 |
begin |
|
364 |
||
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
365 |
definition |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
366 |
"- P = Pred (- eval P)" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
367 |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
368 |
lemma eval_compl [simp]: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
369 |
"eval (- P) = - eval P" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
370 |
by (simp add: uminus_pred_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
371 |
|
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
372 |
definition |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
373 |
"P - Q = Pred (eval P - eval Q)" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
374 |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
375 |
lemma eval_minus [simp]: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
376 |
"eval (P - Q) = eval P - eval Q" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
377 |
by (simp add: minus_pred_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
378 |
|
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
379 |
instance proof |
44415 | 380 |
qed (auto intro!: pred_eqI simp add: uminus_apply minus_apply INF_apply SUP_apply) |
30328 | 381 |
|
22259
476604be7d88
New theory for converting between predicates and sets.
berghofe
parents:
diff
changeset
|
382 |
end |
30328 | 383 |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
384 |
definition single :: "'a \<Rightarrow> 'a pred" where |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
385 |
"single x = Pred ((op =) x)" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
386 |
|
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
387 |
lemma eval_single [simp]: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
388 |
"eval (single x) = (op =) x" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
389 |
by (simp add: single_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
390 |
|
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
391 |
definition bind :: "'a pred \<Rightarrow> ('a \<Rightarrow> 'b pred) \<Rightarrow> 'b pred" (infixl "\<guillemotright>=" 70) where |
41080 | 392 |
"P \<guillemotright>= f = (SUPR {x. eval P x} f)" |
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
393 |
|
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
394 |
lemma eval_bind [simp]: |
41080 | 395 |
"eval (P \<guillemotright>= f) = eval (SUPR {x. eval P x} f)" |
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
396 |
by (simp add: bind_def) |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
397 |
|
30328 | 398 |
lemma bind_bind: |
399 |
"(P \<guillemotright>= Q) \<guillemotright>= R = P \<guillemotright>= (\<lambda>x. Q x \<guillemotright>= R)" |
|
44415 | 400 |
by (rule pred_eqI) (auto simp add: SUP_apply) |
30328 | 401 |
|
402 |
lemma bind_single: |
|
403 |
"P \<guillemotright>= single = P" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
404 |
by (rule pred_eqI) auto |
30328 | 405 |
|
406 |
lemma single_bind: |
|
407 |
"single x \<guillemotright>= P = P x" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
408 |
by (rule pred_eqI) auto |
30328 | 409 |
|
410 |
lemma bottom_bind: |
|
411 |
"\<bottom> \<guillemotright>= P = \<bottom>" |
|
40674
54dbe6a1c349
adhere established Collect/mem convention more closely
haftmann
parents:
40616
diff
changeset
|
412 |
by (rule pred_eqI) auto |
30328 | 413 |
|
414 |
lemma sup_bind: |
|
415 |
"(P \<squnion> Q) \<guillemotright>= R = P \<guillemotright>= R \<squnion> Q \<guillemotright>= R" |
|
40674
54dbe6a1c349
adhere established Collect/mem convention more closely
haftmann
parents:
40616
diff
changeset
|
416 |
by (rule pred_eqI) auto |
30328 | 417 |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
418 |
lemma Sup_bind: |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
419 |
"(\<Squnion>A \<guillemotright>= f) = \<Squnion>((\<lambda>x. x \<guillemotright>= f) ` A)" |
44415 | 420 |
by (rule pred_eqI) (auto simp add: SUP_apply) |
30328 | 421 |
|
422 |
lemma pred_iffI: |
|
423 |
assumes "\<And>x. eval A x \<Longrightarrow> eval B x" |
|
424 |
and "\<And>x. eval B x \<Longrightarrow> eval A x" |
|
425 |
shows "A = B" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
426 |
using assms by (auto intro: pred_eqI) |
30328 | 427 |
|
428 |
lemma singleI: "eval (single x) x" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
429 |
by simp |
30328 | 430 |
|
431 |
lemma singleI_unit: "eval (single ()) x" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
432 |
by simp |
30328 | 433 |
|
434 |
lemma singleE: "eval (single x) y \<Longrightarrow> (y = x \<Longrightarrow> P) \<Longrightarrow> P" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
435 |
by simp |
30328 | 436 |
|
437 |
lemma singleE': "eval (single x) y \<Longrightarrow> (x = y \<Longrightarrow> P) \<Longrightarrow> P" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
438 |
by simp |
30328 | 439 |
|
440 |
lemma bindI: "eval P x \<Longrightarrow> eval (Q x) y \<Longrightarrow> eval (P \<guillemotright>= Q) y" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
441 |
by auto |
30328 | 442 |
|
443 |
lemma bindE: "eval (R \<guillemotright>= Q) y \<Longrightarrow> (\<And>x. eval R x \<Longrightarrow> eval (Q x) y \<Longrightarrow> P) \<Longrightarrow> P" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
444 |
by auto |
30328 | 445 |
|
446 |
lemma botE: "eval \<bottom> x \<Longrightarrow> P" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
447 |
by auto |
30328 | 448 |
|
449 |
lemma supI1: "eval A x \<Longrightarrow> eval (A \<squnion> B) x" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
450 |
by auto |
30328 | 451 |
|
452 |
lemma supI2: "eval B x \<Longrightarrow> eval (A \<squnion> B) x" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
453 |
by auto |
30328 | 454 |
|
455 |
lemma supE: "eval (A \<squnion> B) x \<Longrightarrow> (eval A x \<Longrightarrow> P) \<Longrightarrow> (eval B x \<Longrightarrow> P) \<Longrightarrow> P" |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
456 |
by auto |
30328 | 457 |
|
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
458 |
lemma single_not_bot [simp]: |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
459 |
"single x \<noteq> \<bottom>" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
460 |
by (auto simp add: single_def bot_pred_def fun_eq_iff) |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
461 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
462 |
lemma not_bot: |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
463 |
assumes "A \<noteq> \<bottom>" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
464 |
obtains x where "eval A x" |
45970
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
465 |
using assms by (cases A) (auto simp add: bot_pred_def) |
b6d0cff57d96
adjusted to set/pred distinction by means of type constructor `set`
haftmann
parents:
45630
diff
changeset
|
466 |
|
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
467 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
468 |
subsubsection {* Emptiness check and definite choice *} |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
469 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
470 |
definition is_empty :: "'a pred \<Rightarrow> bool" where |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
471 |
"is_empty A \<longleftrightarrow> A = \<bottom>" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
472 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
473 |
lemma is_empty_bot: |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
474 |
"is_empty \<bottom>" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
475 |
by (simp add: is_empty_def) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
476 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
477 |
lemma not_is_empty_single: |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
478 |
"\<not> is_empty (single x)" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
479 |
by (auto simp add: is_empty_def single_def bot_pred_def fun_eq_iff) |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
480 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
481 |
lemma is_empty_sup: |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
482 |
"is_empty (A \<squnion> B) \<longleftrightarrow> is_empty A \<and> is_empty B" |
36008 | 483 |
by (auto simp add: is_empty_def) |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
484 |
|
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
485 |
definition singleton :: "(unit \<Rightarrow> 'a) \<Rightarrow> 'a pred \<Rightarrow> 'a" where |
33111 | 486 |
"singleton dfault A = (if \<exists>!x. eval A x then THE x. eval A x else dfault ())" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
487 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
488 |
lemma singleton_eqI: |
33110 | 489 |
"\<exists>!x. eval A x \<Longrightarrow> eval A x \<Longrightarrow> singleton dfault A = x" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
490 |
by (auto simp add: singleton_def) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
491 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
492 |
lemma eval_singletonI: |
33110 | 493 |
"\<exists>!x. eval A x \<Longrightarrow> eval A (singleton dfault A)" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
494 |
proof - |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
495 |
assume assm: "\<exists>!x. eval A x" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
496 |
then obtain x where "eval A x" .. |
33110 | 497 |
moreover with assm have "singleton dfault A = x" by (rule singleton_eqI) |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
498 |
ultimately show ?thesis by simp |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
499 |
qed |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
500 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
501 |
lemma single_singleton: |
33110 | 502 |
"\<exists>!x. eval A x \<Longrightarrow> single (singleton dfault A) = A" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
503 |
proof - |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
504 |
assume assm: "\<exists>!x. eval A x" |
33110 | 505 |
then have "eval A (singleton dfault A)" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
506 |
by (rule eval_singletonI) |
33110 | 507 |
moreover from assm have "\<And>x. eval A x \<Longrightarrow> singleton dfault A = x" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
508 |
by (rule singleton_eqI) |
33110 | 509 |
ultimately have "eval (single (singleton dfault A)) = eval A" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
510 |
by (simp (no_asm_use) add: single_def fun_eq_iff) blast |
40616
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
511 |
then have "\<And>x. eval (single (singleton dfault A)) x = eval A x" |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
512 |
by simp |
c5ee1e06d795
eval simp rules for predicate type, simplify primitive proofs
haftmann
parents:
39302
diff
changeset
|
513 |
then show ?thesis by (rule pred_eqI) |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
514 |
qed |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
515 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
516 |
lemma singleton_undefinedI: |
33111 | 517 |
"\<not> (\<exists>!x. eval A x) \<Longrightarrow> singleton dfault A = dfault ()" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
518 |
by (simp add: singleton_def) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
519 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
520 |
lemma singleton_bot: |
33111 | 521 |
"singleton dfault \<bottom> = dfault ()" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
522 |
by (auto simp add: bot_pred_def intro: singleton_undefinedI) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
523 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
524 |
lemma singleton_single: |
33110 | 525 |
"singleton dfault (single x) = x" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
526 |
by (auto simp add: intro: singleton_eqI singleI elim: singleE) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
527 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
528 |
lemma singleton_sup_single_single: |
33111 | 529 |
"singleton dfault (single x \<squnion> single y) = (if x = y then x else dfault ())" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
530 |
proof (cases "x = y") |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
531 |
case True then show ?thesis by (simp add: singleton_single) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
532 |
next |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
533 |
case False |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
534 |
have "eval (single x \<squnion> single y) x" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
535 |
and "eval (single x \<squnion> single y) y" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
536 |
by (auto intro: supI1 supI2 singleI) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
537 |
with False have "\<not> (\<exists>!z. eval (single x \<squnion> single y) z)" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
538 |
by blast |
33111 | 539 |
then have "singleton dfault (single x \<squnion> single y) = dfault ()" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
540 |
by (rule singleton_undefinedI) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
541 |
with False show ?thesis by simp |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
542 |
qed |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
543 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
544 |
lemma singleton_sup_aux: |
33110 | 545 |
"singleton dfault (A \<squnion> B) = (if A = \<bottom> then singleton dfault B |
546 |
else if B = \<bottom> then singleton dfault A |
|
547 |
else singleton dfault |
|
548 |
(single (singleton dfault A) \<squnion> single (singleton dfault B)))" |
|
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
549 |
proof (cases "(\<exists>!x. eval A x) \<and> (\<exists>!y. eval B y)") |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
550 |
case True then show ?thesis by (simp add: single_singleton) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
551 |
next |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
552 |
case False |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
553 |
from False have A_or_B: |
33111 | 554 |
"singleton dfault A = dfault () \<or> singleton dfault B = dfault ()" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
555 |
by (auto intro!: singleton_undefinedI) |
33110 | 556 |
then have rhs: "singleton dfault |
33111 | 557 |
(single (singleton dfault A) \<squnion> single (singleton dfault B)) = dfault ()" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
558 |
by (auto simp add: singleton_sup_single_single singleton_single) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
559 |
from False have not_unique: |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
560 |
"\<not> (\<exists>!x. eval A x) \<or> \<not> (\<exists>!y. eval B y)" by simp |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
561 |
show ?thesis proof (cases "A \<noteq> \<bottom> \<and> B \<noteq> \<bottom>") |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
562 |
case True |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
563 |
then obtain a b where a: "eval A a" and b: "eval B b" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
564 |
by (blast elim: not_bot) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
565 |
with True not_unique have "\<not> (\<exists>!x. eval (A \<squnion> B) x)" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
566 |
by (auto simp add: sup_pred_def bot_pred_def) |
33111 | 567 |
then have "singleton dfault (A \<squnion> B) = dfault ()" by (rule singleton_undefinedI) |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
568 |
with True rhs show ?thesis by simp |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
569 |
next |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
570 |
case False then show ?thesis by auto |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
571 |
qed |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
572 |
qed |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
573 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
574 |
lemma singleton_sup: |
33110 | 575 |
"singleton dfault (A \<squnion> B) = (if A = \<bottom> then singleton dfault B |
576 |
else if B = \<bottom> then singleton dfault A |
|
33111 | 577 |
else if singleton dfault A = singleton dfault B then singleton dfault A else dfault ())" |
33110 | 578 |
using singleton_sup_aux [of dfault A B] by (simp only: singleton_sup_single_single) |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
579 |
|
30328 | 580 |
|
581 |
subsubsection {* Derived operations *} |
|
582 |
||
583 |
definition if_pred :: "bool \<Rightarrow> unit pred" where |
|
584 |
if_pred_eq: "if_pred b = (if b then single () else \<bottom>)" |
|
585 |
||
33754
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
586 |
definition holds :: "unit pred \<Rightarrow> bool" where |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
587 |
holds_eq: "holds P = eval P ()" |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
588 |
|
30328 | 589 |
definition not_pred :: "unit pred \<Rightarrow> unit pred" where |
590 |
not_pred_eq: "not_pred P = (if eval P () then \<bottom> else single ())" |
|
591 |
||
592 |
lemma if_predI: "P \<Longrightarrow> eval (if_pred P) ()" |
|
593 |
unfolding if_pred_eq by (auto intro: singleI) |
|
594 |
||
595 |
lemma if_predE: "eval (if_pred b) x \<Longrightarrow> (b \<Longrightarrow> x = () \<Longrightarrow> P) \<Longrightarrow> P" |
|
596 |
unfolding if_pred_eq by (cases b) (auto elim: botE) |
|
597 |
||
598 |
lemma not_predI: "\<not> P \<Longrightarrow> eval (not_pred (Pred (\<lambda>u. P))) ()" |
|
599 |
unfolding not_pred_eq eval_pred by (auto intro: singleI) |
|
600 |
||
601 |
lemma not_predI': "\<not> eval P () \<Longrightarrow> eval (not_pred P) ()" |
|
602 |
unfolding not_pred_eq by (auto intro: singleI) |
|
603 |
||
604 |
lemma not_predE: "eval (not_pred (Pred (\<lambda>u. P))) x \<Longrightarrow> (\<not> P \<Longrightarrow> thesis) \<Longrightarrow> thesis" |
|
605 |
unfolding not_pred_eq |
|
606 |
by (auto split: split_if_asm elim: botE) |
|
607 |
||
608 |
lemma not_predE': "eval (not_pred P) x \<Longrightarrow> (\<not> eval P x \<Longrightarrow> thesis) \<Longrightarrow> thesis" |
|
609 |
unfolding not_pred_eq |
|
610 |
by (auto split: split_if_asm elim: botE) |
|
33754
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
611 |
lemma "f () = False \<or> f () = True" |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
612 |
by simp |
30328 | 613 |
|
37549 | 614 |
lemma closure_of_bool_cases [no_atp]: |
44007 | 615 |
fixes f :: "unit \<Rightarrow> bool" |
616 |
assumes "f = (\<lambda>u. False) \<Longrightarrow> P f" |
|
617 |
assumes "f = (\<lambda>u. True) \<Longrightarrow> P f" |
|
618 |
shows "P f" |
|
33754
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
619 |
proof - |
44007 | 620 |
have "f = (\<lambda>u. False) \<or> f = (\<lambda>u. True)" |
33754
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
621 |
apply (cases "f ()") |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
622 |
apply (rule disjI2) |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
623 |
apply (rule ext) |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
624 |
apply (simp add: unit_eq) |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
625 |
apply (rule disjI1) |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
626 |
apply (rule ext) |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
627 |
apply (simp add: unit_eq) |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
628 |
done |
41550 | 629 |
from this assms show ?thesis by blast |
33754
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
630 |
qed |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
631 |
|
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
632 |
lemma unit_pred_cases: |
44007 | 633 |
assumes "P \<bottom>" |
634 |
assumes "P (single ())" |
|
635 |
shows "P Q" |
|
44415 | 636 |
using assms unfolding bot_pred_def bot_fun_def bot_bool_def empty_def single_def proof (cases Q) |
44007 | 637 |
fix f |
638 |
assume "P (Pred (\<lambda>u. False))" "P (Pred (\<lambda>u. () = u))" |
|
639 |
then have "P (Pred f)" |
|
640 |
by (cases _ f rule: closure_of_bool_cases) simp_all |
|
641 |
moreover assume "Q = Pred f" |
|
642 |
ultimately show "P Q" by simp |
|
643 |
qed |
|
644 |
||
33754
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
645 |
lemma holds_if_pred: |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
646 |
"holds (if_pred b) = b" |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
647 |
unfolding if_pred_eq holds_eq |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
648 |
by (cases b) (auto intro: singleI elim: botE) |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
649 |
|
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
650 |
lemma if_pred_holds: |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
651 |
"if_pred (holds P) = P" |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
652 |
unfolding if_pred_eq holds_eq |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
653 |
by (rule unit_pred_cases) (auto intro: singleI elim: botE) |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
654 |
|
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
655 |
lemma is_empty_holds: |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
656 |
"is_empty P \<longleftrightarrow> \<not> holds P" |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
657 |
unfolding is_empty_def holds_eq |
f2957bd46faf
adding derived constant Predicate.holds to Predicate theory; adopting the predicate compiler
bulwahn
parents:
33622
diff
changeset
|
658 |
by (rule unit_pred_cases) (auto elim: botE intro: singleI) |
30328 | 659 |
|
41311 | 660 |
definition map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a pred \<Rightarrow> 'b pred" where |
661 |
"map f P = P \<guillemotright>= (single o f)" |
|
662 |
||
663 |
lemma eval_map [simp]: |
|
44363 | 664 |
"eval (map f P) = (\<Squnion>x\<in>{x. eval P x}. (\<lambda>y. f x = y))" |
44415 | 665 |
by (auto simp add: map_def comp_def) |
41311 | 666 |
|
41505
6d19301074cf
"enriched_type" replaces less specific "type_lifting"
haftmann
parents:
41372
diff
changeset
|
667 |
enriched_type map: map |
44363 | 668 |
by (rule ext, rule pred_eqI, auto)+ |
41311 | 669 |
|
670 |
||
30328 | 671 |
subsubsection {* Implementation *} |
672 |
||
673 |
datatype 'a seq = Empty | Insert "'a" "'a pred" | Join "'a pred" "'a seq" |
|
674 |
||
675 |
primrec pred_of_seq :: "'a seq \<Rightarrow> 'a pred" where |
|
44414 | 676 |
"pred_of_seq Empty = \<bottom>" |
677 |
| "pred_of_seq (Insert x P) = single x \<squnion> P" |
|
678 |
| "pred_of_seq (Join P xq) = P \<squnion> pred_of_seq xq" |
|
30328 | 679 |
|
680 |
definition Seq :: "(unit \<Rightarrow> 'a seq) \<Rightarrow> 'a pred" where |
|
681 |
"Seq f = pred_of_seq (f ())" |
|
682 |
||
683 |
code_datatype Seq |
|
684 |
||
685 |
primrec member :: "'a seq \<Rightarrow> 'a \<Rightarrow> bool" where |
|
686 |
"member Empty x \<longleftrightarrow> False" |
|
44414 | 687 |
| "member (Insert y P) x \<longleftrightarrow> x = y \<or> eval P x" |
688 |
| "member (Join P xq) x \<longleftrightarrow> eval P x \<or> member xq x" |
|
30328 | 689 |
|
690 |
lemma eval_member: |
|
691 |
"member xq = eval (pred_of_seq xq)" |
|
692 |
proof (induct xq) |
|
693 |
case Empty show ?case |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
694 |
by (auto simp add: fun_eq_iff elim: botE) |
30328 | 695 |
next |
696 |
case Insert show ?case |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
697 |
by (auto simp add: fun_eq_iff elim: supE singleE intro: supI1 supI2 singleI) |
30328 | 698 |
next |
699 |
case Join then show ?case |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
700 |
by (auto simp add: fun_eq_iff elim: supE intro: supI1 supI2) |
30328 | 701 |
qed |
702 |
||
46038
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
703 |
lemma eval_code [(* FIXME declare simp *)code]: "eval (Seq f) = member (f ())" |
30328 | 704 |
unfolding Seq_def by (rule sym, rule eval_member) |
705 |
||
706 |
lemma single_code [code]: |
|
707 |
"single x = Seq (\<lambda>u. Insert x \<bottom>)" |
|
708 |
unfolding Seq_def by simp |
|
709 |
||
41080 | 710 |
primrec "apply" :: "('a \<Rightarrow> 'b pred) \<Rightarrow> 'a seq \<Rightarrow> 'b seq" where |
44415 | 711 |
"apply f Empty = Empty" |
712 |
| "apply f (Insert x P) = Join (f x) (Join (P \<guillemotright>= f) Empty)" |
|
713 |
| "apply f (Join P xq) = Join (P \<guillemotright>= f) (apply f xq)" |
|
30328 | 714 |
|
715 |
lemma apply_bind: |
|
716 |
"pred_of_seq (apply f xq) = pred_of_seq xq \<guillemotright>= f" |
|
717 |
proof (induct xq) |
|
718 |
case Empty show ?case |
|
719 |
by (simp add: bottom_bind) |
|
720 |
next |
|
721 |
case Insert show ?case |
|
722 |
by (simp add: single_bind sup_bind) |
|
723 |
next |
|
724 |
case Join then show ?case |
|
725 |
by (simp add: sup_bind) |
|
726 |
qed |
|
727 |
||
728 |
lemma bind_code [code]: |
|
729 |
"Seq g \<guillemotright>= f = Seq (\<lambda>u. apply f (g ()))" |
|
730 |
unfolding Seq_def by (rule sym, rule apply_bind) |
|
731 |
||
732 |
lemma bot_set_code [code]: |
|
733 |
"\<bottom> = Seq (\<lambda>u. Empty)" |
|
734 |
unfolding Seq_def by simp |
|
735 |
||
30376 | 736 |
primrec adjunct :: "'a pred \<Rightarrow> 'a seq \<Rightarrow> 'a seq" where |
44415 | 737 |
"adjunct P Empty = Join P Empty" |
738 |
| "adjunct P (Insert x Q) = Insert x (Q \<squnion> P)" |
|
739 |
| "adjunct P (Join Q xq) = Join Q (adjunct P xq)" |
|
30376 | 740 |
|
741 |
lemma adjunct_sup: |
|
742 |
"pred_of_seq (adjunct P xq) = P \<squnion> pred_of_seq xq" |
|
743 |
by (induct xq) (simp_all add: sup_assoc sup_commute sup_left_commute) |
|
744 |
||
30328 | 745 |
lemma sup_code [code]: |
746 |
"Seq f \<squnion> Seq g = Seq (\<lambda>u. case f () |
|
747 |
of Empty \<Rightarrow> g () |
|
748 |
| Insert x P \<Rightarrow> Insert x (P \<squnion> Seq g) |
|
30376 | 749 |
| Join P xq \<Rightarrow> adjunct (Seq g) (Join P xq))" |
30328 | 750 |
proof (cases "f ()") |
751 |
case Empty |
|
752 |
thus ?thesis |
|
34007
aea892559fc5
tuned lattices theory fragements; generlized some lemmas from sets to lattices
haftmann
parents:
33988
diff
changeset
|
753 |
unfolding Seq_def by (simp add: sup_commute [of "\<bottom>"]) |
30328 | 754 |
next |
755 |
case Insert |
|
756 |
thus ?thesis |
|
757 |
unfolding Seq_def by (simp add: sup_assoc) |
|
758 |
next |
|
759 |
case Join |
|
760 |
thus ?thesis |
|
30376 | 761 |
unfolding Seq_def |
762 |
by (simp add: adjunct_sup sup_assoc sup_commute sup_left_commute) |
|
30328 | 763 |
qed |
764 |
||
30430
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
765 |
primrec contained :: "'a seq \<Rightarrow> 'a pred \<Rightarrow> bool" where |
44415 | 766 |
"contained Empty Q \<longleftrightarrow> True" |
767 |
| "contained (Insert x P) Q \<longleftrightarrow> eval Q x \<and> P \<le> Q" |
|
768 |
| "contained (Join P xq) Q \<longleftrightarrow> P \<le> Q \<and> contained xq Q" |
|
30430
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
769 |
|
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
770 |
lemma single_less_eq_eval: |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
771 |
"single x \<le> P \<longleftrightarrow> eval P x" |
44415 | 772 |
by (auto simp add: less_eq_pred_def le_fun_def) |
30430
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
773 |
|
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
774 |
lemma contained_less_eq: |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
775 |
"contained xq Q \<longleftrightarrow> pred_of_seq xq \<le> Q" |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
776 |
by (induct xq) (simp_all add: single_less_eq_eval) |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
777 |
|
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
778 |
lemma less_eq_pred_code [code]: |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
779 |
"Seq f \<le> Q = (case f () |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
780 |
of Empty \<Rightarrow> True |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
781 |
| Insert x P \<Rightarrow> eval Q x \<and> P \<le> Q |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
782 |
| Join P xq \<Rightarrow> P \<le> Q \<and> contained xq Q)" |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
783 |
by (cases "f ()") |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
784 |
(simp_all add: Seq_def single_less_eq_eval contained_less_eq) |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
785 |
|
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
786 |
lemma eq_pred_code [code]: |
31133 | 787 |
fixes P Q :: "'a pred" |
38857
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
haftmann
parents:
38651
diff
changeset
|
788 |
shows "HOL.equal P Q \<longleftrightarrow> P \<le> Q \<and> Q \<le> P" |
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
haftmann
parents:
38651
diff
changeset
|
789 |
by (auto simp add: equal) |
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
haftmann
parents:
38651
diff
changeset
|
790 |
|
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
haftmann
parents:
38651
diff
changeset
|
791 |
lemma [code nbe]: |
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
haftmann
parents:
38651
diff
changeset
|
792 |
"HOL.equal (x :: 'a pred) x \<longleftrightarrow> True" |
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
haftmann
parents:
38651
diff
changeset
|
793 |
by (fact equal_refl) |
30430
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
794 |
|
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
795 |
lemma [code]: |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
796 |
"pred_case f P = f (eval P)" |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
797 |
by (cases P) simp |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
798 |
|
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
799 |
lemma [code]: |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
800 |
"pred_rec f P = f (eval P)" |
42ea5d85edcc
explicit code equations for some rarely used pred operations
haftmann
parents:
30378
diff
changeset
|
801 |
by (cases P) simp |
30328 | 802 |
|
31105
95f66b234086
added general preprocessing of equality in predicates for code generation
bulwahn
parents:
30430
diff
changeset
|
803 |
inductive eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool" where "eq x x" |
95f66b234086
added general preprocessing of equality in predicates for code generation
bulwahn
parents:
30430
diff
changeset
|
804 |
|
95f66b234086
added general preprocessing of equality in predicates for code generation
bulwahn
parents:
30430
diff
changeset
|
805 |
lemma eq_is_eq: "eq x y \<equiv> (x = y)" |
31108 | 806 |
by (rule eq_reflection) (auto intro: eq.intros elim: eq.cases) |
30948 | 807 |
|
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
808 |
primrec null :: "'a seq \<Rightarrow> bool" where |
44415 | 809 |
"null Empty \<longleftrightarrow> True" |
810 |
| "null (Insert x P) \<longleftrightarrow> False" |
|
811 |
| "null (Join P xq) \<longleftrightarrow> is_empty P \<and> null xq" |
|
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
812 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
813 |
lemma null_is_empty: |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
814 |
"null xq \<longleftrightarrow> is_empty (pred_of_seq xq)" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
815 |
by (induct xq) (simp_all add: is_empty_bot not_is_empty_single is_empty_sup) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
816 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
817 |
lemma is_empty_code [code]: |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
818 |
"is_empty (Seq f) \<longleftrightarrow> null (f ())" |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
819 |
by (simp add: null_is_empty Seq_def) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
820 |
|
33111 | 821 |
primrec the_only :: "(unit \<Rightarrow> 'a) \<Rightarrow> 'a seq \<Rightarrow> 'a" where |
822 |
[code del]: "the_only dfault Empty = dfault ()" |
|
44415 | 823 |
| "the_only dfault (Insert x P) = (if is_empty P then x else let y = singleton dfault P in if x = y then x else dfault ())" |
824 |
| "the_only dfault (Join P xq) = (if is_empty P then the_only dfault xq else if null xq then singleton dfault P |
|
33110 | 825 |
else let x = singleton dfault P; y = the_only dfault xq in |
33111 | 826 |
if x = y then x else dfault ())" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
827 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
828 |
lemma the_only_singleton: |
33110 | 829 |
"the_only dfault xq = singleton dfault (pred_of_seq xq)" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
830 |
by (induct xq) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
831 |
(auto simp add: singleton_bot singleton_single is_empty_def |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
832 |
null_is_empty Let_def singleton_sup) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
833 |
|
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
834 |
lemma singleton_code [code]: |
33110 | 835 |
"singleton dfault (Seq f) = (case f () |
33111 | 836 |
of Empty \<Rightarrow> dfault () |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
837 |
| Insert x P \<Rightarrow> if is_empty P then x |
33110 | 838 |
else let y = singleton dfault P in |
33111 | 839 |
if x = y then x else dfault () |
33110 | 840 |
| Join P xq \<Rightarrow> if is_empty P then the_only dfault xq |
841 |
else if null xq then singleton dfault P |
|
842 |
else let x = singleton dfault P; y = the_only dfault xq in |
|
33111 | 843 |
if x = y then x else dfault ())" |
32578
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
844 |
by (cases "f ()") |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
845 |
(auto simp add: Seq_def the_only_singleton is_empty_def |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
846 |
null_is_empty singleton_bot singleton_single singleton_sup Let_def) |
22117a76f943
added emptiness check predicate and singleton projection
haftmann
parents:
32372
diff
changeset
|
847 |
|
44414 | 848 |
definition the :: "'a pred \<Rightarrow> 'a" where |
37767 | 849 |
"the A = (THE x. eval A x)" |
33111 | 850 |
|
40674
54dbe6a1c349
adhere established Collect/mem convention more closely
haftmann
parents:
40616
diff
changeset
|
851 |
lemma the_eqI: |
41080 | 852 |
"(THE x. eval P x) = x \<Longrightarrow> the P = x" |
40674
54dbe6a1c349
adhere established Collect/mem convention more closely
haftmann
parents:
40616
diff
changeset
|
853 |
by (simp add: the_def) |
54dbe6a1c349
adhere established Collect/mem convention more closely
haftmann
parents:
40616
diff
changeset
|
854 |
|
44414 | 855 |
definition not_unique :: "'a pred \<Rightarrow> 'a" where |
856 |
[code del]: "not_unique A = (THE x. eval A x)" |
|
857 |
||
858 |
code_abort not_unique |
|
859 |
||
40674
54dbe6a1c349
adhere established Collect/mem convention more closely
haftmann
parents:
40616
diff
changeset
|
860 |
lemma the_eq [code]: "the A = singleton (\<lambda>x. not_unique A) A" |
54dbe6a1c349
adhere established Collect/mem convention more closely
haftmann
parents:
40616
diff
changeset
|
861 |
by (rule the_eqI) (simp add: singleton_def not_unique_def) |
33110 | 862 |
|
36531
19f6e3b0d9b6
code_reflect: specify module name directly after keyword
haftmann
parents:
36513
diff
changeset
|
863 |
code_reflect Predicate |
36513 | 864 |
datatypes pred = Seq and seq = Empty | Insert | Join |
865 |
functions map |
|
866 |
||
30948 | 867 |
ML {* |
868 |
signature PREDICATE = |
|
869 |
sig |
|
870 |
datatype 'a pred = Seq of (unit -> 'a seq) |
|
871 |
and 'a seq = Empty | Insert of 'a * 'a pred | Join of 'a pred * 'a seq |
|
30959
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
872 |
val yield: 'a pred -> ('a * 'a pred) option |
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
873 |
val yieldn: int -> 'a pred -> 'a list * 'a pred |
31222 | 874 |
val map: ('a -> 'b) -> 'a pred -> 'b pred |
30948 | 875 |
end; |
876 |
||
877 |
structure Predicate : PREDICATE = |
|
878 |
struct |
|
879 |
||
36513 | 880 |
datatype pred = datatype Predicate.pred |
881 |
datatype seq = datatype Predicate.seq |
|
882 |
||
883 |
fun map f = Predicate.map f; |
|
30959
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
884 |
|
36513 | 885 |
fun yield (Seq f) = next (f ()) |
886 |
and next Empty = NONE |
|
887 |
| next (Insert (x, P)) = SOME (x, P) |
|
888 |
| next (Join (P, xq)) = (case yield P |
|
30959
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
889 |
of NONE => next xq |
36513 | 890 |
| SOME (x, Q) => SOME (x, Seq (fn _ => Join (Q, xq)))); |
30959
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
891 |
|
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
892 |
fun anamorph f k x = (if k = 0 then ([], x) |
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
893 |
else case f x |
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
894 |
of NONE => ([], x) |
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
895 |
| SOME (v, y) => let |
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
896 |
val (vs, z) = anamorph f (k - 1) y |
33607 | 897 |
in (v :: vs, z) end); |
30959
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
898 |
|
458e55fd0a33
fixed compilation of predicate types in ML environment
haftmann
parents:
30948
diff
changeset
|
899 |
fun yieldn P = anamorph yield P; |
30948 | 900 |
|
901 |
end; |
|
902 |
*} |
|
903 |
||
46038
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
904 |
text {* Conversion from and to sets *} |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
905 |
|
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
906 |
definition pred_of_set :: "'a set \<Rightarrow> 'a pred" where |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
907 |
"pred_of_set = Pred \<circ> (\<lambda>A x. x \<in> A)" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
908 |
|
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
909 |
lemma eval_pred_of_set [simp]: |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
910 |
"eval (pred_of_set A) x \<longleftrightarrow> x \<in>A" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
911 |
by (simp add: pred_of_set_def) |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
912 |
|
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
913 |
definition set_of_pred :: "'a pred \<Rightarrow> 'a set" where |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
914 |
"set_of_pred = Collect \<circ> eval" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
915 |
|
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
916 |
lemma member_set_of_pred [simp]: |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
917 |
"x \<in> set_of_pred P \<longleftrightarrow> Predicate.eval P x" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
918 |
by (simp add: set_of_pred_def) |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
919 |
|
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
920 |
definition set_of_seq :: "'a seq \<Rightarrow> 'a set" where |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
921 |
"set_of_seq = set_of_pred \<circ> pred_of_seq" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
922 |
|
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
923 |
lemma member_set_of_seq [simp]: |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
924 |
"x \<in> set_of_seq xq = Predicate.member xq x" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
925 |
by (simp add: set_of_seq_def eval_member) |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
926 |
|
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
927 |
lemma of_pred_code [code]: |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
928 |
"set_of_pred (Predicate.Seq f) = (case f () of |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
929 |
Predicate.Empty \<Rightarrow> {} |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
930 |
| Predicate.Insert x P \<Rightarrow> insert x (set_of_pred P) |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
931 |
| Predicate.Join P xq \<Rightarrow> set_of_pred P \<union> set_of_seq xq)" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
932 |
by (auto split: seq.split simp add: eval_code) |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
933 |
|
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
934 |
lemma of_seq_code [code]: |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
935 |
"set_of_seq Predicate.Empty = {}" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
936 |
"set_of_seq (Predicate.Insert x P) = insert x (set_of_pred P)" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
937 |
"set_of_seq (Predicate.Join P xq) = set_of_pred P \<union> set_of_seq xq" |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
938 |
by auto |
bb2f7488a0f1
conversions from sets to predicates and vice versa; extensionality on predicates
haftmann
parents:
45970
diff
changeset
|
939 |
|
30328 | 940 |
no_notation |
41082 | 941 |
bot ("\<bottom>") and |
942 |
top ("\<top>") and |
|
30328 | 943 |
inf (infixl "\<sqinter>" 70) and |
944 |
sup (infixl "\<squnion>" 65) and |
|
945 |
Inf ("\<Sqinter>_" [900] 900) and |
|
946 |
Sup ("\<Squnion>_" [900] 900) and |
|
947 |
bind (infixl "\<guillemotright>=" 70) |
|
948 |
||
41080 | 949 |
no_syntax (xsymbols) |
41082 | 950 |
"_INF1" :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sqinter>_./ _)" [0, 10] 10) |
951 |
"_INF" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10) |
|
41080 | 952 |
"_SUP1" :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Squnion>_./ _)" [0, 10] 10) |
953 |
"_SUP" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10) |
|
954 |
||
36176
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
36008
diff
changeset
|
955 |
hide_type (open) pred seq |
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
36008
diff
changeset
|
956 |
hide_const (open) Pred eval single bind is_empty singleton if_pred not_pred holds |
33111 | 957 |
Empty Insert Join Seq member pred_of_seq "apply" adjunct null the_only eq map not_unique the |
30328 | 958 |
|
959 |
end |