597
+ − 1
theory QuotMain
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 2
imports QuotScript Prove
597
+ − 3
uses ("quotient_info.ML")
725
+ − 4
("quotient_typ.ML")
597
+ − 5
("quotient_def.ML")
+ − 6
begin
+ − 7
+ − 8
locale QUOT_TYPE =
+ − 9
fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
+ − 10
and Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b"
+ − 11
and Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)"
+ − 12
assumes equivp: "equivp R"
+ − 13
and rep_prop: "\<And>y. \<exists>x. Rep y = R x"
+ − 14
and rep_inverse: "\<And>x. Abs (Rep x) = x"
+ − 15
and abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)"
+ − 16
and rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)"
+ − 17
begin
+ − 18
+ − 19
definition
719
+ − 20
abs::"'a \<Rightarrow> 'b"
597
+ − 21
where
719
+ − 22
"abs x \<equiv> Abs (R x)"
597
+ − 23
+ − 24
definition
719
+ − 25
rep::"'b \<Rightarrow> 'a"
597
+ − 26
where
719
+ − 27
"rep a = Eps (Rep a)"
597
+ − 28
+ − 29
lemma lem9:
+ − 30
shows "R (Eps (R x)) = R x"
+ − 31
proof -
+ − 32
have a: "R x x" using equivp by (simp add: equivp_reflp_symp_transp reflp_def)
+ − 33
then have "R x (Eps (R x))" by (rule someI)
+ − 34
then show "R (Eps (R x)) = R x"
+ − 35
using equivp unfolding equivp_def by simp
+ − 36
qed
+ − 37
+ − 38
theorem thm10:
719
+ − 39
shows "abs (rep a) \<equiv> a"
597
+ − 40
apply (rule eq_reflection)
719
+ − 41
unfolding abs_def rep_def
597
+ − 42
proof -
+ − 43
from rep_prop
+ − 44
obtain x where eq: "Rep a = R x" by auto
+ − 45
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp
+ − 46
also have "\<dots> = Abs (R x)" using lem9 by simp
+ − 47
also have "\<dots> = Abs (Rep a)" using eq by simp
+ − 48
also have "\<dots> = a" using rep_inverse by simp
+ − 49
finally
+ − 50
show "Abs (R (Eps (Rep a))) = a" by simp
+ − 51
qed
+ − 52
719
+ − 53
lemma rep_refl:
+ − 54
shows "R (rep a) (rep a)"
+ − 55
unfolding rep_def
597
+ − 56
by (simp add: equivp[simplified equivp_def])
+ − 57
+ − 58
lemma lem7:
+ − 59
shows "(R x = R y) = (Abs (R x) = Abs (R y))"
+ − 60
apply(rule iffI)
+ − 61
apply(simp)
+ − 62
apply(drule rep_inject[THEN iffD2])
+ − 63
apply(simp add: abs_inverse)
+ − 64
done
+ − 65
+ − 66
theorem thm11:
719
+ − 67
shows "R r r' = (abs r = abs r')"
+ − 68
unfolding abs_def
597
+ − 69
by (simp only: equivp[simplified equivp_def] lem7)
+ − 70
+ − 71
719
+ − 72
lemma rep_abs_rsp:
+ − 73
shows "R f (rep (abs g)) = R f g"
+ − 74
and "R (rep (abs g)) f = R g f"
597
+ − 75
by (simp_all add: thm10 thm11)
+ − 76
+ − 77
lemma Quotient:
719
+ − 78
"Quotient R abs rep"
597
+ − 79
apply(unfold Quotient_def)
+ − 80
apply(simp add: thm10)
719
+ − 81
apply(simp add: rep_refl)
597
+ − 82
apply(subst thm11[symmetric])
+ − 83
apply(simp add: equivp[simplified equivp_def])
+ − 84
done
+ − 85
+ − 86
end
+ − 87
+ − 88
section {* type definition for the quotient type *}
+ − 89
+ − 90
(* the auxiliary data for the quotient types *)
+ − 91
use "quotient_info.ML"
+ − 92
699
+ − 93
ML {* print_mapsinfo @{context} *}
+ − 94
597
+ − 95
declare [[map "fun" = (fun_map, fun_rel)]]
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 96
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 97
lemmas [quot_thm] = fun_quotient
597
+ − 98
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 99
lemmas [quot_respect] = quot_rel_rsp
597
+ − 100
+ − 101
(* fun_map is not here since equivp is not true *)
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 102
lemmas [quot_equiv] = identity_equivp
597
+ − 103
+ − 104
(* definition of the quotient types *)
725
+ − 105
use "quotient_typ.ML"
597
+ − 106
+ − 107
(* lifting of constants *)
+ − 108
use "quotient_def.ML"
+ − 109
+ − 110
section {* Simset setup *}
+ − 111
614
+ − 112
(* Since HOL_basic_ss is too "big" for us, *)
+ − 113
(* we set up our own minimal simpset. *)
597
+ − 114
ML {*
+ − 115
fun mk_minimal_ss ctxt =
+ − 116
Simplifier.context ctxt empty_ss
+ − 117
setsubgoaler asm_simp_tac
+ − 118
setmksimps (mksimps [])
+ − 119
*}
+ − 120
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 121
ML {*
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 122
fun OF1 thm1 thm2 = thm2 RS thm1
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 123
*}
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 124
614
+ − 125
section {* Atomize Infrastructure *}
597
+ − 126
+ − 127
lemma atomize_eqv[atomize]:
+ − 128
shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)"
+ − 129
proof
+ − 130
assume "A \<equiv> B"
+ − 131
then show "Trueprop A \<equiv> Trueprop B" by unfold
+ − 132
next
+ − 133
assume *: "Trueprop A \<equiv> Trueprop B"
+ − 134
have "A = B"
+ − 135
proof (cases A)
+ − 136
case True
+ − 137
have "A" by fact
+ − 138
then show "A = B" using * by simp
+ − 139
next
+ − 140
case False
+ − 141
have "\<not>A" by fact
+ − 142
then show "A = B" using * by auto
+ − 143
qed
+ − 144
then show "A \<equiv> B" by (rule eq_reflection)
+ − 145
qed
+ − 146
+ − 147
ML {*
+ − 148
fun atomize_thm thm =
+ − 149
let
+ − 150
val thm' = Thm.freezeT (forall_intr_vars thm)
+ − 151
val thm'' = ObjectLogic.atomize (cprop_of thm')
+ − 152
in
+ − 153
@{thm equal_elim_rule1} OF [thm'', thm']
+ − 154
end
+ − 155
*}
+ − 156
614
+ − 157
section {* Infrastructure about id *}
+ − 158
668
+ − 159
lemmas [id_simps] =
597
+ − 160
fun_map_id[THEN eq_reflection]
+ − 161
id_apply[THEN eq_reflection]
+ − 162
id_def[THEN eq_reflection,symmetric]
+ − 163
612
+ − 164
section {* Computation of the Regularize Goal *}
597
+ − 165
+ − 166
(*
+ − 167
Regularizing an rtrm means:
+ − 168
- quantifiers over a type that needs lifting are replaced by
+ − 169
bounded quantifiers, for example:
+ − 170
\<forall>x. P \<Longrightarrow> \<forall>x \<in> (Respects R). P / All (Respects R) P
+ − 171
+ − 172
the relation R is given by the rty and qty;
+ − 173
+ − 174
- abstractions over a type that needs lifting are replaced
+ − 175
by bounded abstractions:
+ − 176
\<lambda>x. P \<Longrightarrow> Ball (Respects R) (\<lambda>x. P)
+ − 177
+ − 178
- equalities over the type being lifted are replaced by
+ − 179
corresponding relations:
+ − 180
A = B \<Longrightarrow> A \<approx> B
+ − 181
+ − 182
example with more complicated types of A, B:
+ − 183
A = B \<Longrightarrow> (op = \<Longrightarrow> op \<approx>) A B
+ − 184
*)
+ − 185
+ − 186
ML {*
+ − 187
(* builds the relation that is the argument of respects *)
+ − 188
fun mk_resp_arg lthy (rty, qty) =
+ − 189
let
+ − 190
val thy = ProofContext.theory_of lthy
+ − 191
in
+ − 192
if rty = qty
+ − 193
then HOLogic.eq_const rty
+ − 194
else
+ − 195
case (rty, qty) of
+ − 196
(Type (s, tys), Type (s', tys')) =>
+ − 197
if s = s'
+ − 198
then let
+ − 199
val SOME map_info = maps_lookup thy s
+ − 200
val args = map (mk_resp_arg lthy) (tys ~~ tys')
+ − 201
in
+ − 202
list_comb (Const (#relfun map_info, dummyT), args)
+ − 203
end
+ − 204
else let
+ − 205
val SOME qinfo = quotdata_lookup_thy thy s'
+ − 206
(* FIXME: check in this case that the rty and qty *)
+ − 207
(* FIXME: correspond to each other *)
+ − 208
val (s, _) = dest_Const (#rel qinfo)
+ − 209
(* FIXME: the relation should only be the string *)
+ − 210
(* FIXME: and the type needs to be calculated as below; *)
+ − 211
(* FIXME: maybe one should actually have a term *)
+ − 212
(* FIXME: and one needs to force it to have this type *)
+ − 213
in
+ − 214
Const (s, rty --> rty --> @{typ bool})
+ − 215
end
+ − 216
| _ => HOLogic.eq_const dummyT
+ − 217
(* FIXME: check that the types correspond to each other? *)
+ − 218
end
+ − 219
*}
+ − 220
+ − 221
ML {*
+ − 222
val mk_babs = Const (@{const_name Babs}, dummyT)
+ − 223
val mk_ball = Const (@{const_name Ball}, dummyT)
+ − 224
val mk_bex = Const (@{const_name Bex}, dummyT)
+ − 225
val mk_resp = Const (@{const_name Respects}, dummyT)
+ − 226
*}
+ − 227
+ − 228
ML {*
+ − 229
(* - applies f to the subterm of an abstraction, *)
+ − 230
(* otherwise to the given term, *)
+ − 231
(* - used by regularize, therefore abstracted *)
+ − 232
(* variables do not have to be treated specially *)
+ − 233
+ − 234
fun apply_subt f trm1 trm2 =
+ − 235
case (trm1, trm2) of
+ − 236
(Abs (x, T, t), Abs (x', T', t')) => Abs (x, T, f t t')
+ − 237
| _ => f trm1 trm2
+ − 238
+ − 239
(* the major type of All and Ex quantifiers *)
+ − 240
fun qnt_typ ty = domain_type (domain_type ty)
+ − 241
*}
+ − 242
+ − 243
ML {*
632
+ − 244
(* produces a regularized version of rtrm *)
+ − 245
(* - the result is contains dummyT *)
597
+ − 246
(* - does not need any special treatment of *)
+ − 247
(* bound variables *)
+ − 248
+ − 249
fun regularize_trm lthy rtrm qtrm =
+ − 250
case (rtrm, qtrm) of
+ − 251
(Abs (x, ty, t), Abs (x', ty', t')) =>
+ − 252
let
+ − 253
val subtrm = Abs(x, ty, regularize_trm lthy t t')
+ − 254
in
632
+ − 255
if ty = ty' then subtrm
597
+ − 256
else mk_babs $ (mk_resp $ mk_resp_arg lthy (ty, ty')) $ subtrm
+ − 257
end
+ − 258
+ − 259
| (Const (@{const_name "All"}, ty) $ t, Const (@{const_name "All"}, ty') $ t') =>
+ − 260
let
+ − 261
val subtrm = apply_subt (regularize_trm lthy) t t'
+ − 262
in
655
+ − 263
if ty = ty' then Const (@{const_name "All"}, ty) $ subtrm
597
+ − 264
else mk_ball $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm
+ − 265
end
+ − 266
+ − 267
| (Const (@{const_name "Ex"}, ty) $ t, Const (@{const_name "Ex"}, ty') $ t') =>
+ − 268
let
+ − 269
val subtrm = apply_subt (regularize_trm lthy) t t'
+ − 270
in
655
+ − 271
if ty = ty' then Const (@{const_name "Ex"}, ty) $ subtrm
597
+ − 272
else mk_bex $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm
+ − 273
end
+ − 274
+ − 275
| (* equalities need to be replaced by appropriate equivalence relations *)
+ − 276
(Const (@{const_name "op ="}, ty), Const (@{const_name "op ="}, ty')) =>
632
+ − 277
if ty = ty' then rtrm
597
+ − 278
else mk_resp_arg lthy (domain_type ty, domain_type ty')
+ − 279
+ − 280
| (* in this case we check whether the given equivalence relation is correct *)
+ − 281
(rel, Const (@{const_name "op ="}, ty')) =>
+ − 282
let
+ − 283
val exc = LIFT_MATCH "regularise (relation mismatch)"
+ − 284
val rel_ty = (fastype_of rel) handle TERM _ => raise exc
+ − 285
val rel' = mk_resp_arg lthy (domain_type rel_ty, domain_type ty')
+ − 286
in
655
+ − 287
if rel' = rel then rtrm else raise exc
597
+ − 288
end
730
+ − 289
736
+ − 290
| (_, Const _) =>
597
+ − 291
let
736
+ − 292
fun same_name (Const (s, T)) (Const (s', T')) = (s = s') (*andalso (T = T')*)
597
+ − 293
| same_name _ _ = false
736
+ − 294
(* TODO/FIXME: This test is not enough. *)
+ − 295
(* Why? *)
+ − 296
(* Because constants can have the same name but not be the same
+ − 297
constant. All overloaded constants have the same name but because
+ − 298
of different types they do differ.
+ − 299
+ − 300
This code will let one write a theorem where plus on nat is
+ − 301
matched to plus on int, even if the latter is defined differently.
+ − 302
+ − 303
This would result in hard to understand failures in injection and
+ − 304
cleaning. *)
+ − 305
(* cu: if I also test the type, then something else breaks *)
597
+ − 306
in
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 307
if same_name rtrm qtrm then rtrm
597
+ − 308
else
+ − 309
let
+ − 310
val thy = ProofContext.theory_of lthy
736
+ − 311
val qtrm_str = Syntax.string_of_term lthy qtrm
+ − 312
val exc1 = LIFT_MATCH ("regularize (constant " ^ qtrm_str ^ " not found)")
+ − 313
val exc2 = LIFT_MATCH ("regularize (constant " ^ qtrm_str ^ " mismatch)")
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 314
val rtrm' = (#rconst (qconsts_lookup thy qtrm)) handle NotFound => raise exc1
597
+ − 315
in
730
+ − 316
if Pattern.matches thy (rtrm', rtrm)
+ − 317
then rtrm else raise exc2
597
+ − 318
end
+ − 319
end
+ − 320
+ − 321
| (t1 $ t2, t1' $ t2') =>
+ − 322
(regularize_trm lthy t1 t1') $ (regularize_trm lthy t2 t2')
+ − 323
+ − 324
| (Free (x, ty), Free (x', ty')) =>
+ − 325
(* this case cannot arrise as we start with two fully atomized terms *)
+ − 326
raise (LIFT_MATCH "regularize (frees)")
+ − 327
+ − 328
| (Bound i, Bound i') =>
632
+ − 329
if i = i' then rtrm
597
+ − 330
else raise (LIFT_MATCH "regularize (bounds mismatch)")
+ − 331
738
+ − 332
| _ =>
730
+ − 333
let
738
+ − 334
val rtrm_str = Syntax.string_of_term lthy rtrm
+ − 335
val qtrm_str = Syntax.string_of_term lthy qtrm
730
+ − 336
in
738
+ − 337
raise (LIFT_MATCH ("regularize failed (default: " ^ rtrm_str ^ "," ^ qtrm_str ^ ")"))
695
+ − 338
end
597
+ − 339
*}
+ − 340
612
+ − 341
section {* Regularize Tactic *}
+ − 342
597
+ − 343
ML {*
+ − 344
fun equiv_tac ctxt =
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 345
REPEAT_ALL_NEW (resolve_tac (equiv_rules_get ctxt))
597
+ − 346
+ − 347
fun equiv_solver_tac ss = equiv_tac (Simplifier.the_context ss)
+ − 348
val equiv_solver = Simplifier.mk_solver' "Equivalence goal solver" equiv_solver_tac
+ − 349
*}
+ − 350
+ − 351
ML {*
+ − 352
fun prep_trm thy (x, (T, t)) =
+ − 353
(cterm_of thy (Var (x, T)), cterm_of thy t)
+ − 354
+ − 355
fun prep_ty thy (x, (S, ty)) =
+ − 356
(ctyp_of thy (TVar (x, S)), ctyp_of thy ty)
+ − 357
*}
+ − 358
+ − 359
ML {*
+ − 360
fun matching_prs thy pat trm =
+ − 361
let
+ − 362
val univ = Unify.matchers thy [(pat, trm)]
+ − 363
val SOME (env, _) = Seq.pull univ
+ − 364
val tenv = Vartab.dest (Envir.term_env env)
+ − 365
val tyenv = Vartab.dest (Envir.type_env env)
+ − 366
in
+ − 367
(map (prep_ty thy) tyenv, map (prep_trm thy) tenv)
+ − 368
end
+ − 369
*}
+ − 370
+ − 371
ML {*
+ − 372
fun calculate_instance ctxt thm redex R1 R2 =
+ − 373
let
+ − 374
val thy = ProofContext.theory_of ctxt
+ − 375
val goal = Const (@{const_name "equivp"}, dummyT) $ R2
+ − 376
|> Syntax.check_term ctxt
+ − 377
|> HOLogic.mk_Trueprop
738
+ − 378
val eqv_prem = Goal.prove ctxt [] [] goal (fn _ => equiv_tac ctxt 1)
597
+ − 379
val thm = (@{thm eq_reflection} OF [thm OF [eqv_prem]])
+ − 380
val R1c = cterm_of thy R1
+ − 381
val thmi = Drule.instantiate' [] [SOME R1c] thm
+ − 382
val inst = matching_prs thy (term_of (Thm.lhs_of thmi)) redex
+ − 383
val thm2 = Drule.eta_contraction_rule (Drule.instantiate inst thmi)
+ − 384
in
+ − 385
SOME thm2
+ − 386
end
+ − 387
handle _ => NONE
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 388
(* FIXME/TODO: what is the place where the exception is raised: matching_prs? *)
597
+ − 389
*}
+ − 390
+ − 391
ML {*
+ − 392
fun ball_bex_range_simproc ss redex =
+ − 393
let
+ − 394
val ctxt = Simplifier.the_context ss
+ − 395
in
+ − 396
case redex of
+ − 397
(Const (@{const_name "Ball"}, _) $ (Const (@{const_name "Respects"}, _) $
+ − 398
(Const (@{const_name "fun_rel"}, _) $ R1 $ R2)) $ _) =>
+ − 399
calculate_instance ctxt @{thm ball_reg_eqv_range} redex R1 R2
742
+ − 400
597
+ − 401
| (Const (@{const_name "Bex"}, _) $ (Const (@{const_name "Respects"}, _) $
+ − 402
(Const (@{const_name "fun_rel"}, _) $ R1 $ R2)) $ _) =>
+ − 403
calculate_instance ctxt @{thm bex_reg_eqv_range} redex R1 R2
+ − 404
| _ => NONE
+ − 405
end
+ − 406
*}
+ − 407
+ − 408
lemma eq_imp_rel:
+ − 409
shows "equivp R \<Longrightarrow> a = b \<longrightarrow> R a b"
+ − 410
by (simp add: equivp_reflp)
+ − 411
730
+ − 412
ML {*
+ − 413
fun quotient_tac ctxt =
734
+ − 414
DETERM o REPEAT_ALL_NEW (FIRST'
730
+ − 415
[rtac @{thm identity_quotient},
+ − 416
resolve_tac (quotient_rules_get ctxt)])
+ − 417
+ − 418
fun quotient_solver_tac ss = quotient_tac (Simplifier.the_context ss)
+ − 419
val quotient_solver = Simplifier.mk_solver' "Quotient goal solver" quotient_solver_tac
+ − 420
*}
597
+ − 421
734
+ − 422
ML {*
+ − 423
fun solve_quotient_assums ctxt thm =
+ − 424
let
+ − 425
val goal = hd (Drule.strip_imp_prems (cprop_of thm))
+ − 426
in
+ − 427
thm OF [Goal.prove_internal [] goal (fn _ => quotient_tac ctxt 1)]
+ − 428
end
+ − 429
handle _ => error "solve_quotient_assums failed. Maybe a quotient_thm is missing"
+ − 430
*}
+ − 431
+ − 432
612
+ − 433
(* 0. preliminary simplification step according to *)
+ − 434
thm ball_reg_eqv bex_reg_eqv babs_reg_eqv (* the latter of no use *)
+ − 435
ball_reg_eqv_range bex_reg_eqv_range
+ − 436
(* 1. eliminating simple Ball/Bex instances*)
+ − 437
thm ball_reg_right bex_reg_left
+ − 438
(* 2. monos *)
+ − 439
(* 3. commutation rules for ball and bex *)
+ − 440
thm ball_all_comm bex_ex_comm
730
+ − 441
(* 4. then rel-equality (which need to be instantiated to avoid loops) *)
612
+ − 442
thm eq_imp_rel
+ − 443
(* 5. then simplification like 0 *)
+ − 444
(* finally jump back to 1 *)
597
+ − 445
697
+ − 446
ML {*
597
+ − 447
fun regularize_tac ctxt =
+ − 448
let
+ − 449
val thy = ProofContext.theory_of ctxt
+ − 450
val pat_ball = @{term "Ball (Respects (R1 ===> R2)) P"}
+ − 451
val pat_bex = @{term "Bex (Respects (R1 ===> R2)) P"}
+ − 452
val simproc = Simplifier.simproc_i thy "" [pat_ball, pat_bex] (K (ball_bex_range_simproc))
+ − 453
val simpset = (mk_minimal_ss ctxt)
697
+ − 454
addsimps @{thms ball_reg_eqv bex_reg_eqv babs_reg_eqv babs_simp}
+ − 455
addsimprocs [simproc] addSolver equiv_solver addSolver quotient_solver
597
+ − 456
(* TODO: Make sure that there are no list_rel, pair_rel etc involved *)
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 457
(* can this cause loops in equiv_tac ? *)
612
+ − 458
val eq_eqvs = map (OF1 @{thm eq_imp_rel}) (equiv_rules_get ctxt)
597
+ − 459
in
+ − 460
simp_tac simpset THEN'
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 461
REPEAT_ALL_NEW (CHANGED o FIRST' [
612
+ − 462
resolve_tac @{thms ball_reg_right bex_reg_left},
597
+ − 463
resolve_tac (Inductive.get_monos ctxt),
612
+ − 464
resolve_tac @{thms ball_all_comm bex_ex_comm},
605
120e479ed367
first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 465
resolve_tac eq_eqvs,
597
+ − 466
simp_tac simpset])
+ − 467
end
+ − 468
*}
+ − 469
612
+ − 470
section {* Calculation of the Injected Goal *}
597
+ − 471
+ − 472
(*
+ − 473
Injecting repabs means:
+ − 474
+ − 475
For abstractions:
+ − 476
* If the type of the abstraction doesn't need lifting we recurse.
+ − 477
* If it does we add RepAbs around the whole term and check if the
+ − 478
variable needs lifting.
+ − 479
* If it doesn't then we recurse
+ − 480
* If it does we recurse and put 'RepAbs' around all occurences
+ − 481
of the variable in the obtained subterm. This in combination
+ − 482
with the RepAbs above will let us change the type of the
+ − 483
abstraction with rewriting.
+ − 484
For applications:
+ − 485
* If the term is 'Respects' applied to anything we leave it unchanged
+ − 486
* If the term needs lifting and the head is a constant that we know
+ − 487
how to lift, we put a RepAbs and recurse
+ − 488
* If the term needs lifting and the head is a free applied to subterms
+ − 489
(if it is not applied we treated it in Abs branch) then we
+ − 490
put RepAbs and recurse
+ − 491
* Otherwise just recurse.
+ − 492
*)
+ − 493
+ − 494
ML {*
+ − 495
fun mk_repabs lthy (T, T') trm =
+ − 496
Quotient_Def.get_fun repF lthy (T, T')
+ − 497
$ (Quotient_Def.get_fun absF lthy (T, T') $ trm)
+ − 498
*}
+ − 499
+ − 500
ML {*
+ − 501
(* bound variables need to be treated properly, *)
+ − 502
(* as the type of subterms need to be calculated *)
+ − 503
(* in the abstraction case *)
+ − 504
+ − 505
fun inj_repabs_trm lthy (rtrm, qtrm) =
+ − 506
case (rtrm, qtrm) of
+ − 507
(Const (@{const_name "Ball"}, T) $ r $ t, Const (@{const_name "All"}, _) $ t') =>
+ − 508
Const (@{const_name "Ball"}, T) $ r $ (inj_repabs_trm lthy (t, t'))
+ − 509
+ − 510
| (Const (@{const_name "Bex"}, T) $ r $ t, Const (@{const_name "Ex"}, _) $ t') =>
+ − 511
Const (@{const_name "Bex"}, T) $ r $ (inj_repabs_trm lthy (t, t'))
+ − 512
+ − 513
| (Const (@{const_name "Babs"}, T) $ r $ t, t' as (Abs _)) =>
621
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 514
let
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 515
val rty = fastype_of rtrm
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 516
val qty = fastype_of qtrm
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 517
in
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 518
mk_repabs lthy (rty, qty) (Const (@{const_name "Babs"}, T) $ r $ (inj_repabs_trm lthy (t, t')))
c10a46fa0de9
Added a 'rep_abs' in inj_repabs_trm of babs; and proved two lam examples.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 519
end
597
+ − 520
+ − 521
| (Abs (x, T, t), Abs (x', T', t')) =>
+ − 522
let
+ − 523
val rty = fastype_of rtrm
+ − 524
val qty = fastype_of qtrm
+ − 525
val (y, s) = Term.dest_abs (x, T, t)
+ − 526
val (_, s') = Term.dest_abs (x', T', t')
+ − 527
val yvar = Free (y, T)
+ − 528
val result = Term.lambda_name (y, yvar) (inj_repabs_trm lthy (s, s'))
+ − 529
in
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 530
if rty = qty then result
597
+ − 531
else mk_repabs lthy (rty, qty) result
+ − 532
end
+ − 533
+ − 534
| (t $ s, t' $ s') =>
+ − 535
(inj_repabs_trm lthy (t, t')) $ (inj_repabs_trm lthy (s, s'))
+ − 536
+ − 537
| (Free (_, T), Free (_, T')) =>
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 538
if T = T' then rtrm
597
+ − 539
else mk_repabs lthy (T, T') rtrm
+ − 540
+ − 541
| (_, Const (@{const_name "op ="}, _)) => rtrm
+ − 542
+ − 543
| (_, Const (_, T')) =>
+ − 544
let
+ − 545
val rty = fastype_of rtrm
+ − 546
in
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 547
if rty = T' then rtrm
597
+ − 548
else mk_repabs lthy (rty, T') rtrm
+ − 549
end
+ − 550
+ − 551
| _ => raise (LIFT_MATCH "injection")
+ − 552
*}
+ − 553
612
+ − 554
section {* Injection Tactic *}
597
+ − 555
+ − 556
definition
+ − 557
"QUOT_TRUE x \<equiv> True"
+ − 558
+ − 559
ML {*
+ − 560
fun find_qt_asm asms =
741
+ − 561
let
+ − 562
fun find_fun trm =
+ − 563
case trm of
+ − 564
(Const(@{const_name Trueprop}, _) $ (Const (@{const_name QUOT_TRUE}, _) $ _)) => true
+ − 565
| _ => false
+ − 566
in
+ − 567
case find_first find_fun asms of
+ − 568
SOME (_ $ (_ $ (f $ a))) => SOME (f, a)
+ − 569
| _ => NONE
+ − 570
end
597
+ − 571
*}
+ − 572
741
+ − 573
text {*
597
+ − 574
To prove that the regularised theorem implies the abs/rep injected,
+ − 575
we try:
+ − 576
+ − 577
1) theorems 'trans2' from the appropriate QUOT_TYPE
+ − 578
2) remove lambdas from both sides: lambda_rsp_tac
+ − 579
3) remove Ball/Bex from the right hand side
+ − 580
4) use user-supplied RSP theorems
+ − 581
5) remove rep_abs from the right side
+ − 582
6) reflexivity of equality
+ − 583
7) split applications of lifted type (apply_rsp)
+ − 584
8) split applications of non-lifted type (cong_tac)
+ − 585
9) apply extentionality
+ − 586
A) reflexivity of the relation
+ − 587
B) assumption
+ − 588
(Lambdas under respects may have left us some assumptions)
+ − 589
C) proving obvious higher order equalities by simplifying fun_rel
+ − 590
(not sure if it is still needed?)
+ − 591
D) unfolding lambda on one side
+ − 592
E) simplifying (= ===> =) for simpler respectfulness
741
+ − 593
*}
597
+ − 594
+ − 595
lemma quot_true_dests:
+ − 596
shows QT_all: "QUOT_TRUE (All P) \<Longrightarrow> QUOT_TRUE P"
+ − 597
and QT_ex: "QUOT_TRUE (Ex P) \<Longrightarrow> QUOT_TRUE P"
+ − 598
and QT_lam: "QUOT_TRUE (\<lambda>x. P x) \<Longrightarrow> (\<And>x. QUOT_TRUE (P x))"
+ − 599
and QT_ext: "(\<And>x. QUOT_TRUE (a x) \<Longrightarrow> f x = g x) \<Longrightarrow> (QUOT_TRUE a \<Longrightarrow> f = g)"
655
+ − 600
by (simp_all add: QUOT_TRUE_def ext)
597
+ − 601
+ − 602
lemma QUOT_TRUE_imp: "QUOT_TRUE a \<equiv> QUOT_TRUE b"
+ − 603
by (simp add: QUOT_TRUE_def)
+ − 604
697
+ − 605
lemma regularize_to_injection: "(QUOT_TRUE l \<Longrightarrow> y) \<Longrightarrow> (l = r) \<longrightarrow> y"
+ − 606
by(auto simp add: QUOT_TRUE_def)
+ − 607
597
+ − 608
ML {*
738
+ − 609
fun quot_true_simple_conv ctxt fnctn ctrm =
597
+ − 610
case (term_of ctrm) of
+ − 611
(Const (@{const_name QUOT_TRUE}, _) $ x) =>
+ − 612
let
+ − 613
val fx = fnctn x;
+ − 614
val thy = ProofContext.theory_of ctxt;
+ − 615
val cx = cterm_of thy x;
+ − 616
val cfx = cterm_of thy fx;
+ − 617
val cxt = ctyp_of thy (fastype_of x);
+ − 618
val cfxt = ctyp_of thy (fastype_of fx);
+ − 619
val thm = Drule.instantiate' [SOME cxt, SOME cfxt] [SOME cx, SOME cfx] @{thm QUOT_TRUE_imp}
+ − 620
in
+ − 621
Conv.rewr_conv thm ctrm
+ − 622
end
+ − 623
*}
+ − 624
+ − 625
ML {*
+ − 626
fun quot_true_conv ctxt fnctn ctrm =
+ − 627
case (term_of ctrm) of
+ − 628
(Const (@{const_name QUOT_TRUE}, _) $ _) =>
738
+ − 629
quot_true_simple_conv ctxt fnctn ctrm
597
+ − 630
| _ $ _ => Conv.comb_conv (quot_true_conv ctxt fnctn) ctrm
+ − 631
| Abs _ => Conv.abs_conv (fn (_, ctxt) => quot_true_conv ctxt fnctn) ctxt ctrm
+ − 632
| _ => Conv.all_conv ctrm
+ − 633
*}
+ − 634
+ − 635
ML {*
738
+ − 636
fun quot_true_tac ctxt fnctn =
+ − 637
CONVERSION
597
+ − 638
((Conv.params_conv ~1 (fn ctxt =>
+ − 639
(Conv.prems_conv ~1 (quot_true_conv ctxt fnctn)))) ctxt)
+ − 640
*}
+ − 641
+ − 642
ML {* fun dest_comb (f $ a) = (f, a) *}
+ − 643
ML {* fun dest_bcomb ((_ $ l) $ r) = (l, r) *}
+ − 644
(* TODO: Can this be done easier? *)
+ − 645
ML {*
+ − 646
fun unlam t =
+ − 647
case t of
+ − 648
(Abs a) => snd (Term.dest_abs a)
+ − 649
| _ => unlam (Abs("", domain_type (fastype_of t), (incr_boundvars 1 t) $ (Bound 0)))
+ − 650
*}
+ − 651
+ − 652
ML {*
+ − 653
fun dest_fun_type (Type("fun", [T, S])) = (T, S)
+ − 654
| dest_fun_type _ = error "dest_fun_type"
+ − 655
*}
+ − 656
+ − 657
ML {*
+ − 658
val bare_concl = HOLogic.dest_Trueprop o Logic.strip_assums_concl
+ − 659
*}
+ − 660
741
+ − 661
ML {*
+ − 662
(* FIXME / TODO: what is asmf and asma in the code below *)
745
+ − 663
(* asmf is the QUOT_TRUE assumption function
+ − 664
asma are QUOT_TRUE assumption arguments *)
597
+ − 665
val apply_rsp_tac =
+ − 666
Subgoal.FOCUS (fn {concl, asms, context,...} =>
741
+ − 667
let
+ − 668
val bare_concl = HOLogic.dest_Trueprop (term_of concl)
+ − 669
val qt_asm = find_qt_asm (map term_of asms)
+ − 670
in
+ − 671
case (bare_concl, qt_asm) of
+ − 672
(R2 $ (f $ x) $ (g $ y), SOME (asmf, asma)) =>
+ − 673
if (fastype_of asmf) = (fastype_of f)
+ − 674
then no_tac
+ − 675
else
+ − 676
let
+ − 677
val ty_x = fastype_of x
+ − 678
val ty_b = fastype_of asma
+ − 679
val ty_f = range_type (fastype_of f)
+ − 680
val thy = ProofContext.theory_of context
+ − 681
val ty_inst = map (SOME o (ctyp_of thy)) [ty_x, ty_b, ty_f]
+ − 682
val t_inst = map (SOME o (cterm_of thy)) [R2, f, g, x, y];
+ − 683
val inst_thm = Drule.instantiate' ty_inst ([NONE, NONE, NONE] @ t_inst) @{thm apply_rsp}
+ − 684
in
+ − 685
(rtac inst_thm THEN' quotient_tac context) 1
+ − 686
end
+ − 687
| _ => no_tac
+ − 688
end)
597
+ − 689
*}
+ − 690
+ − 691
ML {*
629
+ − 692
fun equals_rsp_tac R ctxt =
734
+ − 693
let
+ − 694
val ty = domain_type (fastype_of R);
+ − 695
val thy = ProofContext.theory_of ctxt
+ − 696
val thm = Drule.instantiate'
+ − 697
[SOME (ctyp_of thy ty)] [SOME (cterm_of thy R)] @{thm equals_rsp}
+ − 698
in
+ − 699
rtac thm THEN' quotient_tac ctxt
+ − 700
end
+ − 701
handle THM _ => K no_tac
+ − 702
| TYPE _ => K no_tac
+ − 703
| TERM _ => K no_tac
629
+ − 704
*}
+ − 705
734
+ − 706
thm rep_abs_rsp
+ − 707
629
+ − 708
ML {*
734
+ − 709
fun rep_abs_rsp_tac ctxt =
597
+ − 710
SUBGOAL (fn (goal, i) =>
+ − 711
case (bare_concl goal) of
+ − 712
(rel $ _ $ (rep $ (abs $ _))) =>
+ − 713
(let
+ − 714
val thy = ProofContext.theory_of ctxt;
+ − 715
val (ty_a, ty_b) = dest_fun_type (fastype_of abs);
+ − 716
val ty_inst = map (SOME o (ctyp_of thy)) [ty_a, ty_b];
+ − 717
val t_inst = map (SOME o (cterm_of thy)) [rel, abs, rep];
742
+ − 718
val inst_thm = Drule.instantiate' ty_inst t_inst @{thm rep_abs_rsp}
597
+ − 719
in
742
+ − 720
(rtac inst_thm THEN' quotient_tac ctxt) i
597
+ − 721
end
742
+ − 722
handle _ => no_tac) (* FIXME / TODO what is the catch for ? Should go away, no? *)
744
+ − 723
(* The catch was for an error of solve_quotient_assum. You replaced it by quotient_tac
+ − 724
so I suppose it is equivalent to a "SOLVES" around quotient_tac. *)
597
+ − 725
| _ => no_tac)
+ − 726
*}
+ − 727
+ − 728
ML {*
629
+ − 729
fun inj_repabs_tac_match ctxt = SUBGOAL (fn (goal, i) =>
597
+ − 730
(case (bare_concl goal) of
+ − 731
(* (R1 ===> R2) (\<lambda>x\<dots>) (\<lambda>y\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> R2 (\<dots>x) (\<dots>y) *)
738
+ − 732
(Const (@{const_name fun_rel}, _) $ _ $ _) $ (Abs _) $ (Abs _)
597
+ − 733
=> rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
+ − 734
+ − 735
(* (op =) (Ball\<dots>) (Ball\<dots>) ----> (op =) (\<dots>) (\<dots>) *)
+ − 736
| (Const (@{const_name "op ="},_) $
+ − 737
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 738
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _))
+ − 739
=> rtac @{thm ball_rsp} THEN' dtac @{thm QT_all}
+ − 740
+ − 741
(* (R1 ===> op =) (Ball\<dots>) (Ball\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> (Ball\<dots>x) = (Ball\<dots>y) *)
+ − 742
| (Const (@{const_name fun_rel}, _) $ _ $ _) $
+ − 743
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 744
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
+ − 745
=> rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
+ − 746
+ − 747
(* (op =) (Bex\<dots>) (Bex\<dots>) ----> (op =) (\<dots>) (\<dots>) *)
+ − 748
| Const (@{const_name "op ="},_) $
+ − 749
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 750
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
+ − 751
=> rtac @{thm bex_rsp} THEN' dtac @{thm QT_ex}
+ − 752
+ − 753
(* (R1 ===> op =) (Bex\<dots>) (Bex\<dots>) ----> \<lbrakk>R1 x y\<rbrakk> \<Longrightarrow> (Bex\<dots>x) = (Bex\<dots>y) *)
+ − 754
| (Const (@{const_name fun_rel}, _) $ _ $ _) $
+ − 755
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 756
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
+ − 757
=> rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
+ − 758
+ − 759
| (_ $
+ − 760
(Const(@{const_name Babs},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 761
(Const(@{const_name Babs},_) $ (Const (@{const_name Respects}, _) $ _) $ _))
+ − 762
=> rtac @{thm babs_rsp} THEN' RANGE [quotient_tac ctxt]
+ − 763
738
+ − 764
| Const (@{const_name "op ="},_) $ (R $ _ $ _) $ (_ $ _ $ _) =>
+ − 765
(rtac @{thm refl} ORELSE'
629
+ − 766
(equals_rsp_tac R ctxt THEN' RANGE [
+ − 767
quot_true_tac ctxt (fst o dest_bcomb), quot_true_tac ctxt (snd o dest_bcomb)]))
+ − 768
597
+ − 769
(* reflexivity of operators arising from Cong_tac *)
629
+ − 770
| Const (@{const_name "op ="},_) $ _ $ _ => rtac @{thm refl}
597
+ − 771
+ − 772
(* respectfulness of constants; in particular of a simple relation *)
+ − 773
| _ $ (Const _) $ (Const _) (* fun_rel, list_rel, etc but not equality *)
+ − 774
=> resolve_tac (rsp_rules_get ctxt) THEN_ALL_NEW quotient_tac ctxt
+ − 775
+ − 776
(* R (\<dots>) (Rep (Abs \<dots>)) ----> R (\<dots>) (\<dots>) *)
+ − 777
(* observe ---> *)
624
c4299ce27e46
Removed pattern from quot_rel_rsp, since list_rel and all used introduced ones cannot be patterned
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 778
| _ $ _ $ _
738
+ − 779
=> (rtac @{thm quot_rel_rsp} THEN_ALL_NEW quotient_tac ctxt)
+ − 780
ORELSE' rep_abs_rsp_tac ctxt
597
+ − 781
738
+ − 782
| _ => K no_tac
597
+ − 783
) i)
+ − 784
*}
+ − 785
+ − 786
ML {*
629
+ − 787
fun inj_repabs_step_tac ctxt rel_refl =
597
+ − 788
(FIRST' [
686
+ − 789
inj_repabs_tac_match ctxt,
597
+ − 790
(* R (t $ \<dots>) (t' $ \<dots>) ----> apply_rsp provided type of t needs lifting *)
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 791
686
+ − 792
apply_rsp_tac ctxt THEN'
+ − 793
RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)],
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 794
597
+ − 795
(* (op =) (t $ \<dots>) (t' $ \<dots>) ----> Cong provided type of t does not need lifting *)
+ − 796
(* merge with previous tactic *)
686
+ − 797
Cong_Tac.cong_tac @{thm cong} THEN'
+ − 798
RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)],
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 799
597
+ − 800
(* (op =) (\<lambda>x\<dots>) (\<lambda>x\<dots>) ----> (op =) (\<dots>) (\<dots>) *)
686
+ − 801
rtac @{thm ext} THEN' quot_true_tac ctxt unlam,
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 802
597
+ − 803
(* resolving with R x y assumptions *)
686
+ − 804
atac,
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 805
597
+ − 806
(* reflexivity of the basic relations *)
+ − 807
(* R \<dots> \<dots> *)
686
+ − 808
resolve_tac rel_refl])
597
+ − 809
*}
+ − 810
+ − 811
ML {*
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 812
fun inj_repabs_tac ctxt =
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 813
let
612
+ − 814
val rel_refl = map (OF1 @{thm equivp_reflp}) (equiv_rules_get ctxt)
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 815
in
629
+ − 816
inj_repabs_step_tac ctxt rel_refl
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 817
end
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 818
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 819
fun all_inj_repabs_tac ctxt =
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 820
REPEAT_ALL_NEW (inj_repabs_tac ctxt)
597
+ − 821
*}
+ − 822
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 823
section {* Cleaning of the Theorem *}
597
+ − 824
659
+ − 825
ML {*
738
+ − 826
(* expands all fun_maps, except in front of bound variables *)
+ − 827
659
+ − 828
fun fun_map_simple_conv xs ctxt ctrm =
+ − 829
case (term_of ctrm) of
+ − 830
((Const (@{const_name "fun_map"}, _) $ _ $ _) $ h $ _) =>
+ − 831
if (member (op=) xs h)
+ − 832
then Conv.all_conv ctrm
+ − 833
else Conv.rewr_conv @{thm fun_map.simps[THEN eq_reflection]} ctrm
+ − 834
| _ => Conv.all_conv ctrm
+ − 835
+ − 836
fun fun_map_conv xs ctxt ctrm =
+ − 837
case (term_of ctrm) of
+ − 838
_ $ _ => (Conv.comb_conv (fun_map_conv xs ctxt) then_conv
+ − 839
fun_map_simple_conv xs ctxt) ctrm
+ − 840
| Abs _ => Conv.abs_conv (fn (x, ctxt) => fun_map_conv ((term_of x)::xs) ctxt) ctxt ctrm
+ − 841
| _ => Conv.all_conv ctrm
+ − 842
+ − 843
fun fun_map_tac ctxt = CONVERSION (fun_map_conv [] ctxt)
+ − 844
*}
+ − 845
694
+ − 846
(* Since the patterns for the lhs are different; there are 2 different make-insts *)
631
+ − 847
(* 1: does ? \<rightarrow> id *)
694
+ − 848
(* 2: does ? \<rightarrow> non-id *)
737
+ − 849
ML {*
+ − 850
fun mk_abs u i t =
+ − 851
if incr_boundvars i u aconv t then Bound i
+ − 852
else (case t of
+ − 853
t1 $ t2 => (mk_abs u i t1) $ (mk_abs u i t2)
+ − 854
| Abs (s, T, t') => Abs (s, T, mk_abs u (i + 1) t')
+ − 855
| Bound j => if i = j then error "make_inst" else t
+ − 856
| _ => t)
+ − 857
597
+ − 858
fun make_inst lhs t =
737
+ − 859
let
+ − 860
val _ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u)) = lhs;
+ − 861
val _ $ (Abs (_, _, g)) = t;
+ − 862
in
+ − 863
(f, Abs ("x", T, mk_abs u 0 g))
+ − 864
end
597
+ − 865
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 866
fun make_inst2 lhs t =
737
+ − 867
let
+ − 868
val _ $ (Abs (_, _, (_ $ ((f as Var (_, Type ("fun", [T, _]))) $ u)))) = lhs;
+ − 869
val _ $ (Abs (_, _, (_ $ g))) = t;
+ − 870
in
+ − 871
(f, Abs ("x", T, mk_abs u 0 g))
+ − 872
end
631
+ − 873
*}
+ − 874
+ − 875
ML {*
742
+ − 876
(* FIXME / TODO this needs to be clarified *)
+ − 877
597
+ − 878
fun lambda_prs_simple_conv ctxt ctrm =
+ − 879
case (term_of ctrm) of
730
+ − 880
(Const (@{const_name fun_map}, _) $ r1 $ a2) $ (Abs _) =>
608
+ − 881
(let
597
+ − 882
val thy = ProofContext.theory_of ctxt
+ − 883
val (ty_b, ty_a) = dest_fun_type (fastype_of r1)
+ − 884
val (ty_c, ty_d) = dest_fun_type (fastype_of a2)
+ − 885
val tyinst = map (SOME o (ctyp_of thy)) [ty_a, ty_b, ty_c, ty_d]
+ − 886
val tinst = [NONE, NONE, SOME (cterm_of thy r1), NONE, SOME (cterm_of thy a2)]
+ − 887
val lpi = Drule.instantiate' tyinst tinst @{thm lambda_prs}
+ − 888
val te = @{thm eq_reflection} OF [solve_quotient_assums ctxt (solve_quotient_assums ctxt lpi)]
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 889
val ti =
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 890
(let
614
+ − 891
val ts = MetaSimplifier.rewrite_rule (id_simps_get ctxt) te
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 892
val (insp, inst) = make_inst (term_of (Thm.lhs_of ts)) (term_of ctrm)
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 893
in
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 894
Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) ts
608
+ − 895
end handle _ => (* TODO handle only Bind | Error "make_inst" *)
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 896
let
631
+ − 897
val ts = MetaSimplifier.rewrite_rule (id_simps_get ctxt) te
+ − 898
val _ = tracing ("ts rule:\n" ^ (Syntax.string_of_term ctxt (prop_of ts)));
+ − 899
val _ = tracing ("redex:\n" ^ (Syntax.string_of_term ctxt (term_of ctrm)));
+ − 900
val (insp, inst) = make_inst2 (term_of (Thm.lhs_of ts)) (term_of ctrm)
+ − 901
in
+ − 902
Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) ts
+ − 903
end handle _ => (* TODO handle only Bind | Error "make_inst" *)
+ − 904
let
662
+ − 905
val (insp, inst) = make_inst2 (term_of (Thm.lhs_of te)) (term_of ctrm)
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 906
val td = Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) te
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 907
in
614
+ − 908
MetaSimplifier.rewrite_rule (id_simps_get ctxt) td
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 909
end);
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 910
val _ = if not (Term.is_Const a2 andalso fst (dest_Const a2) = @{const_name "id"}) then
597
+ − 911
(tracing "lambda_prs";
+ − 912
tracing ("redex:\n" ^ (Syntax.string_of_term ctxt (term_of ctrm)));
+ − 913
tracing ("lpi rule:\n" ^ (Syntax.string_of_term ctxt (prop_of lpi)));
+ − 914
tracing ("te rule:\n" ^ (Syntax.string_of_term ctxt (prop_of te)));
602
e56eeb9fedb3
make_inst for lambda_prs where the second quotient is not identity.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 915
tracing ("ti rule:\n" ^ (Syntax.string_of_term ctxt (prop_of ti))))
597
+ − 916
else ()
631
+ − 917
597
+ − 918
in
+ − 919
Conv.rewr_conv ti ctrm
+ − 920
end
608
+ − 921
handle _ => Conv.all_conv ctrm)
597
+ − 922
| _ => Conv.all_conv ctrm
+ − 923
*}
+ − 924
+ − 925
ML {*
+ − 926
val lambda_prs_conv =
+ − 927
More_Conv.top_conv lambda_prs_simple_conv
+ − 928
+ − 929
fun lambda_prs_tac ctxt = CONVERSION (lambda_prs_conv ctxt)
+ − 930
*}
+ − 931
659
+ − 932
(* 1. folding of definitions and preservation lemmas; *)
+ − 933
(* and simplification with *)
+ − 934
thm babs_prs all_prs ex_prs
+ − 935
(* 2. unfolding of ---> in front of everything, except *)
730
+ − 936
(* bound variables (this prevents lambda_prs from *)
+ − 937
(* becoming stuck *)
660
+ − 938
thm fun_map.simps
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 939
(* 3. simplification with *)
661
+ − 940
thm lambda_prs
660
+ − 941
(* 4. simplification with *)
659
+ − 942
thm Quotient_abs_rep Quotient_rel_rep id_simps
660
+ − 943
(* 5. Test for refl *)
597
+ − 944
652
d8f07b5bcfae
implemented cleaning strategy with fun_map.simps on non-bounded variables; still a few rough edges
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 945
ML {*
597
+ − 946
fun clean_tac lthy =
+ − 947
let
+ − 948
val thy = ProofContext.theory_of lthy;
+ − 949
val defs = map (Thm.varifyT o symmetric o #def) (qconsts_dest thy)
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 950
(* FIXME: why is the Thm.varifyT needed: example where it fails is LamEx *)
658
+ − 951
656
c86a47d4966e
Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
+ − 952
val thms1 = defs @ (prs_rules_get lthy) @ @{thms babs_prs all_prs ex_prs}
658
+ − 953
val thms2 = @{thms Quotient_abs_rep Quotient_rel_rep} @ (id_simps_get lthy)
597
+ − 954
fun simps thms = (mk_minimal_ss lthy) addsimps thms addSolver quotient_solver
+ − 955
in
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 956
EVERY' [simp_tac (simps thms1),
658
+ − 957
fun_map_tac lthy,
648
830b58c2fa94
decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 958
lambda_prs_tac lthy,
597
+ − 959
simp_tac (simps thms2),
+ − 960
TRY o rtac refl]
+ − 961
end
+ − 962
*}
+ − 963
689
+ − 964
section {* Tactic for Genralisation of Free Variables in a Goal *}
597
+ − 965
+ − 966
ML {*
+ − 967
fun inst_spec ctrm =
+ − 968
Drule.instantiate' [SOME (ctyp_of_term ctrm)] [NONE, SOME ctrm] @{thm spec}
+ − 969
+ − 970
fun inst_spec_tac ctrms =
+ − 971
EVERY' (map (dtac o inst_spec) ctrms)
+ − 972
+ − 973
fun all_list xs trm =
+ − 974
fold (fn (x, T) => fn t' => HOLogic.mk_all (x, T, t')) xs trm
+ − 975
+ − 976
fun apply_under_Trueprop f =
+ − 977
HOLogic.dest_Trueprop #> f #> HOLogic.mk_Trueprop
+ − 978
+ − 979
fun gen_frees_tac ctxt =
+ − 980
SUBGOAL (fn (concl, i) =>
+ − 981
let
+ − 982
val thy = ProofContext.theory_of ctxt
+ − 983
val vrs = Term.add_frees concl []
+ − 984
val cvrs = map (cterm_of thy o Free) vrs
+ − 985
val concl' = apply_under_Trueprop (all_list vrs) concl
+ − 986
val goal = Logic.mk_implies (concl', concl)
+ − 987
val rule = Goal.prove ctxt [] [] goal
+ − 988
(K (EVERY1 [inst_spec_tac (rev cvrs), atac]))
+ − 989
in
+ − 990
rtac rule i
+ − 991
end)
+ − 992
*}
+ − 993
699
+ − 994
section {* The General Shape of the Lifting Procedure *}
597
+ − 995
699
+ − 996
(* - A is the original raw theorem *)
+ − 997
(* - B is the regularized theorem *)
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 998
(* - C is the rep/abs injected version of B *)
699
+ − 999
(* - D is the lifted theorem *)
+ − 1000
(* *)
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1001
(* - 1st prem is the regularization step *)
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1002
(* - 2nd prem is the rep/abs injection step *)
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1003
(* - 3rd prem is the cleaning part *)
699
+ − 1004
(* *)
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1005
(* the QUOT_TRUE premise in 2 records the lifted theorem *)
597
+ − 1006
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1007
ML {*
737
+ − 1008
val lifting_procedure =
742
+ − 1009
@{lemma "\<lbrakk>A;
+ − 1010
A \<longrightarrow> B;
+ − 1011
QUOT_TRUE D \<Longrightarrow> B = C;
+ − 1012
C = D\<rbrakk> \<Longrightarrow> D"
+ − 1013
by (simp add: QUOT_TRUE_def)}
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1014
*}
597
+ − 1015
+ − 1016
ML {*
+ − 1017
fun lift_match_error ctxt fun_str rtrm qtrm =
+ − 1018
let
+ − 1019
val rtrm_str = Syntax.string_of_term ctxt rtrm
+ − 1020
val qtrm_str = Syntax.string_of_term ctxt qtrm
704
+ − 1021
val msg = cat_lines [enclose "[" "]" fun_str, "The quotient theorem", qtrm_str,
+ − 1022
"", "does not match with original theorem", rtrm_str]
597
+ − 1023
in
704
+ − 1024
error msg
597
+ − 1025
end
+ − 1026
*}
+ − 1027
+ − 1028
ML {*
+ − 1029
fun procedure_inst ctxt rtrm qtrm =
+ − 1030
let
+ − 1031
val thy = ProofContext.theory_of ctxt
+ − 1032
val rtrm' = HOLogic.dest_Trueprop rtrm
+ − 1033
val qtrm' = HOLogic.dest_Trueprop qtrm
+ − 1034
val reg_goal =
+ − 1035
Syntax.check_term ctxt (regularize_trm ctxt rtrm' qtrm')
+ − 1036
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm
+ − 1037
val inj_goal =
+ − 1038
Syntax.check_term ctxt (inj_repabs_trm ctxt (reg_goal, qtrm'))
+ − 1039
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm
+ − 1040
in
+ − 1041
Drule.instantiate' []
+ − 1042
[SOME (cterm_of thy rtrm'),
+ − 1043
SOME (cterm_of thy reg_goal),
688
+ − 1044
NONE,
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1045
SOME (cterm_of thy inj_goal)] lifting_procedure
597
+ − 1046
end
+ − 1047
*}
+ − 1048
+ − 1049
ML {*
616
+ − 1050
(* the tactic leaves three subgoals to be proved *)
597
+ − 1051
fun procedure_tac ctxt rthm =
+ − 1052
ObjectLogic.full_atomize_tac
+ − 1053
THEN' gen_frees_tac ctxt
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1054
THEN' CSUBGOAL (fn (goal, i) =>
597
+ − 1055
let
+ − 1056
val rthm' = atomize_thm rthm
610
2bee5ca44ef5
removed "global" data and lookup functions; had to move a tactic out from the inj_repabs_match tactic since apply_rsp interferes with a trans2 rule for ===>
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1057
val rule = procedure_inst ctxt (prop_of rthm') (term_of goal)
597
+ − 1058
in
688
+ − 1059
(rtac rule THEN' rtac rthm') i
597
+ − 1060
end)
+ − 1061
*}
+ − 1062
689
+ − 1063
section {* Automatic Proofs *}
+ − 1064
612
+ − 1065
ML {*
616
+ − 1066
fun SOLVES' tac = tac THEN_ALL_NEW (K no_tac)
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1067
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1068
(* prints warning, if goal is unsolved *)
615
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1069
fun WARN (tac, msg) i st =
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1070
case Seq.pull ((SOLVES' tac) i st) of
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1071
NONE => (warning msg; Seq.single st)
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1072
| seqcell => Seq.make (fn () => seqcell)
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1073
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1074
fun RANGE_WARN xs = RANGE (map WARN xs)
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1075
*}
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1076
386a6b1a5203
the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1077
ML {*
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1078
local
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1079
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1080
val msg1 = "Regularize proof failed."
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1081
val msg2 = cat_lines ["Injection proof failed.",
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1082
"This is probably due to missing respects lemmas.",
715
+ − 1083
"Try invoking the injection method manually to see",
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1084
"which lemmas are missing."]
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1085
val msg3 = "Cleaning proof failed."
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1086
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1087
in
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1088
612
+ − 1089
fun lift_tac ctxt rthm =
+ − 1090
procedure_tac ctxt rthm
688
+ − 1091
THEN' RANGE_WARN
703
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1092
[(regularize_tac ctxt, msg1),
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1093
(all_inj_repabs_tac ctxt, msg2),
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1094
(clean_tac ctxt, msg3)]
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1095
8b2c46e11674
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 1096
end
612
+ − 1097
*}
+ − 1098
689
+ − 1099
section {* Methods / Interface *}
+ − 1100
632
+ − 1101
ML {*
+ − 1102
fun mk_method1 tac thm ctxt =
+ − 1103
SIMPLE_METHOD (HEADGOAL (tac ctxt thm))
+ − 1104
+ − 1105
fun mk_method2 tac ctxt =
+ − 1106
SIMPLE_METHOD (HEADGOAL (tac ctxt))
+ − 1107
*}
+ − 1108
+ − 1109
method_setup lifting =
637
+ − 1110
{* Attrib.thm >> (mk_method1 lift_tac) *}
632
+ − 1111
{* Lifting of theorems to quotient types. *}
+ − 1112
+ − 1113
method_setup lifting_setup =
637
+ − 1114
{* Attrib.thm >> (mk_method1 procedure_tac) *}
632
+ − 1115
{* Sets up the three goals for the lifting procedure. *}
+ − 1116
+ − 1117
method_setup regularize =
+ − 1118
{* Scan.succeed (mk_method2 regularize_tac) *}
+ − 1119
{* Proves automatically the regularization goals from the lifting procedure. *}
+ − 1120
+ − 1121
method_setup injection =
+ − 1122
{* Scan.succeed (mk_method2 all_inj_repabs_tac) *}
+ − 1123
{* Proves automatically the rep/abs injection goals from the lifting procedure. *}
+ − 1124
+ − 1125
method_setup cleaning =
+ − 1126
{* Scan.succeed (mk_method2 clean_tac) *}
+ − 1127
{* Proves automatically the cleaning goals from the lifting procedure. *}
+ − 1128
597
+ − 1129
end
+ − 1130