0
+ − 1
theory QuotMain
6
+ − 2
imports QuotScript QuotList Prove
264
+ − 3
uses ("quotient_info.ML")
+ − 4
("quotient.ML")
277
+ − 5
("quotient_def.ML")
0
+ − 6
begin
+ − 7
471
+ − 8
ML {*
+ − 9
let
+ − 10
val parser = Args.context -- Scan.lift Args.name_source
+ − 11
fun term_pat (ctxt, str) =
+ − 12
str |> ProofContext.read_term_pattern ctxt
+ − 13
|> ML_Syntax.print_term
+ − 14
|> ML_Syntax.atomic
+ − 15
in
+ − 16
ML_Antiquote.inline "term_pat" (parser >> term_pat)
+ − 17
end
+ − 18
*}
+ − 19
+ − 20
ML {*
+ − 21
fun make_inst lhs t =
+ − 22
let
+ − 23
val _ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u)) = lhs;
+ − 24
val _ $ (Abs (_, _, g)) = t;
484
+ − 25
+ − 26
fun mk_abs i t =
471
+ − 27
if incr_boundvars i u aconv t then Bound i
+ − 28
else (case t of
+ − 29
t1 $ t2 => mk_abs i t1 $ mk_abs i t2
+ − 30
| Abs (s, T, t') => Abs (s, T, mk_abs (i + 1) t')
+ − 31
| Bound j => if i = j then error "make_inst" else t
+ − 32
| _ => t);
484
+ − 33
471
+ − 34
in (f, Abs ("x", T, mk_abs 0 g)) end;
+ − 35
*}
+ − 36
+ − 37
ML {*
+ − 38
val trm1 = @{term_pat "(P::(nat\<Rightarrow>bool)\<Rightarrow>bool) (\<lambda>(x::nat). (?f ((g::nat\<Rightarrow>nat) x)))"};
+ − 39
val trm2 = @{term_pat "(P::(nat\<Rightarrow>bool)\<Rightarrow>bool) (\<lambda>(x::nat). (h (g x) ((g::nat\<Rightarrow>nat) x)))"}
+ − 40
*}
+ − 41
+ − 42
ML {*
+ − 43
fun test trm =
+ − 44
case trm of
+ − 45
(_ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u))) => (1,f)
+ − 46
| (_ $ (Abs (_, _, (f as (Var (_, _)) $ u)))) => (2,f)
+ − 47
| (_ $ (Abs (_, _, (f $ u)))) => (3,f)
+ − 48
*}
+ − 49
+ − 50
ML {* test trm1 *}
+ − 51
+ − 52
ML {*
+ − 53
make_inst trm1 trm2
+ − 54
|> pairself (Syntax.string_of_term @{context})
+ − 55
|> pairself writeln
+ − 56
*}
+ − 57
+ − 58
+ − 59
+ − 60
0
+ − 61
locale QUOT_TYPE =
+ − 62
fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
+ − 63
and Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b"
+ − 64
and Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)"
+ − 65
assumes equiv: "EQUIV R"
+ − 66
and rep_prop: "\<And>y. \<exists>x. Rep y = R x"
+ − 67
and rep_inverse: "\<And>x. Abs (Rep x) = x"
+ − 68
and abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)"
+ − 69
and rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)"
15
+ − 70
begin
0
+ − 71
+ − 72
definition
200
+ − 73
ABS::"'a \<Rightarrow> 'b"
+ − 74
where
0
+ − 75
"ABS x \<equiv> Abs (R x)"
+ − 76
+ − 77
definition
200
+ − 78
REP::"'b \<Rightarrow> 'a"
+ − 79
where
0
+ − 80
"REP a = Eps (Rep a)"
+ − 81
15
+ − 82
lemma lem9:
0
+ − 83
shows "R (Eps (R x)) = R x"
+ − 84
proof -
+ − 85
have a: "R x x" using equiv by (simp add: EQUIV_REFL_SYM_TRANS REFL_def)
+ − 86
then have "R x (Eps (R x))" by (rule someI)
15
+ − 87
then show "R (Eps (R x)) = R x"
0
+ − 88
using equiv unfolding EQUIV_def by simp
+ − 89
qed
+ − 90
+ − 91
theorem thm10:
24
+ − 92
shows "ABS (REP a) \<equiv> a"
+ − 93
apply (rule eq_reflection)
+ − 94
unfolding ABS_def REP_def
0
+ − 95
proof -
15
+ − 96
from rep_prop
0
+ − 97
obtain x where eq: "Rep a = R x" by auto
+ − 98
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp
+ − 99
also have "\<dots> = Abs (R x)" using lem9 by simp
+ − 100
also have "\<dots> = Abs (Rep a)" using eq by simp
+ − 101
also have "\<dots> = a" using rep_inverse by simp
+ − 102
finally
+ − 103
show "Abs (R (Eps (Rep a))) = a" by simp
+ − 104
qed
+ − 105
15
+ − 106
lemma REP_refl:
0
+ − 107
shows "R (REP a) (REP a)"
+ − 108
unfolding REP_def
+ − 109
by (simp add: equiv[simplified EQUIV_def])
+ − 110
+ − 111
lemma lem7:
22
+ − 112
shows "(R x = R y) = (Abs (R x) = Abs (R y))"
0
+ − 113
apply(rule iffI)
+ − 114
apply(simp)
+ − 115
apply(drule rep_inject[THEN iffD2])
+ − 116
apply(simp add: abs_inverse)
+ − 117
done
15
+ − 118
0
+ − 119
theorem thm11:
+ − 120
shows "R r r' = (ABS r = ABS r')"
+ − 121
unfolding ABS_def
+ − 122
by (simp only: equiv[simplified EQUIV_def] lem7)
+ − 123
4
+ − 124
2
+ − 125
lemma REP_ABS_rsp:
4
+ − 126
shows "R f (REP (ABS g)) = R f g"
+ − 127
and "R (REP (ABS g)) f = R g f"
23
+ − 128
by (simp_all add: thm10 thm11)
4
+ − 129
0
+ − 130
lemma QUOTIENT:
+ − 131
"QUOTIENT R ABS REP"
+ − 132
apply(unfold QUOTIENT_def)
+ − 133
apply(simp add: thm10)
+ − 134
apply(simp add: REP_refl)
+ − 135
apply(subst thm11[symmetric])
+ − 136
apply(simp add: equiv[simplified EQUIV_def])
+ − 137
done
+ − 138
21
+ − 139
lemma R_trans:
49
+ − 140
assumes ab: "R a b"
+ − 141
and bc: "R b c"
22
+ − 142
shows "R a c"
21
+ − 143
proof -
+ − 144
have tr: "TRANS R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp
+ − 145
moreover have ab: "R a b" by fact
+ − 146
moreover have bc: "R b c" by fact
22
+ − 147
ultimately show "R a c" unfolding TRANS_def by blast
21
+ − 148
qed
+ − 149
+ − 150
lemma R_sym:
49
+ − 151
assumes ab: "R a b"
22
+ − 152
shows "R b a"
21
+ − 153
proof -
+ − 154
have re: "SYM R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp
22
+ − 155
then show "R b a" using ab unfolding SYM_def by blast
21
+ − 156
qed
+ − 157
49
+ − 158
lemma R_trans2:
+ − 159
assumes ac: "R a c"
22
+ − 160
and bd: "R b d"
21
+ − 161
shows "R a b = R c d"
200
+ − 162
using ac bd
+ − 163
by (blast intro: R_trans R_sym)
21
+ − 164
+ − 165
lemma REPS_same:
25
+ − 166
shows "R (REP a) (REP b) \<equiv> (a = b)"
38
+ − 167
proof -
+ − 168
have "R (REP a) (REP b) = (a = b)"
+ − 169
proof
+ − 170
assume as: "R (REP a) (REP b)"
+ − 171
from rep_prop
+ − 172
obtain x y
+ − 173
where eqs: "Rep a = R x" "Rep b = R y" by blast
+ − 174
from eqs have "R (Eps (R x)) (Eps (R y))" using as unfolding REP_def by simp
+ − 175
then have "R x (Eps (R y))" using lem9 by simp
+ − 176
then have "R (Eps (R y)) x" using R_sym by blast
+ − 177
then have "R y x" using lem9 by simp
+ − 178
then have "R x y" using R_sym by blast
+ − 179
then have "ABS x = ABS y" using thm11 by simp
+ − 180
then have "Abs (Rep a) = Abs (Rep b)" using eqs unfolding ABS_def by simp
+ − 181
then show "a = b" using rep_inverse by simp
+ − 182
next
+ − 183
assume ab: "a = b"
+ − 184
have "REFL R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp
+ − 185
then show "R (REP a) (REP b)" unfolding REFL_def using ab by auto
+ − 186
qed
+ − 187
then show "R (REP a) (REP b) \<equiv> (a = b)" by simp
21
+ − 188
qed
+ − 189
0
+ − 190
end
+ − 191
458
+ − 192
(* EQUALS_RSP is stronger *)
419
+ − 193
lemma equiv_trans2:
+ − 194
assumes e: "EQUIV R"
+ − 195
and ac: "R a c"
+ − 196
and bd: "R b d"
+ − 197
shows "R a b = R c d"
+ − 198
using ac bd e
+ − 199
unfolding EQUIV_REFL_SYM_TRANS TRANS_def SYM_def
+ − 200
by (blast)
+ − 201
0
+ − 202
section {* type definition for the quotient type *}
+ − 203
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
+ − 204
(* the auxiliary data for the quotient types *)
264
+ − 205
use "quotient_info.ML"
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
+ − 206
185
+ − 207
declare [[map list = (map, LIST_REL)]]
+ − 208
declare [[map * = (prod_fun, prod_rel)]]
+ − 209
declare [[map "fun" = (fun_map, FUN_REL)]]
+ − 210
+ − 211
ML {* maps_lookup @{theory} "List.list" *}
+ − 212
ML {* maps_lookup @{theory} "*" *}
+ − 213
ML {* maps_lookup @{theory} "fun" *}
174
+ − 214
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
+ − 215
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
+ − 216
(* definition of the quotient types *)
277
+ − 217
(* FIXME: should be called quotient_typ.ML *)
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
+ − 218
use "quotient.ML"
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
+ − 219
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
+ − 220
277
+ − 221
(* lifting of constants *)
+ − 222
use "quotient_def.ML"
+ − 223
381
+ − 224
(* TODO: Consider defining it with an "if"; sth like:
+ − 225
Babs p m = \<lambda>x. if x \<in> p then m x else undefined
+ − 226
*)
+ − 227
definition
+ − 228
Babs :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
+ − 229
where
+ − 230
"(x \<in> p) \<Longrightarrow> (Babs p m x = m x)"
310
fec6301a1989
added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 231
139
+ − 232
section {* ATOMIZE *}
+ − 233
381
+ − 234
lemma atomize_eqv[atomize]:
+ − 235
shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)"
139
+ − 236
proof
381
+ − 237
assume "A \<equiv> B"
139
+ − 238
then show "Trueprop A \<equiv> Trueprop B" by unfold
+ − 239
next
+ − 240
assume *: "Trueprop A \<equiv> Trueprop B"
+ − 241
have "A = B"
+ − 242
proof (cases A)
+ − 243
case True
+ − 244
have "A" by fact
+ − 245
then show "A = B" using * by simp
+ − 246
next
+ − 247
case False
+ − 248
have "\<not>A" by fact
+ − 249
then show "A = B" using * by auto
+ − 250
qed
+ − 251
then show "A \<equiv> B" by (rule eq_reflection)
+ − 252
qed
+ − 253
+ − 254
ML {*
+ − 255
fun atomize_thm thm =
+ − 256
let
221
+ − 257
val thm' = Thm.freezeT (forall_intr_vars thm)
139
+ − 258
val thm'' = ObjectLogic.atomize (cprop_of thm')
+ − 259
in
404
+ − 260
@{thm equal_elim_rule1} OF [thm'', thm']
139
+ − 261
end
+ − 262
*}
+ − 263
387
+ − 264
section {* infrastructure about id *}
381
+ − 265
+ − 266
lemma prod_fun_id: "prod_fun id id \<equiv> id"
415
+ − 267
by (rule eq_reflection) (simp add: prod_fun_def)
381
+ − 268
+ − 269
lemma map_id: "map id \<equiv> id"
415
+ − 270
apply (rule eq_reflection)
+ − 271
apply (rule ext)
+ − 272
apply (rule_tac list="x" in list.induct)
+ − 273
apply (simp_all)
+ − 274
done
381
+ − 275
409
+ − 276
lemmas id_simps =
+ − 277
FUN_MAP_I[THEN eq_reflection]
+ − 278
id_apply[THEN eq_reflection]
415
+ − 279
id_def[THEN eq_reflection,symmetric]
+ − 280
prod_fun_id map_id
409
+ − 281
381
+ − 282
ML {*
409
+ − 283
fun simp_ids thm =
+ − 284
MetaSimplifier.rewrite_rule @{thms id_simps} thm
381
+ − 285
*}
+ − 286
407
+ − 287
section {* Debugging infrastructure for testing tactics *}
381
+ − 288
447
3e7ee6f5437d
selective debugging of the inj_repabs_tac (at the moment for step 3 and 4 debugging information is printed)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 289
ML {*
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 290
fun my_print_tac ctxt s i thm =
407
+ − 291
let
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 292
val prem_str = nth (prems_of thm) (i - 1)
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 293
|> Syntax.string_of_term ctxt
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 294
handle Subscript => "no subgoal"
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 295
val _ = tracing (s ^ "\n" ^ prem_str)
407
+ − 296
in
+ − 297
Seq.single thm
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 298
end *}
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 299
407
+ − 300
447
3e7ee6f5437d
selective debugging of the inj_repabs_tac (at the moment for step 3 and 4 debugging information is printed)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 301
ML {*
3e7ee6f5437d
selective debugging of the inj_repabs_tac (at the moment for step 3 and 4 debugging information is printed)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 302
fun DT ctxt s tac i thm =
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 303
let
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 304
val before_goal = nth (prems_of thm) (i - 1)
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 305
|> Syntax.string_of_term ctxt
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 306
val before_msg = ["before: " ^ s, before_goal, "after: " ^ s]
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 307
|> cat_lines
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 308
in
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 309
EVERY [tac i, my_print_tac ctxt before_msg i] thm
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 310
end
444
+ − 311
447
3e7ee6f5437d
selective debugging of the inj_repabs_tac (at the moment for step 3 and 4 debugging information is printed)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 312
fun NDT ctxt s tac thm = tac thm
407
+ − 313
*}
+ − 314
453
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 315
407
+ − 316
section {* Infrastructure for collecting theorems for starting the lifting *}
267
3764566c1151
Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 317
3764566c1151
Automatic FORALL_PRS. 'list.induct' lifts automatically. Faster ALLEX_RSP
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 318
ML {*
239
+ − 319
fun lookup_quot_data lthy qty =
+ − 320
let
311
+ − 321
val qty_name = fst (dest_Type qty)
314
+ − 322
val SOME quotdata = quotdata_lookup lthy qty_name
311
+ − 323
(* cu: Changed the lookup\<dots>not sure whether this works *)
303
+ − 324
(* TODO: Should no longer be needed *)
257
+ − 325
val rty = Logic.unvarifyT (#rtyp quotdata)
239
+ − 326
val rel = #rel quotdata
+ − 327
val rel_eqv = #equiv_thm quotdata
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 328
val rel_refl = @{thm EQUIV_REFL} OF [rel_eqv]
239
+ − 329
in
+ − 330
(rty, rel, rel_refl, rel_eqv)
+ − 331
end
+ − 332
*}
+ − 333
+ − 334
ML {*
+ − 335
fun lookup_quot_thms lthy qty_name =
+ − 336
let
+ − 337
val thy = ProofContext.theory_of lthy;
+ − 338
val trans2 = PureThy.get_thm thy ("QUOT_TYPE_I_" ^ qty_name ^ ".R_trans2")
+ − 339
val reps_same = PureThy.get_thm thy ("QUOT_TYPE_I_" ^ qty_name ^ ".REPS_same")
269
+ − 340
val absrep = PureThy.get_thm thy ("QUOT_TYPE_I_" ^ qty_name ^ ".thm10")
239
+ − 341
val quot = PureThy.get_thm thy ("QUOTIENT_" ^ qty_name)
+ − 342
in
269
+ − 343
(trans2, reps_same, absrep, quot)
239
+ − 344
end
+ − 345
*}
+ − 346
+ − 347
ML {*
+ − 348
fun lookup_quot_consts defs =
+ − 349
let
+ − 350
fun dest_term (a $ b) = (a, b);
+ − 351
val def_terms = map (snd o Logic.dest_equals o concl_of) defs;
+ − 352
in
+ − 353
map (fst o dest_Const o snd o dest_term) def_terms
+ − 354
end
+ − 355
*}
+ − 356
402
+ − 357
section {* Regularization *}
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 358
383
+ − 359
(*
+ − 360
Regularizing an rtrm means:
+ − 361
- quantifiers over a type that needs lifting are replaced by
+ − 362
bounded quantifiers, for example:
+ − 363
\<forall>x. P \<Longrightarrow> \<forall>x \<in> (Respects R). P / All (Respects R) P
+ − 364
+ − 365
the relation R is given by the rty and qty;
330
+ − 366
383
+ − 367
- abstractions over a type that needs lifting are replaced
+ − 368
by bounded abstractions:
+ − 369
\<lambda>x. P \<Longrightarrow> Ball (Respects R) (\<lambda>x. P)
+ − 370
+ − 371
- equalities over the type being lifted are replaced by
+ − 372
corresponding relations:
+ − 373
A = B \<Longrightarrow> A \<approx> B
+ − 374
+ − 375
example with more complicated types of A, B:
+ − 376
A = B \<Longrightarrow> (op = \<Longrightarrow> op \<approx>) A B
+ − 377
*)
+ − 378
404
+ − 379
ML {*
383
+ − 380
(* builds the relation that is the argument of respects *)
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 381
fun mk_resp_arg lthy (rty, qty) =
319
+ − 382
let
+ − 383
val thy = ProofContext.theory_of lthy
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 384
in
334
+ − 385
if rty = qty
+ − 386
then HOLogic.eq_const rty
+ − 387
else
+ − 388
case (rty, qty) of
+ − 389
(Type (s, tys), Type (s', tys')) =>
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 390
if s = s'
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 391
then let
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 392
val SOME map_info = maps_lookup thy s
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 393
val args = map (mk_resp_arg lthy) (tys ~~ tys')
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 394
in
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 395
list_comb (Const (#relfun map_info, dummyT), args)
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 396
end
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 397
else let
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 398
val SOME qinfo = quotdata_lookup_thy thy s'
330
+ − 399
(* FIXME: check in this case that the rty and qty *)
+ − 400
(* FIXME: correspond to each other *)
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
+ − 401
val (s, _) = dest_Const (#rel qinfo)
407
+ − 402
(* FIXME: the relation should only be the string *)
+ − 403
(* FIXME: and the type needs to be calculated as below; *)
+ − 404
(* FIXME: maybe one should actually have a term *)
+ − 405
(* FIXME: and one needs to force it to have this type *)
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 406
in
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
+ − 407
Const (s, rty --> rty --> @{typ bool})
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 408
end
334
+ − 409
| _ => HOLogic.eq_const dummyT
351
+ − 410
(* FIXME: check that the types correspond to each other? *)
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 411
end
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 412
*}
239
+ − 413
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 414
ML {*
467
+ − 415
val mk_babs = Const (@{const_name Babs}, dummyT)
+ − 416
val mk_ball = Const (@{const_name Ball}, dummyT)
+ − 417
val mk_bex = Const (@{const_name Bex}, dummyT)
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 418
val mk_resp = Const (@{const_name Respects}, dummyT)
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 419
*}
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 420
323
+ − 421
ML {*
330
+ − 422
(* - applies f to the subterm of an abstraction, *)
+ − 423
(* otherwise to the given term, *)
405
+ − 424
(* - used by regularize, therefore abstracted *)
330
+ − 425
(* variables do not have to be treated specially *)
+ − 426
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 427
fun apply_subt f trm1 trm2 =
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 428
case (trm1, trm2) of
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 429
(Abs (x, T, t), Abs (x', T', t')) => Abs (x, T, f t t')
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 430
| _ => f trm1 trm2
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 431
330
+ − 432
(* the major type of All and Ex quantifiers *)
334
+ − 433
fun qnt_typ ty = domain_type (domain_type ty)
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 434
*}
319
+ − 435
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 436
ML {*
330
+ − 437
(* produces a regularized version of rtm *)
+ − 438
(* - the result is still not completely typed *)
+ − 439
(* - does not need any special treatment of *)
+ − 440
(* bound variables *)
+ − 441
405
+ − 442
fun regularize_trm lthy rtrm qtrm =
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 443
case (rtrm, qtrm) of
325
+ − 444
(Abs (x, ty, t), Abs (x', ty', t')) =>
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 445
let
405
+ − 446
val subtrm = regularize_trm lthy t t'
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 447
in
325
+ − 448
if ty = ty'
+ − 449
then Abs (x, ty, subtrm)
326
+ − 450
else mk_babs $ (mk_resp $ mk_resp_arg lthy (ty, ty')) $ subtrm
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 451
end
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 452
| (Const (@{const_name "All"}, ty) $ t, Const (@{const_name "All"}, ty') $ t') =>
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 453
let
405
+ − 454
val subtrm = apply_subt (regularize_trm lthy) t t'
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 455
in
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 456
if ty = ty'
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 457
then Const (@{const_name "All"}, ty) $ subtrm
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 458
else mk_ball $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 459
end
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 460
| (Const (@{const_name "Ex"}, ty) $ t, Const (@{const_name "Ex"}, ty') $ t') =>
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 461
let
405
+ − 462
val subtrm = apply_subt (regularize_trm lthy) t t'
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 463
in
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 464
if ty = ty'
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 465
then Const (@{const_name "Ex"}, ty) $ subtrm
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 466
else mk_bex $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 467
end
351
+ − 468
(* FIXME: Should = only be replaced, when fully applied? *)
+ − 469
(* Then there must be a 2nd argument *)
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 470
| (Const (@{const_name "op ="}, ty) $ t, Const (@{const_name "op ="}, ty') $ t') =>
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 471
let
405
+ − 472
val subtrm = regularize_trm lthy t t'
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 473
in
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 474
if ty = ty'
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 475
then Const (@{const_name "op ="}, ty) $ subtrm
349
+ − 476
else mk_resp_arg lthy (domain_type ty, domain_type ty') $ subtrm
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 477
end
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 478
| (t1 $ t2, t1' $ t2') =>
405
+ − 479
(regularize_trm lthy t1 t1') $ (regularize_trm lthy t2 t2')
453
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 480
| (Free (x, ty), Free (x', ty')) =>
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 481
(* this case cannot arrise as we start with two fully atomized terms *)
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 482
raise (LIFT_MATCH "regularize (frees)")
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 483
| (Bound i, Bound i') =>
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 484
if i = i'
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 485
then rtrm
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 486
else raise (LIFT_MATCH "regularize (bounds)")
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 487
| (Const (s, ty), Const (s', ty')) =>
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 488
if s = s' andalso ty = ty'
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 489
then rtrm
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 490
else rtrm (* FIXME: check correspondence according to definitions *)
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 491
| (rt, qt) =>
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 492
raise (LIFT_MATCH "regularize (default)")
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 493
*}
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 494
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 495
(*
407
+ − 496
FIXME / TODO: needs to be adapted
+ − 497
383
+ − 498
To prove that the raw theorem implies the regularised one,
+ − 499
we try in order:
330
+ − 500
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 501
- Reflexivity of the relation
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 502
- Assumption
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 503
- Elimnating quantifiers on both sides of toplevel implication
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 504
- Simplifying implications on both sides of toplevel implication
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 505
- Ball (Respects ?E) ?P = All ?P
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 506
- (\<And>x. ?R x \<Longrightarrow> ?P x \<longrightarrow> ?Q x) \<Longrightarrow> All ?P \<longrightarrow> Ball ?R ?Q
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 507
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 508
*)
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 509
442
7beed9b75ea2
renamed LAMBDA_RES_TAC and WEAK_LAMBDA_RES_TAC to lower case names
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 510
(* FIXME: they should be in in the new Isabelle *)
404
+ − 511
lemma [mono]:
+ − 512
"(\<And>x. P x \<longrightarrow> Q x) \<Longrightarrow> (Ex P) \<longrightarrow> (Ex Q)"
400
+ − 513
by blast
+ − 514
+ − 515
lemma [mono]: "P \<longrightarrow> Q \<Longrightarrow> \<not>Q \<longrightarrow> \<not>P"
+ − 516
by auto
+ − 517
+ − 518
(* FIXME: OPTION_EQUIV, PAIR_EQUIV, ... *)
+ − 519
ML {*
+ − 520
fun equiv_tac rel_eqvs =
420
+ − 521
REPEAT_ALL_NEW (FIRST'
+ − 522
[resolve_tac rel_eqvs,
+ − 523
rtac @{thm IDENTITY_EQUIV},
+ − 524
rtac @{thm LIST_EQUIV}])
400
+ − 525
*}
+ − 526
+ − 527
ML {*
432
+ − 528
fun ball_reg_eqv_simproc rel_eqvs ss redex =
+ − 529
let
+ − 530
val ctxt = Simplifier.the_context ss
+ − 531
val thy = ProofContext.theory_of ctxt
+ − 532
in
+ − 533
case redex of
+ − 534
(ogl as ((Const (@{const_name "Ball"}, _)) $
+ − 535
((Const (@{const_name "Respects"}, _)) $ R) $ P1)) =>
+ − 536
(let
+ − 537
val gl = Const (@{const_name "EQUIV"}, dummyT) $ R;
+ − 538
val glc = HOLogic.mk_Trueprop (Syntax.check_term ctxt gl);
+ − 539
val eqv = Goal.prove ctxt [] [] glc (fn _ => equiv_tac rel_eqvs 1);
+ − 540
val thm = (@{thm eq_reflection} OF [@{thm ball_reg_eqv} OF [eqv]]);
+ − 541
(* val _ = tracing (Syntax.string_of_term ctxt (prop_of thm)); *)
+ − 542
in
+ − 543
SOME thm
+ − 544
end
+ − 545
handle _ => NONE
+ − 546
)
+ − 547
| _ => NONE
+ − 548
end
+ − 549
*}
+ − 550
+ − 551
ML {*
+ − 552
fun bex_reg_eqv_simproc rel_eqvs ss redex =
+ − 553
let
+ − 554
val ctxt = Simplifier.the_context ss
+ − 555
val thy = ProofContext.theory_of ctxt
+ − 556
in
+ − 557
case redex of
+ − 558
(ogl as ((Const (@{const_name "Bex"}, _)) $
+ − 559
((Const (@{const_name "Respects"}, _)) $ R) $ P1)) =>
+ − 560
(let
+ − 561
val gl = Const (@{const_name "EQUIV"}, dummyT) $ R;
+ − 562
val glc = HOLogic.mk_Trueprop (Syntax.check_term ctxt gl);
+ − 563
val eqv = Goal.prove ctxt [] [] glc (fn _ => equiv_tac rel_eqvs 1);
+ − 564
val thm = (@{thm eq_reflection} OF [@{thm bex_reg_eqv} OF [eqv]]);
+ − 565
(* val _ = tracing (Syntax.string_of_term ctxt (prop_of thm)); *)
+ − 566
in
+ − 567
SOME thm
+ − 568
end
+ − 569
handle _ => NONE
+ − 570
)
+ − 571
| _ => NONE
+ − 572
end
+ − 573
*}
+ − 574
+ − 575
ML {*
+ − 576
fun prep_trm thy (x, (T, t)) =
+ − 577
(cterm_of thy (Var (x, T)), cterm_of thy t)
+ − 578
+ − 579
fun prep_ty thy (x, (S, ty)) =
+ − 580
(ctyp_of thy (TVar (x, S)), ctyp_of thy ty)
+ − 581
*}
+ − 582
+ − 583
ML {*
+ − 584
fun matching_prs thy pat trm =
+ − 585
let
+ − 586
val univ = Unify.matchers thy [(pat, trm)]
+ − 587
val SOME (env, _) = Seq.pull univ
+ − 588
val tenv = Vartab.dest (Envir.term_env env)
+ − 589
val tyenv = Vartab.dest (Envir.type_env env)
+ − 590
in
+ − 591
(map (prep_ty thy) tyenv, map (prep_trm thy) tenv)
+ − 592
end
400
+ − 593
*}
+ − 594
+ − 595
ML {*
432
+ − 596
fun ball_reg_eqv_range_simproc rel_eqvs ss redex =
400
+ − 597
let
432
+ − 598
val ctxt = Simplifier.the_context ss
+ − 599
val thy = ProofContext.theory_of ctxt
400
+ − 600
in
432
+ − 601
case redex of
+ − 602
(ogl as ((Const (@{const_name "Ball"}, _)) $
+ − 603
((Const (@{const_name "Respects"}, _)) $ ((Const (@{const_name "FUN_REL"}, _)) $ R1 $ R2)) $ _)) =>
+ − 604
(let
+ − 605
val gl = Const (@{const_name "EQUIV"}, dummyT) $ R2;
+ − 606
val glc = HOLogic.mk_Trueprop (Syntax.check_term ctxt gl);
+ − 607
val _ = tracing (Syntax.string_of_term ctxt glc);
+ − 608
val eqv = Goal.prove ctxt [] [] glc (fn _ => equiv_tac rel_eqvs 1);
+ − 609
val thm = (@{thm eq_reflection} OF [@{thm ball_reg_eqv_range} OF [eqv]]);
+ − 610
val R1c = cterm_of thy R1;
+ − 611
val thmi = Drule.instantiate' [] [SOME R1c] thm;
+ − 612
(* val _ = tracing (Syntax.string_of_term ctxt (prop_of thmi)); *)
+ − 613
val inst = matching_prs thy (term_of (Thm.lhs_of thmi)) ogl
+ − 614
val _ = tracing "AAA";
+ − 615
val thm2 = Drule.eta_contraction_rule (Drule.instantiate inst thmi);
+ − 616
val _ = tracing (Syntax.string_of_term ctxt (prop_of thm2));
+ − 617
in
+ − 618
SOME thm2
+ − 619
end
+ − 620
handle _ => NONE
+ − 621
+ − 622
)
+ − 623
| _ => NONE
400
+ − 624
end
+ − 625
*}
432
+ − 626
+ − 627
ML {*
+ − 628
fun bex_reg_eqv_range_simproc rel_eqvs ss redex =
+ − 629
let
+ − 630
val ctxt = Simplifier.the_context ss
+ − 631
val thy = ProofContext.theory_of ctxt
+ − 632
in
+ − 633
case redex of
+ − 634
(ogl as ((Const (@{const_name "Bex"}, _)) $
+ − 635
((Const (@{const_name "Respects"}, _)) $ ((Const (@{const_name "FUN_REL"}, _)) $ R1 $ R2)) $ _)) =>
+ − 636
(let
+ − 637
val gl = Const (@{const_name "EQUIV"}, dummyT) $ R2;
+ − 638
val glc = HOLogic.mk_Trueprop (Syntax.check_term ctxt gl);
+ − 639
val _ = tracing (Syntax.string_of_term ctxt glc);
+ − 640
val eqv = Goal.prove ctxt [] [] glc (fn _ => equiv_tac rel_eqvs 1);
+ − 641
val thm = (@{thm eq_reflection} OF [@{thm bex_reg_eqv_range} OF [eqv]]);
+ − 642
val R1c = cterm_of thy R1;
+ − 643
val thmi = Drule.instantiate' [] [SOME R1c] thm;
+ − 644
(* val _ = tracing (Syntax.string_of_term ctxt (prop_of thmi)); *)
+ − 645
val inst = matching_prs thy (term_of (Thm.lhs_of thmi)) ogl
+ − 646
val _ = tracing "AAA";
+ − 647
val thm2 = Drule.eta_contraction_rule (Drule.instantiate inst thmi);
+ − 648
val _ = tracing (Syntax.string_of_term ctxt (prop_of thm2));
+ − 649
in
+ − 650
SOME thm2
+ − 651
end
+ − 652
handle _ => NONE
+ − 653
+ − 654
)
+ − 655
| _ => NONE
+ − 656
end
+ − 657
*}
+ − 658
+ − 659
lemma eq_imp_rel: "EQUIV R \<Longrightarrow> a = b \<longrightarrow> R a b"
+ − 660
by (simp add: EQUIV_REFL)
+ − 661
+ − 662
ML {*
+ − 663
fun regularize_tac ctxt rel_eqvs =
+ − 664
let
+ − 665
val pat1 = [@{term "Ball (Respects R) P"}];
+ − 666
val pat2 = [@{term "Bex (Respects R) P"}];
+ − 667
val pat3 = [@{term "Ball (Respects (R1 ===> R2)) P"}];
+ − 668
val pat4 = [@{term "Bex (Respects (R1 ===> R2)) P"}];
+ − 669
val thy = ProofContext.theory_of ctxt
+ − 670
val simproc1 = Simplifier.simproc_i thy "" pat1 (K (ball_reg_eqv_simproc rel_eqvs))
+ − 671
val simproc2 = Simplifier.simproc_i thy "" pat2 (K (bex_reg_eqv_simproc rel_eqvs))
+ − 672
val simproc3 = Simplifier.simproc_i thy "" pat3 (K (ball_reg_eqv_range_simproc rel_eqvs))
+ − 673
val simproc4 = Simplifier.simproc_i thy "" pat4 (K (bex_reg_eqv_range_simproc rel_eqvs))
+ − 674
val simp_ctxt = (Simplifier.context ctxt empty_ss) addsimprocs [simproc1, simproc2, simproc3, simproc4]
+ − 675
(* TODO: Make sure that there are no LIST_REL, PAIR_REL etc involved *)
+ − 676
val eq_eqvs = map (fn x => @{thm eq_imp_rel} OF [x]) rel_eqvs
+ − 677
in
+ − 678
ObjectLogic.full_atomize_tac THEN'
+ − 679
simp_tac simp_ctxt THEN'
+ − 680
REPEAT_ALL_NEW (FIRST' [
+ − 681
rtac @{thm ball_reg_right},
+ − 682
rtac @{thm bex_reg_left},
+ − 683
resolve_tac (Inductive.get_monos ctxt),
+ − 684
rtac @{thm ball_all_comm},
+ − 685
rtac @{thm bex_ex_comm},
+ − 686
resolve_tac eq_eqvs,
+ − 687
simp_tac simp_ctxt
+ − 688
])
+ − 689
end
+ − 690
*}
390
+ − 691
+ − 692
section {* Injections of REP and ABSes *}
383
+ − 693
381
+ − 694
(*
+ − 695
Injecting REPABS means:
+ − 696
+ − 697
For abstractions:
+ − 698
* If the type of the abstraction doesn't need lifting we recurse.
+ − 699
* If it does we add RepAbs around the whole term and check if the
+ − 700
variable needs lifting.
+ − 701
* If it doesn't then we recurse
+ − 702
* If it does we recurse and put 'RepAbs' around all occurences
+ − 703
of the variable in the obtained subterm. This in combination
+ − 704
with the RepAbs above will let us change the type of the
+ − 705
abstraction with rewriting.
+ − 706
For applications:
+ − 707
* If the term is 'Respects' applied to anything we leave it unchanged
+ − 708
* If the term needs lifting and the head is a constant that we know
+ − 709
how to lift, we put a RepAbs and recurse
+ − 710
* If the term needs lifting and the head is a free applied to subterms
+ − 711
(if it is not applied we treated it in Abs branch) then we
+ − 712
put RepAbs and recurse
+ − 713
* Otherwise just recurse.
+ − 714
*)
+ − 715
336
+ − 716
ML {*
+ − 717
fun mk_repabs lthy (T, T') trm =
+ − 718
Quotient_Def.get_fun repF lthy (T, T')
354
2eb6d527dfe4
addded a tactic, which sets up the three goals of the `algorithm'
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 719
$ (Quotient_Def.get_fun absF lthy (T, T') $ trm)
336
+ − 720
*}
+ − 721
+ − 722
ML {*
+ − 723
(* bound variables need to be treated properly, *)
+ − 724
(* as the type of subterms need to be calculated *)
+ − 725
408
+ − 726
fun inj_repabs_trm lthy (rtrm, qtrm) =
336
+ − 727
let
+ − 728
val rty = fastype_of rtrm
+ − 729
val qty = fastype_of qtrm
+ − 730
in
+ − 731
case (rtrm, qtrm) of
+ − 732
(Const (@{const_name "Ball"}, T) $ r $ t, Const (@{const_name "All"}, _) $ t') =>
408
+ − 733
Const (@{const_name "Ball"}, T) $ r $ (inj_repabs_trm lthy (t, t'))
336
+ − 734
| (Const (@{const_name "Bex"}, T) $ r $ t, Const (@{const_name "Ex"}, _) $ t') =>
408
+ − 735
Const (@{const_name "Bex"}, T) $ r $ (inj_repabs_trm lthy (t, t'))
336
+ − 736
| (Const (@{const_name "Babs"}, T) $ r $ t, t') =>
408
+ − 737
Const (@{const_name "Babs"}, T) $ r $ (inj_repabs_trm lthy (t, t'))
336
+ − 738
| (Abs (x, T, t), Abs (x', T', t')) =>
+ − 739
let
+ − 740
val (y, s) = Term.dest_abs (x, T, t)
+ − 741
val (_, s') = Term.dest_abs (x', T', t')
+ − 742
val yvar = Free (y, T)
453
c22ab554a32d
started functions for qid-insertion and fixed a bug in regularise
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 743
val result = Term.lambda_name (y, yvar) (inj_repabs_trm lthy (s, s'))
336
+ − 744
in
345
+ − 745
if rty = qty
+ − 746
then result
+ − 747
else mk_repabs lthy (rty, qty) result
336
+ − 748
end
+ − 749
| _ =>
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 750
let
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 751
val (rhead, rargs) = strip_comb rtrm
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 752
val (qhead, qargs) = strip_comb qtrm
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 753
val rargs' = map (inj_repabs_trm lthy) (rargs ~~ qargs)
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 754
in
464
+ − 755
case (rhead, qhead) of
+ − 756
(Const _, Const _) =>
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 757
if rty = qty
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 758
then list_comb (rhead, rargs')
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 759
else mk_repabs lthy (rty, qty) (list_comb (rhead, rargs'))
464
+ − 760
| (Free (x, T), Free (x', T')) =>
+ − 761
if T = T'
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 762
then list_comb (rhead, rargs')
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 763
else list_comb (mk_repabs lthy (T, T') rhead, rargs')
464
+ − 764
| (Abs _, Abs _) =>
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 765
list_comb (inj_repabs_trm lthy (rhead, qhead), rargs')
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 766
| _ => raise (LIFT_MATCH "injection")
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 767
end
336
+ − 768
end
+ − 769
*}
+ − 770
404
+ − 771
section {* RepAbs Injection Tactic *}
387
+ − 772
470
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 773
(* TODO: check if it still works with first_order_match *)
387
+ − 774
ML {*
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 775
fun instantiate_tac thm =
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 776
Subgoal.FOCUS (fn {concl, ...} =>
387
+ − 777
let
+ − 778
val pat = Drule.strip_imp_concl (cprop_of thm)
481
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 779
val insts = Thm.first_order_match (pat, concl)
387
+ − 780
in
+ − 781
rtac (Drule.instantiate insts thm) 1
+ − 782
end
+ − 783
handle _ => no_tac)
+ − 784
*}
+ − 785
+ − 786
ML {*
468
+ − 787
fun quotient_tac ctxt quot_thms =
+ − 788
REPEAT_ALL_NEW (FIRST'
420
+ − 789
[rtac @{thm FUN_QUOTIENT},
+ − 790
resolve_tac quot_thms,
+ − 791
rtac @{thm IDENTITY_QUOTIENT},
485
4efb104514f7
More experiments with higher order quotients and theorems with non-lifted constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 792
rtac @{thm LIST_QUOTIENT},
420
+ − 793
(* For functional identity quotients, (op = ---> op =) *)
+ − 794
(* TODO: think about the other way around, if we need to shorten the relation *)
468
+ − 795
CHANGED o (simp_tac ((Simplifier.context ctxt empty_ss) addsimps @{thms id_simps}))])
387
+ − 796
*}
+ − 797
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 798
lemma FUN_REL_I:
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 799
assumes a: "\<And>x y. R1 x y \<Longrightarrow> R2 (f x) (g y)"
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 800
shows "(R1 ===> R2) f g"
466
+ − 801
using a by simp
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 802
387
+ − 803
ML {*
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 804
val lambda_rsp_tac =
472
+ − 805
SUBGOAL (fn (goal, i) =>
475
+ − 806
case HOLogic.dest_Trueprop (Logic.strip_assums_concl goal) of
472
+ − 807
(_ $ (Abs _) $ (Abs _)) => rtac @{thm FUN_REL_I} i
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 808
| _ => no_tac)
387
+ − 809
*}
+ − 810
+ − 811
ML {*
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 812
val weak_lambda_rsp_tac =
472
+ − 813
SUBGOAL (fn (goal, i) =>
475
+ − 814
case HOLogic.dest_Trueprop (Logic.strip_assums_concl goal) of
473
+ − 815
(_ $ _ $ (Abs _)) => rtac @{thm FUN_REL_I} i
+ − 816
| (_ $ (Abs _) $ _) => rtac @{thm FUN_REL_I} i
428
+ − 817
| _ => no_tac)
387
+ − 818
*}
+ − 819
434
+ − 820
ML {*
+ − 821
val ball_rsp_tac =
472
+ − 822
SUBGOAL (fn (goal, i) =>
475
+ − 823
case HOLogic.dest_Trueprop (Logic.strip_assums_concl goal) of
448
+ − 824
(_ $ (Const (@{const_name Ball}, _) $ _)
473
+ − 825
$ (Const (@{const_name Ball}, _) $ _)) => rtac @{thm FUN_REL_I} i
434
+ − 826
|_ => no_tac)
+ − 827
*}
+ − 828
+ − 829
ML {*
+ − 830
val bex_rsp_tac =
472
+ − 831
SUBGOAL (fn (goal, i) =>
475
+ − 832
case HOLogic.dest_Trueprop (Logic.strip_assums_concl goal) of
448
+ − 833
(_ $ (Const (@{const_name Bex}, _) $ _)
473
+ − 834
$ (Const (@{const_name Bex}, _) $ _)) => rtac @{thm FUN_REL_I} i
434
+ − 835
| _ => no_tac)
+ − 836
*}
+ − 837
387
+ − 838
ML {* (* Legacy *)
+ − 839
fun needs_lift (rty as Type (rty_s, _)) ty =
+ − 840
case ty of
448
+ − 841
Type (s, tys) => (s = rty_s) orelse (exists (needs_lift rty) tys)
387
+ − 842
| _ => false
+ − 843
+ − 844
*}
+ − 845
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 846
definition
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 847
"QUOT_TRUE x \<equiv> True"
472
+ − 848
387
+ − 849
ML {*
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 850
fun find_qt_asm asms =
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 851
let
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 852
fun find_fun trm =
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 853
case trm of
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 854
(Const(@{const_name Trueprop}, _) $ (Const (@{const_name QUOT_TRUE}, _) $ _)) => true
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 855
| _ => false
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 856
in
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 857
case find_first find_fun asms of
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 858
SOME (_ $ (_ $ (f $ a))) => (f, a)
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 859
| _ => error "find_qt_asm"
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 860
end
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 861
*}
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 862
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 863
ML {*
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 864
fun APPLY_RSP_TAC rty =
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 865
Subgoal.FOCUS (fn {concl, asms, ...} =>
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 866
case ((HOLogic.dest_Trueprop (term_of concl))) of
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 867
((_ $ (f $ _) $ (_ $ _))) =>
431
+ − 868
let
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 869
val (asmf, asma) = find_qt_asm (map term_of asms);
431
+ − 870
val pat = Drule.strip_imp_concl (cprop_of @{thm APPLY_RSP});
481
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 871
val insts = Thm.first_order_match (pat, concl)
431
+ − 872
in
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 873
if (fastype_of asmf) = (fastype_of f)
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 874
then no_tac
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 875
else rtac (Drule.instantiate insts @{thm APPLY_RSP}) 1
431
+ − 876
end
+ − 877
| _ => no_tac)
387
+ − 878
*}
+ − 879
+ − 880
ML {*
482
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 881
val APPLY_RSP_TAC' =
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 882
Subgoal.FOCUS (fn {concl, asms, context,...} =>
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 883
case ((HOLogic.dest_Trueprop (term_of concl))) of
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 884
((R2 $ (f $ x) $ (g $ y))) =>
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 885
let
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 886
val (asmf, asma) = find_qt_asm (map term_of asms);
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 887
in
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 888
if (fastype_of asmf) = (fastype_of f) then no_tac else let
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 889
val ty_a = fastype_of x;
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 890
val ty_b = fastype_of asma;
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 891
val ty_c = range_type (type_of f);
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 892
val ty_d = range_type (type_of asmf);
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 893
val thy = ProofContext.theory_of context;
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 894
val ty_inst = map (fn x => SOME (ctyp_of thy x)) [ty_a, ty_b, ty_c, ty_d];
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 895
val [R2, f, g, x, y] = map (cterm_of thy) [R2, f, g, x, y];
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 896
val t_inst = [NONE, NONE, NONE, SOME R2, NONE, NONE, SOME f, SOME g, SOME x, SOME y];
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 897
val thm = Drule.instantiate' ty_inst t_inst @{thm APPLY_RSP}
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 898
(*val _ = tracing (Syntax.string_of_term @{context} (prop_of thm))*)
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 899
in
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 900
rtac thm 1
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 901
end
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 902
end
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 903
| _ => no_tac)
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 904
*}
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 905
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 906
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 907
ML {*
432
+ − 908
fun SOLVES' tac = tac THEN_ALL_NEW (fn _ => no_tac)
+ − 909
*}
+ − 910
398
+ − 911
(*
+ − 912
To prove that the regularised theorem implies the abs/rep injected,
+ − 913
we try:
+ − 914
+ − 915
1) theorems 'trans2' from the appropriate QUOT_TYPE
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 916
2) remove lambdas from both sides: lambda_rsp_tac
398
+ − 917
3) remove Ball/Bex from the right hand side
+ − 918
4) use user-supplied RSP theorems
+ − 919
5) remove rep_abs from the right side
+ − 920
6) reflexivity of equality
+ − 921
7) split applications of lifted type (apply_rsp)
+ − 922
8) split applications of non-lifted type (cong_tac)
+ − 923
9) apply extentionality
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 924
A) reflexivity of the relation
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 925
B) assumption
398
+ − 926
(Lambdas under respects may have left us some assumptions)
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 927
C) proving obvious higher order equalities by simplifying fun_rel
398
+ − 928
(not sure if it is still needed?)
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 929
D) unfolding lambda on one side
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 930
E) simplifying (= ===> =) for simpler respectfulness
398
+ − 931
+ − 932
*)
+ − 933
469
+ − 934
lemma quot_true_dests:
+ − 935
shows QT_all: "QUOT_TRUE (All P) \<Longrightarrow> QUOT_TRUE P"
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 936
and QT_ex: "QUOT_TRUE (Ex P) \<Longrightarrow> QUOT_TRUE P"
469
+ − 937
and QT_lam: "QUOT_TRUE (\<lambda>x. P x) \<Longrightarrow> (\<And>x. QUOT_TRUE (P x))"
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 938
and QT_ext: "(\<And>x. QUOT_TRUE (a x) \<Longrightarrow> f x = g x) \<Longrightarrow> (QUOT_TRUE a \<Longrightarrow> f = g)"
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 939
apply(simp_all add: QUOT_TRUE_def ext)
469
+ − 940
done
+ − 941
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 942
lemma QUOT_TRUE_i: "(QUOT_TRUE (a :: bool) \<Longrightarrow> P) \<Longrightarrow> P"
470
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 943
by (simp add: QUOT_TRUE_def)
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 944
479
+ − 945
lemma QUOT_TRUE_imp: "QUOT_TRUE a \<equiv> QUOT_TRUE b"
470
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 946
by (simp add: QUOT_TRUE_def)
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 947
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 948
ML {*
479
+ − 949
fun quot_true_conv1 ctxt fnctn ctrm =
+ − 950
case (term_of ctrm) of
+ − 951
(Const (@{const_name QUOT_TRUE}, _) $ x) =>
+ − 952
let
+ − 953
val fx = fnctn x;
+ − 954
val thy = ProofContext.theory_of ctxt;
+ − 955
val cx = cterm_of thy x;
+ − 956
val cfx = cterm_of thy fx;
+ − 957
val cxt = ctyp_of thy (fastype_of x);
+ − 958
val cfxt = ctyp_of thy (fastype_of fx);
+ − 959
val thm = Drule.instantiate' [SOME cxt, SOME cfxt] [SOME cx, SOME cfx] @{thm QUOT_TRUE_imp}
+ − 960
in
+ − 961
Conv.rewr_conv thm ctrm
+ − 962
end
470
fc16faef5dfa
Transformation of QUOT_TRUE assumption by any given function
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 963
*}
469
+ − 964
479
+ − 965
ML {*
+ − 966
fun quot_true_conv ctxt fnctn ctrm =
+ − 967
case (term_of ctrm) of
+ − 968
(Const (@{const_name QUOT_TRUE}, _) $ _) =>
+ − 969
quot_true_conv1 ctxt fnctn ctrm
+ − 970
| _ $ _ => Conv.comb_conv (quot_true_conv ctxt fnctn) ctrm
+ − 971
| Abs _ => Conv.abs_conv (fn (_, ctxt) => quot_true_conv ctxt fnctn) ctxt ctrm
+ − 972
| _ => Conv.all_conv ctrm
+ − 973
*}
+ − 974
+ − 975
ML {*
+ − 976
fun quot_true_tac ctxt fnctn = CSUBGOAL (fn (goal, i) =>
+ − 977
CONVERSION
+ − 978
(Conv.params_conv ~1 (fn ctxt =>
+ − 979
(Conv.prems_conv ~1 (quot_true_conv ctxt fnctn))) ctxt) i)
+ − 980
*}
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 981
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 982
ML {* fun dest_comb (f $ a) = (f, a) *}
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 983
ML {* fun dest_bcomb ((_ $ l) $ r) = (l, r) *}
481
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 984
(* TODO: Can this be done easier? *)
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 985
ML {*
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 986
fun unlam t =
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 987
case t of
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 988
(Abs a) => snd (Term.dest_abs a)
7f97c52021c9
Fixed unlam for non-abstractions and updated list_induct_part proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 989
| _ => unlam (Abs("", domain_type (fastype_of t), (incr_boundvars 1 t) $ (Bound 0))) *}
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 990
398
+ − 991
ML {*
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 992
fun inj_repabs_tac_old ctxt rty quot_thms rel_refl trans2 =
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 993
(FIRST' [
449
+ − 994
(* "cong" rule of the of the relation / transitivity*)
+ − 995
(* (op =) (R a b) (R c d) ----> \<lbrakk>R a c; R b d\<rbrakk> *)
469
+ − 996
DT ctxt "1" (resolve_tac trans2),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 997
443
+ − 998
(* (R1 ===> R2) (\<lambda>x\<dots>) (\<lambda>y\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (\<dots>x) (\<dots>y) *)
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 999
NDT ctxt "2" (lambda_rsp_tac),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1000
443
+ − 1001
(* (op =) (Ball\<dots>) (Ball\<dots>) ----> (op =) (\<dots>) (\<dots>) *)
458
+ − 1002
NDT ctxt "3" (rtac @{thm ball_rsp}),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1003
443
+ − 1004
(* (R1 ===> R2) (Ball\<dots>) (Ball\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Ball\<dots>x) (Ball\<dots>y) *)
473
+ − 1005
NDT ctxt "4" (ball_rsp_tac),
434
+ − 1006
443
+ − 1007
(* (op =) (Bex\<dots>) (Bex\<dots>) ----> (op =) (\<dots>) (\<dots>) *)
458
+ − 1008
NDT ctxt "5" (rtac @{thm bex_rsp}),
434
+ − 1009
443
+ − 1010
(* (R1 ===> R2) (Bex\<dots>) (Bex\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Bex\<dots>x) (Bex\<dots>y) *)
473
+ − 1011
NDT ctxt "6" (bex_rsp_tac),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1012
442
7beed9b75ea2
renamed LAMBDA_RES_TAC and WEAK_LAMBDA_RES_TAC to lower case names
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1013
(* respectfulness of constants *)
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1014
NDT ctxt "7" (resolve_tac (rsp_rules_get ctxt)),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1015
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1016
(* reflexivity of operators arising from Cong_tac *)
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1017
NDT ctxt "8" (rtac @{thm refl}),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1018
443
+ − 1019
(* R (\<dots>) (Rep (Abs \<dots>)) ----> R (\<dots>) (\<dots>) *)
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1020
(* observe ---> *)
459
+ − 1021
NDT ctxt "9" ((instantiate_tac @{thm REP_ABS_RSP} ctxt
468
+ − 1022
THEN' (RANGE [SOLVES' (quotient_tac ctxt quot_thms)]))),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1023
449
+ − 1024
(* R (t $ \<dots>) (t' $ \<dots>) ----> APPLY_RSP provided type of t needs lifting *)
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1025
NDT ctxt "A" ((APPLY_RSP_TAC rty ctxt THEN'
468
+ − 1026
(RANGE [SOLVES' (quotient_tac ctxt quot_thms), SOLVES' (quotient_tac ctxt quot_thms)]))),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1027
449
+ − 1028
(* (op =) (t $ \<dots>) (t' $ \<dots>) ----> Cong provided type of t does not need lifting *)
444
+ − 1029
(* merge with previous tactic *)
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1030
NDT ctxt "B" (Cong_Tac.cong_tac @{thm cong}),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1031
443
+ − 1032
(* (op =) (\<lambda>x\<dots>) (\<lambda>x\<dots>) ----> (op =) (\<dots>) (\<dots>) *)
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1033
NDT ctxt "C" (rtac @{thm ext}),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1034
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1035
(* reflexivity of the basic relations *)
449
+ − 1036
(* R \<dots> \<dots> *)
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1037
NDT ctxt "D" (resolve_tac rel_refl),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1038
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1039
(* resolving with R x y assumptions *)
446
84ee3973f083
removed old inj_repabs_tac; kept only the one with (selective) debugging information
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1040
NDT ctxt "E" (atac),
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1041
443
+ − 1042
(* (op =) ===> (op =) \<Longrightarrow> (op =), needed in order to apply respectfulness theorems *)
+ − 1043
(* global simplification *)
452
7ba2c16fe0c8
Removed unnecessary HOL_ss which proved one of the subgoals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1044
NDT ctxt "H" (CHANGED o (asm_full_simp_tac ((Simplifier.context ctxt empty_ss) addsimps @{thms eq_reflection[OF FUN_REL_EQ]})))])
443
+ − 1045
*}
423
2f0ad33f0241
annotated a proof with all steps and simplified LAMBDA_RES_TAC
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1046
443
+ − 1047
ML {*
480
7fbbb2690bc5
Removed the use of 'rty' from APPLY_RSP, finally LF proofs go automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1048
fun inj_repabs_tac ctxt rty quot_thms rel_refl trans2 =
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1049
(FIRST' [
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1050
(* "cong" rule of the of the relation / transitivity*)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1051
(* (op =) (R a b) (R c d) ----> \<lbrakk>R a c; R b d\<rbrakk> *)
482
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1052
NDT ctxt "1" (resolve_tac trans2 THEN' RANGE [
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1053
quot_true_tac ctxt (fst o dest_bcomb), quot_true_tac ctxt (snd o dest_bcomb)]),
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1054
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1055
(* (R1 ===> R2) (\<lambda>x\<dots>) (\<lambda>y\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (\<dots>x) (\<dots>y) *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1056
NDT ctxt "2" (lambda_rsp_tac THEN' quot_true_tac ctxt unlam),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1057
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1058
(* (op =) (Ball\<dots>) (Ball\<dots>) ----> (op =) (\<dots>) (\<dots>) *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1059
NDT ctxt "3" (rtac @{thm ball_rsp} THEN' dtac @{thm QT_all}),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1060
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1061
(* R2 is always equality *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1062
(* (R1 ===> R2) (Ball\<dots>) (Ball\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Ball\<dots>x) (Ball\<dots>y) *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1063
NDT ctxt "4" (ball_rsp_tac THEN' quot_true_tac ctxt unlam),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1064
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1065
(* (op =) (Bex\<dots>) (Bex\<dots>) ----> (op =) (\<dots>) (\<dots>) *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1066
NDT ctxt "5" (rtac @{thm bex_rsp} THEN' dtac @{thm QT_ex}),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1067
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1068
(* (R1 ===> R2) (Bex\<dots>) (Bex\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (Bex\<dots>x) (Bex\<dots>y) *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1069
NDT ctxt "6" (bex_rsp_tac THEN' dtac @{thm QT_ext}),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1070
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1071
(* respectfulness of constants *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1072
NDT ctxt "7" (resolve_tac (rsp_rules_get ctxt)),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1073
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1074
(* reflexivity of operators arising from Cong_tac *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1075
NDT ctxt "8" (rtac @{thm refl}),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1076
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1077
(* R (\<dots>) (Rep (Abs \<dots>)) ----> R (\<dots>) (\<dots>) *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1078
(* observe ---> *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1079
NDT ctxt "9" ((instantiate_tac @{thm REP_ABS_RSP} ctxt
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1080
THEN' (RANGE [SOLVES' (quotient_tac ctxt quot_thms)]))),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1081
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1082
(* R (t $ \<dots>) (t' $ \<dots>) ----> APPLY_RSP provided type of t needs lifting *)
482
767baada01dc
New APPLY_RSP which finally does automatic partial lifting :). Doesn't support same relation yet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1083
NDT ctxt "A" (APPLY_RSP_TAC' ctxt THEN'
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1084
(RANGE [SOLVES' (quotient_tac ctxt quot_thms), SOLVES' (quotient_tac ctxt quot_thms),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1085
quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)])),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1086
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1087
(* (op =) (t $ \<dots>) (t' $ \<dots>) ----> Cong provided type of t does not need lifting *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1088
(* merge with previous tactic *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1089
NDT ctxt "B" (Cong_Tac.cong_tac @{thm cong} THEN'
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1090
(RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)])),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1091
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1092
(* (op =) (\<lambda>x\<dots>) (\<lambda>x\<dots>) ----> (op =) (\<dots>) (\<dots>) *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1093
NDT ctxt "C" (rtac @{thm ext} THEN' quot_true_tac ctxt unlam),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1094
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1095
(* reflexivity of the basic relations *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1096
(* R \<dots> \<dots> *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1097
NDT ctxt "D" (resolve_tac rel_refl),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1098
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1099
(* resolving with R x y assumptions *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1100
NDT ctxt "E" (atac),
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1101
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1102
(* (op =) ===> (op =) \<Longrightarrow> (op =), needed in order to apply respectfulness theorems *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1103
(* global simplification *)
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1104
NDT ctxt "H" (CHANGED o (asm_full_simp_tac ((Simplifier.context ctxt empty_ss) addsimps @{thms eq_reflection[OF FUN_REL_EQ]})))])
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1105
*}
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1106
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1107
ML {*
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1108
fun all_inj_repabs_tac ctxt rty quot_thms rel_refl trans2 =
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1109
REPEAT_ALL_NEW (inj_repabs_tac ctxt rty quot_thms rel_refl trans2)
398
+ − 1110
*}
+ − 1111
399
+ − 1112
section {* Cleaning of the theorem *}
387
+ − 1113
389
+ − 1114
462
+ − 1115
(* TODO: This is slow *)
389
+ − 1116
ML {*
468
+ − 1117
fun allex_prs_tac ctxt quot =
+ − 1118
(EqSubst.eqsubst_tac ctxt [0] @{thms all_prs ex_prs}) THEN' (quotient_tac ctxt quot)
387
+ − 1119
*}
+ − 1120
426
+ − 1121
(* Rewrites the term with LAMBDA_PRS thm.
+ − 1122
+ − 1123
Replaces: (Rep1 ---> Abs2) (\<lambda>x. Rep2 (f (Abs1 x)))
+ − 1124
with: f
+ − 1125
+ − 1126
It proves the QUOTIENT assumptions by calling quotient_tac
+ − 1127
*)
387
+ − 1128
ML {*
440
+ − 1129
fun make_inst lhs t =
+ − 1130
let
+ − 1131
val _ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u)) = lhs;
+ − 1132
val _ $ (Abs (_, _, g)) = t;
+ − 1133
fun mk_abs i t =
+ − 1134
if incr_boundvars i u aconv t then Bound i
+ − 1135
else (case t of
+ − 1136
t1 $ t2 => mk_abs i t1 $ mk_abs i t2
469
+ − 1137
| Abs (s, T, t') => Abs (s, T, mk_abs (i + 1) t')
440
+ − 1138
| Bound j => if i = j then error "make_inst" else t
+ − 1139
| _ => t);
+ − 1140
in (f, Abs ("x", T, mk_abs 0 g)) end;
+ − 1141
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1142
fun lambda_prs_conv1 ctxt quot_thms ctrm =
387
+ − 1143
case (term_of ctrm) of ((Const (@{const_name "fun_map"}, _) $ r1 $ a2) $ (Abs _)) =>
+ − 1144
let
+ − 1145
val (_, [ty_b, ty_a]) = dest_Type (fastype_of r1);
+ − 1146
val (_, [ty_c, ty_d]) = dest_Type (fastype_of a2);
+ − 1147
val thy = ProofContext.theory_of ctxt;
+ − 1148
val [cty_a, cty_b, cty_c, cty_d] = map (ctyp_of thy) [ty_a, ty_b, ty_c, ty_d]
+ − 1149
val tyinst = [SOME cty_a, SOME cty_b, SOME cty_c, SOME cty_d];
+ − 1150
val tinst = [NONE, NONE, SOME (cterm_of thy r1), NONE, SOME (cterm_of thy a2)]
+ − 1151
val lpi = Drule.instantiate' tyinst tinst @{thm LAMBDA_PRS};
+ − 1152
val tac =
+ − 1153
(compose_tac (false, lpi, 2)) THEN_ALL_NEW
468
+ − 1154
(quotient_tac ctxt quot_thms);
387
+ − 1155
val gc = Drule.strip_imp_concl (cprop_of lpi);
+ − 1156
val t = Goal.prove_internal [] gc (fn _ => tac 1)
+ − 1157
val te = @{thm eq_reflection} OF [t]
415
+ − 1158
val ts = MetaSimplifier.rewrite_rule @{thms id_simps} te
440
+ − 1159
val tl = Thm.lhs_of ts;
+ − 1160
val (insp, inst) = make_inst (term_of tl) (term_of ctrm);
+ − 1161
val ti = Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) ts;
+ − 1162
(* val _ = writeln (Syntax.string_of_term @{context} (term_of (cprop_of ti)));*)
387
+ − 1163
in
+ − 1164
Conv.rewr_conv ti ctrm
+ − 1165
end
+ − 1166
*}
+ − 1167
440
+ − 1168
(* quot stands for the QUOTIENT theorems: *)
387
+ − 1169
(* could be potentially all of them *)
+ − 1170
ML {*
+ − 1171
fun lambda_prs_conv ctxt quot ctrm =
+ − 1172
case (term_of ctrm) of
+ − 1173
(Const (@{const_name "fun_map"}, _) $ _ $ _) $ (Abs _) =>
+ − 1174
(Conv.arg_conv (Conv.abs_conv (fn (_, ctxt) => lambda_prs_conv ctxt quot) ctxt)
+ − 1175
then_conv (lambda_prs_conv1 ctxt quot)) ctrm
+ − 1176
| _ $ _ => Conv.comb_conv (lambda_prs_conv ctxt quot) ctrm
+ − 1177
| Abs _ => Conv.abs_conv (fn (_, ctxt) => lambda_prs_conv ctxt quot) ctxt ctrm
+ − 1178
| _ => Conv.all_conv ctrm
+ − 1179
*}
+ − 1180
+ − 1181
ML {*
+ − 1182
fun lambda_prs_tac ctxt quot = CSUBGOAL (fn (goal, i) =>
+ − 1183
CONVERSION
+ − 1184
(Conv.params_conv ~1 (fn ctxt =>
+ − 1185
(Conv.prems_conv ~1 (lambda_prs_conv ctxt quot) then_conv
+ − 1186
Conv.concl_conv ~1 (lambda_prs_conv ctxt quot))) ctxt) i)
+ − 1187
*}
+ − 1188
457
+ − 1189
(*
465
+ − 1190
Cleaning the theorem consists of 6 kinds of rewrites.
+ − 1191
The first two need to be done before fun_map is unfolded
457
+ − 1192
+ − 1193
- LAMBDA_PRS:
469
+ − 1194
(Rep1 ---> Abs2) (\<lambda>x. Rep2 (f (Abs1 x))) ----> f
+ − 1195
465
+ − 1196
- FORALL_PRS (and the same for exists: EXISTS_PRS)
469
+ − 1197
\<forall>x\<in>Respects R. (abs ---> id) f ----> \<forall>x. f
+ − 1198
457
+ − 1199
- Rewriting with definitions from the argument defs
469
+ − 1200
NewConst ----> (rep ---> abs) oldConst
+ − 1201
457
+ − 1202
- QUOTIENT_REL_REP:
469
+ − 1203
Rel (Rep x) (Rep y) ----> x = y
+ − 1204
465
+ − 1205
- ABS_REP
469
+ − 1206
Abs (Rep x) ----> x
+ − 1207
465
+ − 1208
- id_simps; fun_map.simps
457
+ − 1209
+ − 1210
The first one is implemented as a conversion (fast).
465
+ − 1211
The second one is an EqSubst (slow).
+ − 1212
The rest are a simp_tac and are fast.
457
+ − 1213
*)
469
+ − 1214
+ − 1215
thm all_prs ex_prs
+ − 1216
+ − 1217
387
+ − 1218
ML {*
466
+ − 1219
fun clean_tac lthy quot defs =
387
+ − 1220
let
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1221
val absrep = map (fn x => @{thm QUOTIENT_ABS_REP} OF [x]) quot
462
+ − 1222
val meta_absrep = map (fn x => @{thm eq_reflection} OF [x]) absrep;
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1223
val reps_same = map (fn x => @{thm QUOTIENT_REL_REP} OF [x]) quot
440
+ − 1224
val meta_reps_same = map (fn x => @{thm eq_reflection} OF [x]) reps_same
462
+ − 1225
val simp_ctxt = (Simplifier.context lthy empty_ss) addsimps
+ − 1226
(@{thm eq_reflection[OF fun_map.simps]} :: @{thms id_simps} @ meta_absrep @ meta_reps_same @ defs)
387
+ − 1227
in
485
4efb104514f7
More experiments with higher order quotients and theorems with non-lifted constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1228
EVERY' [TRY o lambda_prs_tac lthy quot,
462
+ − 1229
TRY o REPEAT_ALL_NEW (allex_prs_tac lthy quot),
440
+ − 1230
TRY o simp_tac simp_ctxt,
451
586e3dc4afdb
Added 'TRY' to refl in clean_tac to get as far as possible. Removed unnecessary [quot_rsp] in FSet. Added necessary [quot_rsp] and one lifted thm in LamEx.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1231
TRY o rtac refl]
387
+ − 1232
end
+ − 1233
*}
381
+ − 1234
404
+ − 1235
section {* Genralisation of free variables in a goal *}
347
+ − 1236
+ − 1237
ML {*
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1238
fun inst_spec ctrm =
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1239
Drule.instantiate' [SOME (ctyp_of_term ctrm)] [NONE, SOME ctrm] @{thm spec}
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1240
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1241
fun inst_spec_tac ctrms =
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1242
EVERY' (map (dtac o inst_spec) ctrms)
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1243
412
+ − 1244
fun all_list xs trm =
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1245
fold (fn (x, T) => fn t' => HOLogic.mk_all (x, T, t')) xs trm
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1246
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1247
fun apply_under_Trueprop f =
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1248
HOLogic.dest_Trueprop #> f #> HOLogic.mk_Trueprop
362
+ − 1249
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1250
fun gen_frees_tac ctxt =
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1251
SUBGOAL (fn (concl, i) =>
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1252
let
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1253
val thy = ProofContext.theory_of ctxt
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1254
val vrs = Term.add_frees concl []
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1255
val cvrs = map (cterm_of thy o Free) vrs
412
+ − 1256
val concl' = apply_under_Trueprop (all_list vrs) concl
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1257
val goal = Logic.mk_implies (concl', concl)
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1258
val rule = Goal.prove ctxt [] [] goal
411
c10e314761fa
simplified gen_frees_tac and properly named abstracted variables
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1259
(K (EVERY1 [inst_spec_tac (rev cvrs), atac]))
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1260
in
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1261
rtac rule i
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1262
end)
362
+ − 1263
*}
+ − 1264
402
+ − 1265
section {* General outline of the lifting procedure *}
+ − 1266
383
+ − 1267
(* - A is the original raw theorem *)
+ − 1268
(* - B is the regularized theorem *)
+ − 1269
(* - C is the rep/abs injected version of B *)
+ − 1270
(* - D is the lifted theorem *)
+ − 1271
(* *)
+ − 1272
(* - b is the regularization step *)
+ − 1273
(* - c is the rep/abs injection step *)
+ − 1274
(* - d is the cleaning part *)
+ − 1275
413
+ − 1276
lemma lifting_procedure:
360
+ − 1277
assumes a: "A"
+ − 1278
and b: "A \<Longrightarrow> B"
+ − 1279
and c: "B = C"
+ − 1280
and d: "C = D"
+ − 1281
shows "D"
+ − 1282
using a b c d
+ − 1283
by simp
+ − 1284
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1285
ML {*
412
+ − 1286
fun lift_match_error ctxt fun_str rtrm qtrm =
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1287
let
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1288
val rtrm_str = Syntax.string_of_term ctxt rtrm
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1289
val qtrm_str = Syntax.string_of_term ctxt qtrm
388
+ − 1290
val msg = [enclose "[" "]" fun_str, "The quotient theorem\n", qtrm_str,
+ − 1291
"and the lifted theorem\n", rtrm_str, "do not match"]
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1292
in
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1293
error (space_implode " " msg)
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1294
end
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1295
*}
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1296
360
+ − 1297
ML {*
+ − 1298
fun procedure_inst ctxt rtrm qtrm =
+ − 1299
let
+ − 1300
val thy = ProofContext.theory_of ctxt
+ − 1301
val rtrm' = HOLogic.dest_Trueprop rtrm
+ − 1302
val qtrm' = HOLogic.dest_Trueprop qtrm
383
+ − 1303
val reg_goal =
405
+ − 1304
Syntax.check_term ctxt (regularize_trm ctxt rtrm' qtrm')
412
+ − 1305
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm
383
+ − 1306
val inj_goal =
408
+ − 1307
Syntax.check_term ctxt (inj_repabs_trm ctxt (reg_goal, qtrm'))
412
+ − 1308
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm
360
+ − 1309
in
+ − 1310
Drule.instantiate' []
+ − 1311
[SOME (cterm_of thy rtrm'),
+ − 1312
SOME (cterm_of thy reg_goal),
413
+ − 1313
SOME (cterm_of thy inj_goal)] @{thm lifting_procedure}
360
+ − 1314
end
362
+ − 1315
*}
389
+ − 1316
+ − 1317
(* Left for debugging *)
362
+ − 1318
ML {*
389
+ − 1319
fun procedure_tac lthy rthm =
+ − 1320
ObjectLogic.full_atomize_tac
+ − 1321
THEN' gen_frees_tac lthy
374
980fdf92a834
fixed the problem with generalising variables; at the moment it is quite a hack
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1322
THEN' Subgoal.FOCUS (fn {context, concl, ...} =>
389
+ − 1323
let
+ − 1324
val rthm' = atomize_thm rthm
+ − 1325
val rule = procedure_inst context (prop_of rthm') (term_of concl)
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1326
val thm = Drule.instantiate' [] [SOME (snd (Thm.dest_comb concl))] @{thm QUOT_TRUE_i}
389
+ − 1327
in
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1328
EVERY1 [rtac rule, rtac rthm'] THEN RANGE [(fn _ => all_tac), rtac thm] 1
412
+ − 1329
end) lthy
360
+ − 1330
*}
+ − 1331
361
+ − 1332
ML {*
413
+ − 1333
(* FIXME/TODO should only get as arguments the rthm like procedure_tac *)
450
2dc708ddb93a
introduced a global list of respectfulness lemmas; the attribute is [quot_rsp]
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1334
fun lift_tac lthy rthm rel_eqv rty quot defs =
389
+ − 1335
ObjectLogic.full_atomize_tac
+ − 1336
THEN' gen_frees_tac lthy
+ − 1337
THEN' Subgoal.FOCUS (fn {context, concl, ...} =>
+ − 1338
let
+ − 1339
val rthm' = atomize_thm rthm
+ − 1340
val rule = procedure_inst context (prop_of rthm') (term_of concl)
416
3f3927f793d4
Removing arguments of tactics: absrep, rel_refl, reps_same are computed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1341
val rel_refl = map (fn x => @{thm EQUIV_REFL} OF [x]) rel_eqv
419
+ − 1342
val trans2 = map (fn x => @{thm equiv_trans2} OF [x]) rel_eqv
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1343
val thm = Drule.instantiate' [] [SOME (snd (Thm.dest_comb concl))] @{thm QUOT_TRUE_i}
389
+ − 1344
in
432
+ − 1345
EVERY1
+ − 1346
[rtac rule,
413
+ − 1347
RANGE [rtac rthm',
432
+ − 1348
regularize_tac lthy rel_eqv,
476
325d6e9a7515
Added tactic for dealing with QUOT_TRUE and introducing QUOT_TRUE.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 1349
rtac thm THEN' all_inj_repabs_tac lthy rty quot rel_refl trans2,
466
+ − 1350
clean_tac lthy quot defs]]
412
+ − 1351
end) lthy
361
+ − 1352
*}
+ − 1353
198
+ − 1354
end
239
+ − 1355