author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Tue, 26 Jan 2010 08:55:55 +0100 | |
changeset 929 | e812f58fd128 |
parent 927 | 04ef4bd3b936 |
child 936 | da5e4b8317c7 |
permissions | -rw-r--r-- |
698 | 1 |
theory QuotOption |
2 |
imports QuotMain |
|
3 |
begin |
|
4 |
||
5 |
fun |
|
6 |
option_rel |
|
7 |
where |
|
8 |
"option_rel R None None = True" |
|
9 |
| "option_rel R (Some x) None = False" |
|
10 |
| "option_rel R None (Some x) = False" |
|
11 |
| "option_rel R (Some x) (Some y) = R x y" |
|
12 |
||
13 |
fun |
|
14 |
option_map |
|
15 |
where |
|
16 |
"option_map f None = None" |
|
17 |
| "option_map f (Some x) = Some (f x)" |
|
18 |
||
779
3b21b24a5fb6
corrected map declarations for Sum and Prod; moved absrep_fun examples in separate file
Christian Urban <urbanc@in.tum.de>
parents:
698
diff
changeset
|
19 |
declare [[map option = (option_map, option_rel)]] |
3b21b24a5fb6
corrected map declarations for Sum and Prod; moved absrep_fun examples in separate file
Christian Urban <urbanc@in.tum.de>
parents:
698
diff
changeset
|
20 |
|
698 | 21 |
|
22 |
lemma option_quotient[quot_thm]: |
|
23 |
assumes q: "Quotient R Abs Rep" |
|
24 |
shows "Quotient (option_rel R) (option_map Abs) (option_map Rep)" |
|
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
25 |
apply(unfold Quotient_def) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
26 |
apply(auto) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
27 |
apply(case_tac a, simp_all add: Quotient_abs_rep[OF q] Quotient_rel_rep[OF q]) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
28 |
apply(case_tac a, simp_all add: Quotient_abs_rep[OF q] Quotient_rel_rep[OF q]) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
29 |
apply(case_tac [!] r) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
30 |
apply(case_tac [!] s) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
31 |
apply(simp_all add: Quotient_abs_rep[OF q] Quotient_rel_rep[OF q] ) |
698 | 32 |
using q |
33 |
unfolding Quotient_def |
|
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
34 |
apply(blast)+ |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
35 |
done |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
36 |
|
698 | 37 |
lemma option_equivp[quot_equiv]: |
38 |
assumes a: "equivp R" |
|
39 |
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
|
40 |
apply(rule equivpI) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
41 |
unfolding reflp_def symp_def transp_def |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
42 |
apply(auto) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
43 |
apply(case_tac [!] x) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
44 |
apply(simp_all add: equivp_reflp[OF a]) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
45 |
apply(case_tac [!] y) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
46 |
apply(simp_all add: equivp_symp[OF a]) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
47 |
apply(case_tac [!] z) |
698 | 48 |
apply(simp_all) |
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
49 |
apply(clarify) |
698 | 50 |
apply(rule equivp_transp[OF a]) |
51 |
apply(assumption)+ |
|
52 |
done |
|
53 |
||
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
by simp |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
58 |
|
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
by simp |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
63 |
|
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
64 |
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
|
65 |
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
|
66 |
shows "option_map Abs None = None" |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
67 |
by simp |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
68 |
|
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
69 |
lemma option_Some_prs[quot_respect]: |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
70 |
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
|
71 |
shows "(Rep ---> option_map Abs) Some = Some" |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
72 |
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
|
73 |
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
|
74 |
done |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
75 |
|
927
04ef4bd3b936
more eq_reflection & other cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
925
diff
changeset
|
76 |
lemma option_map_id[id_simps]: |
04ef4bd3b936
more eq_reflection & other cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
925
diff
changeset
|
77 |
shows "option_map id = id" |
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
78 |
apply (auto simp add: expand_fun_eq) |
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 |
apply (case_tac x) |
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 |
apply (auto) |
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
|
81 |
done |
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
|
82 |
|
927
04ef4bd3b936
more eq_reflection & other cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
925
diff
changeset
|
83 |
lemma option_rel_eq[id_simps]: |
04ef4bd3b936
more eq_reflection & other cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
925
diff
changeset
|
84 |
shows "option_rel (op =) = (op =)" |
923
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
85 |
apply(auto 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
|
86 |
apply(case_tac x) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
87 |
apply(case_tac [!] xa) |
0419b20ee83c
added prs and rsp lemmas for Some and None
Christian Urban <urbanc@in.tum.de>
parents:
829
diff
changeset
|
88 |
apply(auto) |
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
|
89 |
done |
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
|
90 |
|
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
|
91 |
end |