author | wenzelm |
Tue, 03 Sep 2013 01:12:40 +0200 | |
changeset 53374 | a14d2a854c02 |
parent 53012 | cb82606b8215 |
child 55564 | e81ee43ab290 |
permissions | -rw-r--r-- |
47455 | 1 |
(* Title: HOL/Library/Quotient_List.thy |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
52308
diff
changeset
|
2 |
Author: Cezary Kaliszyk and Christian Urban |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
3 |
*) |
35788 | 4 |
|
5 |
header {* Quotient infrastructure for the list type *} |
|
6 |
||
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
7 |
theory Quotient_List |
47929 | 8 |
imports Main Quotient_Set Quotient_Product Quotient_Option |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
9 |
begin |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
10 |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
52308
diff
changeset
|
11 |
subsection {* Rules for the Quotient package *} |
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
12 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
13 |
lemma map_id [id_simps]: |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
14 |
"map id = id" |
46663 | 15 |
by (fact List.map.id) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
16 |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
52308
diff
changeset
|
17 |
lemma list_all2_eq [id_simps]: |
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
18 |
"list_all2 (op =) = (op =)" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
19 |
proof (rule ext)+ |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
20 |
fix xs ys |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
21 |
show "list_all2 (op =) xs ys \<longleftrightarrow> xs = ys" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
22 |
by (induct xs ys rule: list_induct2') simp_all |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
23 |
qed |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
24 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
25 |
lemma list_symp: |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
26 |
assumes "symp R" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
27 |
shows "symp (list_all2 R)" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
28 |
proof (rule sympI) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
29 |
from assms have *: "\<And>xs ys. R xs ys \<Longrightarrow> R ys xs" by (rule sympE) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
30 |
fix xs ys |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
31 |
assume "list_all2 R xs ys" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
32 |
then show "list_all2 R ys xs" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
33 |
by (induct xs ys rule: list_induct2') (simp_all add: *) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
34 |
qed |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
35 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
36 |
lemma list_transp: |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
37 |
assumes "transp R" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
38 |
shows "transp (list_all2 R)" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
39 |
proof (rule transpI) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
40 |
from assms have *: "\<And>xs ys zs. R xs ys \<Longrightarrow> R ys zs \<Longrightarrow> R xs zs" by (rule transpE) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
41 |
fix xs ys zs |
45803
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
42 |
assume "list_all2 R xs ys" and "list_all2 R ys zs" |
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
43 |
then show "list_all2 R xs zs" |
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
44 |
by (induct arbitrary: zs) (auto simp: list_all2_Cons1 intro: *) |
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
45 |
qed |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
46 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
47 |
lemma list_equivp [quot_equiv]: |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
48 |
"equivp R \<Longrightarrow> equivp (list_all2 R)" |
51994 | 49 |
by (blast intro: equivpI reflp_list_all2 list_symp list_transp elim: equivpE) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
50 |
|
47308 | 51 |
lemma list_quotient3 [quot_thm]: |
52 |
assumes "Quotient3 R Abs Rep" |
|
53 |
shows "Quotient3 (list_all2 R) (map Abs) (map Rep)" |
|
54 |
proof (rule Quotient3I) |
|
55 |
from assms have "\<And>x. Abs (Rep x) = x" by (rule Quotient3_abs_rep) |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
56 |
then show "\<And>xs. map Abs (map Rep xs) = xs" by (simp add: comp_def) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
57 |
next |
47308 | 58 |
from assms have "\<And>x y. R (Rep x) (Rep y) \<longleftrightarrow> x = y" by (rule Quotient3_rel_rep) |
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
59 |
then show "\<And>xs. list_all2 R (map Rep xs) (map Rep xs)" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
60 |
by (simp add: list_all2_map1 list_all2_map2 list_all2_eq) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
61 |
next |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
62 |
fix xs ys |
47308 | 63 |
from assms have "\<And>x y. R x x \<and> R y y \<and> Abs x = Abs y \<longleftrightarrow> R x y" by (rule Quotient3_rel) |
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
64 |
then show "list_all2 R xs ys \<longleftrightarrow> list_all2 R xs xs \<and> list_all2 R ys ys \<and> map Abs xs = map Abs ys" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
65 |
by (induct xs ys rule: list_induct2') auto |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
66 |
qed |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
67 |
|
47308 | 68 |
declare [[mapQ3 list = (list_all2, list_quotient3)]] |
47094 | 69 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
70 |
lemma cons_prs [quot_preserve]: |
47308 | 71 |
assumes q: "Quotient3 R Abs Rep" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
72 |
shows "(Rep ---> (map Rep) ---> (map Abs)) (op #) = (op #)" |
47308 | 73 |
by (auto simp add: fun_eq_iff comp_def Quotient3_abs_rep [OF q]) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
74 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
75 |
lemma cons_rsp [quot_respect]: |
47308 | 76 |
assumes q: "Quotient3 R Abs Rep" |
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
77 |
shows "(R ===> list_all2 R ===> list_all2 R) (op #) (op #)" |
40463 | 78 |
by auto |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
79 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
80 |
lemma nil_prs [quot_preserve]: |
47308 | 81 |
assumes q: "Quotient3 R Abs Rep" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
82 |
shows "map Abs [] = []" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
83 |
by simp |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
84 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
85 |
lemma nil_rsp [quot_respect]: |
47308 | 86 |
assumes q: "Quotient3 R Abs Rep" |
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
87 |
shows "list_all2 R [] []" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
88 |
by simp |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
89 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
90 |
lemma map_prs_aux: |
47308 | 91 |
assumes a: "Quotient3 R1 abs1 rep1" |
92 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
93 |
shows "(map abs2) (map ((abs1 ---> rep2) f) (map rep1 l)) = map f l" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
94 |
by (induct l) |
47308 | 95 |
(simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b]) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
96 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
97 |
lemma map_prs [quot_preserve]: |
47308 | 98 |
assumes a: "Quotient3 R1 abs1 rep1" |
99 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
100 |
shows "((abs1 ---> rep2) ---> (map rep1) ---> (map abs2)) map = map" |
36216
8fb6cc6f3b94
respectfullness and preservation of map for identity quotients
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36154
diff
changeset
|
101 |
and "((abs1 ---> id) ---> map rep1 ---> id) map = map" |
40463 | 102 |
by (simp_all only: fun_eq_iff map_prs_aux[OF a b] comp_def) |
47308 | 103 |
(simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b]) |
40463 | 104 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
105 |
lemma map_rsp [quot_respect]: |
47308 | 106 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
107 |
and q2: "Quotient3 R2 Abs2 Rep2" |
|
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
108 |
shows "((R1 ===> R2) ===> (list_all2 R1) ===> list_all2 R2) map map" |
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
109 |
and "((R1 ===> op =) ===> (list_all2 R1) ===> op =) map map" |
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
110 |
unfolding list_all2_eq [symmetric] by (rule map_transfer)+ |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
111 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
112 |
lemma foldr_prs_aux: |
47308 | 113 |
assumes a: "Quotient3 R1 abs1 rep1" |
114 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
115 |
shows "abs2 (foldr ((abs1 ---> abs2 ---> rep2) f) (map rep1 l) (rep2 e)) = foldr f l e" |
47308 | 116 |
by (induct l) (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b]) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
117 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
118 |
lemma foldr_prs [quot_preserve]: |
47308 | 119 |
assumes a: "Quotient3 R1 abs1 rep1" |
120 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
121 |
shows "((abs1 ---> abs2 ---> rep2) ---> (map rep1) ---> rep2 ---> abs2) foldr = foldr" |
40463 | 122 |
apply (simp add: fun_eq_iff) |
123 |
by (simp only: fun_eq_iff foldr_prs_aux[OF a b]) |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
124 |
(simp) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
125 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
126 |
lemma foldl_prs_aux: |
47308 | 127 |
assumes a: "Quotient3 R1 abs1 rep1" |
128 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
129 |
shows "abs1 (foldl ((abs1 ---> abs2 ---> rep1) f) (rep1 e) (map rep2 l)) = foldl f e l" |
47308 | 130 |
by (induct l arbitrary:e) (simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b]) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
131 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
132 |
lemma foldl_prs [quot_preserve]: |
47308 | 133 |
assumes a: "Quotient3 R1 abs1 rep1" |
134 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
135 |
shows "((abs1 ---> abs2 ---> rep1) ---> rep1 ---> (map rep2) ---> abs1) foldl = foldl" |
40463 | 136 |
by (simp add: fun_eq_iff foldl_prs_aux [OF a b]) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
137 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
138 |
(* induct_tac doesn't accept 'arbitrary', so we manually 'spec' *) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
139 |
lemma foldl_rsp[quot_respect]: |
47308 | 140 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
141 |
and q2: "Quotient3 R2 Abs2 Rep2" |
|
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
142 |
shows "((R1 ===> R2 ===> R1) ===> R1 ===> list_all2 R2 ===> R1) foldl foldl" |
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
143 |
by (rule foldl_transfer) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
144 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
145 |
lemma foldr_rsp[quot_respect]: |
47308 | 146 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
147 |
and q2: "Quotient3 R2 Abs2 Rep2" |
|
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
148 |
shows "((R1 ===> R2 ===> R2) ===> list_all2 R1 ===> R2 ===> R2) foldr foldr" |
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
149 |
by (rule foldr_transfer) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
150 |
|
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
151 |
lemma list_all2_rsp: |
36154
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
152 |
assumes r: "\<forall>x y. R x y \<longrightarrow> (\<forall>a b. R a b \<longrightarrow> S x a = T y b)" |
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
153 |
and l1: "list_all2 R x y" |
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
154 |
and l2: "list_all2 R a b" |
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
155 |
shows "list_all2 S x a = list_all2 T y b" |
45803
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
156 |
using l1 l2 |
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
157 |
by (induct arbitrary: a b rule: list_all2_induct, |
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
158 |
auto simp: list_all2_Cons1 list_all2_Cons2 r) |
36154
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
159 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
160 |
lemma [quot_respect]: |
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
161 |
"((R ===> R ===> op =) ===> list_all2 R ===> list_all2 R ===> op =) list_all2 list_all2" |
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
162 |
by (rule list_all2_transfer) |
36154
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
163 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
164 |
lemma [quot_preserve]: |
47308 | 165 |
assumes a: "Quotient3 R abs1 rep1" |
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
166 |
shows "((abs1 ---> abs1 ---> id) ---> map rep1 ---> map rep1 ---> id) list_all2 = list_all2" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
167 |
apply (simp add: fun_eq_iff) |
36154
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
168 |
apply clarify |
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
169 |
apply (induct_tac xa xb rule: list_induct2') |
47308 | 170 |
apply (simp_all add: Quotient3_abs_rep[OF a]) |
36154
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
171 |
done |
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
172 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
173 |
lemma [quot_preserve]: |
47308 | 174 |
assumes a: "Quotient3 R abs1 rep1" |
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
175 |
shows "(list_all2 ((rep1 ---> rep1 ---> id) R) l m) = (l = m)" |
47308 | 176 |
by (induct l m rule: list_induct2') (simp_all add: Quotient3_rel_rep[OF a]) |
36154
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
177 |
|
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
178 |
lemma list_all2_find_element: |
36276
92011cc923f5
fun_rel introduction and list_rel elimination for quotient package
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36216
diff
changeset
|
179 |
assumes a: "x \<in> set a" |
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
180 |
and b: "list_all2 R a b" |
36276
92011cc923f5
fun_rel introduction and list_rel elimination for quotient package
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36216
diff
changeset
|
181 |
shows "\<exists>y. (y \<in> set b \<and> R x y)" |
45803
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
182 |
using b a by induct auto |
36276
92011cc923f5
fun_rel introduction and list_rel elimination for quotient package
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36216
diff
changeset
|
183 |
|
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
184 |
lemma list_all2_refl: |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
185 |
assumes a: "\<And>x y. R x y = (R x = R y)" |
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
186 |
shows "list_all2 R x x" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
187 |
by (induct x) (auto simp add: a) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
188 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
189 |
end |