author | blanchet |
Thu, 06 Mar 2014 15:40:33 +0100 | |
changeset 55945 | e96383acecf9 |
parent 55938 | f20d1db5aa3c |
child 56166 | 9a241bc276cd |
permissions | -rw-r--r-- |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
1 |
(* Title: HOL/Lifting_Set.thy |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
2 |
Author: Brian Huffman and Ondrej Kuncar |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
3 |
*) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
4 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
5 |
header {* Setup for Lifting/Transfer for the set type *} |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
6 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
7 |
theory Lifting_Set |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
8 |
imports Lifting |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
9 |
begin |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
10 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
11 |
subsection {* Relator and predicator properties *} |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
12 |
|
55938 | 13 |
definition rel_set :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> 'b set \<Rightarrow> bool" |
14 |
where "rel_set R = (\<lambda>A B. (\<forall>x\<in>A. \<exists>y\<in>B. R x y) \<and> (\<forall>y\<in>B. \<exists>x\<in>A. R x y))" |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
15 |
|
55938 | 16 |
lemma rel_setI: |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
17 |
assumes "\<And>x. x \<in> A \<Longrightarrow> \<exists>y\<in>B. R x y" |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
18 |
assumes "\<And>y. y \<in> B \<Longrightarrow> \<exists>x\<in>A. R x y" |
55938 | 19 |
shows "rel_set R A B" |
20 |
using assms unfolding rel_set_def by simp |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
21 |
|
55938 | 22 |
lemma rel_setD1: "\<lbrakk> rel_set R A B; x \<in> A \<rbrakk> \<Longrightarrow> \<exists>y \<in> B. R x y" |
23 |
and rel_setD2: "\<lbrakk> rel_set R A B; y \<in> B \<rbrakk> \<Longrightarrow> \<exists>x \<in> A. R x y" |
|
24 |
by(simp_all add: rel_set_def) |
|
53927 | 25 |
|
55938 | 26 |
lemma rel_set_conversep [simp]: "rel_set A\<inverse>\<inverse> = (rel_set A)\<inverse>\<inverse>" |
27 |
unfolding rel_set_def by auto |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
28 |
|
55938 | 29 |
lemma rel_set_eq [relator_eq]: "rel_set (op =) = (op =)" |
30 |
unfolding rel_set_def fun_eq_iff by auto |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
31 |
|
55938 | 32 |
lemma rel_set_mono[relator_mono]: |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
33 |
assumes "A \<le> B" |
55938 | 34 |
shows "rel_set A \<le> rel_set B" |
35 |
using assms unfolding rel_set_def by blast |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
36 |
|
55938 | 37 |
lemma rel_set_OO[relator_distr]: "rel_set R OO rel_set S = rel_set (R OO S)" |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
38 |
apply (rule sym) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
39 |
apply (intro ext, rename_tac X Z) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
40 |
apply (rule iffI) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
41 |
apply (rule_tac b="{y. (\<exists>x\<in>X. R x y) \<and> (\<exists>z\<in>Z. S y z)}" in relcomppI) |
55938 | 42 |
apply (simp add: rel_set_def, fast) |
43 |
apply (simp add: rel_set_def, fast) |
|
44 |
apply (simp add: rel_set_def, fast) |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
45 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
46 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
47 |
lemma Domainp_set[relator_domain]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
48 |
assumes "Domainp T = R" |
55938 | 49 |
shows "Domainp (rel_set T) = (\<lambda>A. Ball A R)" |
50 |
using assms unfolding rel_set_def Domainp_iff[abs_def] |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
51 |
apply (intro ext) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
52 |
apply (rule iffI) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
53 |
apply blast |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
54 |
apply (rename_tac A, rule_tac x="{y. \<exists>x\<in>A. T x y}" in exI, fast) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
55 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
56 |
|
55938 | 57 |
lemma left_total_rel_set[reflexivity_rule]: |
58 |
"left_total A \<Longrightarrow> left_total (rel_set A)" |
|
59 |
unfolding left_total_def rel_set_def |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
60 |
apply safe |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
61 |
apply (rename_tac X, rule_tac x="{y. \<exists>x\<in>X. A x y}" in exI, fast) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
62 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
63 |
|
55938 | 64 |
lemma left_unique_rel_set[reflexivity_rule]: |
65 |
"left_unique A \<Longrightarrow> left_unique (rel_set A)" |
|
66 |
unfolding left_unique_def rel_set_def |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
67 |
by fast |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
68 |
|
55938 | 69 |
lemma right_total_rel_set [transfer_rule]: |
70 |
"right_total A \<Longrightarrow> right_total (rel_set A)" |
|
71 |
using left_total_rel_set[of "A\<inverse>\<inverse>"] by simp |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
72 |
|
55938 | 73 |
lemma right_unique_rel_set [transfer_rule]: |
74 |
"right_unique A \<Longrightarrow> right_unique (rel_set A)" |
|
75 |
unfolding right_unique_def rel_set_def by fast |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
76 |
|
55938 | 77 |
lemma bi_total_rel_set [transfer_rule]: |
78 |
"bi_total A \<Longrightarrow> bi_total (rel_set A)" |
|
79 |
by(simp add: bi_total_conv_left_right left_total_rel_set right_total_rel_set) |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
80 |
|
55938 | 81 |
lemma bi_unique_rel_set [transfer_rule]: |
82 |
"bi_unique A \<Longrightarrow> bi_unique (rel_set A)" |
|
83 |
unfolding bi_unique_def rel_set_def by fast |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
84 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
85 |
lemma set_invariant_commute [invariant_commute]: |
55938 | 86 |
"rel_set (Lifting.invariant P) = Lifting.invariant (\<lambda>A. Ball A P)" |
87 |
unfolding fun_eq_iff rel_set_def Lifting.invariant_def Ball_def by fast |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
88 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
89 |
subsection {* Quotient theorem for the Lifting package *} |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
90 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
91 |
lemma Quotient_set[quot_map]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
92 |
assumes "Quotient R Abs Rep T" |
55938 | 93 |
shows "Quotient (rel_set R) (image Abs) (image Rep) (rel_set T)" |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
94 |
using assms unfolding Quotient_alt_def4 |
55938 | 95 |
apply (simp add: rel_set_OO[symmetric]) |
96 |
apply (simp add: rel_set_def, fast) |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
97 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
98 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
99 |
subsection {* Transfer rules for the Transfer package *} |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
100 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
101 |
subsubsection {* Unconditional transfer rules *} |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
102 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
103 |
context |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
104 |
begin |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
105 |
interpretation lifting_syntax . |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
106 |
|
55938 | 107 |
lemma empty_transfer [transfer_rule]: "(rel_set A) {} {}" |
108 |
unfolding rel_set_def by simp |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
109 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
110 |
lemma insert_transfer [transfer_rule]: |
55938 | 111 |
"(A ===> rel_set A ===> rel_set A) insert insert" |
55945 | 112 |
unfolding rel_fun_def rel_set_def by auto |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
113 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
114 |
lemma union_transfer [transfer_rule]: |
55938 | 115 |
"(rel_set A ===> rel_set A ===> rel_set A) union union" |
55945 | 116 |
unfolding rel_fun_def rel_set_def by auto |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
117 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
118 |
lemma Union_transfer [transfer_rule]: |
55938 | 119 |
"(rel_set (rel_set A) ===> rel_set A) Union Union" |
55945 | 120 |
unfolding rel_fun_def rel_set_def by simp fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
121 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
122 |
lemma image_transfer [transfer_rule]: |
55938 | 123 |
"((A ===> B) ===> rel_set A ===> rel_set B) image image" |
55945 | 124 |
unfolding rel_fun_def rel_set_def by simp fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
125 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
126 |
lemma UNION_transfer [transfer_rule]: |
55938 | 127 |
"(rel_set A ===> (A ===> rel_set B) ===> rel_set B) UNION UNION" |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
128 |
unfolding SUP_def [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
129 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
130 |
lemma Ball_transfer [transfer_rule]: |
55938 | 131 |
"(rel_set A ===> (A ===> op =) ===> op =) Ball Ball" |
55945 | 132 |
unfolding rel_set_def rel_fun_def by fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
133 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
134 |
lemma Bex_transfer [transfer_rule]: |
55938 | 135 |
"(rel_set A ===> (A ===> op =) ===> op =) Bex Bex" |
55945 | 136 |
unfolding rel_set_def rel_fun_def by fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
137 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
138 |
lemma Pow_transfer [transfer_rule]: |
55938 | 139 |
"(rel_set A ===> rel_set (rel_set A)) Pow Pow" |
55945 | 140 |
apply (rule rel_funI, rename_tac X Y, rule rel_setI) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
141 |
apply (rename_tac X', rule_tac x="{y\<in>Y. \<exists>x\<in>X'. A x y}" in rev_bexI, clarsimp) |
55938 | 142 |
apply (simp add: rel_set_def, fast) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
143 |
apply (rename_tac Y', rule_tac x="{x\<in>X. \<exists>y\<in>Y'. A x y}" in rev_bexI, clarsimp) |
55938 | 144 |
apply (simp add: rel_set_def, fast) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
145 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
146 |
|
55938 | 147 |
lemma rel_set_transfer [transfer_rule]: |
148 |
"((A ===> B ===> op =) ===> rel_set A ===> rel_set B ===> op =) |
|
149 |
rel_set rel_set" |
|
55945 | 150 |
unfolding rel_fun_def rel_set_def by fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
151 |
|
53927 | 152 |
lemma SUPR_parametric [transfer_rule]: |
55938 | 153 |
"(rel_set R ===> (R ===> op =) ===> op =) SUPR (SUPR :: _ \<Rightarrow> _ \<Rightarrow> _::complete_lattice)" |
55945 | 154 |
proof(rule rel_funI)+ |
53927 | 155 |
fix A B f and g :: "'b \<Rightarrow> 'c" |
55938 | 156 |
assume AB: "rel_set R A B" |
53927 | 157 |
and fg: "(R ===> op =) f g" |
158 |
show "SUPR A f = SUPR B g" |
|
55945 | 159 |
by(rule SUPR_eq)(auto 4 4 dest: rel_setD1[OF AB] rel_setD2[OF AB] rel_funD[OF fg] intro: rev_bexI) |
53927 | 160 |
qed |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
161 |
|
53952 | 162 |
lemma bind_transfer [transfer_rule]: |
55938 | 163 |
"(rel_set A ===> (A ===> rel_set B) ===> rel_set B) Set.bind Set.bind" |
53952 | 164 |
unfolding bind_UNION[abs_def] by transfer_prover |
165 |
||
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
166 |
subsubsection {* Rules requiring bi-unique, bi-total or right-total relations *} |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
167 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
168 |
lemma member_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
169 |
assumes "bi_unique A" |
55938 | 170 |
shows "(A ===> rel_set A ===> op =) (op \<in>) (op \<in>)" |
55945 | 171 |
using assms unfolding rel_fun_def rel_set_def bi_unique_def by fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
172 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
173 |
lemma right_total_Collect_transfer[transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
174 |
assumes "right_total A" |
55938 | 175 |
shows "((A ===> op =) ===> rel_set A) (\<lambda>P. Collect (\<lambda>x. P x \<and> Domainp A x)) Collect" |
55945 | 176 |
using assms unfolding right_total_def rel_set_def rel_fun_def Domainp_iff by fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
177 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
178 |
lemma Collect_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
179 |
assumes "bi_total A" |
55938 | 180 |
shows "((A ===> op =) ===> rel_set A) Collect Collect" |
55945 | 181 |
using assms unfolding rel_fun_def rel_set_def bi_total_def by fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
182 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
183 |
lemma inter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
184 |
assumes "bi_unique A" |
55938 | 185 |
shows "(rel_set A ===> rel_set A ===> rel_set A) inter inter" |
55945 | 186 |
using assms unfolding rel_fun_def rel_set_def bi_unique_def by fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
187 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
188 |
lemma Diff_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
189 |
assumes "bi_unique A" |
55938 | 190 |
shows "(rel_set A ===> rel_set A ===> rel_set A) (op -) (op -)" |
55945 | 191 |
using assms unfolding rel_fun_def rel_set_def bi_unique_def |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
192 |
unfolding Ball_def Bex_def Diff_eq |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
193 |
by (safe, simp, metis, simp, metis) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
194 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
195 |
lemma subset_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
196 |
assumes [transfer_rule]: "bi_unique A" |
55938 | 197 |
shows "(rel_set A ===> rel_set A ===> op =) (op \<subseteq>) (op \<subseteq>)" |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
198 |
unfolding subset_eq [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
199 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
200 |
lemma right_total_UNIV_transfer[transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
201 |
assumes "right_total A" |
55938 | 202 |
shows "(rel_set A) (Collect (Domainp A)) UNIV" |
203 |
using assms unfolding right_total_def rel_set_def Domainp_iff by blast |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
204 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
205 |
lemma UNIV_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
206 |
assumes "bi_total A" |
55938 | 207 |
shows "(rel_set A) UNIV UNIV" |
208 |
using assms unfolding rel_set_def bi_total_def by simp |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
209 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
210 |
lemma right_total_Compl_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
211 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "right_total A" |
55938 | 212 |
shows "(rel_set A ===> rel_set A) (\<lambda>S. uminus S \<inter> Collect (Domainp A)) uminus" |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
213 |
unfolding Compl_eq [abs_def] |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
214 |
by (subst Collect_conj_eq[symmetric]) transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
215 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
216 |
lemma Compl_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
217 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "bi_total A" |
55938 | 218 |
shows "(rel_set A ===> rel_set A) uminus uminus" |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
219 |
unfolding Compl_eq [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
220 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
221 |
lemma right_total_Inter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
222 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "right_total A" |
55938 | 223 |
shows "(rel_set (rel_set A) ===> rel_set A) (\<lambda>S. Inter S \<inter> Collect (Domainp A)) Inter" |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
224 |
unfolding Inter_eq[abs_def] |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
225 |
by (subst Collect_conj_eq[symmetric]) transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
226 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
227 |
lemma Inter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
228 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "bi_total A" |
55938 | 229 |
shows "(rel_set (rel_set A) ===> rel_set A) Inter Inter" |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
230 |
unfolding Inter_eq [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
231 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
232 |
lemma filter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
233 |
assumes [transfer_rule]: "bi_unique A" |
55938 | 234 |
shows "((A ===> op=) ===> rel_set A ===> rel_set A) Set.filter Set.filter" |
55945 | 235 |
unfolding Set.filter_def[abs_def] rel_fun_def rel_set_def by blast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
236 |
|
55938 | 237 |
lemma bi_unique_rel_set_lemma: |
238 |
assumes "bi_unique R" and "rel_set R X Y" |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
239 |
obtains f where "Y = image f X" and "inj_on f X" and "\<forall>x\<in>X. R x (f x)" |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
240 |
proof |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
241 |
let ?f = "\<lambda>x. THE y. R x y" |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
242 |
from assms show f: "\<forall>x\<in>X. R x (?f x)" |
55938 | 243 |
apply (clarsimp simp add: rel_set_def) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
244 |
apply (drule (1) bspec, clarify) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
245 |
apply (rule theI2, assumption) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
246 |
apply (simp add: bi_unique_def) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
247 |
apply assumption |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
248 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
249 |
from assms show "Y = image ?f X" |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
250 |
apply safe |
55938 | 251 |
apply (clarsimp simp add: rel_set_def) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
252 |
apply (drule (1) bspec, clarify) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
253 |
apply (rule image_eqI) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
254 |
apply (rule the_equality [symmetric], assumption) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
255 |
apply (simp add: bi_unique_def) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
256 |
apply assumption |
55938 | 257 |
apply (clarsimp simp add: rel_set_def) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
258 |
apply (frule (1) bspec, clarify) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
259 |
apply (rule theI2, assumption) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
260 |
apply (clarsimp simp add: bi_unique_def) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
261 |
apply (simp add: bi_unique_def, metis) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
262 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
263 |
show "inj_on ?f X" |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
264 |
apply (rule inj_onI) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
265 |
apply (drule f [rule_format]) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
266 |
apply (drule f [rule_format]) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
267 |
apply (simp add: assms(1) [unfolded bi_unique_def]) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
268 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
269 |
qed |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
270 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
271 |
lemma finite_transfer [transfer_rule]: |
55938 | 272 |
"bi_unique A \<Longrightarrow> (rel_set A ===> op =) finite finite" |
55945 | 273 |
by (rule rel_funI, erule (1) bi_unique_rel_set_lemma, |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
274 |
auto dest: finite_imageD) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
275 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
276 |
lemma card_transfer [transfer_rule]: |
55938 | 277 |
"bi_unique A \<Longrightarrow> (rel_set A ===> op =) card card" |
55945 | 278 |
by (rule rel_funI, erule (1) bi_unique_rel_set_lemma, simp add: card_image) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
279 |
|
53927 | 280 |
lemma vimage_parametric [transfer_rule]: |
281 |
assumes [transfer_rule]: "bi_total A" "bi_unique B" |
|
55938 | 282 |
shows "((A ===> B) ===> rel_set B ===> rel_set A) vimage vimage" |
53927 | 283 |
unfolding vimage_def[abs_def] by transfer_prover |
284 |
||
285 |
lemma setsum_parametric [transfer_rule]: |
|
286 |
assumes "bi_unique A" |
|
55938 | 287 |
shows "((A ===> op =) ===> rel_set A ===> op =) setsum setsum" |
55945 | 288 |
proof(rule rel_funI)+ |
53927 | 289 |
fix f :: "'a \<Rightarrow> 'c" and g S T |
290 |
assume fg: "(A ===> op =) f g" |
|
55938 | 291 |
and ST: "rel_set A S T" |
53927 | 292 |
show "setsum f S = setsum g T" |
293 |
proof(rule setsum_reindex_cong) |
|
294 |
let ?f = "\<lambda>t. THE s. A s t" |
|
295 |
show "S = ?f ` T" |
|
55938 | 296 |
by(blast dest: rel_setD1[OF ST] rel_setD2[OF ST] bi_uniqueDl[OF assms] |
53927 | 297 |
intro: rev_image_eqI the_equality[symmetric] subst[rotated, where P="\<lambda>x. x \<in> S"]) |
298 |
||
299 |
show "inj_on ?f T" |
|
300 |
proof(rule inj_onI) |
|
301 |
fix t1 t2 |
|
302 |
assume "t1 \<in> T" "t2 \<in> T" "?f t1 = ?f t2" |
|
55938 | 303 |
from ST `t1 \<in> T` obtain s1 where "A s1 t1" "s1 \<in> S" by(auto dest: rel_setD2) |
53927 | 304 |
hence "?f t1 = s1" by(auto dest: bi_uniqueDl[OF assms]) |
305 |
moreover |
|
55938 | 306 |
from ST `t2 \<in> T` obtain s2 where "A s2 t2" "s2 \<in> S" by(auto dest: rel_setD2) |
53927 | 307 |
hence "?f t2 = s2" by(auto dest: bi_uniqueDl[OF assms]) |
308 |
ultimately have "s1 = s2" using `?f t1 = ?f t2` by simp |
|
309 |
with `A s1 t1` `A s2 t2` show "t1 = t2" by(auto dest: bi_uniqueDr[OF assms]) |
|
310 |
qed |
|
311 |
||
312 |
fix t |
|
313 |
assume "t \<in> T" |
|
55938 | 314 |
with ST obtain s where "A s t" "s \<in> S" by(auto dest: rel_setD2) |
53927 | 315 |
hence "?f t = s" by(auto dest: bi_uniqueDl[OF assms]) |
55945 | 316 |
moreover from fg `A s t` have "f s = g t" by(rule rel_funD) |
53927 | 317 |
ultimately show "g t = f (?f t)" by simp |
318 |
qed |
|
319 |
qed |
|
320 |
||
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
321 |
end |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
322 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
323 |
end |