0
+ − 1
theory QuotScript
530
+ − 2
imports Plain ATP_Linkup
0
+ − 3
begin
+ − 4
543
+ − 5
definition
+ − 6
"equivp E \<equiv> \<forall>x y. E x y = (E x = E y)"
0
+ − 7
+ − 8
definition
528
+ − 9
"reflp E \<equiv> \<forall>x. E x x"
0
+ − 10
543
+ − 11
definition
528
+ − 12
"symp E \<equiv> \<forall>x y. E x y \<longrightarrow> E y x"
0
+ − 13
+ − 14
definition
528
+ − 15
"transp E \<equiv> \<forall>x y z. E x y \<and> E y z \<longrightarrow> E x z"
0
+ − 16
528
+ − 17
lemma equivp_reflp_symp_transp:
+ − 18
shows "equivp E = (reflp E \<and> symp E \<and> transp E)"
543
+ − 19
unfolding equivp_def reflp_def symp_def transp_def expand_fun_eq
+ − 20
by (blast)
0
+ − 21
528
+ − 22
lemma equivp_refl:
+ − 23
shows "equivp R \<Longrightarrow> (\<And>x. R x x)"
+ − 24
by (simp add: equivp_reflp_symp_transp reflp_def)
+ − 25
+ − 26
lemma equivp_reflp:
+ − 27
shows "equivp E \<Longrightarrow> (\<And>x. E x x)"
+ − 28
by (simp add: equivp_reflp_symp_transp reflp_def)
217
+ − 29
0
+ − 30
definition
541
+ − 31
"part_equivp E \<equiv> (\<exists>x. E x x) \<and> (\<forall>x y. E x y = (E x x \<and> E y y \<and> (E x = E y)))"
0
+ − 32
541
+ − 33
lemma equivp_IMP_part_equivp:
528
+ − 34
assumes a: "equivp E"
541
+ − 35
shows "part_equivp E"
543
+ − 36
using a unfolding equivp_def part_equivp_def
+ − 37
by auto
0
+ − 38
+ − 39
definition
543
+ − 40
"Quotient E Abs Rep \<equiv> (\<forall>a. Abs (Rep a) = a) \<and>
+ − 41
(\<forall>a. E (Rep a) (Rep a)) \<and>
0
+ − 42
(\<forall>r s. E r s = (E r r \<and> E s s \<and> (Abs r = Abs s)))"
+ − 43
540
c0b13fb70d6d
More code cleaning and renaming: moved rsp and prs lemmas from Int to QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 44
lemma Quotient_abs_rep:
528
+ − 45
assumes a: "Quotient E Abs Rep"
546
+ − 46
shows "Abs (Rep a) \<equiv> a"
543
+ − 47
using a unfolding Quotient_def
+ − 48
by simp
0
+ − 49
541
+ − 50
lemma Quotient_rep_reflp:
528
+ − 51
assumes a: "Quotient E Abs Rep"
541
+ − 52
shows "E (Rep a) (Rep a)"
543
+ − 53
using a unfolding Quotient_def
+ − 54
by blast
0
+ − 55
539
+ − 56
lemma Quotient_rel:
528
+ − 57
assumes a: "Quotient E Abs Rep"
0
+ − 58
shows " E r s = (E r r \<and> E s s \<and> (Abs r = Abs s))"
543
+ − 59
using a unfolding Quotient_def
+ − 60
by blast
0
+ − 61
541
+ − 62
lemma Quotient_rel_rep:
528
+ − 63
assumes a: "Quotient R Abs Rep"
541
+ − 64
shows "R (Rep a) (Rep b) \<equiv> (a = b)"
543
+ − 65
apply (rule eq_reflection)
+ − 66
using a unfolding Quotient_def
+ − 67
by metis
0
+ − 68
540
c0b13fb70d6d
More code cleaning and renaming: moved rsp and prs lemmas from Int to QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 69
lemma Quotient_rep_abs:
528
+ − 70
assumes a: "Quotient R Abs Rep"
459
+ − 71
shows "R r r \<Longrightarrow> R (Rep (Abs r)) r"
543
+ − 72
using a unfolding Quotient_def
+ − 73
by blast
0
+ − 74
542
+ − 75
lemma identity_equivp:
528
+ − 76
shows "equivp (op =)"
543
+ − 77
unfolding equivp_def
+ − 78
by auto
0
+ − 79
542
+ − 80
lemma identity_quotient:
528
+ − 81
shows "Quotient (op =) id id"
543
+ − 82
unfolding Quotient_def id_def
+ − 83
by blast
0
+ − 84
528
+ − 85
lemma Quotient_symp:
+ − 86
assumes a: "Quotient E Abs Rep"
+ − 87
shows "symp E"
543
+ − 88
using a unfolding Quotient_def symp_def
+ − 89
by metis
0
+ − 90
528
+ − 91
lemma Quotient_transp:
+ − 92
assumes a: "Quotient E Abs Rep"
+ − 93
shows "transp E"
543
+ − 94
using a unfolding Quotient_def transp_def
+ − 95
by metis
0
+ − 96
+ − 97
fun
93
+ − 98
prod_rel
+ − 99
where
+ − 100
"prod_rel r1 r2 = (\<lambda>(a,b) (c,d). r1 a c \<and> r2 b d)"
+ − 101
+ − 102
fun
112
+ − 103
fun_map
0
+ − 104
where
+ − 105
"fun_map f g h x = g (h (f x))"
+ − 106
+ − 107
abbreviation
112
+ − 108
fun_map_syn (infixr "--->" 55)
0
+ − 109
where
112
+ − 110
"f ---> g \<equiv> fun_map f g"
0
+ − 111
537
+ − 112
lemma fun_map_id:
126
+ − 113
shows "(id ---> id) = id"
543
+ − 114
by (simp add: expand_fun_eq id_def)
0
+ − 115
+ − 116
fun
536
+ − 117
fun_rel
0
+ − 118
where
536
+ − 119
"fun_rel E1 E2 f g = (\<forall>x y. E1 x y \<longrightarrow> E2 (f x) (g y))"
0
+ − 120
+ − 121
abbreviation
536
+ − 122
fun_rel_syn (infixr "===>" 55)
0
+ − 123
where
536
+ − 124
"E1 ===> E2 \<equiv> fun_rel E1 E2"
0
+ − 125
536
+ − 126
lemma fun_rel_eq:
511
+ − 127
"(op =) ===> (op =) \<equiv> (op =)"
515
+ − 128
by (rule eq_reflection) (simp add: expand_fun_eq)
0
+ − 129
537
+ − 130
lemma fun_quotient:
528
+ − 131
assumes q1: "Quotient R1 abs1 rep1"
+ − 132
and q2: "Quotient R2 abs2 rep2"
+ − 133
shows "Quotient (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2)"
0
+ − 134
proof -
+ − 135
have "\<forall>a. (rep1 ---> abs2) ((abs1 ---> rep2) a) = a"
+ − 136
apply(simp add: expand_fun_eq)
+ − 137
using q1 q2
528
+ − 138
apply(simp add: Quotient_def)
0
+ − 139
done
+ − 140
moreover
+ − 141
have "\<forall>a. (R1 ===> R2) ((abs1 ---> rep2) a) ((abs1 ---> rep2) a)"
+ − 142
apply(auto)
528
+ − 143
using q1 q2 unfolding Quotient_def
0
+ − 144
apply(metis)
+ − 145
done
+ − 146
moreover
+ − 147
have "\<forall>r s. (R1 ===> R2) r s = ((R1 ===> R2) r r \<and> (R1 ===> R2) s s \<and>
+ − 148
(rep1 ---> abs2) r = (rep1 ---> abs2) s)"
+ − 149
apply(auto simp add: expand_fun_eq)
528
+ − 150
using q1 q2 unfolding Quotient_def
0
+ − 151
apply(metis)
528
+ − 152
using q1 q2 unfolding Quotient_def
0
+ − 153
apply(metis)
528
+ − 154
using q1 q2 unfolding Quotient_def
0
+ − 155
apply(metis)
528
+ − 156
using q1 q2 unfolding Quotient_def
0
+ − 157
apply(metis)
+ − 158
done
+ − 159
ultimately
528
+ − 160
show "Quotient (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2)"
+ − 161
unfolding Quotient_def by blast
0
+ − 162
qed
+ − 163
+ − 164
definition
+ − 165
Respects
+ − 166
where
+ − 167
"Respects R x \<equiv> (R x x)"
+ − 168
542
+ − 169
lemma in_respects:
0
+ − 170
shows "(x \<in> Respects R) = R x x"
543
+ − 171
unfolding mem_def Respects_def by simp
0
+ − 172
527
+ − 173
lemma equals_rsp:
528
+ − 174
assumes q: "Quotient R Abs Rep"
519
ebfd747b47ab
Change equiv_trans2 to EQUALS_RSP, since we can prove it for any quotient type, not only for eqv relations.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 175
and a: "R xa xb" "R ya yb"
ebfd747b47ab
Change equiv_trans2 to EQUALS_RSP, since we can prove it for any quotient type, not only for eqv relations.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 176
shows "R xa ya = R xb yb"
543
+ − 177
using Quotient_symp[OF q] Quotient_transp[OF q] unfolding symp_def transp_def
+ − 178
using a by blast
0
+ − 179
527
+ − 180
lemma lambda_prs:
528
+ − 181
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 182
and q2: "Quotient R2 Abs2 Rep2"
253
e169a99c6ada
Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 183
shows "(Rep1 ---> Abs2) (\<lambda>x. Rep2 (f (Abs1 x))) = (\<lambda>x. f x)"
543
+ − 184
unfolding expand_fun_eq
+ − 185
using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2]
+ − 186
by simp
0
+ − 187
527
+ − 188
lemma lambda_prs1:
528
+ − 189
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 190
and q2: "Quotient R2 Abs2 Rep2"
527
+ − 191
shows "(Rep1 ---> Abs2) (\<lambda>x. (Abs1 ---> Rep2) f x) = (\<lambda>x. f x)"
543
+ − 192
unfolding expand_fun_eq
+ − 193
using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2]
+ − 194
by simp
253
e169a99c6ada
Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 195
542
+ − 196
lemma rep_abs_rsp:
528
+ − 197
assumes q: "Quotient R Abs Rep"
459
+ − 198
and a: "R x1 x2"
+ − 199
shows "R x1 (Rep (Abs x2))"
543
+ − 200
using q a by (metis Quotient_rel[OF q] Quotient_abs_rep[OF q] Quotient_rep_reflp[OF q])
0
+ − 201
527
+ − 202
(* In the following theorem R1 can be instantiated with anything,
516
+ − 203
but we know some of the types of the Rep and Abs functions;
543
+ − 204
so by solving Quotient assumptions we can get a unique R1 that
+ − 205
will be provable; which is why we need to use apply_rsp and
+ − 206
not the primed version *)
527
+ − 207
lemma apply_rsp:
528
+ − 208
assumes q: "Quotient R1 Abs1 Rep1"
516
+ − 209
and a: "(R1 ===> R2) f g" "R1 x y"
+ − 210
shows "R2 ((f::'a\<Rightarrow>'c) x) ((g::'a\<Rightarrow>'c) y)"
543
+ − 211
using a by simp
516
+ − 212
527
+ − 213
lemma apply_rsp':
317
+ − 214
assumes a: "(R1 ===> R2) f g" "R1 x y"
+ − 215
shows "R2 (f x) (g y)"
543
+ − 216
using a by simp
458
+ − 217
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 218
(* Set of lemmas for regularisation of ball and bex *)
543
+ − 219
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 220
lemma ball_reg_eqv:
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 221
fixes P :: "'a \<Rightarrow> bool"
528
+ − 222
assumes a: "equivp R"
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 223
shows "Ball (Respects R) P = (All P)"
542
+ − 224
by (metis equivp_def in_respects a)
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 225
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 226
lemma bex_reg_eqv:
93
+ − 227
fixes P :: "'a \<Rightarrow> bool"
528
+ − 228
assumes a: "equivp R"
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 229
shows "Bex (Respects R) P = (Ex P)"
542
+ − 230
by (metis equivp_def in_respects a)
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 231
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 232
lemma ball_reg_right:
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 233
assumes a: "\<And>x. R x \<Longrightarrow> P x \<longrightarrow> Q x"
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 234
shows "All P \<longrightarrow> Ball R Q"
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 235
by (metis COMBC_def Collect_def Collect_mem_eq a)
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 236
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 237
lemma bex_reg_left:
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 238
assumes a: "\<And>x. R x \<Longrightarrow> Q x \<longrightarrow> P x"
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 239
shows "Bex R Q \<longrightarrow> Ex P"
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 240
by (metis COMBC_def Collect_def Collect_mem_eq a)
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 241
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 242
lemma ball_reg_left:
528
+ − 243
assumes a: "equivp R"
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 244
shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ball (Respects R) Q \<longrightarrow> All P"
542
+ − 245
by (metis equivp_reflp in_respects a)
93
+ − 246
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 247
lemma bex_reg_right:
528
+ − 248
assumes a: "equivp R"
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 249
shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ex Q \<longrightarrow> Bex (Respects R) P"
542
+ − 250
by (metis equivp_reflp in_respects a)
93
+ − 251
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 252
lemma ball_reg_eqv_range:
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 253
fixes P::"'a \<Rightarrow> bool"
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 254
and x::"'a"
528
+ − 255
assumes a: "equivp R2"
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 256
shows "(Ball (Respects (R1 ===> R2)) (\<lambda>f. P (f x)) = All (\<lambda>f. P (f x)))"
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 257
apply(rule iffI)
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 258
apply(rule allI)
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 259
apply(drule_tac x="\<lambda>y. f x" in bspec)
542
+ − 260
apply(simp add: Respects_def in_respects)
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 261
apply(rule impI)
528
+ − 262
using a equivp_reflp_symp_transp[of "R2"]
+ − 263
apply(simp add: reflp_def)
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 264
apply(simp)
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 265
apply(simp)
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 266
done
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 267
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 268
lemma bex_reg_eqv_range:
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 269
fixes P::"'a \<Rightarrow> bool"
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 270
and x::"'a"
528
+ − 271
assumes a: "equivp R2"
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 272
shows "(Bex (Respects (R1 ===> R2)) (\<lambda>f. P (f x)) = Ex (\<lambda>f. P (f x)))"
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 273
apply(auto)
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 274
apply(rule_tac x="\<lambda>y. f x" in bexI)
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 275
apply(simp)
542
+ − 276
apply(simp add: Respects_def in_respects)
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 277
apply(rule impI)
528
+ − 278
using a equivp_reflp_symp_transp[of "R2"]
+ − 279
apply(simp add: reflp_def)
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 280
done
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 281
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 282
lemma all_reg:
96
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 283
assumes a: "!x :: 'a. (P x --> Q x)"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 284
and b: "All P"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 285
shows "All Q"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 286
using a b by (metis)
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 287
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 288
lemma ex_reg:
96
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 289
assumes a: "!x :: 'a. (P x --> Q x)"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 290
and b: "Ex P"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 291
shows "Ex Q"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 292
using a b by (metis)
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 293
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 294
lemma ball_reg:
96
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 295
assumes a: "!x :: 'a. (R x --> P x --> Q x)"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 296
and b: "Ball R P"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 297
shows "Ball R Q"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 298
using a b by (metis COMBC_def Collect_def Collect_mem_eq)
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 299
427
5a3965aa4d80
Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 300
lemma bex_reg:
96
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 301
assumes a: "!x :: 'a. (R x --> P x --> Q x)"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 302
and b: "Bex R P"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 303
shows "Bex R Q"
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 304
using a b by (metis COMBC_def Collect_def Collect_mem_eq)
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 305
432
+ − 306
lemma ball_all_comm:
+ − 307
"(\<And>y. (\<forall>x\<in>P. A x y) \<longrightarrow> (\<forall>x. B x y)) \<Longrightarrow> ((\<forall>x\<in>P. \<forall>y. A x y) \<longrightarrow> (\<forall>x. \<forall>y. B x y))"
+ − 308
by auto
+ − 309
+ − 310
lemma bex_ex_comm:
+ − 311
"((\<exists>y. \<exists>x. A x y) \<longrightarrow> (\<exists>y. \<exists>x\<in>P. B x y)) \<Longrightarrow> ((\<exists>x. \<exists>y. A x y) \<longrightarrow> (\<exists>x\<in>P. \<exists>y. B x y))"
+ − 312
by auto
96
4da714704611
A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 313
458
+ − 314
(* 2 lemmas needed for proving repabs_inj *)
+ − 315
lemma ball_rsp:
+ − 316
assumes a: "(R ===> (op =)) f g"
+ − 317
shows "Ball (Respects R) f = Ball (Respects R) g"
542
+ − 318
using a by (simp add: Ball_def in_respects)
153
+ − 319
458
+ − 320
lemma bex_rsp:
+ − 321
assumes a: "(R ===> (op =)) f g"
+ − 322
shows "(Bex (Respects R) f = Bex (Respects R) g)"
542
+ − 323
using a by (simp add: Bex_def in_respects)
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 324
458
+ − 325
(* 2 lemmas needed for cleaning of quantifiers *)
+ − 326
lemma all_prs:
528
+ − 327
assumes a: "Quotient R absf repf"
458
+ − 328
shows "Ball (Respects R) ((absf ---> id) f) = All f"
528
+ − 329
using a unfolding Quotient_def
542
+ − 330
by (metis in_respects fun_map.simps id_apply)
162
+ − 331
458
+ − 332
lemma ex_prs:
528
+ − 333
assumes a: "Quotient R absf repf"
458
+ − 334
shows "Bex (Respects R) ((absf ---> id) f) = Ex f"
528
+ − 335
using a unfolding Quotient_def
542
+ − 336
by (metis COMBC_def Collect_def Collect_mem_eq in_respects fun_map.simps id_apply)
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 337
554
+ − 338
lemma fun_rel_id:
+ − 339
assumes a: "\<And>x y. R1 x y \<Longrightarrow> R2 (f x) (g y)"
+ − 340
shows "(R1 ===> R2) f g"
+ − 341
using a by simp
+ − 342
+ − 343
lemma quot_rel_rsp:
+ − 344
assumes a: "Quotient R Abs Rep"
+ − 345
shows "(R ===> R ===> op =) R R"
+ − 346
apply(rule fun_rel_id)+
+ − 347
apply(rule equals_rsp[OF a])
+ − 348
apply(assumption)+
+ − 349
done
+ − 350
541
+ − 351
543
+ − 352
+ − 353
+ − 354
+ − 355
+ − 356
(******************************************)
+ − 357
(* REST OF THE FILE IS UNUSED (until now) *)
+ − 358
(******************************************)
541
+ − 359
lemma Quotient_rel_abs:
+ − 360
assumes a: "Quotient E Abs Rep"
+ − 361
shows "E r s \<Longrightarrow> Abs r = Abs s"
+ − 362
using a unfolding Quotient_def
+ − 363
by blast
+ − 364
+ − 365
lemma Quotient_rel_abs_eq:
+ − 366
assumes a: "Quotient E Abs Rep"
+ − 367
shows "E r r \<Longrightarrow> E s s \<Longrightarrow> E r s = (Abs r = Abs s)"
+ − 368
using a unfolding Quotient_def
+ − 369
by blast
+ − 370
542
+ − 371
lemma in_fun:
+ − 372
shows "x \<in> ((f ---> g) s) = g (f x \<in> s)"
+ − 373
by (simp add: mem_def)
+ − 374
+ − 375
lemma RESPECTS_THM:
+ − 376
shows "Respects (R1 ===> R2) f = (\<forall>x y. R1 x y \<longrightarrow> R2 (f x) (f y))"
+ − 377
unfolding Respects_def
+ − 378
by (simp add: expand_fun_eq)
+ − 379
+ − 380
lemma RESPECTS_REP_ABS:
+ − 381
assumes a: "Quotient R1 Abs1 Rep1"
+ − 382
and b: "Respects (R1 ===> R2) f"
+ − 383
and c: "R1 x x"
+ − 384
shows "R2 (f (Rep1 (Abs1 x))) (f x)"
+ − 385
using a b[simplified RESPECTS_THM] c unfolding Quotient_def
+ − 386
by blast
+ − 387
+ − 388
lemma RESPECTS_MP:
+ − 389
assumes a: "Respects (R1 ===> R2) f"
+ − 390
and b: "R1 x y"
+ − 391
shows "R2 (f x) (f y)"
+ − 392
using a b unfolding Respects_def
+ − 393
by simp
+ − 394
+ − 395
lemma RESPECTS_o:
+ − 396
assumes a: "Respects (R2 ===> R3) f"
+ − 397
and b: "Respects (R1 ===> R2) g"
+ − 398
shows "Respects (R1 ===> R3) (f o g)"
+ − 399
using a b unfolding Respects_def
+ − 400
by simp
+ − 401
+ − 402
lemma fun_rel_EQ_REL:
+ − 403
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 404
and q2: "Quotient R2 Abs2 Rep2"
+ − 405
shows "(R1 ===> R2) f g = ((Respects (R1 ===> R2) f) \<and> (Respects (R1 ===> R2) g)
+ − 406
\<and> ((Rep1 ---> Abs2) f = (Rep1 ---> Abs2) g))"
+ − 407
using fun_quotient[OF q1 q2] unfolding Respects_def Quotient_def expand_fun_eq
+ − 408
by blast
+ − 409
+ − 410
(* Not used since in the end we just unfold fun_map *)
+ − 411
lemma APP_PRS:
+ − 412
assumes q1: "Quotient R1 abs1 rep1"
+ − 413
and q2: "Quotient R2 abs2 rep2"
+ − 414
shows "abs2 ((abs1 ---> rep2) f (rep1 x)) = f x"
+ − 415
unfolding expand_fun_eq
+ − 416
using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2]
+ − 417
by simp
+ − 418
+ − 419
(* Ask Peter: assumption q1 and q2 not used and lemma is the 'identity' *)
+ − 420
lemma LAMBDA_RSP:
+ − 421
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 422
and q2: "Quotient R2 Abs2 Rep2"
+ − 423
and a: "(R1 ===> R2) f1 f2"
+ − 424
shows "(R1 ===> R2) (\<lambda>x. f1 x) (\<lambda>y. f2 y)"
+ − 425
by (rule a)
+ − 426
+ − 427
(* ASK Peter about next four lemmas in quotientScript
+ − 428
lemma ABSTRACT_PRS:
+ − 429
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 430
and q2: "Quotient R2 Abs2 Rep2"
+ − 431
shows "f = (Rep1 ---> Abs2) ???"
+ − 432
*)
+ − 433
+ − 434
+ − 435
lemma fun_rel_EQUALS:
+ − 436
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 437
and q2: "Quotient R2 Abs2 Rep2"
+ − 438
and r1: "Respects (R1 ===> R2) f"
+ − 439
and r2: "Respects (R1 ===> R2) g"
+ − 440
shows "((Rep1 ---> Abs2) f = (Rep1 ---> Abs2) g) = (\<forall>x y. R1 x y \<longrightarrow> R2 (f x) (g y))"
+ − 441
apply(rule_tac iffI)
+ − 442
using fun_quotient[OF q1 q2] r1 r2 unfolding Quotient_def Respects_def
543
+ − 443
apply(metis apply_rsp')
542
+ − 444
using r1 unfolding Respects_def expand_fun_eq
+ − 445
apply(simp (no_asm_use))
+ − 446
apply(metis Quotient_rel[OF q2] Quotient_rel_rep[OF q1])
+ − 447
done
+ − 448
+ − 449
(* ask Peter: fun_rel_IMP used twice *)
+ − 450
lemma fun_rel_IMP2:
+ − 451
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 452
and q2: "Quotient R2 Abs2 Rep2"
+ − 453
and r1: "Respects (R1 ===> R2) f"
+ − 454
and r2: "Respects (R1 ===> R2) g"
+ − 455
and a: "(Rep1 ---> Abs2) f = (Rep1 ---> Abs2) g"
+ − 456
shows "R1 x y \<Longrightarrow> R2 (f x) (g y)"
+ − 457
using q1 q2 r1 r2 a
+ − 458
by (simp add: fun_rel_EQUALS)
+ − 459
+ − 460
lemma LAMBDA_REP_ABS_RSP:
+ − 461
assumes r1: "\<And>r r'. R1 r r' \<Longrightarrow>R1 r (Rep1 (Abs1 r'))"
+ − 462
and r2: "\<And>r r'. R2 r r' \<Longrightarrow>R2 r (Rep2 (Abs2 r'))"
+ − 463
shows "(R1 ===> R2) f1 f2 \<Longrightarrow> (R1 ===> R2) f1 ((Abs1 ---> Rep2) ((Rep1 ---> Abs2) f2))"
+ − 464
using r1 r2 by auto
+ − 465
+ − 466
(* Not used *)
+ − 467
lemma rep_abs_rsp_left:
+ − 468
assumes q: "Quotient R Abs Rep"
+ − 469
and a: "R x1 x2"
+ − 470
shows "R x1 (Rep (Abs x2))"
+ − 471
using q a by (metis Quotient_rel[OF q] Quotient_abs_rep[OF q] Quotient_rep_reflp[OF q])
541
+ − 472
+ − 473
543
+ − 474
+ − 475
(* bool theory: COND, LET *)
+ − 476
lemma IF_PRS:
+ − 477
assumes q: "Quotient R Abs Rep"
+ − 478
shows "If a b c = Abs (If a (Rep b) (Rep c))"
+ − 479
using Quotient_abs_rep[OF q] by auto
+ − 480
+ − 481
(* ask peter: no use of q *)
+ − 482
lemma IF_RSP:
+ − 483
assumes q: "Quotient R Abs Rep"
+ − 484
and a: "a1 = a2" "R b1 b2" "R c1 c2"
+ − 485
shows "R (If a1 b1 c1) (If a2 b2 c2)"
+ − 486
using a by auto
+ − 487
+ − 488
lemma LET_PRS:
+ − 489
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 490
and q2: "Quotient R2 Abs2 Rep2"
+ − 491
shows "Let x f = Abs2 (Let (Rep1 x) ((Abs1 ---> Rep2) f))"
+ − 492
using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2] by auto
+ − 493
+ − 494
lemma LET_RSP:
+ − 495
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 496
and a1: "(R1 ===> R2) f g"
+ − 497
and a2: "R1 x y"
+ − 498
shows "R2 ((Let x f)::'c) ((Let y g)::'c)"
+ − 499
using apply_rsp[OF q1 a1] a2
+ − 500
by auto
+ − 501
+ − 502
+ − 503
+ − 504
(* ask peter what are literal_case *)
+ − 505
(* literal_case_PRS *)
+ − 506
(* literal_case_RSP *)
+ − 507
+ − 508
+ − 509
+ − 510
+ − 511
+ − 512
(* combinators: I, K, o, C, W *)
+ − 513
+ − 514
(* We use id_simps which includes id_apply; so these 2 theorems can be removed *)
+ − 515
+ − 516
lemma I_PRS:
+ − 517
assumes q: "Quotient R Abs Rep"
+ − 518
shows "id e = Abs (id (Rep e))"
+ − 519
using Quotient_abs_rep[OF q] by auto
+ − 520
+ − 521
lemma I_RSP:
+ − 522
assumes q: "Quotient R Abs Rep"
+ − 523
and a: "R e1 e2"
+ − 524
shows "R (id e1) (id e2)"
+ − 525
using a by auto
+ − 526
+ − 527
lemma o_PRS:
+ − 528
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 529
and q2: "Quotient R2 Abs2 Rep2"
+ − 530
and q3: "Quotient R3 Abs3 Rep3"
+ − 531
shows "f o g = (Rep1 ---> Abs3) (((Abs2 ---> Rep3) f) o ((Abs1 ---> Rep2) g))"
+ − 532
using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2] Quotient_abs_rep[OF q3]
+ − 533
unfolding o_def expand_fun_eq
+ − 534
by simp
+ − 535
+ − 536
lemma o_RSP:
+ − 537
assumes q1: "Quotient R1 Abs1 Rep1"
+ − 538
and q2: "Quotient R2 Abs2 Rep2"
+ − 539
and q3: "Quotient R3 Abs3 Rep3"
+ − 540
and a1: "(R2 ===> R3) f1 f2"
+ − 541
and a2: "(R1 ===> R2) g1 g2"
+ − 542
shows "(R1 ===> R3) (f1 o g1) (f2 o g2)"
+ − 543
using a1 a2 unfolding o_def expand_fun_eq
+ − 544
by (auto)
+ − 545
+ − 546
lemma COND_PRS:
+ − 547
assumes a: "Quotient R absf repf"
+ − 548
shows "(if a then b else c) = absf (if a then repf b else repf c)"
+ − 549
using a unfolding Quotient_def by auto
+ − 550
+ − 551
93
+ − 552
end
95
+ − 553