author | Christian Urban <urbanc@in.tum.de> |
Fri, 01 Jan 2010 01:08:19 +0100 | |
changeset 800 | 71225f4a4635 |
parent 779 | 3b21b24a5fb6 |
child 829 | 42b90994ac77 |
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)" |
|
25 |
apply (unfold Quotient_def) |
|
26 |
apply (rule conjI) |
|
27 |
apply (rule allI) |
|
28 |
apply (case_tac a) |
|
29 |
apply (simp_all add: Quotient_abs_rep[OF q]) |
|
30 |
apply (rule conjI) |
|
31 |
apply (rule allI) |
|
32 |
apply (case_tac a) |
|
33 |
apply (simp_all add: Quotient_rel_rep[OF q]) |
|
34 |
apply (rule allI)+ |
|
35 |
apply (case_tac r) |
|
36 |
apply (case_tac s) |
|
37 |
apply (simp_all add: Quotient_abs_rep[OF q] add: Quotient_rel_rep[OF q]) |
|
38 |
apply (case_tac s) |
|
39 |
apply (simp_all add: Quotient_abs_rep[OF q] add: Quotient_rel_rep[OF q]) |
|
40 |
using q |
|
41 |
unfolding Quotient_def |
|
42 |
apply metis |
|
43 |
done |
|
44 |
||
45 |
lemma option_rel_some: |
|
46 |
assumes e: "equivp R" |
|
47 |
and a: "option_rel R (Some a) = option_rel R (Some aa)" |
|
48 |
shows "R a aa" |
|
49 |
using a apply(drule_tac x="Some aa" in fun_cong) |
|
50 |
apply(simp add: equivp_reflp[OF e]) |
|
51 |
done |
|
52 |
||
53 |
lemma option_equivp[quot_equiv]: |
|
54 |
assumes a: "equivp R" |
|
55 |
shows "equivp (option_rel R)" |
|
56 |
unfolding equivp_def |
|
57 |
apply(rule allI)+ |
|
58 |
apply(case_tac x) |
|
59 |
apply(case_tac y) |
|
60 |
apply(simp_all) |
|
61 |
apply(unfold not_def) |
|
62 |
apply(rule impI) |
|
63 |
apply(drule_tac x="None" in fun_cong) |
|
64 |
apply simp |
|
65 |
apply(case_tac y) |
|
66 |
apply(simp_all) |
|
67 |
apply(unfold not_def) |
|
68 |
apply(rule impI) |
|
69 |
apply(drule_tac x="None" in fun_cong) |
|
70 |
apply simp |
|
71 |
apply(rule iffI) |
|
72 |
apply(rule ext) |
|
73 |
apply(case_tac xa) |
|
74 |
apply(auto) |
|
75 |
apply(rule equivp_transp[OF a]) |
|
76 |
apply(rule equivp_symp[OF a]) |
|
77 |
apply(assumption)+ |
|
78 |
apply(rule equivp_transp[OF a]) |
|
79 |
apply(assumption)+ |
|
80 |
apply(simp only: option_rel_some[OF a]) |
|
81 |
done |
|
82 |
||
83 |
end |