author | paulson <lp15@cam.ac.uk> |
Thu, 26 Sep 2024 14:44:37 +0100 | |
changeset 80948 | 572970d15ab0 |
parent 74979 | 4d77dd3019d1 |
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 |
|
60758 | 5 |
section \<open>Setup for Lifting/Transfer for the set type\<close> |
53012
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 |
74979 | 8 |
imports Lifting Groups_Big |
53012
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 |
|
60758 | 11 |
subsection \<open>Relator and predicator properties\<close> |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
12 |
|
55938 | 13 |
lemma rel_setD1: "\<lbrakk> rel_set R A B; x \<in> A \<rbrakk> \<Longrightarrow> \<exists>y \<in> B. R x y" |
14 |
and rel_setD2: "\<lbrakk> rel_set R A B; y \<in> B \<rbrakk> \<Longrightarrow> \<exists>x \<in> A. R x y" |
|
60676 | 15 |
by (simp_all add: rel_set_def) |
53927 | 16 |
|
55938 | 17 |
lemma rel_set_conversep [simp]: "rel_set A\<inverse>\<inverse> = (rel_set A)\<inverse>\<inverse>" |
18 |
unfolding rel_set_def by auto |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
19 |
|
67399 | 20 |
lemma rel_set_eq [relator_eq]: "rel_set (=) = (=)" |
55938 | 21 |
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
|
22 |
|
55938 | 23 |
lemma rel_set_mono[relator_mono]: |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
24 |
assumes "A \<le> B" |
55938 | 25 |
shows "rel_set A \<le> rel_set B" |
60676 | 26 |
using assms unfolding rel_set_def by blast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
27 |
|
55938 | 28 |
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
|
29 |
apply (rule sym) |
60676 | 30 |
apply (intro ext) |
31 |
subgoal for X Z |
|
32 |
apply (rule iffI) |
|
33 |
apply (rule relcomppI [where b="{y. (\<exists>x\<in>X. R x y) \<and> (\<exists>z\<in>Z. S y z)}"]) |
|
34 |
apply (simp add: rel_set_def, fast)+ |
|
35 |
done |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
36 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
37 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
38 |
lemma Domainp_set[relator_domain]: |
56520
3373f5d1e074
abstract Domainp in relator_domain rules => more natural statement of the rule
kuncar
parents:
56519
diff
changeset
|
39 |
"Domainp (rel_set T) = (\<lambda>A. Ball A (Domainp T))" |
60676 | 40 |
unfolding rel_set_def Domainp_iff[abs_def] |
41 |
apply (intro ext) |
|
42 |
apply (rule iffI) |
|
43 |
apply blast |
|
44 |
subgoal for A by (rule exI [where x="{y. \<exists>x\<in>A. T x y}"]) fast |
|
45 |
done |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
46 |
|
56518
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
kuncar
parents:
56482
diff
changeset
|
47 |
lemma left_total_rel_set[transfer_rule]: |
55938 | 48 |
"left_total A \<Longrightarrow> left_total (rel_set A)" |
49 |
unfolding left_total_def rel_set_def |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
50 |
apply safe |
60676 | 51 |
subgoal for X by (rule exI [where x="{y. \<exists>x\<in>X. A x y}"]) fast |
52 |
done |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
53 |
|
56518
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
kuncar
parents:
56482
diff
changeset
|
54 |
lemma left_unique_rel_set[transfer_rule]: |
55938 | 55 |
"left_unique A \<Longrightarrow> left_unique (rel_set A)" |
56 |
unfolding left_unique_def rel_set_def |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
57 |
by fast |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
58 |
|
55938 | 59 |
lemma right_total_rel_set [transfer_rule]: |
60 |
"right_total A \<Longrightarrow> right_total (rel_set A)" |
|
60676 | 61 |
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
|
62 |
|
55938 | 63 |
lemma right_unique_rel_set [transfer_rule]: |
64 |
"right_unique A \<Longrightarrow> right_unique (rel_set A)" |
|
65 |
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
|
66 |
|
55938 | 67 |
lemma bi_total_rel_set [transfer_rule]: |
68 |
"bi_total A \<Longrightarrow> bi_total (rel_set A)" |
|
60676 | 69 |
by(simp add: bi_total_alt_def left_total_rel_set right_total_rel_set) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
70 |
|
55938 | 71 |
lemma bi_unique_rel_set [transfer_rule]: |
72 |
"bi_unique A \<Longrightarrow> bi_unique (rel_set A)" |
|
73 |
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
|
74 |
|
56519
c1048f5bbb45
more appropriate name (Lifting.invariant -> eq_onp)
kuncar
parents:
56518
diff
changeset
|
75 |
lemma set_relator_eq_onp [relator_eq_onp]: |
c1048f5bbb45
more appropriate name (Lifting.invariant -> eq_onp)
kuncar
parents:
56518
diff
changeset
|
76 |
"rel_set (eq_onp P) = eq_onp (\<lambda>A. Ball A P)" |
c1048f5bbb45
more appropriate name (Lifting.invariant -> eq_onp)
kuncar
parents:
56518
diff
changeset
|
77 |
unfolding fun_eq_iff rel_set_def eq_onp_def Ball_def by fast |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
78 |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
79 |
lemma bi_unique_rel_set_lemma: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
80 |
assumes "bi_unique R" and "rel_set R X Y" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
81 |
obtains f where "Y = image f X" and "inj_on f X" and "\<forall>x\<in>X. R x (f x)" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
82 |
proof |
63040 | 83 |
define f where "f x = (THE y. R x y)" for x |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
84 |
{ fix x assume "x \<in> X" |
60758 | 85 |
with \<open>rel_set R X Y\<close> \<open>bi_unique R\<close> have "R x (f x)" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
86 |
by (simp add: bi_unique_def rel_set_def f_def) (metis theI) |
60758 | 87 |
with assms \<open>x \<in> X\<close> |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
88 |
have "R x (f x)" "\<forall>x'\<in>X. R x' (f x) \<longrightarrow> x = x'" "\<forall>y\<in>Y. R x y \<longrightarrow> y = f x" "f x \<in> Y" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
89 |
by (fastforce simp add: bi_unique_def rel_set_def)+ } |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
90 |
note * = this |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
91 |
moreover |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
92 |
{ fix y assume "y \<in> Y" |
60758 | 93 |
with \<open>rel_set R X Y\<close> *(3) \<open>y \<in> Y\<close> have "\<exists>x\<in>X. y = f x" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
94 |
by (fastforce simp: rel_set_def) } |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
95 |
ultimately show "\<forall>x\<in>X. R x (f x)" "Y = image f X" "inj_on f X" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
96 |
by (auto simp: inj_on_def image_iff) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
97 |
qed |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
98 |
|
60758 | 99 |
subsection \<open>Quotient theorem for the Lifting package\<close> |
53012
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 |
lemma Quotient_set[quot_map]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
102 |
assumes "Quotient R Abs Rep T" |
55938 | 103 |
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
|
104 |
using assms unfolding Quotient_alt_def4 |
55938 | 105 |
apply (simp add: rel_set_OO[symmetric]) |
60676 | 106 |
apply (simp add: rel_set_def) |
107 |
apply fast |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
108 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
109 |
|
60676 | 110 |
|
60758 | 111 |
subsection \<open>Transfer rules for the Transfer package\<close> |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
112 |
|
60758 | 113 |
subsubsection \<open>Unconditional transfer rules\<close> |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
114 |
|
63343 | 115 |
context includes lifting_syntax |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
116 |
begin |
60676 | 117 |
|
55938 | 118 |
lemma empty_transfer [transfer_rule]: "(rel_set A) {} {}" |
119 |
unfolding rel_set_def by simp |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
120 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
121 |
lemma insert_transfer [transfer_rule]: |
55938 | 122 |
"(A ===> rel_set A ===> rel_set A) insert insert" |
55945 | 123 |
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
|
124 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
125 |
lemma union_transfer [transfer_rule]: |
55938 | 126 |
"(rel_set A ===> rel_set A ===> rel_set A) union union" |
55945 | 127 |
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
|
128 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
129 |
lemma Union_transfer [transfer_rule]: |
55938 | 130 |
"(rel_set (rel_set A) ===> rel_set A) Union Union" |
55945 | 131 |
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
|
132 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
133 |
lemma image_transfer [transfer_rule]: |
55938 | 134 |
"((A ===> B) ===> rel_set A ===> rel_set B) image image" |
55945 | 135 |
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
|
136 |
|
69275 | 137 |
lemma UNION_transfer [transfer_rule]: \<comment> \<open>TODO deletion candidate\<close> |
138 |
"(rel_set A ===> (A ===> rel_set B) ===> rel_set B) (\<lambda>A f. \<Union>(f ` A)) (\<lambda>A f. \<Union>(f ` A))" |
|
62343
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61952
diff
changeset
|
139 |
by transfer_prover |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
140 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
141 |
lemma Ball_transfer [transfer_rule]: |
67399 | 142 |
"(rel_set A ===> (A ===> (=)) ===> (=)) Ball Ball" |
55945 | 143 |
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
|
144 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
145 |
lemma Bex_transfer [transfer_rule]: |
67399 | 146 |
"(rel_set A ===> (A ===> (=)) ===> (=)) Bex Bex" |
55945 | 147 |
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
|
148 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
149 |
lemma Pow_transfer [transfer_rule]: |
55938 | 150 |
"(rel_set A ===> rel_set (rel_set A)) Pow Pow" |
60676 | 151 |
apply (rule rel_funI) |
152 |
apply (rule rel_setI) |
|
153 |
subgoal for X Y X' |
|
154 |
apply (rule rev_bexI [where x="{y\<in>Y. \<exists>x\<in>X'. A x y}"]) |
|
155 |
apply clarsimp |
|
156 |
apply (simp add: rel_set_def) |
|
157 |
apply fast |
|
158 |
done |
|
159 |
subgoal for X Y Y' |
|
160 |
apply (rule rev_bexI [where x="{x\<in>X. \<exists>y\<in>Y'. A x y}"]) |
|
161 |
apply clarsimp |
|
162 |
apply (simp add: rel_set_def) |
|
163 |
apply fast |
|
164 |
done |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
165 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
166 |
|
55938 | 167 |
lemma rel_set_transfer [transfer_rule]: |
67399 | 168 |
"((A ===> B ===> (=)) ===> rel_set A ===> rel_set B ===> (=)) rel_set rel_set" |
55945 | 169 |
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
|
170 |
|
53952 | 171 |
lemma bind_transfer [transfer_rule]: |
55938 | 172 |
"(rel_set A ===> (A ===> rel_set B) ===> rel_set B) Set.bind Set.bind" |
56482
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
173 |
unfolding bind_UNION [abs_def] by transfer_prover |
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
174 |
|
69275 | 175 |
lemma INF_parametric [transfer_rule]: \<comment> \<open>TODO deletion candidate\<close> |
176 |
"(rel_set A ===> (A ===> HOL.eq) ===> HOL.eq) (\<lambda>A f. Inf (f ` A)) (\<lambda>A f. Inf (f ` A))" |
|
62343
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61952
diff
changeset
|
177 |
by transfer_prover |
56482
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
178 |
|
69275 | 179 |
lemma SUP_parametric [transfer_rule]: \<comment> \<open>TODO deletion candidate\<close> |
180 |
"(rel_set R ===> (R ===> HOL.eq) ===> HOL.eq) (\<lambda>A f. Sup (f ` A)) (\<lambda>A f. Sup (f ` A))" |
|
62343
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents:
61952
diff
changeset
|
181 |
by transfer_prover |
56482
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
182 |
|
53952 | 183 |
|
60758 | 184 |
subsubsection \<open>Rules requiring bi-unique, bi-total or right-total relations\<close> |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
185 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
186 |
lemma member_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
187 |
assumes "bi_unique A" |
67399 | 188 |
shows "(A ===> rel_set A ===> (=)) (\<in>) (\<in>)" |
55945 | 189 |
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
|
190 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
191 |
lemma right_total_Collect_transfer[transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
192 |
assumes "right_total A" |
67399 | 193 |
shows "((A ===> (=)) ===> rel_set A) (\<lambda>P. Collect (\<lambda>x. P x \<and> Domainp A x)) Collect" |
55945 | 194 |
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
|
195 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
196 |
lemma Collect_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
197 |
assumes "bi_total A" |
67399 | 198 |
shows "((A ===> (=)) ===> rel_set A) Collect Collect" |
55945 | 199 |
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
|
200 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
201 |
lemma inter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
202 |
assumes "bi_unique A" |
55938 | 203 |
shows "(rel_set A ===> rel_set A ===> rel_set A) inter inter" |
55945 | 204 |
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
|
205 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
206 |
lemma Diff_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
207 |
assumes "bi_unique A" |
67399 | 208 |
shows "(rel_set A ===> rel_set A ===> rel_set A) (-) (-)" |
55945 | 209 |
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
|
210 |
unfolding Ball_def Bex_def Diff_eq |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
211 |
by (safe, simp, metis, simp, metis) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
212 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
213 |
lemma subset_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
214 |
assumes [transfer_rule]: "bi_unique A" |
67399 | 215 |
shows "(rel_set A ===> rel_set A ===> (=)) (\<subseteq>) (\<subseteq>)" |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
216 |
unfolding subset_eq [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
217 |
|
70927 | 218 |
context |
219 |
includes lifting_syntax |
|
220 |
begin |
|
221 |
||
68521 | 222 |
lemma strict_subset_transfer [transfer_rule]: |
223 |
assumes [transfer_rule]: "bi_unique A" |
|
224 |
shows "(rel_set A ===> rel_set A ===> (=)) (\<subset>) (\<subset>)" |
|
225 |
unfolding subset_not_subset_eq by transfer_prover |
|
226 |
||
70927 | 227 |
end |
228 |
||
60229
4cd6462c1fda
Workaround that allows us to execute lifted constants that have as a return type a datatype containing a subtype
kuncar
parents:
60057
diff
changeset
|
229 |
declare right_total_UNIV_transfer[transfer_rule] |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
230 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
231 |
lemma UNIV_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
232 |
assumes "bi_total A" |
55938 | 233 |
shows "(rel_set A) UNIV UNIV" |
234 |
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
|
235 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
236 |
lemma right_total_Compl_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
237 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "right_total A" |
55938 | 238 |
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
|
239 |
unfolding Compl_eq [abs_def] |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
240 |
by (subst Collect_conj_eq[symmetric]) transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
241 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
242 |
lemma Compl_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
243 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "bi_total A" |
55938 | 244 |
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
|
245 |
unfolding Compl_eq [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
246 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
247 |
lemma right_total_Inter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
248 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "right_total A" |
61952 | 249 |
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
|
250 |
unfolding Inter_eq[abs_def] |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
251 |
by (subst Collect_conj_eq[symmetric]) transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
252 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
253 |
lemma Inter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
254 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "bi_total A" |
55938 | 255 |
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
|
256 |
unfolding Inter_eq [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
257 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
258 |
lemma filter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
259 |
assumes [transfer_rule]: "bi_unique A" |
67399 | 260 |
shows "((A ===> (=)) ===> rel_set A ===> rel_set A) Set.filter Set.filter" |
55945 | 261 |
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
|
262 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
263 |
lemma finite_transfer [transfer_rule]: |
67399 | 264 |
"bi_unique A \<Longrightarrow> (rel_set A ===> (=)) finite finite" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
265 |
by (rule rel_funI, erule (1) bi_unique_rel_set_lemma) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
266 |
(auto dest: finite_imageD) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
267 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
268 |
lemma card_transfer [transfer_rule]: |
67399 | 269 |
"bi_unique A \<Longrightarrow> (rel_set A ===> (=)) card card" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
270 |
by (rule rel_funI, erule (1) bi_unique_rel_set_lemma) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
271 |
(simp add: card_image) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
272 |
|
70927 | 273 |
context |
274 |
includes lifting_syntax |
|
275 |
begin |
|
276 |
||
68521 | 277 |
lemma vimage_right_total_transfer[transfer_rule]: |
278 |
assumes [transfer_rule]: "bi_unique B" "right_total A" |
|
279 |
shows "((A ===> B) ===> rel_set B ===> rel_set A) (\<lambda>f X. f -` X \<inter> Collect (Domainp A)) vimage" |
|
280 |
proof - |
|
281 |
let ?vimage = "(\<lambda>f B. {x. f x \<in> B \<and> Domainp A x})" |
|
282 |
have "((A ===> B) ===> rel_set B ===> rel_set A) ?vimage vimage" |
|
283 |
unfolding vimage_def |
|
284 |
by transfer_prover |
|
285 |
also have "?vimage = (\<lambda>f X. f -` X \<inter> Collect (Domainp A))" |
|
286 |
by auto |
|
287 |
finally show ?thesis . |
|
288 |
qed |
|
289 |
||
70927 | 290 |
end |
291 |
||
53927 | 292 |
lemma vimage_parametric [transfer_rule]: |
293 |
assumes [transfer_rule]: "bi_total A" "bi_unique B" |
|
55938 | 294 |
shows "((A ===> B) ===> rel_set B ===> rel_set A) vimage vimage" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
295 |
unfolding vimage_def[abs_def] by transfer_prover |
53927 | 296 |
|
57599 | 297 |
lemma Image_parametric [transfer_rule]: |
298 |
assumes "bi_unique A" |
|
67399 | 299 |
shows "(rel_set (rel_prod A B) ===> rel_set A ===> rel_set B) (``) (``)" |
60676 | 300 |
by (intro rel_funI rel_setI) |
301 |
(force dest: rel_setD1 bi_uniqueDr[OF assms], force dest: rel_setD2 bi_uniqueDl[OF assms]) |
|
57599 | 302 |
|
68521 | 303 |
lemma inj_on_transfer[transfer_rule]: |
304 |
"((A ===> B) ===> rel_set A ===> (=)) inj_on inj_on" |
|
305 |
if [transfer_rule]: "bi_unique A" "bi_unique B" |
|
306 |
unfolding inj_on_def |
|
307 |
by transfer_prover |
|
308 |
||
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
309 |
end |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
310 |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
311 |
lemma (in comm_monoid_set) F_parametric [transfer_rule]: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
312 |
fixes A :: "'b \<Rightarrow> 'c \<Rightarrow> bool" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
313 |
assumes "bi_unique A" |
67399 | 314 |
shows "rel_fun (rel_fun A (=)) (rel_fun (rel_set A) (=)) F F" |
60676 | 315 |
proof (rule rel_funI)+ |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
316 |
fix f :: "'b \<Rightarrow> 'a" and g S T |
67399 | 317 |
assume "rel_fun A (=) f g" "rel_set A S T" |
60758 | 318 |
with \<open>bi_unique A\<close> obtain i where "bij_betw i S T" "\<And>x. x \<in> S \<Longrightarrow> f x = g (i x)" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
319 |
by (auto elim: bi_unique_rel_set_lemma simp: rel_fun_def bij_betw_def) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
320 |
then show "F f S = F g T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
321 |
by (simp add: reindex_bij_betw) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
322 |
qed |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
323 |
|
64267 | 324 |
lemmas sum_parametric = sum.F_parametric |
64272 | 325 |
lemmas prod_parametric = prod.F_parametric |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
326 |
|
60057 | 327 |
lemma rel_set_UNION: |
328 |
assumes [transfer_rule]: "rel_set Q A B" "rel_fun Q (rel_set R) f g" |
|
69275 | 329 |
shows "rel_set R (\<Union>(f ` A)) (\<Union>(g ` B))" |
60676 | 330 |
by transfer_prover |
60057 | 331 |
|
73832 | 332 |
context |
333 |
includes lifting_syntax |
|
334 |
begin |
|
335 |
||
336 |
lemma fold_graph_transfer[transfer_rule]: |
|
337 |
assumes "bi_unique R" "right_total R" |
|
338 |
shows "((R ===> (=) ===> (=)) ===> (=) ===> rel_set R ===> (=) ===> (=)) fold_graph fold_graph" |
|
339 |
proof(intro rel_funI) |
|
340 |
fix f1 :: "'a \<Rightarrow> 'c \<Rightarrow> 'c" and f2 :: "'b \<Rightarrow> 'c \<Rightarrow> 'c" |
|
341 |
assume rel_f: "(R ===> (=) ===> (=)) f1 f2" |
|
342 |
fix z1 z2 :: 'c assume [simp]: "z1 = z2" |
|
343 |
fix A1 A2 assume rel_A: "rel_set R A1 A2" |
|
344 |
fix y1 y2 :: 'c assume [simp]: "y1 = y2" |
|
345 |
||
346 |
from \<open>bi_unique R\<close> \<open>right_total R\<close> have The_y: "\<forall>y. \<exists>!x. R x y" |
|
347 |
unfolding bi_unique_def right_total_def by auto |
|
348 |
define r where "r \<equiv> \<lambda>y. THE x. R x y" |
|
349 |
||
350 |
from The_y have r_y: "R (r y) y" for y |
|
351 |
unfolding r_def using the_equality by fastforce |
|
352 |
with assms rel_A have "inj_on r A2" "A1 = r ` A2" |
|
353 |
unfolding r_def rel_set_def inj_on_def bi_unique_def |
|
354 |
apply(auto simp: image_iff) by metis+ |
|
355 |
with \<open>bi_unique R\<close> rel_f r_y have "(f1 o r) y = f2 y" for y |
|
356 |
unfolding bi_unique_def rel_fun_def by auto |
|
357 |
then have "(f1 o r) = f2" |
|
358 |
by blast |
|
359 |
then show "fold_graph f1 z1 A1 y1 = fold_graph f2 z2 A2 y2" |
|
360 |
by (fastforce simp: fold_graph_image[OF \<open>inj_on r A2\<close>] \<open>A1 = r ` A2\<close>) |
|
361 |
qed |
|
362 |
||
363 |
lemma fold_transfer[transfer_rule]: |
|
364 |
assumes [transfer_rule]: "bi_unique R" "right_total R" |
|
365 |
shows "((R ===> (=) ===> (=)) ===> (=) ===> rel_set R ===> (=)) Finite_Set.fold Finite_Set.fold" |
|
366 |
unfolding Finite_Set.fold_def |
|
367 |
by transfer_prover |
|
368 |
||
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
369 |
end |
73832 | 370 |
|
371 |
||
372 |
end |