author | Christian Urban <urbanc@in.tum.de> |
Thu, 03 Jun 2010 15:02:52 +0200 | |
changeset 2310 | dd3b9c046c7d |
parent 1260 | 9df6144e281b |
permissions | -rw-r--r-- |
1128
17ca92ab4660
Main renaming + fixes for new Isabelle in IntEx2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1122
diff
changeset
|
1 |
(* Title: Quotient_Option.thy |
932
7781c7cbd27e
used the internal Option.map instead of custom option_map
Christian Urban <urbanc@in.tum.de>
parents:
925
diff
changeset
|
2 |
Author: Cezary Kaliszyk and Christian Urban |
7781c7cbd27e
used the internal Option.map instead of custom option_map
Christian Urban <urbanc@in.tum.de>
parents:
925
diff
changeset
|
3 |
*) |
1128
17ca92ab4660
Main renaming + fixes for new Isabelle in IntEx2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1122
diff
changeset
|
4 |
theory Quotient_Option |
1129
9a86f0ef6503
Notation available locally
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1128
diff
changeset
|
5 |
imports Quotient Quotient_Syntax |
698 | 6 |
begin |
7 |
||
937 | 8 |
section {* Quotient infrastructure for the option type. *} |
932
7781c7cbd27e
used the internal Option.map instead of custom option_map
Christian Urban <urbanc@in.tum.de>
parents:
925
diff
changeset
|
9 |
|
698 | 10 |
fun |
11 |
option_rel |
|
12 |
where |
|
13 |
"option_rel R None None = True" |
|
14 |
| "option_rel R (Some x) None = False" |
|
15 |
| "option_rel R None (Some x) = False" |
|
16 |
| "option_rel R (Some x) (Some y) = R x y" |
|
17 |
||
932
7781c7cbd27e
used the internal Option.map instead of custom option_map
Christian Urban <urbanc@in.tum.de>
parents:
925
diff
changeset
|
18 |
declare [[map option = (Option.map, option_rel)]] |
698 | 19 |
|
933
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
20 |
text {* should probably be in Option.thy *} |
1128
17ca92ab4660
Main renaming + fixes for new Isabelle in IntEx2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1122
diff
changeset
|
21 |
lemma split_option_all: |
933
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
22 |
shows "(\<forall>x. P x) \<longleftrightarrow> P None \<and> (\<forall>a. P (Some a))" |
937 | 23 |
apply(auto) |
24 |
apply(case_tac x) |
|
25 |
apply(simp_all) |
|
26 |
done |
|
698 | 27 |
|
28 |
lemma option_quotient[quot_thm]: |
|
29 |
assumes q: "Quotient R Abs Rep" |
|
932
7781c7cbd27e
used the internal Option.map instead of custom option_map
Christian Urban <urbanc@in.tum.de>
parents:
925
diff
changeset
|
30 |
shows "Quotient (option_rel R) (Option.map Abs) (Option.map Rep)" |
7781c7cbd27e
used the internal Option.map instead of custom option_map
Christian Urban <urbanc@in.tum.de>
parents:
925
diff
changeset
|
31 |
unfolding Quotient_def |
933
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
32 |
apply(simp add: split_option_all) |
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
33 |
apply(simp add: Quotient_abs_rep[OF q] Quotient_rel_rep[OF q]) |
698 | 34 |
using q |
35 |
unfolding Quotient_def |
|
933
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
36 |
apply(blast) |
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
37 |
done |
1128
17ca92ab4660
Main renaming + fixes for new Isabelle in IntEx2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1122
diff
changeset
|
38 |
|
698 | 39 |
lemma option_equivp[quot_equiv]: |
40 |
assumes a: "equivp R" |
|
41 |
shows "equivp (option_rel R)" |
|
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
42 |
apply(rule equivpI) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
43 |
unfolding reflp_def symp_def transp_def |
933
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
44 |
apply(simp_all add: split_option_all) |
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
45 |
apply(blast intro: equivp_reflp[OF a]) |
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
46 |
apply(blast intro: equivp_symp[OF a]) |
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
47 |
apply(blast intro: equivp_transp[OF a]) |
698 | 48 |
done |
49 |
||
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
50 |
lemma option_None_rsp[quot_respect]: |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
51 |
assumes q: "Quotient R Abs Rep" |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
52 |
shows "option_rel R None None" |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
53 |
by simp |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
54 |
|
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
55 |
lemma option_Some_rsp[quot_respect]: |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
56 |
assumes q: "Quotient R Abs Rep" |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
57 |
shows "(R ===> option_rel R) Some Some" |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
58 |
by simp |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
59 |
|
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
60 |
lemma option_None_prs[quot_preserve]: |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
61 |
assumes q: "Quotient R Abs Rep" |
932
7781c7cbd27e
used the internal Option.map instead of custom option_map
Christian Urban <urbanc@in.tum.de>
parents:
925
diff
changeset
|
62 |
shows "Option.map Abs None = None" |
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
63 |
by simp |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
64 |
|
1122
d1eaed018e5d
Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
937
diff
changeset
|
65 |
lemma option_Some_prs[quot_preserve]: |
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
66 |
assumes q: "Quotient R Abs Rep" |
932
7781c7cbd27e
used the internal Option.map instead of custom option_map
Christian Urban <urbanc@in.tum.de>
parents:
925
diff
changeset
|
67 |
shows "(Rep ---> Option.map Abs) Some = Some" |
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
68 |
apply(simp add: expand_fun_eq) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
69 |
apply(simp add: Quotient_abs_rep[OF q]) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
70 |
done |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
71 |
|
1128
17ca92ab4660
Main renaming + fixes for new Isabelle in IntEx2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1122
diff
changeset
|
72 |
lemma option_map_id[id_simps]: |
936 | 73 |
shows "Option.map id = id" |
933
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
74 |
by (simp add: expand_fun_eq split_option_all) |
829
42b90994ac77
map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
779
diff
changeset
|
75 |
|
1128
17ca92ab4660
Main renaming + fixes for new Isabelle in IntEx2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1122
diff
changeset
|
76 |
lemma option_rel_eq[id_simps]: |
927
04ef4bd3b936
more eq_reflection & other cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
925
diff
changeset
|
77 |
shows "option_rel (op =) = (op =)" |
933
762f0eae88fd
used split_option_all lemma
Christian Urban <urbanc@in.tum.de>
parents:
932
diff
changeset
|
78 |
by (simp add: expand_fun_eq split_option_all) |
829
42b90994ac77
map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
779
diff
changeset
|
79 |
|
42b90994ac77
map and rel simps for all quotients; needed when changing the relations to aggregate ones.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
779
diff
changeset
|
80 |
end |