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