author | haftmann |
Mon, 20 Oct 2014 07:45:58 +0200 | |
changeset 58710 | 7216a10d69ba |
parent 58104 | c5316f843f72 |
child 58889 | 5b7a9633cfa8 |
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 |
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" |
|
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 |
|
55938 | 20 |
lemma rel_set_eq [relator_eq]: "rel_set (op =) = (op =)" |
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" |
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) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
30 |
apply (intro ext, rename_tac X Z) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
31 |
apply (rule iffI) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
32 |
apply (rule_tac b="{y. (\<exists>x\<in>X. R x y) \<and> (\<exists>z\<in>Z. S y z)}" in relcomppI) |
55938 | 33 |
apply (simp add: rel_set_def, fast) |
34 |
apply (simp add: rel_set_def, fast) |
|
35 |
apply (simp add: rel_set_def, fast) |
|
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))" |
3373f5d1e074
abstract Domainp in relator_domain rules => more natural statement of the rule
kuncar
parents:
56519
diff
changeset
|
40 |
unfolding rel_set_def Domainp_iff[abs_def] |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
41 |
apply (intro ext) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
42 |
apply (rule iffI) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
43 |
apply blast |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
44 |
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
|
45 |
done |
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 |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
51 |
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
|
52 |
done |
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)" |
|
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)" |
|
56524
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
kuncar
parents:
56520
diff
changeset
|
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 |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
83 |
def f \<equiv> "\<lambda>x. THE y. R x y" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
84 |
{ fix x assume "x \<in> X" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
85 |
with `rel_set R X Y` `bi_unique R` have "R x (f x)" |
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) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
87 |
with assms `x \<in> X` |
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" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
93 |
with `rel_set R X Y` *(3) `y \<in> Y` have "\<exists>x\<in>X. y = f x" |
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 |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
99 |
subsection {* Quotient theorem for the Lifting 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 |
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]) |
106 |
apply (simp add: rel_set_def, fast) |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
107 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
108 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
109 |
subsection {* Transfer rules for the Transfer package *} |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
110 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
111 |
subsubsection {* Unconditional transfer rules *} |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
112 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
113 |
context |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
114 |
begin |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
115 |
interpretation lifting_syntax . |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
116 |
|
55938 | 117 |
lemma empty_transfer [transfer_rule]: "(rel_set A) {} {}" |
118 |
unfolding rel_set_def by simp |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
119 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
120 |
lemma insert_transfer [transfer_rule]: |
55938 | 121 |
"(A ===> rel_set A ===> rel_set A) insert insert" |
55945 | 122 |
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
|
123 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
124 |
lemma union_transfer [transfer_rule]: |
55938 | 125 |
"(rel_set A ===> rel_set A ===> rel_set A) union union" |
55945 | 126 |
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
|
127 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
128 |
lemma Union_transfer [transfer_rule]: |
55938 | 129 |
"(rel_set (rel_set A) ===> rel_set A) Union Union" |
55945 | 130 |
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
|
131 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
132 |
lemma image_transfer [transfer_rule]: |
55938 | 133 |
"((A ===> B) ===> rel_set A ===> rel_set B) image image" |
55945 | 134 |
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
|
135 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
136 |
lemma UNION_transfer [transfer_rule]: |
55938 | 137 |
"(rel_set A ===> (A ===> rel_set B) ===> rel_set B) UNION UNION" |
56166 | 138 |
unfolding Union_image_eq [symmetric, abs_def] by transfer_prover |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
139 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
140 |
lemma Ball_transfer [transfer_rule]: |
55938 | 141 |
"(rel_set A ===> (A ===> op =) ===> op =) Ball Ball" |
55945 | 142 |
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
|
143 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
144 |
lemma Bex_transfer [transfer_rule]: |
55938 | 145 |
"(rel_set A ===> (A ===> op =) ===> op =) Bex Bex" |
55945 | 146 |
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
|
147 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
148 |
lemma Pow_transfer [transfer_rule]: |
55938 | 149 |
"(rel_set A ===> rel_set (rel_set A)) Pow Pow" |
55945 | 150 |
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
|
151 |
apply (rename_tac X', rule_tac x="{y\<in>Y. \<exists>x\<in>X'. A x y}" in rev_bexI, clarsimp) |
55938 | 152 |
apply (simp add: rel_set_def, fast) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
153 |
apply (rename_tac Y', rule_tac x="{x\<in>X. \<exists>y\<in>Y'. A x y}" in rev_bexI, clarsimp) |
55938 | 154 |
apply (simp add: rel_set_def, fast) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
155 |
done |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
156 |
|
55938 | 157 |
lemma rel_set_transfer [transfer_rule]: |
56482
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
158 |
"((A ===> B ===> op =) ===> rel_set A ===> rel_set B ===> op =) rel_set rel_set" |
55945 | 159 |
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
|
160 |
|
53952 | 161 |
lemma bind_transfer [transfer_rule]: |
55938 | 162 |
"(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
|
163 |
unfolding bind_UNION [abs_def] by transfer_prover |
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
164 |
|
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
165 |
lemma INF_parametric [transfer_rule]: |
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
166 |
"(rel_set A ===> (A ===> HOL.eq) ===> HOL.eq) INFIMUM INFIMUM" |
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
167 |
unfolding INF_def [abs_def] by transfer_prover |
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
168 |
|
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
169 |
lemma SUP_parametric [transfer_rule]: |
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
170 |
"(rel_set R ===> (R ===> HOL.eq) ===> HOL.eq) SUPREMUM SUPREMUM" |
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
171 |
unfolding SUP_def [abs_def] by transfer_prover |
39ac12b655ab
parametricity transfer rule for INFIMUM, SUPREMUM
haftmann
parents:
56218
diff
changeset
|
172 |
|
53952 | 173 |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
174 |
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
|
175 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
176 |
lemma member_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
177 |
assumes "bi_unique A" |
55938 | 178 |
shows "(A ===> rel_set A ===> op =) (op \<in>) (op \<in>)" |
55945 | 179 |
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
|
180 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
181 |
lemma right_total_Collect_transfer[transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
182 |
assumes "right_total A" |
55938 | 183 |
shows "((A ===> op =) ===> rel_set A) (\<lambda>P. Collect (\<lambda>x. P x \<and> Domainp A x)) Collect" |
55945 | 184 |
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
|
185 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
186 |
lemma Collect_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
187 |
assumes "bi_total A" |
55938 | 188 |
shows "((A ===> op =) ===> rel_set A) Collect Collect" |
55945 | 189 |
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
|
190 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
191 |
lemma inter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
192 |
assumes "bi_unique A" |
55938 | 193 |
shows "(rel_set A ===> rel_set A ===> rel_set A) inter inter" |
55945 | 194 |
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
|
195 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
196 |
lemma Diff_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
197 |
assumes "bi_unique A" |
55938 | 198 |
shows "(rel_set A ===> rel_set A ===> rel_set A) (op -) (op -)" |
55945 | 199 |
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
|
200 |
unfolding Ball_def Bex_def Diff_eq |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
201 |
by (safe, simp, metis, simp, metis) |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
202 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
203 |
lemma subset_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
204 |
assumes [transfer_rule]: "bi_unique A" |
55938 | 205 |
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
|
206 |
unfolding subset_eq [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
207 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
208 |
lemma right_total_UNIV_transfer[transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
209 |
assumes "right_total A" |
55938 | 210 |
shows "(rel_set A) (Collect (Domainp A)) UNIV" |
211 |
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
|
212 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
213 |
lemma UNIV_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
214 |
assumes "bi_total A" |
55938 | 215 |
shows "(rel_set A) UNIV UNIV" |
216 |
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
|
217 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
218 |
lemma right_total_Compl_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
219 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "right_total A" |
55938 | 220 |
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
|
221 |
unfolding Compl_eq [abs_def] |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
222 |
by (subst Collect_conj_eq[symmetric]) transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
223 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
224 |
lemma Compl_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
225 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "bi_total A" |
55938 | 226 |
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
|
227 |
unfolding Compl_eq [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
228 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
229 |
lemma right_total_Inter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
230 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "right_total A" |
55938 | 231 |
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
|
232 |
unfolding Inter_eq[abs_def] |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
233 |
by (subst Collect_conj_eq[symmetric]) transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
234 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
235 |
lemma Inter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
236 |
assumes [transfer_rule]: "bi_unique A" and [transfer_rule]: "bi_total A" |
55938 | 237 |
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
|
238 |
unfolding Inter_eq [abs_def] by transfer_prover |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
239 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
240 |
lemma filter_transfer [transfer_rule]: |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
241 |
assumes [transfer_rule]: "bi_unique A" |
55938 | 242 |
shows "((A ===> op=) ===> rel_set A ===> rel_set A) Set.filter Set.filter" |
55945 | 243 |
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
|
244 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
245 |
lemma finite_transfer [transfer_rule]: |
55938 | 246 |
"bi_unique A \<Longrightarrow> (rel_set A ===> op =) finite finite" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
247 |
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
|
248 |
(auto dest: finite_imageD) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
249 |
|
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
250 |
lemma card_transfer [transfer_rule]: |
55938 | 251 |
"bi_unique A \<Longrightarrow> (rel_set A ===> op =) card card" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
252 |
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
|
253 |
(simp add: card_image) |
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
254 |
|
53927 | 255 |
lemma vimage_parametric [transfer_rule]: |
256 |
assumes [transfer_rule]: "bi_total A" "bi_unique B" |
|
55938 | 257 |
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
|
258 |
unfolding vimage_def[abs_def] by transfer_prover |
53927 | 259 |
|
57599 | 260 |
lemma Image_parametric [transfer_rule]: |
261 |
assumes "bi_unique A" |
|
262 |
shows "(rel_set (rel_prod A B) ===> rel_set A ===> rel_set B) op `` op ``" |
|
263 |
by(intro rel_funI rel_setI) |
|
264 |
(force dest: rel_setD1 bi_uniqueDr[OF assms], force dest: rel_setD2 bi_uniqueDl[OF assms]) |
|
265 |
||
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
266 |
end |
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
267 |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
268 |
lemma (in comm_monoid_set) F_parametric [transfer_rule]: |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
269 |
fixes A :: "'b \<Rightarrow> 'c \<Rightarrow> bool" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
270 |
assumes "bi_unique A" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
271 |
shows "rel_fun (rel_fun A (op =)) (rel_fun (rel_set A) (op =)) F F" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
272 |
proof(rule rel_funI)+ |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
273 |
fix f :: "'b \<Rightarrow> 'a" and g S T |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
274 |
assume "rel_fun A (op =) f g" "rel_set A S T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
275 |
with `bi_unique A` obtain i where "bij_betw i S T" "\<And>x. x \<in> S \<Longrightarrow> f x = g (i x)" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
276 |
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
|
277 |
then show "F f S = F g T" |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
278 |
by (simp add: reindex_bij_betw) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
279 |
qed |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
280 |
|
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
281 |
lemmas setsum_parametric = setsum.F_parametric |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
282 |
lemmas setprod_parametric = setprod.F_parametric |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56524
diff
changeset
|
283 |
|
53012
cb82606b8215
move Lifting/Transfer relevant parts of Library/Quotient_* to Main
kuncar
parents:
diff
changeset
|
284 |
end |