163
+ − 1
theory FSet
+ − 2
imports QuotMain
+ − 3
begin
+ − 4
+ − 5
inductive
+ − 6
list_eq (infix "\<approx>" 50)
+ − 7
where
+ − 8
"a#b#xs \<approx> b#a#xs"
+ − 9
| "[] \<approx> []"
+ − 10
| "xs \<approx> ys \<Longrightarrow> ys \<approx> xs"
+ − 11
| "a#a#xs \<approx> a#xs"
+ − 12
| "xs \<approx> ys \<Longrightarrow> a#xs \<approx> a#ys"
+ − 13
| "\<lbrakk>xs1 \<approx> xs2; xs2 \<approx> xs3\<rbrakk> \<Longrightarrow> xs1 \<approx> xs3"
+ − 14
+ − 15
lemma list_eq_refl:
+ − 16
shows "xs \<approx> xs"
+ − 17
apply (induct xs)
+ − 18
apply (auto intro: list_eq.intros)
+ − 19
done
+ − 20
+ − 21
lemma equiv_list_eq:
+ − 22
shows "EQUIV list_eq"
+ − 23
unfolding EQUIV_REFL_SYM_TRANS REFL_def SYM_def TRANS_def
+ − 24
apply(auto intro: list_eq.intros list_eq_refl)
+ − 25
done
+ − 26
+ − 27
quotient fset = "'a list" / "list_eq"
+ − 28
apply(rule equiv_list_eq)
+ − 29
done
+ − 30
+ − 31
print_theorems
+ − 32
+ − 33
typ "'a fset"
+ − 34
thm "Rep_fset"
+ − 35
thm "ABS_fset_def"
+ − 36
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 37
quotient_def
231
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 38
EMPTY :: "'a fset"
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 39
where
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 40
"EMPTY \<equiv> ([]::'a list)"
163
+ − 41
+ − 42
term Nil
+ − 43
term EMPTY
+ − 44
thm EMPTY_def
+ − 45
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 46
quotient_def
254
+ − 47
INSERT :: "'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
231
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 48
where
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 49
"INSERT \<equiv> op #"
163
+ − 50
+ − 51
term Cons
+ − 52
term INSERT
+ − 53
thm INSERT_def
+ − 54
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 55
quotient_def
231
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 56
FUNION :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 57
where
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 58
"FUNION \<equiv> (op @)"
163
+ − 59
+ − 60
term append
231
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 61
term FUNION
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 62
thm FUNION_def
163
+ − 63
+ − 64
thm QUOTIENT_fset
+ − 65
+ − 66
thm QUOT_TYPE_I_fset.thm11
+ − 67
+ − 68
+ − 69
fun
+ − 70
membship :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" (infix "memb" 100)
+ − 71
where
+ − 72
m1: "(x memb []) = False"
+ − 73
| m2: "(x memb (y#xs)) = ((x=y) \<or> (x memb xs))"
+ − 74
+ − 75
fun
+ − 76
card1 :: "'a list \<Rightarrow> nat"
+ − 77
where
+ − 78
card1_nil: "(card1 []) = 0"
+ − 79
| card1_cons: "(card1 (x # xs)) = (if (x memb xs) then (card1 xs) else (Suc (card1 xs)))"
+ − 80
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 81
quotient_def
231
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 82
CARD :: "'a fset \<Rightarrow> nat"
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 83
where
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 84
"CARD \<equiv> card1"
163
+ − 85
+ − 86
term card1
231
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 87
term CARD
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 88
thm CARD_def
163
+ − 89
+ − 90
(* text {*
+ − 91
Maybe make_const_def should require a theorem that says that the particular lifted function
+ − 92
respects the relation. With it such a definition would be impossible:
+ − 93
make_const_def @{binding CARD} @{term "length"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd
+ − 94
*}*)
+ − 95
+ − 96
lemma card1_0:
+ − 97
fixes a :: "'a list"
+ − 98
shows "(card1 a = 0) = (a = [])"
214
+ − 99
by (induct a) auto
163
+ − 100
+ − 101
lemma not_mem_card1:
+ − 102
fixes x :: "'a"
+ − 103
fixes xs :: "'a list"
309
+ − 104
shows "(~(x memb xs)) = (card1 (x # xs) = Suc (card1 xs))"
+ − 105
by auto
163
+ − 106
+ − 107
lemma mem_cons:
+ − 108
fixes x :: "'a"
+ − 109
fixes xs :: "'a list"
+ − 110
assumes a : "x memb xs"
+ − 111
shows "x # xs \<approx> xs"
214
+ − 112
using a by (induct xs) (auto intro: list_eq.intros )
163
+ − 113
+ − 114
lemma card1_suc:
+ − 115
fixes xs :: "'a list"
+ − 116
fixes n :: "nat"
+ − 117
assumes c: "card1 xs = Suc n"
+ − 118
shows "\<exists>a ys. ~(a memb ys) \<and> xs \<approx> (a # ys)"
+ − 119
using c
+ − 120
apply(induct xs)
+ − 121
apply (metis Suc_neq_Zero card1_0)
+ − 122
apply (metis QUOT_TYPE_I_fset.R_trans card1_cons list_eq_refl mem_cons)
+ − 123
done
+ − 124
294
+ − 125
definition
+ − 126
rsp_fold
+ − 127
where
+ − 128
"rsp_fold f = ((!u v. (f u v = f v u)) \<and> (!u v w. ((f u (f v w) = f (f u v) w))))"
+ − 129
163
+ − 130
primrec
+ − 131
fold1
+ − 132
where
+ − 133
"fold1 f (g :: 'a \<Rightarrow> 'b) (z :: 'b) [] = z"
+ − 134
| "fold1 f g z (a # A) =
294
+ − 135
(if rsp_fold f
163
+ − 136
then (
+ − 137
if (a memb A) then (fold1 f g z A) else (f (g a) (fold1 f g z A))
+ − 138
) else z)"
+ − 139
+ − 140
(* fold1_def is not usable, but: *)
+ − 141
thm fold1.simps
+ − 142
+ − 143
lemma fs1_strong_cases:
+ − 144
fixes X :: "'a list"
+ − 145
shows "(X = []) \<or> (\<exists>a. \<exists> Y. (~(a memb Y) \<and> (X \<approx> a # Y)))"
+ − 146
apply (induct X)
+ − 147
apply (simp)
+ − 148
apply (metis QUOT_TYPE_I_fset.thm11 list_eq_refl mem_cons m1)
+ − 149
done
+ − 150
296
+ − 151
quotient_def
231
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 152
IN :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool"
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 153
where
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 154
"IN \<equiv> membship"
163
+ − 155
+ − 156
term membship
+ − 157
term IN
+ − 158
thm IN_def
+ − 159
274
+ − 160
term fold1
+ − 161
quotient_def
+ − 162
FOLD :: "('a \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'b fset \<Rightarrow> 'a"
231
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 163
where
c643938b846a
updated some definitions; had to give sometimes different names; somewhere I introduced a bug, since not everything is working anymore (needs fixing!)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 164
"FOLD \<equiv> fold1"
194
+ − 165
+ − 166
term fold1
+ − 167
term fold
+ − 168
thm fold_def
+ − 169
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 170
quotient_def
254
+ − 171
fmap::"('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
225
+ − 172
where
254
+ − 173
"fmap \<equiv> map"
194
+ − 174
+ − 175
term map
+ − 176
term fmap
+ − 177
thm fmap_def
+ − 178
274
+ − 179
ML {* val defs = @{thms EMPTY_def IN_def FUNION_def CARD_def INSERT_def fmap_def FOLD_def} *}
163
+ − 180
164
+ − 181
lemma memb_rsp:
163
+ − 182
fixes z
+ − 183
assumes a: "list_eq x y"
+ − 184
shows "(z memb x) = (z memb y)"
+ − 185
using a by induct auto
+ − 186
164
+ − 187
lemma ho_memb_rsp:
+ − 188
"(op = ===> (op \<approx> ===> op =)) (op memb) (op memb)"
214
+ − 189
by (simp add: memb_rsp)
164
+ − 190
163
+ − 191
lemma card1_rsp:
+ − 192
fixes a b :: "'a list"
+ − 193
assumes e: "a \<approx> b"
+ − 194
shows "card1 a = card1 b"
214
+ − 195
using e by induct (simp_all add:memb_rsp)
163
+ − 196
228
+ − 197
lemma ho_card1_rsp: "(op \<approx> ===> op =) card1 card1"
214
+ − 198
by (simp add: card1_rsp)
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 199
164
+ − 200
lemma cons_rsp:
163
+ − 201
fixes z
+ − 202
assumes a: "xs \<approx> ys"
+ − 203
shows "(z # xs) \<approx> (z # ys)"
+ − 204
using a by (rule list_eq.intros(5))
+ − 205
164
+ − 206
lemma ho_cons_rsp:
228
+ − 207
"(op = ===> op \<approx> ===> op \<approx>) op # op #"
214
+ − 208
by (simp add: cons_rsp)
164
+ − 209
175
+ − 210
lemma append_rsp_fst:
163
+ − 211
assumes a : "list_eq l1 l2"
214
+ − 212
shows "(l1 @ s) \<approx> (l2 @ s)"
163
+ − 213
using a
214
+ − 214
by (induct) (auto intro: list_eq.intros list_eq_refl)
+ − 215
+ − 216
lemma append_end:
+ − 217
shows "(e # l) \<approx> (l @ [e])"
+ − 218
apply (induct l)
+ − 219
apply (auto intro: list_eq.intros list_eq_refl)
+ − 220
done
+ − 221
+ − 222
lemma rev_rsp:
+ − 223
shows "a \<approx> rev a"
+ − 224
apply (induct a)
+ − 225
apply simp
+ − 226
apply (rule list_eq_refl)
+ − 227
apply simp_all
+ − 228
apply (rule list_eq.intros(6))
+ − 229
prefer 2
+ − 230
apply (rule append_rsp_fst)
+ − 231
apply assumption
+ − 232
apply (rule append_end)
+ − 233
done
163
+ − 234
214
+ − 235
lemma append_sym_rsp:
+ − 236
shows "(a @ b) \<approx> (b @ a)"
+ − 237
apply (rule list_eq.intros(6))
+ − 238
apply (rule append_rsp_fst)
+ − 239
apply (rule rev_rsp)
+ − 240
apply (rule list_eq.intros(6))
+ − 241
apply (rule rev_rsp)
+ − 242
apply (simp)
+ − 243
apply (rule append_rsp_fst)
+ − 244
apply (rule list_eq.intros(3))
+ − 245
apply (rule rev_rsp)
+ − 246
done
+ − 247
+ − 248
lemma append_rsp:
+ − 249
assumes a : "list_eq l1 r1"
+ − 250
assumes b : "list_eq l2 r2 "
+ − 251
shows "(l1 @ l2) \<approx> (r1 @ r2)"
+ − 252
apply (rule list_eq.intros(6))
+ − 253
apply (rule append_rsp_fst)
+ − 254
using a apply (assumption)
+ − 255
apply (rule list_eq.intros(6))
+ − 256
apply (rule append_sym_rsp)
+ − 257
apply (rule list_eq.intros(6))
+ − 258
apply (rule append_rsp_fst)
+ − 259
using b apply (assumption)
+ − 260
apply (rule append_sym_rsp)
+ − 261
done
175
+ − 262
194
+ − 263
lemma ho_append_rsp:
228
+ − 264
"(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @"
214
+ − 265
by (simp add: append_rsp)
175
+ − 266
194
+ − 267
lemma map_rsp:
+ − 268
assumes a: "a \<approx> b"
+ − 269
shows "map f a \<approx> map f b"
+ − 270
using a
+ − 271
apply (induct)
+ − 272
apply(auto intro: list_eq.intros)
+ − 273
done
+ − 274
+ − 275
lemma ho_map_rsp:
294
+ − 276
"(op = ===> op \<approx> ===> op \<approx>) map map"
+ − 277
by (simp add: map_rsp)
194
+ − 278
294
+ − 279
lemma map_append:
258
+ − 280
"(map f (a @ b)) \<approx>
+ − 281
(map f a) @ (map f b)"
215
+ − 282
by simp (rule list_eq_refl)
194
+ − 283
273
+ − 284
lemma ho_fold_rsp:
294
+ − 285
"(op = ===> op = ===> op = ===> op \<approx> ===> op =) fold1 fold1"
292
+ − 286
apply (auto simp add: FUN_REL_EQ)
294
+ − 287
apply (case_tac "rsp_fold x")
+ − 288
prefer 2
+ − 289
apply (erule_tac list_eq.induct)
+ − 290
apply (simp_all)
+ − 291
apply (erule_tac list_eq.induct)
+ − 292
apply (simp_all)
+ − 293
apply (auto simp add: memb_rsp rsp_fold_def)
+ − 294
done
241
60acf3d3a4a0
Finding applications and duplicates filtered out in abstractions
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 295
254
+ − 296
print_quotients
+ − 297
+ − 298
226
+ − 299
ML {* val qty = @{typ "'a fset"} *}
+ − 300
ML {* val rsp_thms =
273
+ − 301
@{thms ho_memb_rsp ho_cons_rsp ho_card1_rsp ho_map_rsp ho_append_rsp ho_fold_rsp}
226
+ − 302
@ @{thms ho_all_prs ho_ex_prs} *}
206
+ − 303
364
+ − 304
ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *}
+ − 305
ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "fset"; *}
+ − 306
ML {* val consts = lookup_quot_consts defs *}
389
+ − 307
ML {* fun lift_tac_fset lthy t = lift_tac lthy t rel_eqv rel_refl rty quot trans2 rsp_thms reps_same absrep defs *}
314
+ − 308
364
+ − 309
lemma "IN x EMPTY = False"
+ − 310
by (tactic {* lift_tac_fset @{context} @{thm m1} 1 *})
353
9a0e8ab42ee8
fixed the error by a temporary fix (the data of the eqivalence relation should be only its name)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 311
364
+ − 312
lemma "IN x (INSERT y xa) = (x = y \<or> IN x xa)"
+ − 313
by (tactic {* lift_tac_fset @{context} @{thm m2} 1 *})
356
51aafebf4d06
Another theorem for which the new regularize differs from old one, so the goal is not proved. But it seems, that the new one is better.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 314
364
+ − 315
lemma "INSERT a (INSERT a x) = INSERT a x"
+ − 316
apply (tactic {* lift_tac_fset @{context} @{thm list_eq.intros(4)} 1 *})
+ − 317
done
+ − 318
367
+ − 319
lemma "x = xa \<Longrightarrow> INSERT a x = INSERT a xa"
364
+ − 320
apply (tactic {* lift_tac_fset @{context} @{thm list_eq.intros(5)} 1 *})
+ − 321
done
353
9a0e8ab42ee8
fixed the error by a temporary fix (the data of the eqivalence relation should be only its name)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 322
367
+ − 323
lemma "CARD x = Suc n \<Longrightarrow> (\<exists>a b. \<not> IN a b & x = INSERT a b)"
364
+ − 324
apply (tactic {* lift_tac_fset @{context} @{thm card1_suc} 1 *})
+ − 325
done
+ − 326
+ − 327
lemma "(\<not> IN x xa) = (CARD (INSERT x xa) = Suc (CARD xa))"
+ − 328
apply (tactic {* lift_tac_fset @{context} @{thm not_mem_card1} 1 *})
+ − 329
done
356
51aafebf4d06
Another theorem for which the new regularize differs from old one, so the goal is not proved. But it seems, that the new one is better.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 330
364
+ − 331
lemma "\<forall>f g z a x. FOLD f g (z::'b) (INSERT a x) =
+ − 332
(if rsp_fold f then if IN a x then FOLD f g z x else f (g a) (FOLD f g z x) else z)"
+ − 333
apply (tactic {* lift_tac_fset @{context} @{thm fold1.simps(2)} 1 *})
+ − 334
done
356
51aafebf4d06
Another theorem for which the new regularize differs from old one, so the goal is not proved. But it seems, that the new one is better.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 335
368
+ − 336
lemma "fmap f (FUNION (x::'b fset) (xa::'b fset)) = FUNION (fmap f x) (fmap f xa)"
+ − 337
apply (tactic {* lift_tac_fset @{context} @{thm map_append} 1 *})
+ − 338
done
+ − 339
367
+ − 340
lemma "FUNION (FUNION x xa) xb = FUNION x (FUNION xa xb)"
+ − 341
apply (tactic {* lift_tac_fset @{context} @{thm append_assoc} 1 *})
+ − 342
done
+ − 343
376
+ − 344
ML {* val aps = findaps rty (prop_of (atomize_thm @{thm list.induct})) *}
392
+ − 345
ML {* val app_prs_thms = map (applic_prs_old @{context} rty qty absrep) aps *}
390
+ − 346
+ − 347
lemma cheat: "P" sorry
+ − 348
+ − 349
lemma imp_refl: "P \<longrightarrow> P" by simp
+ − 350
395
+ − 351
lemma [mono]: "P \<longrightarrow> Q \<Longrightarrow> \<not>Q \<longrightarrow> \<not>P"
+ − 352
apply(auto)
+ − 353
done
+ − 354
390
+ − 355
thm Set.conj_mono
+ − 356
thm Set.imp_mono
+ − 357
ML {* Inductive.get_monos @{context} *}
397
+ − 358
thm LEFT_RES_FORALL_REGULAR
+ − 359
+ − 360
lemma test:
+ − 361
fixes P Q::"'a \<Rightarrow> bool"
+ − 362
and x::"'a"
+ − 363
assumes a: "REFL R2"
+ − 364
and b: "\<And>f. Q (f x) \<Longrightarrow> P (f x)"
+ − 365
shows "(\<forall>f\<in>(Respects (R1 ===> R2)). Q (f x)) \<longrightarrow> (\<forall>f. P (f x))"
+ − 366
apply(rule impI)
+ − 367
apply(rule allI)
+ − 368
apply(drule_tac x="\<lambda>y. f x" in bspec)
+ − 369
apply(simp add: Respects_def IN_RESPECTS)
+ − 370
apply(rule impI)
+ − 371
using a
+ − 372
apply(simp add: REFL_def)
+ − 373
using b
+ − 374
apply -
+ − 375
apply(simp)
+ − 376
done
390
+ − 377
376
+ − 378
lemma "\<lbrakk>P EMPTY; \<And>a x. P x \<Longrightarrow> P (INSERT a x)\<rbrakk> \<Longrightarrow> P l"
392
+ − 379
apply(tactic {* procedure_tac @{context} @{thm list.induct} 1 *})
390
+ − 380
defer
+ − 381
apply(rule cheat)
+ − 382
apply(rule cheat)
+ − 383
apply(atomize (full))
397
+ − 384
apply(rule RIGHT_RES_FORALL_REGULAR)
+ − 385
apply(rule RIGHT_RES_FORALL_REGULAR)
+ − 386
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})+
+ − 387
apply(rule LEFT_RES_FORALL_REGULAR)
+ − 388
apply(rule conjI)
+ − 389
using list_eq_refl
+ − 390
thm Ball_def IN_RESPECTS FUN_REL.simps
+ − 391
+ − 392
apply -
+ − 393
apply(simp (no_asm) add: Respects_def)
+ − 394
apply(blast)
390
+ − 395
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 396
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 397
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
395
+ − 398
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 399
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 400
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 401
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
397
+ − 402
apply(rule LEFT_RES_FORALL_REGULAR)
+ − 403
apply(rule conjI)
+ − 404
defer
390
+ − 405
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 406
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 407
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 408
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 409
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
+ − 410
apply(tactic {* resolve_tac (Inductive.get_monos @{context}) 1 *})
397
+ − 411
apply(unfold Respects_def)
+ − 412
sorry
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 413
390
+ − 414
lemma "\<lbrakk>P EMPTY; \<And>a x. P x \<Longrightarrow> P (INSERT a x)\<rbrakk> \<Longrightarrow> P l"
392
+ − 415
apply(tactic {* procedure_tac @{context} @{thm list.induct} 1 *})
390
+ − 416
defer
+ − 417
apply(rule cheat)
+ − 418
apply(rule cheat)
+ − 419
apply(tactic {* regularize_tac @{context} rel_eqv rel_refl 1 *})
392
+ − 420
done
390
+ − 421
273
+ − 422
quotient_def
276
+ − 423
fset_rec::"'a \<Rightarrow> ('b \<Rightarrow> 'b fset \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> 'b fset \<Rightarrow> 'a"
273
+ − 424
where
+ − 425
"fset_rec \<equiv> list_rec"
+ − 426
292
+ − 427
quotient_def
+ − 428
fset_case::"'a \<Rightarrow> ('b \<Rightarrow> 'b fset \<Rightarrow> 'a) \<Rightarrow> 'b fset \<Rightarrow> 'a"
+ − 429
where
+ − 430
"fset_case \<equiv> list_case"
+ − 431
296
+ − 432
(* Probably not true without additional assumptions about the function *)
292
+ − 433
lemma list_rec_rsp:
+ − 434
"(op = ===> (op = ===> op \<approx> ===> op =) ===> op \<approx> ===> op =) list_rec list_rec"
+ − 435
apply (auto simp add: FUN_REL_EQ)
296
+ − 436
apply (erule_tac list_eq.induct)
+ − 437
apply (simp_all)
292
+ − 438
sorry
289
7e8617f20b59
Remaining fixes for polymorphic types. map_append now lifts properly with 'a list and 'b list.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 439
292
+ − 440
lemma list_case_rsp:
+ − 441
"(op = ===> (op = ===> op \<approx> ===> op =) ===> op \<approx> ===> op =) list_case list_case"
+ − 442
apply (auto simp add: FUN_REL_EQ)
+ − 443
sorry
+ − 444
+ − 445
ML {* val rsp_thms = @{thms list_rec_rsp list_case_rsp} @ rsp_thms *}
+ − 446
ML {* val defs = @{thms fset_rec_def fset_case_def} @ defs *}
389
+ − 447
ML {* fun lift_tac_fset lthy t = lift_tac lthy t rel_eqv rel_refl rty quot trans2 rsp_thms reps_same absrep defs *}
356
51aafebf4d06
Another theorem for which the new regularize differs from old one, so the goal is not proved. But it seems, that the new one is better.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 448
376
+ − 449
lemma "fset_rec (f1::'t) x (INSERT a xa) = x a xa (fset_rec f1 x xa)"
+ − 450
apply (tactic {* lift_tac_fset @{context} @{thm list.recs(2)} 1 *})
+ − 451
done
+ − 452
+ − 453
lemma "fset_case (f1::'t) f2 (INSERT a xa) = f2 a xa"
+ − 454
apply (tactic {* lift_tac_fset @{context} @{thm list.cases(2)} 1 *})
+ − 455
done
348
+ − 456
304
+ − 457
lemma list_induct_part:
386
+ − 458
assumes a: "P (x :: 'a list) ([] :: 'c list)"
304
+ − 459
assumes b: "\<And>e t. P x t \<Longrightarrow> P x (e # t)"
+ − 460
shows "P x l"
+ − 461
apply (rule_tac P="P x" in list.induct)
+ − 462
apply (rule a)
+ − 463
apply (rule b)
+ − 464
apply (assumption)
+ − 465
done
273
+ − 466
292
+ − 467
379
+ − 468
ML {* fun r_mk_comb_tac_fset lthy = r_mk_comb_tac lthy rty quot rel_refl trans2 rsp_thms *}
292
+ − 469
334
+ − 470
+ − 471
384
+ − 472
379
+ − 473
(* Construction site starts here *)
386
+ − 474
lemma "P (x :: 'a list) (EMPTY :: 'c fset) \<Longrightarrow> (\<And>e t. P x t \<Longrightarrow> P x (INSERT e t)) \<Longrightarrow> P x l"
389
+ − 475
apply (tactic {* procedure_tac @{context} @{thm list_induct_part} 1 *})
379
+ − 476
apply (tactic {* regularize_tac @{context} rel_eqv rel_refl 1 *})
309
+ − 477
apply (tactic {* (APPLY_RSP_TAC rty @{context}) 1 *})
+ − 478
apply (rule FUN_QUOTIENT)
+ − 479
apply (rule FUN_QUOTIENT)
+ − 480
apply (rule IDENTITY_QUOTIENT)
+ − 481
apply (rule FUN_QUOTIENT)
+ − 482
apply (rule QUOTIENT_fset)
+ − 483
apply (rule IDENTITY_QUOTIENT)
+ − 484
apply (rule IDENTITY_QUOTIENT)
+ − 485
apply (rule IDENTITY_QUOTIENT)
+ − 486
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 487
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 488
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 489
apply (tactic {* (APPLY_RSP_TAC rty @{context}) 1 *})
+ − 490
apply (rule IDENTITY_QUOTIENT)
+ − 491
apply (rule IDENTITY_QUOTIENT)
+ − 492
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 493
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 494
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 495
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 496
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 497
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 498
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 499
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 500
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 501
apply (tactic {* (APPLY_RSP_TAC rty @{context}) 1 *})
+ − 502
apply (rule IDENTITY_QUOTIENT)
+ − 503
apply (rule FUN_QUOTIENT)
+ − 504
apply (rule QUOTIENT_fset)
+ − 505
apply (rule IDENTITY_QUOTIENT)
+ − 506
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 507
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 508
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 509
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 510
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 511
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 512
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 513
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 514
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 515
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 516
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 517
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 518
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 519
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 520
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 521
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 522
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 523
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
317
+ − 524
apply (tactic {* instantiate_tac @{thm APPLY_RSP2} @{context} 1 *})
+ − 525
apply (tactic {* (instantiate_tac @{thm REP_ABS_RSP(1)} @{context} THEN' (RANGE [quotient_tac quot])) 1 *})
+ − 526
apply assumption
+ − 527
apply (rule refl)
309
+ − 528
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 529
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
317
+ − 530
apply (tactic {* instantiate_tac @{thm APPLY_RSP2} @{context} 1 *})
+ − 531
apply (tactic {* instantiate_tac @{thm APPLY_RSP2} @{context} 1 *})
+ − 532
apply (tactic {* (instantiate_tac @{thm REP_ABS_RSP(1)} @{context} THEN' (RANGE [quotient_tac quot])) 1 *})
309
+ − 533
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 534
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 535
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_fset @{context}) 1 *})
+ − 536
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
317
+ − 537
apply (tactic {* instantiate_tac @{thm APPLY_RSP2} @{context} 1 *})
+ − 538
apply (tactic {* (instantiate_tac @{thm REP_ABS_RSP(1)} @{context} THEN' (RANGE [quotient_tac quot])) 1 *})
309
+ − 539
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 540
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 541
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
+ − 542
apply (tactic {* (r_mk_comb_tac_fset @{context}) 1 *})
389
+ − 543
apply (tactic {* clean_tac @{context} quot defs reps_same absrep [(@{typ "('a list \<Rightarrow> 'c list \<Rightarrow> bool)"},@{typ "('a list \<Rightarrow> 'c fset \<Rightarrow> bool)"})] 1 *})
309
+ − 544
done
+ − 545
163
+ − 546
end