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
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
+ − 37
quotient_def (for "'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
+ − 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
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
+ − 46
quotient_def (for "'a fset")
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
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
+ − 55
quotient_def (for "'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
+ − 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
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
+ − 81
quotient_def (for "'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
+ − 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"
+ − 104
shows "~(x memb xs) \<Longrightarrow> card1 (x # xs) = Suc (card1 xs)"
+ − 105
by simp
+ − 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
+ − 125
primrec
+ − 126
fold1
+ − 127
where
+ − 128
"fold1 f (g :: 'a \<Rightarrow> 'b) (z :: 'b) [] = z"
+ − 129
| "fold1 f g z (a # A) =
+ − 130
(if ((!u v. (f u v = f v u))
+ − 131
\<and> (!u v w. ((f u (f v w) = f (f u v) w))))
+ − 132
then (
+ − 133
if (a memb A) then (fold1 f g z A) else (f (g a) (fold1 f g z A))
+ − 134
) else z)"
+ − 135
+ − 136
(* fold1_def is not usable, but: *)
+ − 137
thm fold1.simps
+ − 138
+ − 139
lemma fs1_strong_cases:
+ − 140
fixes X :: "'a list"
+ − 141
shows "(X = []) \<or> (\<exists>a. \<exists> Y. (~(a memb Y) \<and> (X \<approx> a # Y)))"
+ − 142
apply (induct X)
+ − 143
apply (simp)
+ − 144
apply (metis QUOT_TYPE_I_fset.thm11 list_eq_refl mem_cons m1)
+ − 145
done
+ − 146
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
+ − 147
quotient_def (for "'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
+ − 148
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
+ − 149
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
+ − 150
"IN \<equiv> membship"
163
+ − 151
+ − 152
term membship
+ − 153
term IN
+ − 154
thm IN_def
+ − 155
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
+ − 156
(* FIXME: does not work yet
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
+ − 157
quotient_def (for "'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
+ − 158
FOLD :: "('b \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b"
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
+ − 159
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
+ − 160
"FOLD \<equiv> fold1"
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
+ − 161
*)
194
+ − 162
local_setup {*
218
+ − 163
old_make_const_def @{binding fold} @{term "fold1::('b \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b"} NoSyn @{typ "'a list"} @{typ "'a fset"} #> snd
194
+ − 164
*}
+ − 165
+ − 166
term fold1
+ − 167
term fold
+ − 168
thm fold_def
+ − 169
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
+ − 170
(* FIXME: does not work yet for all types*)
254
+ − 171
quotient_def (for "'a fset" "'b fset")
+ − 172
fmap::"('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
225
+ − 173
where
254
+ − 174
"fmap \<equiv> map"
194
+ − 175
+ − 176
term map
+ − 177
term fmap
+ − 178
thm fmap_def
+ − 179
239
+ − 180
ML {* val defs = @{thms EMPTY_def IN_def FUNION_def CARD_def INSERT_def fmap_def fold_def} *}
+ − 181
ML {* val consts = lookup_quot_consts defs *}
+ − 182
ML {* val defs_sym = add_lower_defs @{context} defs *}
163
+ − 183
164
+ − 184
lemma memb_rsp:
163
+ − 185
fixes z
+ − 186
assumes a: "list_eq x y"
+ − 187
shows "(z memb x) = (z memb y)"
+ − 188
using a by induct auto
+ − 189
164
+ − 190
lemma ho_memb_rsp:
+ − 191
"(op = ===> (op \<approx> ===> op =)) (op memb) (op memb)"
214
+ − 192
by (simp add: memb_rsp)
164
+ − 193
163
+ − 194
lemma card1_rsp:
+ − 195
fixes a b :: "'a list"
+ − 196
assumes e: "a \<approx> b"
+ − 197
shows "card1 a = card1 b"
214
+ − 198
using e by induct (simp_all add:memb_rsp)
163
+ − 199
228
+ − 200
lemma ho_card1_rsp: "(op \<approx> ===> op =) card1 card1"
214
+ − 201
by (simp add: card1_rsp)
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 202
164
+ − 203
lemma cons_rsp:
163
+ − 204
fixes z
+ − 205
assumes a: "xs \<approx> ys"
+ − 206
shows "(z # xs) \<approx> (z # ys)"
+ − 207
using a by (rule list_eq.intros(5))
+ − 208
164
+ − 209
lemma ho_cons_rsp:
228
+ − 210
"(op = ===> op \<approx> ===> op \<approx>) op # op #"
214
+ − 211
by (simp add: cons_rsp)
164
+ − 212
175
+ − 213
lemma append_rsp_fst:
163
+ − 214
assumes a : "list_eq l1 l2"
214
+ − 215
shows "(l1 @ s) \<approx> (l2 @ s)"
163
+ − 216
using a
214
+ − 217
by (induct) (auto intro: list_eq.intros list_eq_refl)
+ − 218
+ − 219
lemma append_end:
+ − 220
shows "(e # l) \<approx> (l @ [e])"
+ − 221
apply (induct l)
+ − 222
apply (auto intro: list_eq.intros list_eq_refl)
+ − 223
done
+ − 224
+ − 225
lemma rev_rsp:
+ − 226
shows "a \<approx> rev a"
+ − 227
apply (induct a)
+ − 228
apply simp
+ − 229
apply (rule list_eq_refl)
+ − 230
apply simp_all
+ − 231
apply (rule list_eq.intros(6))
+ − 232
prefer 2
+ − 233
apply (rule append_rsp_fst)
+ − 234
apply assumption
+ − 235
apply (rule append_end)
+ − 236
done
163
+ − 237
214
+ − 238
lemma append_sym_rsp:
+ − 239
shows "(a @ b) \<approx> (b @ a)"
+ − 240
apply (rule list_eq.intros(6))
+ − 241
apply (rule append_rsp_fst)
+ − 242
apply (rule rev_rsp)
+ − 243
apply (rule list_eq.intros(6))
+ − 244
apply (rule rev_rsp)
+ − 245
apply (simp)
+ − 246
apply (rule append_rsp_fst)
+ − 247
apply (rule list_eq.intros(3))
+ − 248
apply (rule rev_rsp)
+ − 249
done
+ − 250
+ − 251
lemma append_rsp:
+ − 252
assumes a : "list_eq l1 r1"
+ − 253
assumes b : "list_eq l2 r2 "
+ − 254
shows "(l1 @ l2) \<approx> (r1 @ r2)"
+ − 255
apply (rule list_eq.intros(6))
+ − 256
apply (rule append_rsp_fst)
+ − 257
using a apply (assumption)
+ − 258
apply (rule list_eq.intros(6))
+ − 259
apply (rule append_sym_rsp)
+ − 260
apply (rule list_eq.intros(6))
+ − 261
apply (rule append_rsp_fst)
+ − 262
using b apply (assumption)
+ − 263
apply (rule append_sym_rsp)
+ − 264
done
175
+ − 265
194
+ − 266
lemma ho_append_rsp:
228
+ − 267
"(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @"
214
+ − 268
by (simp add: append_rsp)
175
+ − 269
194
+ − 270
lemma map_rsp:
+ − 271
assumes a: "a \<approx> b"
+ − 272
shows "map f a \<approx> map f b"
+ − 273
using a
+ − 274
apply (induct)
+ − 275
apply(auto intro: list_eq.intros)
+ − 276
done
+ − 277
215
+ − 278
lemma fun_rel_id:
228
+ − 279
"(op = ===> op =) \<equiv> op ="
215
+ − 280
apply (rule eq_reflection)
+ − 281
apply (rule ext)
+ − 282
apply (rule ext)
+ − 283
apply (simp)
+ − 284
apply (auto)
+ − 285
apply (rule ext)
+ − 286
apply (simp)
+ − 287
done
+ − 288
194
+ − 289
lemma ho_map_rsp:
228
+ − 290
"((op = ===> op =) ===> op \<approx> ===> op \<approx>) map map"
215
+ − 291
by (simp add: fun_rel_id map_rsp)
194
+ − 292
+ − 293
lemma map_append :
258
+ − 294
"(map f (a @ b)) \<approx>
+ − 295
(map f a) @ (map f b)"
215
+ − 296
by simp (rule list_eq_refl)
194
+ − 297
241
60acf3d3a4a0
Finding applications and duplicates filtered out in abstractions
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 298
254
+ − 299
print_quotients
+ − 300
+ − 301
226
+ − 302
ML {* val qty = @{typ "'a fset"} *}
239
+ − 303
ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *}
+ − 304
ML {* val (trans2, reps_same, quot) = lookup_quot_thms @{context} "fset" *}
+ − 305
226
+ − 306
ML {* val rsp_thms =
+ − 307
@{thms ho_memb_rsp ho_cons_rsp ho_card1_rsp ho_map_rsp ho_append_rsp}
+ − 308
@ @{thms ho_all_prs ho_ex_prs} *}
206
+ − 309
239
+ − 310
ML {* fun lift_thm_fset lthy t = lift_thm lthy qty "fset" rsp_thms defs t *}
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 311
248
6ed87b3d358c
Finally merged the code of the versions of regularize and tested examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 312
(* ML {* lift_thm_fset @{context} @{thm neq_Nil_conv} *} *)
226
+ − 313
ML {* lift_thm_fset @{context} @{thm m1} *}
+ − 314
ML {* lift_thm_fset @{context} @{thm m2} *}
+ − 315
ML {* lift_thm_fset @{context} @{thm list_eq.intros(4)} *}
+ − 316
ML {* lift_thm_fset @{context} @{thm list_eq.intros(5)} *}
+ − 317
ML {* lift_thm_fset @{context} @{thm card1_suc} *}
258
+ − 318
(*ML {* lift_thm_fset @{context} @{thm map_append} *}*)
251
+ − 319
ML {* lift_thm_fset @{context} @{thm append_assoc} *}
267
3764566c1151
Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 320
ML {* lift_thm_fset @{context} @{thm list.induct} *}
171
13aab4c59096
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 321
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 322
thm fold1.simps(2)
173
7cf227756e2a
Finally completely lift the previously lifted theorems + clean some old stuff
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 323
thm list.recs(2)
248
6ed87b3d358c
Finally merged the code of the versions of regularize and tested examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 324
thm list.cases
6ed87b3d358c
Finally merged the code of the versions of regularize and tested examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 325
252
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 326
ML {* val ind_r_a = atomize_thm @{thm list.induct} *}
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 327
(* prove {* build_regularize_goal ind_r_a rty rel @{context} *}
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 328
ML_prf {* fun tac ctxt =
251
+ − 329
(FIRST' [
+ − 330
rtac rel_refl,
+ − 331
atac,
252
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 332
rtac @{thm get_rid},
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 333
rtac @{thm get_rid2},
251
+ − 334
(fn i => CHANGED (asm_full_simp_tac ((Simplifier.context ctxt HOL_ss) addsimps
239
+ − 335
[(@{thm equiv_res_forall} OF [rel_eqv]),
251
+ − 336
(@{thm equiv_res_exists} OF [rel_eqv])]) i)),
252
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 337
(rtac @{thm impI} THEN' (asm_full_simp_tac (Simplifier.context ctxt HOL_ss)) THEN' rtac rel_refl),
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 338
(rtac @{thm RIGHT_RES_FORALL_REGULAR})
251
+ − 339
]);
+ − 340
*}
252
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 341
apply (atomize(full))
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 342
apply (tactic {* tac @{context} 1 *}) *)
e30997c88050
Regularize for equalities and a better tactic. "alpha.cases" now lifts.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 343
ML {* val ind_r_r = regularize ind_r_a rty rel rel_eqv rel_refl @{context} *}
267
3764566c1151
Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 344
(*ML {*
239
+ − 345
val rt = build_repabs_term @{context} ind_r_r consts rty qty
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 346
val rg = Logic.mk_equals ((Thm.prop_of ind_r_r), rt);
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 347
*}
257
+ − 348
prove rg
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 349
apply(atomize(full))
257
+ − 350
ML_prf {* fun r_mk_comb_tac_fset lthy = r_mk_comb_tac lthy rty quot rel_refl trans2 rsp_thms *}
194
+ − 351
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_fset @{context}) 1 *})
226
+ − 352
done*)
210
+ − 353
ML {* val ind_r_t =
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 354
Toplevel.program (fn () =>
239
+ − 355
repabs @{context} ind_r_r consts rty qty quot rel_refl trans2 rsp_thms
172
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 356
)
da38ce2711a6
More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 357
*}
241
60acf3d3a4a0
Finding applications and duplicates filtered out in abstractions
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 358
226
+ − 359
ML {* val abs = findabs rty (prop_of (atomize_thm @{thm list.induct})) *}
241
60acf3d3a4a0
Finding applications and duplicates filtered out in abstractions
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 360
ML {* val aps = findaps rty (prop_of (atomize_thm @{thm list.induct})) *}
253
e169a99c6ada
Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 361
ML {* val simp_app_prs_thms = map (make_simp_prs_thm @{context} quot @{thm APP_PRS}) aps *}
267
3764566c1151
Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 362
thm APP_PRS
3764566c1151
Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 363
ML aps
253
e169a99c6ada
Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 364
ML {* val simp_lam_prs_thms = map (make_simp_prs_thm @{context} quot @{thm LAMBDA_PRS}) abs *}
e169a99c6ada
Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 365
ML {* val ind_r_l = repeat_eqsubst_thm @{context} (simp_app_prs_thms @ simp_lam_prs_thms) ind_r_t *}
260
59578f428bbe
Fixes after optimization and preparing for a general FORALL_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 366
ML {* val thm = @{thm FORALL_PRS[OF FUN_QUOTIENT[OF QUOTIENT_fset IDENTITY_QUOTIENT]]} *}
59578f428bbe
Fixes after optimization and preparing for a general FORALL_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 367
ML {* val ind_r_a = simp_allex_prs quot [thm] ind_r_l *}
226
+ − 368
ML {* val defs_sym = add_lower_defs @{context} defs *}
260
59578f428bbe
Fixes after optimization and preparing for a general FORALL_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 369
ML {* val ind_r_d = repeat_eqsubst_thm @{context} defs_sym ind_r_a *}
178
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 370
ML {* val ind_r_s = MetaSimplifier.rewrite_rule @{thms QUOT_TYPE_I_fset.REPS_same} ind_r_d *}
209
+ − 371
ML {* ObjectLogic.rulify ind_r_s *}
178
945786a68ec6
Finally lifted induction, with some manually added simplification lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 372
163
+ − 373
ML {*
226
+ − 374
fun lift_thm_fset_note name thm lthy =
163
+ − 375
let
226
+ − 376
val lifted_thm = lift_thm_fset lthy thm;
163
+ − 377
val (_, lthy2) = note (name, lifted_thm) lthy;
+ − 378
in
+ − 379
lthy2
+ − 380
end;
+ − 381
*}
+ − 382
226
+ − 383
local_setup {*
+ − 384
lift_thm_fset_note @{binding "m1l"} @{thm m1} #>
+ − 385
lift_thm_fset_note @{binding "m2l"} @{thm m2} #>
+ − 386
lift_thm_fset_note @{binding "leqi4l"} @{thm list_eq.intros(4)} #>
+ − 387
lift_thm_fset_note @{binding "leqi5l"} @{thm list_eq.intros(5)}
163
+ − 388
*}
226
+ − 389
thm m1l
+ − 390
thm m2l
+ − 391
thm leqi4l
+ − 392
thm leqi5l
163
+ − 393
+ − 394
end