author | wenzelm |
Sun, 05 Aug 2012 20:11:32 +0200 | |
changeset 48683 | eeb4480b5877 |
parent 47982 | 7aa35601ff65 |
child 51377 | 7da251a6c16e |
permissions | -rw-r--r-- |
47455 | 1 |
(* Title: HOL/Library/Quotient_List.thy |
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
2 |
Author: Cezary Kaliszyk, Christian Urban and Brian Huffman |
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 |
|
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
11 |
subsection {* Relator for list type *} |
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 |
|
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
17 |
lemma list_all2_eq [id_simps, relator_eq]: |
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 |
|
47660 | 25 |
lemma list_all2_OO: "list_all2 (A OO B) = list_all2 A OO list_all2 B" |
26 |
proof (intro ext iffI) |
|
27 |
fix xs ys |
|
28 |
assume "list_all2 (A OO B) xs ys" |
|
29 |
thus "(list_all2 A OO list_all2 B) xs ys" |
|
30 |
unfolding OO_def |
|
31 |
by (induct, simp, simp add: list_all2_Cons1 list_all2_Cons2, fast) |
|
32 |
next |
|
33 |
fix xs ys |
|
34 |
assume "(list_all2 A OO list_all2 B) xs ys" |
|
35 |
then obtain zs where "list_all2 A xs zs" and "list_all2 B zs ys" .. |
|
36 |
thus "list_all2 (A OO B) xs ys" |
|
37 |
by (induct arbitrary: ys, simp, clarsimp simp add: list_all2_Cons1, fast) |
|
38 |
qed |
|
39 |
||
47982
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
40 |
lemma list_reflp[reflexivity_rule]: |
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
41 |
assumes "reflp R" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
42 |
shows "reflp (list_all2 R)" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
43 |
proof (rule reflpI) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
44 |
from assms have *: "\<And>xs. R xs xs" by (rule reflpE) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
45 |
fix xs |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
46 |
show "list_all2 R xs xs" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
47 |
by (induct xs) (simp_all add: *) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
48 |
qed |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
49 |
|
47982
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
50 |
lemma list_left_total[reflexivity_rule]: |
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
51 |
assumes "left_total R" |
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
52 |
shows "left_total (list_all2 R)" |
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
53 |
proof (rule left_totalI) |
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
54 |
from assms have *: "\<And>xs. \<exists>ys. R xs ys" by (rule left_totalE) |
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
55 |
fix xs |
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
56 |
show "\<exists> ys. list_all2 R xs ys" |
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
57 |
by (induct xs) (simp_all add: * list_all2_Cons1) |
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
58 |
qed |
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
59 |
|
7aa35601ff65
prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents:
47936
diff
changeset
|
60 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
61 |
lemma list_symp: |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
62 |
assumes "symp R" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
63 |
shows "symp (list_all2 R)" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
64 |
proof (rule sympI) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
65 |
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
|
66 |
fix xs ys |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
qed |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
71 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
72 |
lemma list_transp: |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
73 |
assumes "transp R" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
74 |
shows "transp (list_all2 R)" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
75 |
proof (rule transpI) |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
76 |
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
|
77 |
fix xs ys zs |
45803
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
78 |
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
|
79 |
then show "list_all2 R xs zs" |
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
80 |
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
|
81 |
qed |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
82 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
83 |
lemma list_equivp [quot_equiv]: |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
84 |
"equivp R \<Longrightarrow> equivp (list_all2 R)" |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
85 |
by (blast intro: equivpI list_reflp list_symp list_transp elim: equivpE) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
86 |
|
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
87 |
lemma right_total_list_all2 [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
88 |
"right_total R \<Longrightarrow> right_total (list_all2 R)" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
89 |
unfolding right_total_def |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
90 |
by (rule allI, induct_tac y, simp, simp add: list_all2_Cons2) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
91 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
92 |
lemma right_unique_list_all2 [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
93 |
"right_unique R \<Longrightarrow> right_unique (list_all2 R)" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
94 |
unfolding right_unique_def |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
95 |
apply (rule allI, rename_tac xs, induct_tac xs) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
96 |
apply (auto simp add: list_all2_Cons1) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
97 |
done |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
98 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
99 |
lemma bi_total_list_all2 [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
100 |
"bi_total A \<Longrightarrow> bi_total (list_all2 A)" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
101 |
unfolding bi_total_def |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
102 |
apply safe |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
103 |
apply (rename_tac xs, induct_tac xs, simp, simp add: list_all2_Cons1) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
104 |
apply (rename_tac ys, induct_tac ys, simp, simp add: list_all2_Cons2) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
105 |
done |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
106 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
107 |
lemma bi_unique_list_all2 [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
108 |
"bi_unique A \<Longrightarrow> bi_unique (list_all2 A)" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
109 |
unfolding bi_unique_def |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
110 |
apply (rule conjI) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
111 |
apply (rule allI, rename_tac xs, induct_tac xs) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
112 |
apply (simp, force simp add: list_all2_Cons1) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
113 |
apply (subst (2) all_comm, subst (1) all_comm) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
114 |
apply (rule allI, rename_tac xs, induct_tac xs) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
115 |
apply (simp, force simp add: list_all2_Cons2) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
116 |
done |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
117 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
118 |
subsection {* Transfer rules for transfer package *} |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
119 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
120 |
lemma Nil_transfer [transfer_rule]: "(list_all2 A) [] []" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
121 |
by simp |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
122 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
123 |
lemma Cons_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
124 |
"(A ===> list_all2 A ===> list_all2 A) Cons Cons" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
125 |
unfolding fun_rel_def by simp |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
126 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
127 |
lemma list_case_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
128 |
"(B ===> (A ===> list_all2 A ===> B) ===> list_all2 A ===> B) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
129 |
list_case list_case" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
130 |
unfolding fun_rel_def by (simp split: list.split) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
131 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
132 |
lemma list_rec_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
133 |
"(B ===> (A ===> list_all2 A ===> B ===> B) ===> list_all2 A ===> B) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
134 |
list_rec list_rec" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
135 |
unfolding fun_rel_def by (clarify, erule list_all2_induct, simp_all) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
136 |
|
47929 | 137 |
lemma tl_transfer [transfer_rule]: |
138 |
"(list_all2 A ===> list_all2 A) tl tl" |
|
139 |
unfolding tl_def by transfer_prover |
|
140 |
||
141 |
lemma butlast_transfer [transfer_rule]: |
|
142 |
"(list_all2 A ===> list_all2 A) butlast butlast" |
|
143 |
by (rule fun_relI, erule list_all2_induct, auto) |
|
144 |
||
145 |
lemma set_transfer [transfer_rule]: |
|
146 |
"(list_all2 A ===> set_rel A) set set" |
|
147 |
unfolding set_def by transfer_prover |
|
148 |
||
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
149 |
lemma map_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
150 |
"((A ===> B) ===> list_all2 A ===> list_all2 B) map map" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
151 |
unfolding List.map_def by transfer_prover |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
152 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
153 |
lemma append_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
154 |
"(list_all2 A ===> list_all2 A ===> list_all2 A) append append" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
155 |
unfolding List.append_def by transfer_prover |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
156 |
|
47929 | 157 |
lemma rev_transfer [transfer_rule]: |
158 |
"(list_all2 A ===> list_all2 A) rev rev" |
|
159 |
unfolding List.rev_def by transfer_prover |
|
160 |
||
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
161 |
lemma filter_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
162 |
"((A ===> op =) ===> list_all2 A ===> list_all2 A) filter filter" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
163 |
unfolding List.filter_def by transfer_prover |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
164 |
|
47929 | 165 |
lemma fold_transfer [transfer_rule]: |
166 |
"((A ===> B ===> B) ===> list_all2 A ===> B ===> B) fold fold" |
|
167 |
unfolding List.fold_def by transfer_prover |
|
168 |
||
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
169 |
lemma foldr_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
170 |
"((A ===> B ===> B) ===> list_all2 A ===> B ===> B) foldr foldr" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
171 |
unfolding List.foldr_def by transfer_prover |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
172 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
173 |
lemma foldl_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
174 |
"((B ===> A ===> B) ===> B ===> list_all2 A ===> B) foldl foldl" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
175 |
unfolding List.foldl_def by transfer_prover |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
176 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
177 |
lemma concat_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
178 |
"(list_all2 (list_all2 A) ===> list_all2 A) concat concat" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
179 |
unfolding List.concat_def by transfer_prover |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
180 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
181 |
lemma drop_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
182 |
"(op = ===> list_all2 A ===> list_all2 A) drop drop" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
183 |
unfolding List.drop_def by transfer_prover |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
184 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
185 |
lemma take_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
186 |
"(op = ===> list_all2 A ===> list_all2 A) take take" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
187 |
unfolding List.take_def by transfer_prover |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
188 |
|
47929 | 189 |
lemma list_update_transfer [transfer_rule]: |
190 |
"(list_all2 A ===> op = ===> A ===> list_all2 A) list_update list_update" |
|
191 |
unfolding list_update_def by transfer_prover |
|
192 |
||
193 |
lemma takeWhile_transfer [transfer_rule]: |
|
194 |
"((A ===> op =) ===> list_all2 A ===> list_all2 A) takeWhile takeWhile" |
|
195 |
unfolding takeWhile_def by transfer_prover |
|
196 |
||
197 |
lemma dropWhile_transfer [transfer_rule]: |
|
198 |
"((A ===> op =) ===> list_all2 A ===> list_all2 A) dropWhile dropWhile" |
|
199 |
unfolding dropWhile_def by transfer_prover |
|
200 |
||
201 |
lemma zip_transfer [transfer_rule]: |
|
202 |
"(list_all2 A ===> list_all2 B ===> list_all2 (prod_rel A B)) zip zip" |
|
203 |
unfolding zip_def by transfer_prover |
|
204 |
||
205 |
lemma insert_transfer [transfer_rule]: |
|
206 |
assumes [transfer_rule]: "bi_unique A" |
|
207 |
shows "(A ===> list_all2 A ===> list_all2 A) List.insert List.insert" |
|
208 |
unfolding List.insert_def [abs_def] by transfer_prover |
|
209 |
||
210 |
lemma find_transfer [transfer_rule]: |
|
211 |
"((A ===> op =) ===> list_all2 A ===> option_rel A) List.find List.find" |
|
212 |
unfolding List.find_def by transfer_prover |
|
213 |
||
214 |
lemma remove1_transfer [transfer_rule]: |
|
215 |
assumes [transfer_rule]: "bi_unique A" |
|
216 |
shows "(A ===> list_all2 A ===> list_all2 A) remove1 remove1" |
|
217 |
unfolding remove1_def by transfer_prover |
|
218 |
||
219 |
lemma removeAll_transfer [transfer_rule]: |
|
220 |
assumes [transfer_rule]: "bi_unique A" |
|
221 |
shows "(A ===> list_all2 A ===> list_all2 A) removeAll removeAll" |
|
222 |
unfolding removeAll_def by transfer_prover |
|
223 |
||
224 |
lemma distinct_transfer [transfer_rule]: |
|
225 |
assumes [transfer_rule]: "bi_unique A" |
|
226 |
shows "(list_all2 A ===> op =) distinct distinct" |
|
227 |
unfolding distinct_def by transfer_prover |
|
228 |
||
229 |
lemma remdups_transfer [transfer_rule]: |
|
230 |
assumes [transfer_rule]: "bi_unique A" |
|
231 |
shows "(list_all2 A ===> list_all2 A) remdups remdups" |
|
232 |
unfolding remdups_def by transfer_prover |
|
233 |
||
234 |
lemma replicate_transfer [transfer_rule]: |
|
235 |
"(op = ===> A ===> list_all2 A) replicate replicate" |
|
236 |
unfolding replicate_def by transfer_prover |
|
237 |
||
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
238 |
lemma length_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
239 |
"(list_all2 A ===> op =) length length" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
240 |
unfolding list_size_overloaded_def by transfer_prover |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
241 |
|
47929 | 242 |
lemma rotate1_transfer [transfer_rule]: |
243 |
"(list_all2 A ===> list_all2 A) rotate1 rotate1" |
|
244 |
unfolding rotate1_def by transfer_prover |
|
245 |
||
246 |
lemma funpow_transfer [transfer_rule]: (* FIXME: move to Transfer.thy *) |
|
247 |
"(op = ===> (A ===> A) ===> (A ===> A)) compow compow" |
|
248 |
unfolding funpow_def by transfer_prover |
|
249 |
||
250 |
lemma rotate_transfer [transfer_rule]: |
|
251 |
"(op = ===> list_all2 A ===> list_all2 A) rotate rotate" |
|
252 |
unfolding rotate_def [abs_def] by transfer_prover |
|
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
253 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
254 |
lemma list_all2_transfer [transfer_rule]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
255 |
"((A ===> B ===> op =) ===> list_all2 A ===> list_all2 B ===> op =) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
256 |
list_all2 list_all2" |
47929 | 257 |
apply (subst (4) list_all2_def [abs_def]) |
258 |
apply (subst (3) list_all2_def [abs_def]) |
|
259 |
apply transfer_prover |
|
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
260 |
done |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
261 |
|
47929 | 262 |
lemma sublist_transfer [transfer_rule]: |
263 |
"(list_all2 A ===> set_rel (op =) ===> list_all2 A) sublist sublist" |
|
264 |
unfolding sublist_def [abs_def] by transfer_prover |
|
265 |
||
266 |
lemma partition_transfer [transfer_rule]: |
|
267 |
"((A ===> op =) ===> list_all2 A ===> prod_rel (list_all2 A) (list_all2 A)) |
|
268 |
partition partition" |
|
269 |
unfolding partition_def by transfer_prover |
|
47650 | 270 |
|
47923 | 271 |
lemma lists_transfer [transfer_rule]: |
272 |
"(set_rel A ===> set_rel (list_all2 A)) lists lists" |
|
273 |
apply (rule fun_relI, rule set_relI) |
|
274 |
apply (erule lists.induct, simp) |
|
275 |
apply (simp only: set_rel_def list_all2_Cons1, metis lists.Cons) |
|
276 |
apply (erule lists.induct, simp) |
|
277 |
apply (simp only: set_rel_def list_all2_Cons2, metis lists.Cons) |
|
278 |
done |
|
279 |
||
47929 | 280 |
lemma set_Cons_transfer [transfer_rule]: |
281 |
"(set_rel A ===> set_rel (list_all2 A) ===> set_rel (list_all2 A)) |
|
282 |
set_Cons set_Cons" |
|
283 |
unfolding fun_rel_def set_rel_def set_Cons_def |
|
284 |
apply safe |
|
285 |
apply (simp add: list_all2_Cons1, fast) |
|
286 |
apply (simp add: list_all2_Cons2, fast) |
|
287 |
done |
|
288 |
||
289 |
lemma listset_transfer [transfer_rule]: |
|
290 |
"(list_all2 (set_rel A) ===> set_rel (list_all2 A)) listset listset" |
|
291 |
unfolding listset_def by transfer_prover |
|
292 |
||
293 |
lemma null_transfer [transfer_rule]: |
|
294 |
"(list_all2 A ===> op =) List.null List.null" |
|
295 |
unfolding fun_rel_def List.null_def by auto |
|
296 |
||
297 |
lemma list_all_transfer [transfer_rule]: |
|
298 |
"((A ===> op =) ===> list_all2 A ===> op =) list_all list_all" |
|
299 |
unfolding list_all_iff [abs_def] by transfer_prover |
|
300 |
||
301 |
lemma list_ex_transfer [transfer_rule]: |
|
302 |
"((A ===> op =) ===> list_all2 A ===> op =) list_ex list_ex" |
|
303 |
unfolding list_ex_iff [abs_def] by transfer_prover |
|
304 |
||
305 |
lemma splice_transfer [transfer_rule]: |
|
306 |
"(list_all2 A ===> list_all2 A ===> list_all2 A) splice splice" |
|
307 |
apply (rule fun_relI, erule list_all2_induct, simp add: fun_rel_def, simp) |
|
308 |
apply (rule fun_relI) |
|
309 |
apply (erule_tac xs=x in list_all2_induct, simp, simp add: fun_rel_def) |
|
310 |
done |
|
311 |
||
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
312 |
subsection {* Setup for lifting package *} |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
313 |
|
47777
f29e7dcd7c40
use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents:
47660
diff
changeset
|
314 |
lemma Quotient_list[quot_map]: |
47641
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
315 |
assumes "Quotient R Abs Rep T" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
316 |
shows "Quotient (list_all2 R) (map Abs) (map Rep) (list_all2 T)" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
317 |
proof (unfold Quotient_alt_def, intro conjI allI impI) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
318 |
from assms have 1: "\<And>x y. T x y \<Longrightarrow> Abs x = y" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
319 |
unfolding Quotient_alt_def by simp |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
320 |
fix xs ys assume "list_all2 T xs ys" thus "map Abs xs = ys" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
321 |
by (induct, simp, simp add: 1) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
322 |
next |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
323 |
from assms have 2: "\<And>x. T (Rep x) x" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
324 |
unfolding Quotient_alt_def by simp |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
325 |
fix xs show "list_all2 T (map Rep xs) xs" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
326 |
by (induct xs, simp, simp add: 2) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
327 |
next |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
328 |
from assms have 3: "\<And>x y. R x y \<longleftrightarrow> T x (Abs x) \<and> T y (Abs y) \<and> Abs x = Abs y" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
329 |
unfolding Quotient_alt_def by simp |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
330 |
fix xs ys show "list_all2 R xs ys \<longleftrightarrow> list_all2 T xs (map Abs xs) \<and> |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
331 |
list_all2 T ys (map Abs ys) \<and> map Abs xs = map Abs ys" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
332 |
by (induct xs ys rule: list_induct2', simp_all, metis 3) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
333 |
qed |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
334 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
335 |
lemma list_invariant_commute [invariant_commute]: |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
336 |
"list_all2 (Lifting.invariant P) = Lifting.invariant (list_all P)" |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
337 |
apply (simp add: fun_eq_iff list_all2_def list_all_iff Lifting.invariant_def Ball_def) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
338 |
apply (intro allI) |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
339 |
apply (induct_tac rule: list_induct2') |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
340 |
apply simp_all |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
341 |
apply metis |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
342 |
done |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
343 |
|
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
344 |
subsection {* Rules for quotient package *} |
2cddc27a881f
new transfer package rules and lifting setup for lists
huffman
parents:
47634
diff
changeset
|
345 |
|
47308 | 346 |
lemma list_quotient3 [quot_thm]: |
347 |
assumes "Quotient3 R Abs Rep" |
|
348 |
shows "Quotient3 (list_all2 R) (map Abs) (map Rep)" |
|
349 |
proof (rule Quotient3I) |
|
350 |
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
|
351 |
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
|
352 |
next |
47308 | 353 |
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
|
354 |
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
|
355 |
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
|
356 |
next |
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
357 |
fix xs ys |
47308 | 358 |
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
|
359 |
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
|
360 |
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
|
361 |
qed |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
362 |
|
47308 | 363 |
declare [[mapQ3 list = (list_all2, list_quotient3)]] |
47094 | 364 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
365 |
lemma cons_prs [quot_preserve]: |
47308 | 366 |
assumes q: "Quotient3 R Abs Rep" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
367 |
shows "(Rep ---> (map Rep) ---> (map Abs)) (op #) = (op #)" |
47308 | 368 |
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
|
369 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
370 |
lemma cons_rsp [quot_respect]: |
47308 | 371 |
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
|
372 |
shows "(R ===> list_all2 R ===> list_all2 R) (op #) (op #)" |
40463 | 373 |
by auto |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
374 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
375 |
lemma nil_prs [quot_preserve]: |
47308 | 376 |
assumes q: "Quotient3 R Abs Rep" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
377 |
shows "map Abs [] = []" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
378 |
by simp |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
379 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
380 |
lemma nil_rsp [quot_respect]: |
47308 | 381 |
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
|
382 |
shows "list_all2 R [] []" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
383 |
by simp |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
384 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
385 |
lemma map_prs_aux: |
47308 | 386 |
assumes a: "Quotient3 R1 abs1 rep1" |
387 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
388 |
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
|
389 |
by (induct l) |
47308 | 390 |
(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
|
391 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
392 |
lemma map_prs [quot_preserve]: |
47308 | 393 |
assumes a: "Quotient3 R1 abs1 rep1" |
394 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
395 |
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
|
396 |
and "((abs1 ---> id) ---> map rep1 ---> id) map = map" |
40463 | 397 |
by (simp_all only: fun_eq_iff map_prs_aux[OF a b] comp_def) |
47308 | 398 |
(simp_all add: Quotient3_abs_rep[OF a] Quotient3_abs_rep[OF b]) |
40463 | 399 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
400 |
lemma map_rsp [quot_respect]: |
47308 | 401 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
402 |
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
|
403 |
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
|
404 |
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
|
405 |
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
|
406 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
407 |
lemma foldr_prs_aux: |
47308 | 408 |
assumes a: "Quotient3 R1 abs1 rep1" |
409 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
410 |
shows "abs2 (foldr ((abs1 ---> abs2 ---> rep2) f) (map rep1 l) (rep2 e)) = foldr f l e" |
47308 | 411 |
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
|
412 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
413 |
lemma foldr_prs [quot_preserve]: |
47308 | 414 |
assumes a: "Quotient3 R1 abs1 rep1" |
415 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
416 |
shows "((abs1 ---> abs2 ---> rep2) ---> (map rep1) ---> rep2 ---> abs2) foldr = foldr" |
40463 | 417 |
apply (simp add: fun_eq_iff) |
418 |
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
|
419 |
(simp) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
420 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
421 |
lemma foldl_prs_aux: |
47308 | 422 |
assumes a: "Quotient3 R1 abs1 rep1" |
423 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
424 |
shows "abs1 (foldl ((abs1 ---> abs2 ---> rep1) f) (rep1 e) (map rep2 l)) = foldl f e l" |
47308 | 425 |
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
|
426 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
427 |
lemma foldl_prs [quot_preserve]: |
47308 | 428 |
assumes a: "Quotient3 R1 abs1 rep1" |
429 |
and b: "Quotient3 R2 abs2 rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
430 |
shows "((abs1 ---> abs2 ---> rep1) ---> rep1 ---> (map rep2) ---> abs1) foldl = foldl" |
40463 | 431 |
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
|
432 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
433 |
(* 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
|
434 |
lemma foldl_rsp[quot_respect]: |
47308 | 435 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
436 |
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
|
437 |
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
|
438 |
by (rule foldl_transfer) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
439 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
440 |
lemma foldr_rsp[quot_respect]: |
47308 | 441 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
442 |
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
|
443 |
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
|
444 |
by (rule foldr_transfer) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
445 |
|
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
446 |
lemma list_all2_rsp: |
36154
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
using l1 l2 |
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
452 |
by (induct arbitrary: a b rule: list_all2_induct, |
fe44c0b216ef
remove some duplicate lemmas, simplify some proofs
huffman
parents:
40820
diff
changeset
|
453 |
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
|
454 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
455 |
lemma [quot_respect]: |
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
456 |
"((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
|
457 |
by (rule list_all2_transfer) |
36154
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
458 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
459 |
lemma [quot_preserve]: |
47308 | 460 |
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
|
461 |
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
|
462 |
apply (simp add: fun_eq_iff) |
36154
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
463 |
apply clarify |
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
464 |
apply (induct_tac xa xb rule: list_induct2') |
47308 | 465 |
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
|
466 |
done |
11c6106d7787
Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
35788
diff
changeset
|
467 |
|
40820
fd9c98ead9a9
more systematic and compact proofs on type relation operators using natural deduction rules
haftmann
parents:
40463
diff
changeset
|
468 |
lemma [quot_preserve]: |
47308 | 469 |
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
|
470 |
shows "(list_all2 ((rep1 ---> rep1 ---> id) R) l m) = (l = m)" |
47308 | 471 |
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
|
472 |
|
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
473 |
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
|
474 |
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
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
|
37492
ab36b1a50ca8
Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36812
diff
changeset
|
479 |
lemma list_all2_refl: |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
480 |
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
|
481 |
shows "list_all2 R x x" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
482 |
by (induct x) (auto simp add: a) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
483 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
484 |
end |