author | wenzelm |
Thu, 14 Mar 2019 16:55:06 +0100 | |
changeset 69913 | ca515cf61651 |
parent 69605 | a96320074298 |
child 69990 | eb072ce80f82 |
permissions | -rw-r--r-- |
41959 | 1 |
(* Title: HOL/Quotient.thy |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
2 |
Author: Cezary Kaliszyk and Christian Urban |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
3 |
*) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
4 |
|
60758 | 5 |
section \<open>Definition of Quotient Types\<close> |
35294 | 6 |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
7 |
theory Quotient |
54555 | 8 |
imports Lifting |
46950
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
wenzelm
parents:
46947
diff
changeset
|
9 |
keywords |
47308 | 10 |
"print_quotmapsQ3" "print_quotientsQ3" "print_quotconsts" :: diag and |
69913 | 11 |
"quotient_type" :: thy_goal_defn and "/" and |
12 |
"quotient_definition" :: thy_goal_defn |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
13 |
begin |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
14 |
|
60758 | 15 |
text \<open> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
16 |
Basic definition for equivalence relations |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
17 |
that are represented by predicates. |
60758 | 18 |
\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
19 |
|
60758 | 20 |
text \<open>Composition of Relations\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
21 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
22 |
abbreviation |
40818
b117df72e56b
reorienting iff in Quotient_rel prevents simplifier looping;
haftmann
parents:
40814
diff
changeset
|
23 |
rel_conj :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" (infixr "OOO" 75) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
24 |
where |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
25 |
"r1 OOO r2 \<equiv> r1 OO r2 OO r1" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
26 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
27 |
lemma eq_comp_r: |
67399 | 28 |
shows "((=) OOO R) = R" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
29 |
by (auto simp add: fun_eq_iff) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
30 |
|
63343 | 31 |
context includes lifting_syntax |
53011
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
kuncar
parents:
51112
diff
changeset
|
32 |
begin |
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
kuncar
parents:
51112
diff
changeset
|
33 |
|
60758 | 34 |
subsection \<open>Quotient Predicate\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
35 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
36 |
definition |
47308 | 37 |
"Quotient3 R Abs Rep \<longleftrightarrow> |
40814
fa64f6278568
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents:
40615
diff
changeset
|
38 |
(\<forall>a. Abs (Rep a) = a) \<and> (\<forall>a. R (Rep a) (Rep a)) \<and> |
40818
b117df72e56b
reorienting iff in Quotient_rel prevents simplifier looping;
haftmann
parents:
40814
diff
changeset
|
39 |
(\<forall>r s. R r s \<longleftrightarrow> R r r \<and> R s s \<and> Abs r = Abs s)" |
b117df72e56b
reorienting iff in Quotient_rel prevents simplifier looping;
haftmann
parents:
40814
diff
changeset
|
40 |
|
47308 | 41 |
lemma Quotient3I: |
40818
b117df72e56b
reorienting iff in Quotient_rel prevents simplifier looping;
haftmann
parents:
40814
diff
changeset
|
42 |
assumes "\<And>a. Abs (Rep a) = a" |
b117df72e56b
reorienting iff in Quotient_rel prevents simplifier looping;
haftmann
parents:
40814
diff
changeset
|
43 |
and "\<And>a. R (Rep a) (Rep a)" |
b117df72e56b
reorienting iff in Quotient_rel prevents simplifier looping;
haftmann
parents:
40814
diff
changeset
|
44 |
and "\<And>r s. R r s \<longleftrightarrow> R r r \<and> R s s \<and> Abs r = Abs s" |
47308 | 45 |
shows "Quotient3 R Abs Rep" |
46 |
using assms unfolding Quotient3_def by blast |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
47 |
|
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
48 |
context |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
49 |
fixes R Abs Rep |
47308 | 50 |
assumes a: "Quotient3 R Abs Rep" |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
51 |
begin |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
52 |
|
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
53 |
lemma Quotient3_abs_rep: |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
54 |
"Abs (Rep a) = a" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
55 |
using a |
47308 | 56 |
unfolding Quotient3_def |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
57 |
by simp |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
58 |
|
47308 | 59 |
lemma Quotient3_rep_reflp: |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
60 |
"R (Rep a) (Rep a)" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
61 |
using a |
47308 | 62 |
unfolding Quotient3_def |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
63 |
by blast |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
64 |
|
47308 | 65 |
lemma Quotient3_rel: |
61799 | 66 |
"R r r \<and> R s s \<and> Abs r = Abs s \<longleftrightarrow> R r s" \<comment> \<open>orientation does not loop on rewriting\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
67 |
using a |
47308 | 68 |
unfolding Quotient3_def |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
69 |
by blast |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
70 |
|
47308 | 71 |
lemma Quotient3_refl1: |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
72 |
"R r s \<Longrightarrow> R r r" |
47308 | 73 |
using a unfolding Quotient3_def |
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
74 |
by fast |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
75 |
|
47308 | 76 |
lemma Quotient3_refl2: |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
77 |
"R r s \<Longrightarrow> R s s" |
47308 | 78 |
using a unfolding Quotient3_def |
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
79 |
by fast |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
80 |
|
47308 | 81 |
lemma Quotient3_rel_rep: |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
82 |
"R (Rep a) (Rep b) \<longleftrightarrow> a = b" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
83 |
using a |
47308 | 84 |
unfolding Quotient3_def |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
85 |
by metis |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
86 |
|
47308 | 87 |
lemma Quotient3_rep_abs: |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
88 |
"R r r \<Longrightarrow> R (Rep (Abs r)) r" |
47308 | 89 |
using a unfolding Quotient3_def |
90 |
by blast |
|
91 |
||
92 |
lemma Quotient3_rel_abs: |
|
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
93 |
"R r s \<Longrightarrow> Abs r = Abs s" |
47308 | 94 |
using a unfolding Quotient3_def |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
95 |
by blast |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
96 |
|
47308 | 97 |
lemma Quotient3_symp: |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
98 |
"symp R" |
47308 | 99 |
using a unfolding Quotient3_def using sympI by metis |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
100 |
|
47308 | 101 |
lemma Quotient3_transp: |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
102 |
"transp R" |
47308 | 103 |
using a unfolding Quotient3_def using transpI by (metis (full_types)) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
104 |
|
47308 | 105 |
lemma Quotient3_part_equivp: |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
106 |
"part_equivp R" |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
107 |
by (metis Quotient3_rep_reflp Quotient3_symp Quotient3_transp part_equivpI) |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
108 |
|
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
109 |
lemma abs_o_rep: |
67091 | 110 |
"Abs \<circ> Rep = id" |
54867
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
111 |
unfolding fun_eq_iff |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
112 |
by (simp add: Quotient3_abs_rep) |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
113 |
|
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
114 |
lemma equals_rsp: |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
115 |
assumes b: "R xa xb" "R ya yb" |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
116 |
shows "R xa ya = R xb yb" |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
117 |
using b Quotient3_symp Quotient3_transp |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
118 |
by (blast elim: sympE transpE) |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
119 |
|
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
120 |
lemma rep_abs_rsp: |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
121 |
assumes b: "R x1 x2" |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
122 |
shows "R x1 (Rep (Abs x2))" |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
123 |
using b Quotient3_rel Quotient3_abs_rep Quotient3_rep_reflp |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
124 |
by metis |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
125 |
|
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
126 |
lemma rep_abs_rsp_left: |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
127 |
assumes b: "R x1 x2" |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
128 |
shows "R (Rep (Abs x1)) x2" |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
129 |
using b Quotient3_rel Quotient3_abs_rep Quotient3_rep_reflp |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
130 |
by metis |
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
131 |
|
c21a2465cac1
prefer ephemeral interpretation over interpretation in proof contexts;
haftmann
parents:
54555
diff
changeset
|
132 |
end |
47308 | 133 |
|
134 |
lemma identity_quotient3: |
|
67399 | 135 |
"Quotient3 (=) id id" |
47308 | 136 |
unfolding Quotient3_def id_def |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
137 |
by blast |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
138 |
|
47308 | 139 |
lemma fun_quotient3: |
140 |
assumes q1: "Quotient3 R1 abs1 rep1" |
|
141 |
and q2: "Quotient3 R2 abs2 rep2" |
|
142 |
shows "Quotient3 (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2)" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
143 |
proof - |
47308 | 144 |
have "\<And>a.(rep1 ---> abs2) ((abs1 ---> rep2) a) = a" |
145 |
using q1 q2 by (simp add: Quotient3_def fun_eq_iff) |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
146 |
moreover |
47308 | 147 |
have "\<And>a.(R1 ===> R2) ((abs1 ---> rep2) a) ((abs1 ---> rep2) a)" |
55945 | 148 |
by (rule rel_funI) |
47308 | 149 |
(insert q1 q2 Quotient3_rel_abs [of R1 abs1 rep1] Quotient3_rel_rep [of R2 abs2 rep2], |
150 |
simp (no_asm) add: Quotient3_def, simp) |
|
151 |
||
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
152 |
moreover |
47308 | 153 |
{ |
154 |
fix r s |
|
155 |
have "(R1 ===> R2) r s = ((R1 ===> R2) r r \<and> (R1 ===> R2) s s \<and> |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
156 |
(rep1 ---> abs2) r = (rep1 ---> abs2) s)" |
47308 | 157 |
proof - |
158 |
||
55945 | 159 |
have "(R1 ===> R2) r s \<Longrightarrow> (R1 ===> R2) r r" unfolding rel_fun_def |
47308 | 160 |
using Quotient3_part_equivp[OF q1] Quotient3_part_equivp[OF q2] |
161 |
by (metis (full_types) part_equivp_def) |
|
55945 | 162 |
moreover have "(R1 ===> R2) r s \<Longrightarrow> (R1 ===> R2) s s" unfolding rel_fun_def |
47308 | 163 |
using Quotient3_part_equivp[OF q1] Quotient3_part_equivp[OF q2] |
164 |
by (metis (full_types) part_equivp_def) |
|
165 |
moreover have "(R1 ===> R2) r s \<Longrightarrow> (rep1 ---> abs2) r = (rep1 ---> abs2) s" |
|
55945 | 166 |
apply(auto simp add: rel_fun_def fun_eq_iff) using q1 q2 unfolding Quotient3_def by metis |
47308 | 167 |
moreover have "((R1 ===> R2) r r \<and> (R1 ===> R2) s s \<and> |
168 |
(rep1 ---> abs2) r = (rep1 ---> abs2) s) \<Longrightarrow> (R1 ===> R2) r s" |
|
55945 | 169 |
apply(auto simp add: rel_fun_def fun_eq_iff) using q1 q2 unfolding Quotient3_def |
47308 | 170 |
by (metis map_fun_apply) |
171 |
||
172 |
ultimately show ?thesis by blast |
|
173 |
qed |
|
174 |
} |
|
175 |
ultimately show ?thesis by (intro Quotient3I) (assumption+) |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
176 |
qed |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
177 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
178 |
lemma lambda_prs: |
47308 | 179 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
180 |
and q2: "Quotient3 R2 Abs2 Rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
181 |
shows "(Rep1 ---> Abs2) (\<lambda>x. Rep2 (f (Abs1 x))) = (\<lambda>x. f x)" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
182 |
unfolding fun_eq_iff |
47308 | 183 |
using Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2] |
40814
fa64f6278568
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents:
40615
diff
changeset
|
184 |
by simp |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
185 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
186 |
lemma lambda_prs1: |
47308 | 187 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
188 |
and q2: "Quotient3 R2 Abs2 Rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
189 |
shows "(Rep1 ---> Abs2) (\<lambda>x. (Abs1 ---> Rep2) f x) = (\<lambda>x. f x)" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
190 |
unfolding fun_eq_iff |
47308 | 191 |
using Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2] |
40814
fa64f6278568
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents:
40615
diff
changeset
|
192 |
by simp |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
193 |
|
60758 | 194 |
text\<open> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
195 |
In the following theorem R1 can be instantiated with anything, |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
196 |
but we know some of the types of the Rep and Abs functions; |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
197 |
so by solving Quotient assumptions we can get a unique R1 that |
61799 | 198 |
will be provable; which is why we need to use \<open>apply_rsp\<close> and |
60758 | 199 |
not the primed version\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
200 |
|
47308 | 201 |
lemma apply_rspQ3: |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
202 |
fixes f g::"'a \<Rightarrow> 'c" |
47308 | 203 |
assumes q: "Quotient3 R1 Abs1 Rep1" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
204 |
and a: "(R1 ===> R2) f g" "R1 x y" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
205 |
shows "R2 (f x) (g y)" |
55945 | 206 |
using a by (auto elim: rel_funE) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
207 |
|
47308 | 208 |
lemma apply_rspQ3'': |
209 |
assumes "Quotient3 R Abs Rep" |
|
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
210 |
and "(R ===> S) f f" |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
211 |
shows "S (f (Rep x)) (f (Rep x))" |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
212 |
proof - |
47308 | 213 |
from assms(1) have "R (Rep x) (Rep x)" by (rule Quotient3_rep_reflp) |
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
214 |
then show ?thesis using assms(2) by (auto intro: apply_rsp') |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
215 |
qed |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
216 |
|
60758 | 217 |
subsection \<open>lemmas for regularisation of ball and bex\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
218 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
219 |
lemma ball_reg_eqv: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
220 |
fixes P :: "'a \<Rightarrow> bool" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
221 |
assumes a: "equivp R" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
222 |
shows "Ball (Respects R) P = (All P)" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
223 |
using a |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
224 |
unfolding equivp_def |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
225 |
by (auto simp add: in_respects) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
226 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
227 |
lemma bex_reg_eqv: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
228 |
fixes P :: "'a \<Rightarrow> bool" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
229 |
assumes a: "equivp R" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
230 |
shows "Bex (Respects R) P = (Ex P)" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
231 |
using a |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
232 |
unfolding equivp_def |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
233 |
by (auto simp add: in_respects) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
234 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
235 |
lemma ball_reg_right: |
44553
4d39b032a021
avoid intermixing set and predicates; dropped lemmas mem_rsp and mem_prs (now in Quotient_Set.thy)
haftmann
parents:
44413
diff
changeset
|
236 |
assumes a: "\<And>x. x \<in> R \<Longrightarrow> P x \<longrightarrow> Q x" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
237 |
shows "All P \<longrightarrow> Ball R Q" |
44921 | 238 |
using a by fast |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
239 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
240 |
lemma bex_reg_left: |
44553
4d39b032a021
avoid intermixing set and predicates; dropped lemmas mem_rsp and mem_prs (now in Quotient_Set.thy)
haftmann
parents:
44413
diff
changeset
|
241 |
assumes a: "\<And>x. x \<in> R \<Longrightarrow> Q x \<longrightarrow> P x" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
242 |
shows "Bex R Q \<longrightarrow> Ex P" |
44921 | 243 |
using a by fast |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
244 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
245 |
lemma ball_reg_left: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
246 |
assumes a: "equivp R" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
247 |
shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ball (Respects R) Q \<longrightarrow> All P" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
248 |
using a by (metis equivp_reflp in_respects) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
249 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
250 |
lemma bex_reg_right: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
251 |
assumes a: "equivp R" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
252 |
shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ex Q \<longrightarrow> Bex (Respects R) P" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
253 |
using a by (metis equivp_reflp in_respects) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
254 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
255 |
lemma ball_reg_eqv_range: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
256 |
fixes P::"'a \<Rightarrow> bool" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
257 |
and x::"'a" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
258 |
assumes a: "equivp R2" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
259 |
shows "(Ball (Respects (R1 ===> R2)) (\<lambda>f. P (f x)) = All (\<lambda>f. P (f x)))" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
260 |
apply(rule iffI) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
261 |
apply(rule allI) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
262 |
apply(drule_tac x="\<lambda>y. f x" in bspec) |
55945 | 263 |
apply(simp add: in_respects rel_fun_def) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
264 |
apply(rule impI) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
265 |
using a equivp_reflp_symp_transp[of "R2"] |
40814
fa64f6278568
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents:
40615
diff
changeset
|
266 |
apply (auto elim: equivpE reflpE) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
267 |
done |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
268 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
269 |
lemma bex_reg_eqv_range: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
270 |
assumes a: "equivp R2" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
271 |
shows "(Bex (Respects (R1 ===> R2)) (\<lambda>f. P (f x)) = Ex (\<lambda>f. P (f x)))" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
272 |
apply(auto) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
273 |
apply(rule_tac x="\<lambda>y. f x" in bexI) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
274 |
apply(simp) |
55945 | 275 |
apply(simp add: Respects_def in_respects rel_fun_def) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
276 |
apply(rule impI) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
277 |
using a equivp_reflp_symp_transp[of "R2"] |
40814
fa64f6278568
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents:
40615
diff
changeset
|
278 |
apply (auto elim: equivpE reflpE) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
279 |
done |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
280 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
281 |
(* Next four lemmas are unused *) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
282 |
lemma all_reg: |
67091 | 283 |
assumes a: "\<forall>x :: 'a. (P x \<longrightarrow> Q x)" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
284 |
and b: "All P" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
285 |
shows "All Q" |
44921 | 286 |
using a b by fast |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
287 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
288 |
lemma ex_reg: |
67091 | 289 |
assumes a: "\<forall>x :: 'a. (P x \<longrightarrow> Q x)" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
290 |
and b: "Ex P" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
291 |
shows "Ex Q" |
44921 | 292 |
using a b by fast |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
293 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
294 |
lemma ball_reg: |
67091 | 295 |
assumes a: "\<forall>x :: 'a. (x \<in> R \<longrightarrow> P x \<longrightarrow> Q x)" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
296 |
and b: "Ball R P" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
297 |
shows "Ball R Q" |
44921 | 298 |
using a b by fast |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
299 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
300 |
lemma bex_reg: |
67091 | 301 |
assumes a: "\<forall>x :: 'a. (x \<in> R \<longrightarrow> P x \<longrightarrow> Q x)" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
302 |
and b: "Bex R P" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
303 |
shows "Bex R Q" |
44921 | 304 |
using a b by fast |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
305 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
306 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
307 |
lemma ball_all_comm: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
308 |
assumes "\<And>y. (\<forall>x\<in>P. A x y) \<longrightarrow> (\<forall>x. B x y)" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
309 |
shows "(\<forall>x\<in>P. \<forall>y. A x y) \<longrightarrow> (\<forall>x. \<forall>y. B x y)" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
310 |
using assms by auto |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
311 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
312 |
lemma bex_ex_comm: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
313 |
assumes "(\<exists>y. \<exists>x. A x y) \<longrightarrow> (\<exists>y. \<exists>x\<in>P. B x y)" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
314 |
shows "(\<exists>x. \<exists>y. A x y) \<longrightarrow> (\<exists>x\<in>P. \<exists>y. B x y)" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
315 |
using assms by auto |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
316 |
|
60758 | 317 |
subsection \<open>Bounded abstraction\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
318 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
319 |
definition |
40466
c6587375088e
type annotations in specifications; fun_rel_def is no simp rule by default; slightly changed fun_map_def; more on predicates on relation functions; proper HOL equations in definitions
haftmann
parents:
40031
diff
changeset
|
320 |
Babs :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
321 |
where |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
322 |
"x \<in> p \<Longrightarrow> Babs p m x = m x" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
323 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
324 |
lemma babs_rsp: |
47308 | 325 |
assumes q: "Quotient3 R1 Abs1 Rep1" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
326 |
and a: "(R1 ===> R2) f g" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
327 |
shows "(R1 ===> R2) (Babs (Respects R1) f) (Babs (Respects R1) g)" |
55945 | 328 |
apply (auto simp add: Babs_def in_respects rel_fun_def) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
329 |
apply (subgoal_tac "x \<in> Respects R1 \<and> y \<in> Respects R1") |
55945 | 330 |
using a apply (simp add: Babs_def rel_fun_def) |
331 |
apply (simp add: in_respects rel_fun_def) |
|
47308 | 332 |
using Quotient3_rel[OF q] |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
333 |
by metis |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
334 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
335 |
lemma babs_prs: |
47308 | 336 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
337 |
and q2: "Quotient3 R2 Abs2 Rep2" |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
338 |
shows "((Rep1 ---> Abs2) (Babs (Respects R1) ((Abs1 ---> Rep2) f))) = f" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
339 |
apply (rule ext) |
40466
c6587375088e
type annotations in specifications; fun_rel_def is no simp rule by default; slightly changed fun_map_def; more on predicates on relation functions; proper HOL equations in definitions
haftmann
parents:
40031
diff
changeset
|
340 |
apply (simp add:) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
341 |
apply (subgoal_tac "Rep1 x \<in> Respects R1") |
47308 | 342 |
apply (simp add: Babs_def Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2]) |
343 |
apply (simp add: in_respects Quotient3_rel_rep[OF q1]) |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
344 |
done |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
345 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
346 |
lemma babs_simp: |
47308 | 347 |
assumes q: "Quotient3 R1 Abs Rep" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
348 |
shows "((R1 ===> R2) (Babs (Respects R1) f) (Babs (Respects R1) g)) = ((R1 ===> R2) f g)" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
349 |
apply(rule iffI) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
350 |
apply(simp_all only: babs_rsp[OF q]) |
55945 | 351 |
apply(auto simp add: Babs_def rel_fun_def) |
68615 | 352 |
apply(metis Babs_def in_respects Quotient3_rel[OF q]) |
353 |
done |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
354 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
355 |
(* If a user proves that a particular functional relation |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
356 |
is an equivalence this may be useful in regularising *) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
357 |
lemma babs_reg_eqv: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
358 |
shows "equivp R \<Longrightarrow> Babs (Respects R) P = P" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
359 |
by (simp add: fun_eq_iff Babs_def in_respects equivp_reflp) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
360 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
361 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
362 |
(* 3 lemmas needed for proving repabs_inj *) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
363 |
lemma ball_rsp: |
67399 | 364 |
assumes a: "(R ===> (=)) f g" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
365 |
shows "Ball (Respects R) f = Ball (Respects R) g" |
55945 | 366 |
using a by (auto simp add: Ball_def in_respects elim: rel_funE) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
367 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
368 |
lemma bex_rsp: |
67399 | 369 |
assumes a: "(R ===> (=)) f g" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
370 |
shows "(Bex (Respects R) f = Bex (Respects R) g)" |
55945 | 371 |
using a by (auto simp add: Bex_def in_respects elim: rel_funE) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
372 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
373 |
lemma bex1_rsp: |
67399 | 374 |
assumes a: "(R ===> (=)) f g" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
375 |
shows "Ex1 (\<lambda>x. x \<in> Respects R \<and> f x) = Ex1 (\<lambda>x. x \<in> Respects R \<and> g x)" |
55945 | 376 |
using a by (auto elim: rel_funE simp add: Ex1_def in_respects) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
377 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
378 |
(* 2 lemmas needed for cleaning of quantifiers *) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
379 |
lemma all_prs: |
47308 | 380 |
assumes a: "Quotient3 R absf repf" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
381 |
shows "Ball (Respects R) ((absf ---> id) f) = All f" |
47308 | 382 |
using a unfolding Quotient3_def Ball_def in_respects id_apply comp_def map_fun_def |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
383 |
by metis |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
384 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
385 |
lemma ex_prs: |
47308 | 386 |
assumes a: "Quotient3 R absf repf" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
387 |
shows "Bex (Respects R) ((absf ---> id) f) = Ex f" |
47308 | 388 |
using a unfolding Quotient3_def Bex_def in_respects id_apply comp_def map_fun_def |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
389 |
by metis |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
390 |
|
61799 | 391 |
subsection \<open>\<open>Bex1_rel\<close> quantifier\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
392 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
393 |
definition |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
394 |
Bex1_rel :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
395 |
where |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
396 |
"Bex1_rel R P \<longleftrightarrow> (\<exists>x \<in> Respects R. P x) \<and> (\<forall>x \<in> Respects R. \<forall>y \<in> Respects R. ((P x \<and> P y) \<longrightarrow> (R x y)))" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
397 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
398 |
lemma bex1_rel_aux: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
399 |
"\<lbrakk>\<forall>xa ya. R xa ya \<longrightarrow> x xa = y ya; Bex1_rel R x\<rbrakk> \<Longrightarrow> Bex1_rel R y" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
400 |
unfolding Bex1_rel_def |
68615 | 401 |
by (metis in_respects) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
402 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
403 |
lemma bex1_rel_aux2: |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
404 |
"\<lbrakk>\<forall>xa ya. R xa ya \<longrightarrow> x xa = y ya; Bex1_rel R y\<rbrakk> \<Longrightarrow> Bex1_rel R x" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
405 |
unfolding Bex1_rel_def |
68615 | 406 |
by (metis in_respects) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
407 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
408 |
lemma bex1_rel_rsp: |
47308 | 409 |
assumes a: "Quotient3 R absf repf" |
67399 | 410 |
shows "((R ===> (=)) ===> (=)) (Bex1_rel R) (Bex1_rel R)" |
68615 | 411 |
unfolding rel_fun_def by (metis bex1_rel_aux bex1_rel_aux2) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
412 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
413 |
lemma ex1_prs: |
68616 | 414 |
assumes "Quotient3 R absf repf" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
415 |
shows "((absf ---> id) ---> id) (Bex1_rel R) f = Ex1 f" |
68616 | 416 |
apply (auto simp: Bex1_rel_def Respects_def) |
417 |
apply (metis Quotient3_def assms) |
|
418 |
apply (metis (full_types) Quotient3_def assms) |
|
419 |
by (meson Quotient3_rel assms) |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
420 |
|
38702
72fd257f4343
Quotient Package / lemma for regularization of bex1_rel for equivalence relations
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
38317
diff
changeset
|
421 |
lemma bex1_bexeq_reg: |
72fd257f4343
Quotient Package / lemma for regularization of bex1_rel for equivalence relations
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
38317
diff
changeset
|
422 |
shows "(\<exists>!x\<in>Respects R. P x) \<longrightarrow> (Bex1_rel R (\<lambda>x. P x))" |
56073
29e308b56d23
enhanced simplifier solver for preconditions of rewrite rule, can now deal with conjunctions
nipkow
parents:
55945
diff
changeset
|
423 |
by (auto simp add: Ex1_def Bex1_rel_def Bex_def Ball_def in_respects) |
68616 | 424 |
|
38702
72fd257f4343
Quotient Package / lemma for regularization of bex1_rel for equivalence relations
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
38317
diff
changeset
|
425 |
lemma bex1_bexeq_reg_eqv: |
72fd257f4343
Quotient Package / lemma for regularization of bex1_rel for equivalence relations
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
38317
diff
changeset
|
426 |
assumes a: "equivp R" |
72fd257f4343
Quotient Package / lemma for regularization of bex1_rel for equivalence relations
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
38317
diff
changeset
|
427 |
shows "(\<exists>!x. P x) \<longrightarrow> Bex1_rel R P" |
72fd257f4343
Quotient Package / lemma for regularization of bex1_rel for equivalence relations
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
38317
diff
changeset
|
428 |
using equivp_reflp[OF a] |
68616 | 429 |
by (metis (full_types) Bex1_rel_def in_respects) |
38702
72fd257f4343
Quotient Package / lemma for regularization of bex1_rel for equivalence relations
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
38317
diff
changeset
|
430 |
|
60758 | 431 |
subsection \<open>Various respects and preserve lemmas\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
432 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
433 |
lemma quot_rel_rsp: |
47308 | 434 |
assumes a: "Quotient3 R Abs Rep" |
67399 | 435 |
shows "(R ===> R ===> (=)) R R" |
55945 | 436 |
apply(rule rel_funI)+ |
68616 | 437 |
by (meson assms equals_rsp) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
438 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
439 |
lemma o_prs: |
47308 | 440 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
441 |
and q2: "Quotient3 R2 Abs2 Rep2" |
|
442 |
and q3: "Quotient3 R3 Abs3 Rep3" |
|
67399 | 443 |
shows "((Abs2 ---> Rep3) ---> (Abs1 ---> Rep2) ---> (Rep1 ---> Abs3)) (\<circ>) = (\<circ>)" |
444 |
and "(id ---> (Abs1 ---> id) ---> Rep1 ---> id) (\<circ>) = (\<circ>)" |
|
47308 | 445 |
using Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2] Quotient3_abs_rep[OF q3] |
40466
c6587375088e
type annotations in specifications; fun_rel_def is no simp rule by default; slightly changed fun_map_def; more on predicates on relation functions; proper HOL equations in definitions
haftmann
parents:
40031
diff
changeset
|
446 |
by (simp_all add: fun_eq_iff) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
447 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
448 |
lemma o_rsp: |
67399 | 449 |
"((R2 ===> R3) ===> (R1 ===> R2) ===> (R1 ===> R3)) (\<circ>) (\<circ>)" |
450 |
"((=) ===> (R1 ===> (=)) ===> R1 ===> (=)) (\<circ>) (\<circ>)" |
|
55945 | 451 |
by (force elim: rel_funE)+ |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
452 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
453 |
lemma cond_prs: |
47308 | 454 |
assumes a: "Quotient3 R absf repf" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
455 |
shows "absf (if a then repf b else repf c) = (if a then b else c)" |
47308 | 456 |
using a unfolding Quotient3_def by auto |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
457 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
458 |
lemma if_prs: |
47308 | 459 |
assumes q: "Quotient3 R Abs Rep" |
36123
7f877bbad5b2
add If respectfullness and preservation to Quotient package database
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36116
diff
changeset
|
460 |
shows "(id ---> Rep ---> Rep ---> Abs) If = If" |
47308 | 461 |
using Quotient3_abs_rep[OF q] |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
462 |
by (auto simp add: fun_eq_iff) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
463 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
464 |
lemma if_rsp: |
47308 | 465 |
assumes q: "Quotient3 R Abs Rep" |
67399 | 466 |
shows "((=) ===> R ===> R ===> R) If If" |
44921 | 467 |
by force |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
468 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
469 |
lemma let_prs: |
47308 | 470 |
assumes q1: "Quotient3 R1 Abs1 Rep1" |
471 |
and q2: "Quotient3 R2 Abs2 Rep2" |
|
37049
ca1c293e521e
Let rsp and prs in fun_rel/fun_map format
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36276
diff
changeset
|
472 |
shows "(Rep2 ---> (Abs2 ---> Rep1) ---> Abs1) Let = Let" |
47308 | 473 |
using Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2] |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
474 |
by (auto simp add: fun_eq_iff) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
475 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
476 |
lemma let_rsp: |
37049
ca1c293e521e
Let rsp and prs in fun_rel/fun_map format
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
36276
diff
changeset
|
477 |
shows "(R1 ===> (R1 ===> R2) ===> R2) Let Let" |
55945 | 478 |
by (force elim: rel_funE) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
479 |
|
39669
9e3b035841e4
quotient package: respectfulness and preservation of identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
39302
diff
changeset
|
480 |
lemma id_rsp: |
9e3b035841e4
quotient package: respectfulness and preservation of identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
39302
diff
changeset
|
481 |
shows "(R ===> R) id id" |
44921 | 482 |
by auto |
39669
9e3b035841e4
quotient package: respectfulness and preservation of identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
39302
diff
changeset
|
483 |
|
9e3b035841e4
quotient package: respectfulness and preservation of identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
39302
diff
changeset
|
484 |
lemma id_prs: |
47308 | 485 |
assumes a: "Quotient3 R Abs Rep" |
39669
9e3b035841e4
quotient package: respectfulness and preservation of identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
39302
diff
changeset
|
486 |
shows "(Rep ---> Abs) id = id" |
47308 | 487 |
by (simp add: fun_eq_iff Quotient3_abs_rep [OF a]) |
39669
9e3b035841e4
quotient package: respectfulness and preservation of identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
39302
diff
changeset
|
488 |
|
53011
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
kuncar
parents:
51112
diff
changeset
|
489 |
end |
39669
9e3b035841e4
quotient package: respectfulness and preservation of identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
39302
diff
changeset
|
490 |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
491 |
locale quot_type = |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
492 |
fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
493 |
and Abs :: "'a set \<Rightarrow> 'b" |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
494 |
and Rep :: "'b \<Rightarrow> 'a set" |
37493
2377d246a631
Quotient package now uses Partial Equivalence instead place of equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
37049
diff
changeset
|
495 |
assumes equivp: "part_equivp R" |
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
496 |
and rep_prop: "\<And>y. \<exists>x. R x x \<and> Rep y = Collect (R x)" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
497 |
and rep_inverse: "\<And>x. Abs (Rep x) = x" |
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
498 |
and abs_inverse: "\<And>c. (\<exists>x. ((R x x) \<and> (c = Collect (R x)))) \<Longrightarrow> (Rep (Abs c)) = c" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
499 |
and rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
500 |
begin |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
501 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
502 |
definition |
40466
c6587375088e
type annotations in specifications; fun_rel_def is no simp rule by default; slightly changed fun_map_def; more on predicates on relation functions; proper HOL equations in definitions
haftmann
parents:
40031
diff
changeset
|
503 |
abs :: "'a \<Rightarrow> 'b" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
504 |
where |
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
505 |
"abs x = Abs (Collect (R x))" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
506 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
507 |
definition |
40466
c6587375088e
type annotations in specifications; fun_rel_def is no simp rule by default; slightly changed fun_map_def; more on predicates on relation functions; proper HOL equations in definitions
haftmann
parents:
40031
diff
changeset
|
508 |
rep :: "'b \<Rightarrow> 'a" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
509 |
where |
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
510 |
"rep a = (SOME x. x \<in> Rep a)" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
511 |
|
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
512 |
lemma some_collect: |
37493
2377d246a631
Quotient package now uses Partial Equivalence instead place of equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
37049
diff
changeset
|
513 |
assumes "R r r" |
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
514 |
shows "R (SOME x. x \<in> Collect (R r)) = R r" |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
515 |
apply simp |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
516 |
by (metis assms exE_some equivp[simplified part_equivp_def]) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
517 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
518 |
lemma Quotient: |
47308 | 519 |
shows "Quotient3 R abs rep" |
520 |
unfolding Quotient3_def abs_def rep_def |
|
37493
2377d246a631
Quotient package now uses Partial Equivalence instead place of equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
37049
diff
changeset
|
521 |
proof (intro conjI allI) |
2377d246a631
Quotient package now uses Partial Equivalence instead place of equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
37049
diff
changeset
|
522 |
fix a r s |
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
523 |
show x: "R (SOME x. x \<in> Rep a) (SOME x. x \<in> Rep a)" proof - |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
524 |
obtain x where r: "R x x" and rep: "Rep a = Collect (R x)" using rep_prop[of a] by auto |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
525 |
have "R (SOME x. x \<in> Rep a) x" using r rep some_collect by metis |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
526 |
then have "R x (SOME x. x \<in> Rep a)" using part_equivp_symp[OF equivp] by fast |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
527 |
then show "R (SOME x. x \<in> Rep a) (SOME x. x \<in> Rep a)" |
60758 | 528 |
using part_equivp_transp[OF equivp] by (metis \<open>R (SOME x. x \<in> Rep a) x\<close>) |
37493
2377d246a631
Quotient package now uses Partial Equivalence instead place of equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
37049
diff
changeset
|
529 |
qed |
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
530 |
have "Collect (R (SOME x. x \<in> Rep a)) = (Rep a)" by (metis some_collect rep_prop) |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
531 |
then show "Abs (Collect (R (SOME x. x \<in> Rep a))) = a" using rep_inverse by auto |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
532 |
have "R r r \<Longrightarrow> R s s \<Longrightarrow> Abs (Collect (R r)) = Abs (Collect (R s)) \<longleftrightarrow> R r = R s" |
44242 | 533 |
proof - |
534 |
assume "R r r" and "R s s" |
|
535 |
then have "Abs (Collect (R r)) = Abs (Collect (R s)) \<longleftrightarrow> Collect (R r) = Collect (R s)" |
|
536 |
by (metis abs_inverse) |
|
537 |
also have "Collect (R r) = Collect (R s) \<longleftrightarrow> (\<lambda>A x. x \<in> A) (Collect (R r)) = (\<lambda>A x. x \<in> A) (Collect (R s))" |
|
538 |
by rule simp_all |
|
539 |
finally show "Abs (Collect (R r)) = Abs (Collect (R s)) \<longleftrightarrow> R r = R s" by simp |
|
540 |
qed |
|
44204
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
541 |
then show "R r s \<longleftrightarrow> R r r \<and> R s s \<and> (Abs (Collect (R r)) = Abs (Collect (R s)))" |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
542 |
using equivp[simplified part_equivp_def] by metis |
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
42814
diff
changeset
|
543 |
qed |
44242 | 544 |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
545 |
end |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
546 |
|
60758 | 547 |
subsection \<open>Quotient composition\<close> |
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
548 |
|
68616 | 549 |
|
47308 | 550 |
lemma OOO_quotient3: |
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
551 |
fixes R1 :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
552 |
fixes Abs1 :: "'a \<Rightarrow> 'b" and Rep1 :: "'b \<Rightarrow> 'a" |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
553 |
fixes Abs2 :: "'b \<Rightarrow> 'c" and Rep2 :: "'c \<Rightarrow> 'b" |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
554 |
fixes R2' :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
555 |
fixes R2 :: "'b \<Rightarrow> 'b \<Rightarrow> bool" |
47308 | 556 |
assumes R1: "Quotient3 R1 Abs1 Rep1" |
557 |
assumes R2: "Quotient3 R2 Abs2 Rep2" |
|
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
558 |
assumes Abs1: "\<And>x y. R2' x y \<Longrightarrow> R1 x x \<Longrightarrow> R1 y y \<Longrightarrow> R2 (Abs1 x) (Abs1 y)" |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
559 |
assumes Rep1: "\<And>x y. R2 x y \<Longrightarrow> R2' (Rep1 x) (Rep1 y)" |
47308 | 560 |
shows "Quotient3 (R1 OO R2' OO R1) (Abs2 \<circ> Abs1) (Rep1 \<circ> Rep2)" |
68616 | 561 |
proof - |
562 |
have *: "(R1 OOO R2') r r \<and> (R1 OOO R2') s s \<and> (Abs2 \<circ> Abs1) r = (Abs2 \<circ> Abs1) s |
|
563 |
\<longleftrightarrow> (R1 OOO R2') r s" for r s |
|
564 |
apply safe |
|
565 |
subgoal for a b c d |
|
566 |
apply simp |
|
567 |
apply (rule_tac b="Rep1 (Abs1 r)" in relcomppI) |
|
568 |
using Quotient3_refl1 R1 rep_abs_rsp apply fastforce |
|
569 |
apply (rule_tac b="Rep1 (Abs1 s)" in relcomppI) |
|
570 |
apply (metis (full_types) Rep1 Abs1 Quotient3_rel R2 Quotient3_refl1 [OF R1] Quotient3_refl2 [OF R1] Quotient3_rel_abs [OF R1]) |
|
571 |
by (metis Quotient3_rel R1 rep_abs_rsp_left) |
|
572 |
subgoal for x y |
|
573 |
apply (drule Abs1) |
|
574 |
apply (erule Quotient3_refl2 [OF R1]) |
|
575 |
apply (erule Quotient3_refl1 [OF R1]) |
|
576 |
apply (drule Quotient3_refl1 [OF R2], drule Rep1) |
|
577 |
by (metis (full_types) Quotient3_def R1 relcompp.relcompI) |
|
578 |
subgoal for x y |
|
579 |
apply (drule Abs1) |
|
580 |
apply (erule Quotient3_refl2 [OF R1]) |
|
581 |
apply (erule Quotient3_refl1 [OF R1]) |
|
582 |
apply (drule Quotient3_refl2 [OF R2], drule Rep1) |
|
583 |
by (metis (full_types) Quotient3_def R1 relcompp.relcompI) |
|
584 |
subgoal for x y |
|
585 |
by simp (metis (full_types) Abs1 Quotient3_rel R1 R2) |
|
586 |
done |
|
587 |
show ?thesis |
|
588 |
apply (rule Quotient3I) |
|
589 |
using * apply (simp_all add: o_def Quotient3_abs_rep [OF R2] Quotient3_abs_rep [OF R1]) |
|
590 |
apply (metis Quotient3_rep_reflp R1 R2 Rep1 relcompp.relcompI) |
|
591 |
done |
|
592 |
qed |
|
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
593 |
|
47308 | 594 |
lemma OOO_eq_quotient3: |
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
595 |
fixes R1 :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
596 |
fixes Abs1 :: "'a \<Rightarrow> 'b" and Rep1 :: "'b \<Rightarrow> 'a" |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
597 |
fixes Abs2 :: "'b \<Rightarrow> 'c" and Rep2 :: "'c \<Rightarrow> 'b" |
47308 | 598 |
assumes R1: "Quotient3 R1 Abs1 Rep1" |
67399 | 599 |
assumes R2: "Quotient3 (=) Abs2 Rep2" |
600 |
shows "Quotient3 (R1 OOO (=)) (Abs2 \<circ> Abs1) (Rep1 \<circ> Rep2)" |
|
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
601 |
using assms |
47308 | 602 |
by (rule OOO_quotient3) auto |
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
603 |
|
60758 | 604 |
subsection \<open>Quotient3 to Quotient\<close> |
47362
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
605 |
|
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
606 |
lemma Quotient3_to_Quotient: |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
607 |
assumes "Quotient3 R Abs Rep" |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
608 |
and "T \<equiv> \<lambda>x y. R x x \<and> Abs x = y" |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
609 |
shows "Quotient R Abs Rep T" |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
610 |
using assms unfolding Quotient3_def by (intro QuotientI) blast+ |
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
611 |
|
47362
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
612 |
lemma Quotient3_to_Quotient_equivp: |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
613 |
assumes q: "Quotient3 R Abs Rep" |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
614 |
and T_def: "T \<equiv> \<lambda>x y. Abs x = y" |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
615 |
and eR: "equivp R" |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
616 |
shows "Quotient R Abs Rep T" |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
617 |
proof (intro QuotientI) |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
618 |
fix a |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
619 |
show "Abs (Rep a) = a" using q by(rule Quotient3_abs_rep) |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
620 |
next |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
621 |
fix a |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
622 |
show "R (Rep a) (Rep a)" using q by(rule Quotient3_rep_reflp) |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
623 |
next |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
624 |
fix r s |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
625 |
show "R r s = (R r r \<and> R s s \<and> Abs r = Abs s)" using q by(rule Quotient3_rel[symmetric]) |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
626 |
next |
b1f099bdfbba
connect the Quotient package to the Lifting package
kuncar
parents:
47361
diff
changeset
|
627 |
show "T = (\<lambda>x y. R x x \<and> Abs x = y)" using T_def equivp_reflp[OF eR] by simp |
47096
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
628 |
qed |
3ea48c19673e
generation of a code certificate from a respectfulness theorem for constants lifted by the quotient_definition command & setup_lifting command: setups Quotient infrastructure from a typedef theorem
kuncar
parents:
47094
diff
changeset
|
629 |
|
60758 | 630 |
subsection \<open>ML setup\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
631 |
|
60758 | 632 |
text \<open>Auxiliary data for the quotient package\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
633 |
|
57960 | 634 |
named_theorems quot_equiv "equivalence relation theorems" |
59028 | 635 |
and quot_respect "respectfulness theorems" |
636 |
and quot_preserve "preservation theorems" |
|
637 |
and id_simps "identity simp rules for maps" |
|
638 |
and quot_thm "quotient theorems" |
|
69605 | 639 |
ML_file \<open>Tools/Quotient/quotient_info.ML\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
640 |
|
55945 | 641 |
declare [[mapQ3 "fun" = (rel_fun, fun_quotient3)]] |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
642 |
|
47308 | 643 |
lemmas [quot_thm] = fun_quotient3 |
44553
4d39b032a021
avoid intermixing set and predicates; dropped lemmas mem_rsp and mem_prs (now in Quotient_Set.thy)
haftmann
parents:
44413
diff
changeset
|
644 |
lemmas [quot_respect] = quot_rel_rsp if_rsp o_rsp let_rsp id_rsp |
4d39b032a021
avoid intermixing set and predicates; dropped lemmas mem_rsp and mem_prs (now in Quotient_Set.thy)
haftmann
parents:
44413
diff
changeset
|
645 |
lemmas [quot_preserve] = if_prs o_prs let_prs id_prs |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
646 |
lemmas [quot_equiv] = identity_equivp |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
647 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
648 |
|
60758 | 649 |
text \<open>Lemmas about simplifying id's.\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
650 |
lemmas [id_simps] = |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
651 |
id_def[symmetric] |
40602 | 652 |
map_fun_id |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
653 |
id_apply |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
654 |
id_o |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
655 |
o_id |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
656 |
eq_comp_r |
44413
80d460bc6fa8
Quotient Package: some infrastructure for lifting inside sets
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
44242
diff
changeset
|
657 |
vimage_id |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
658 |
|
60758 | 659 |
text \<open>Translation functions for the lifting process.\<close> |
69605 | 660 |
ML_file \<open>Tools/Quotient/quotient_term.ML\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
661 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
662 |
|
60758 | 663 |
text \<open>Definitions of the quotient types.\<close> |
69605 | 664 |
ML_file \<open>Tools/Quotient/quotient_type.ML\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
665 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
666 |
|
60758 | 667 |
text \<open>Definitions for quotient constants.\<close> |
69605 | 668 |
ML_file \<open>Tools/Quotient/quotient_def.ML\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
669 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
670 |
|
60758 | 671 |
text \<open> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
672 |
An auxiliary constant for recording some information |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
673 |
about the lifted theorem in a tactic. |
60758 | 674 |
\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
675 |
definition |
40466
c6587375088e
type annotations in specifications; fun_rel_def is no simp rule by default; slightly changed fun_map_def; more on predicates on relation functions; proper HOL equations in definitions
haftmann
parents:
40031
diff
changeset
|
676 |
Quot_True :: "'a \<Rightarrow> bool" |
c6587375088e
type annotations in specifications; fun_rel_def is no simp rule by default; slightly changed fun_map_def; more on predicates on relation functions; proper HOL equations in definitions
haftmann
parents:
40031
diff
changeset
|
677 |
where |
c6587375088e
type annotations in specifications; fun_rel_def is no simp rule by default; slightly changed fun_map_def; more on predicates on relation functions; proper HOL equations in definitions
haftmann
parents:
40031
diff
changeset
|
678 |
"Quot_True x \<longleftrightarrow> True" |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
679 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
680 |
lemma |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
681 |
shows QT_all: "Quot_True (All P) \<Longrightarrow> Quot_True P" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
682 |
and QT_ex: "Quot_True (Ex P) \<Longrightarrow> Quot_True P" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
683 |
and QT_ex1: "Quot_True (Ex1 P) \<Longrightarrow> Quot_True P" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
684 |
and QT_lam: "Quot_True (\<lambda>x. P x) \<Longrightarrow> (\<And>x. Quot_True (P x))" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
685 |
and QT_ext: "(\<And>x. Quot_True (a x) \<Longrightarrow> f x = g x) \<Longrightarrow> (Quot_True a \<Longrightarrow> f = g)" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
686 |
by (simp_all add: Quot_True_def ext) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
687 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
688 |
lemma QT_imp: "Quot_True a \<equiv> Quot_True b" |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
689 |
by (simp add: Quot_True_def) |
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
690 |
|
63343 | 691 |
context includes lifting_syntax |
53011
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
kuncar
parents:
51112
diff
changeset
|
692 |
begin |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
693 |
|
60758 | 694 |
text \<open>Tactics for proving the lifted theorems\<close> |
69605 | 695 |
ML_file \<open>Tools/Quotient/quotient_tacs.ML\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
696 |
|
53011
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
kuncar
parents:
51112
diff
changeset
|
697 |
end |
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
kuncar
parents:
51112
diff
changeset
|
698 |
|
60758 | 699 |
subsection \<open>Methods / Interface\<close> |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
700 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
701 |
method_setup lifting = |
60758 | 702 |
\<open>Attrib.thms >> (fn thms => fn ctxt => |
703 |
SIMPLE_METHOD' (Quotient_Tacs.lift_tac ctxt [] thms))\<close> |
|
704 |
\<open>lift theorems to quotient types\<close> |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
705 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
706 |
method_setup lifting_setup = |
60758 | 707 |
\<open>Attrib.thm >> (fn thm => fn ctxt => |
708 |
SIMPLE_METHOD' (Quotient_Tacs.lift_procedure_tac ctxt [] thm))\<close> |
|
709 |
\<open>set up the three goals for the quotient lifting procedure\<close> |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
710 |
|
37593
2505feaf2d70
separated the lifting and descending procedures in the quotient package
Christian Urban <urbanc@in.tum.de>
parents:
37564
diff
changeset
|
711 |
method_setup descending = |
60758 | 712 |
\<open>Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.descend_tac ctxt []))\<close> |
713 |
\<open>decend theorems to the raw level\<close> |
|
37593
2505feaf2d70
separated the lifting and descending procedures in the quotient package
Christian Urban <urbanc@in.tum.de>
parents:
37564
diff
changeset
|
714 |
|
2505feaf2d70
separated the lifting and descending procedures in the quotient package
Christian Urban <urbanc@in.tum.de>
parents:
37564
diff
changeset
|
715 |
method_setup descending_setup = |
60758 | 716 |
\<open>Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.descend_procedure_tac ctxt []))\<close> |
717 |
\<open>set up the three goals for the decending theorems\<close> |
|
37593
2505feaf2d70
separated the lifting and descending procedures in the quotient package
Christian Urban <urbanc@in.tum.de>
parents:
37564
diff
changeset
|
718 |
|
45782
f82020ca3248
added a specific tactic and method that deal with partial equivalence relations
Christian Urban <urbanc@in.tum.de>
parents:
45680
diff
changeset
|
719 |
method_setup partiality_descending = |
60758 | 720 |
\<open>Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.partiality_descend_tac ctxt []))\<close> |
721 |
\<open>decend theorems to the raw level\<close> |
|
45782
f82020ca3248
added a specific tactic and method that deal with partial equivalence relations
Christian Urban <urbanc@in.tum.de>
parents:
45680
diff
changeset
|
722 |
|
f82020ca3248
added a specific tactic and method that deal with partial equivalence relations
Christian Urban <urbanc@in.tum.de>
parents:
45680
diff
changeset
|
723 |
method_setup partiality_descending_setup = |
60758 | 724 |
\<open>Scan.succeed (fn ctxt => |
725 |
SIMPLE_METHOD' (Quotient_Tacs.partiality_descend_procedure_tac ctxt []))\<close> |
|
726 |
\<open>set up the three goals for the decending theorems\<close> |
|
45782
f82020ca3248
added a specific tactic and method that deal with partial equivalence relations
Christian Urban <urbanc@in.tum.de>
parents:
45680
diff
changeset
|
727 |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
728 |
method_setup regularize = |
60758 | 729 |
\<open>Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.regularize_tac ctxt))\<close> |
730 |
\<open>prove the regularization goals from the quotient lifting procedure\<close> |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
731 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
732 |
method_setup injection = |
60758 | 733 |
\<open>Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.all_injection_tac ctxt))\<close> |
734 |
\<open>prove the rep/abs injection goals from the quotient lifting procedure\<close> |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
735 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
736 |
method_setup cleaning = |
60758 | 737 |
\<open>Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.clean_tac ctxt))\<close> |
738 |
\<open>prove the cleaning goals from the quotient lifting procedure\<close> |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
739 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
740 |
attribute_setup quot_lifted = |
60758 | 741 |
\<open>Scan.succeed Quotient_Tacs.lifted_attrib\<close> |
742 |
\<open>lift theorems to quotient types\<close> |
|
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
743 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
744 |
no_notation |
53011
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
kuncar
parents:
51112
diff
changeset
|
745 |
rel_conj (infixr "OOO" 75) |
35222
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
746 |
|
4f1fba00f66d
Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
747 |
end |
47488
be6dd389639d
centralized enriched_type declaration, thanks to in-situ available Isar commands
haftmann
parents:
47436
diff
changeset
|
748 |