author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Fri, 04 Dec 2009 16:12:40 +0100 | |
changeset 539 | 8287fb5b8d7a |
parent 537 | 57073b0b8fac |
child 540 | c0b13fb70d6d |
permissions | -rw-r--r-- |
0 | 1 |
theory QuotList |
533
4318ab0df27b
smaller theory footprint
Christian Urban <urbanc@in.tum.de>
parents:
529
diff
changeset
|
2 |
imports QuotScript List |
0 | 3 |
begin |
4 |
||
5 |
fun |
|
537
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
6 |
list_rel |
0 | 7 |
where |
537
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
8 |
"list_rel R [] [] = True" |
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
9 |
| "list_rel R (x#xs) [] = False" |
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
10 |
| "list_rel R [] (x#xs) = False" |
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
11 |
| "list_rel R (x#xs) (y#ys) = (R x y \<and> list_rel R xs ys)" |
0 | 12 |
|
539
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
13 |
lemma list_equivp: |
529 | 14 |
assumes a: "equivp R" |
537
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
15 |
shows "equivp (list_rel R)" |
539
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
16 |
unfolding equivp_def |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
17 |
apply(rule allI)+ |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
18 |
apply(induct_tac x y rule: list_induct2') |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
19 |
apply(simp_all add: expand_fun_eq) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
20 |
apply(metis list_rel.simps(1) list_rel.simps(2)) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
21 |
apply(metis list_rel.simps(1) list_rel.simps(2)) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
22 |
apply(rule iffI) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
23 |
apply(rule allI) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
24 |
apply(case_tac x) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
25 |
apply(simp_all) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
26 |
using a |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
27 |
apply(unfold equivp_def) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
28 |
apply(auto)[1] |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
29 |
apply(metis list_rel.simps(4)) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
30 |
done |
0 | 31 |
|
539
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
32 |
lemma list_rel_rel: |
529 | 33 |
assumes q: "Quotient R Abs Rep" |
537
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
34 |
shows "list_rel R r s = (list_rel R r r \<and> list_rel R s s \<and> (map Abs r = map Abs s))" |
539
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
35 |
apply(induct r s rule: list_induct2') |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
36 |
apply(simp_all) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
37 |
using Quotient_rel[OF q] |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
38 |
apply(metis) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
39 |
done |
0 | 40 |
|
537
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
41 |
lemma list_quotient: |
529 | 42 |
assumes q: "Quotient R Abs Rep" |
537
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
43 |
shows "Quotient (list_rel R) (map Abs) (map Rep)" |
539
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
44 |
unfolding Quotient_def |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
45 |
apply(rule conjI) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
46 |
apply(rule allI) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
47 |
apply(induct_tac a) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
48 |
apply(simp) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
49 |
apply(simp add: Quotient_ABS_REP[OF q]) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
50 |
apply(rule conjI) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
51 |
apply(rule allI) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
52 |
apply(induct_tac a) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
53 |
apply(simp) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
54 |
apply(simp) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
55 |
apply(simp add: Quotient_REP_reflp[OF q]) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
56 |
apply(rule allI)+ |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
57 |
apply(rule list_rel_rel[OF q]) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
58 |
done |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
59 |
|
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
60 |
|
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
61 |
|
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
62 |
|
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
63 |
|
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
64 |
|
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
65 |
(* Rest is not used *) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
66 |
|
0 | 67 |
|
68 |
lemma CONS_PRS: |
|
529 | 69 |
assumes q: "Quotient R Abs Rep" |
0 | 70 |
shows "(h#t) = (map Abs) ((Rep h)#(map Rep t))" |
529 | 71 |
by (induct t) (simp_all add: Quotient_ABS_REP[OF q]) |
0 | 72 |
|
73 |
lemma CONS_RSP: |
|
529 | 74 |
assumes q: "Quotient R Abs Rep" |
537
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
75 |
and a: "R h1 h2" "list_rel R t1 t2" |
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
76 |
shows "list_rel R (h1#t1) (h2#t2)" |
0 | 77 |
using a by (auto) |
78 |
||
79 |
lemma NIL_PRS: |
|
529 | 80 |
assumes q: "Quotient R Abs Rep" |
0 | 81 |
shows "[] = (map Abs [])" |
82 |
by (simp) |
|
83 |
||
84 |
lemma NIL_RSP: |
|
529 | 85 |
assumes q: "Quotient R Abs Rep" |
537
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
86 |
shows "list_rel R [] []" |
0 | 87 |
by simp |
88 |
||
89 |
lemma MAP_PRS: |
|
529 | 90 |
assumes q1: "Quotient R1 Abs1 Rep1" |
91 |
and q2: "Quotient R2 Abs2 Rep2" |
|
0 | 92 |
shows "map f l = (map Abs2) (map ((Abs1 ---> Rep2) f) (map Rep1 l))" |
93 |
by (induct l) |
|
529 | 94 |
(simp_all add: Quotient_ABS_REP[OF q1] Quotient_ABS_REP[OF q2]) |
0 | 95 |
|
96 |
lemma MAP_RSP: |
|
529 | 97 |
assumes q1: "Quotient R1 Abs1 Rep1" |
98 |
and q2: "Quotient R2 Abs2 Rep2" |
|
537
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
99 |
and a: "(R1 ===> R2) f1 f2" |
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
100 |
and b: "list_rel R1 l1 l2" |
57073b0b8fac
Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
533
diff
changeset
|
101 |
shows "list_rel R2 (map f1 l1) (map f2 l2)" |
0 | 102 |
using b a |
103 |
by (induct l1 l2 rule: list_induct2') |
|
104 |
(simp_all) |
|
105 |
||
106 |
||
107 |
||
539
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
108 |
lemma LIST_map_id: |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
109 |
shows "map (\<lambda>x. x) = (\<lambda>x. x)" |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
110 |
by simp |
0 | 111 |
|
539
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
112 |
lemma list_rel_EQ: |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
113 |
shows "list_rel (op =) \<equiv> (op =)" |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
114 |
apply(rule eq_reflection) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
115 |
unfolding expand_fun_eq |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
116 |
apply(rule allI)+ |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
117 |
apply(induct_tac x xa rule: list_induct2') |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
118 |
apply(simp_all) |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
119 |
done |
0 | 120 |
|
539
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
121 |
lemma list_rel_REFL: |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
122 |
assumes a: "\<And>x y. R x y = (R x = R y)" |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
123 |
shows "list_rel R x x" |
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
124 |
by (induct x) (auto simp add: a) |
0 | 125 |
|
126 |
||
539
8287fb5b8d7a
Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
537
diff
changeset
|
127 |
end |