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