758
+ − 1
signature QUOTIENT_TACS =
+ − 2
sig
+ − 3
val regularize_tac: Proof.context -> int -> tactic
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 4
val all_injection_tac: Proof.context -> int -> tactic
758
+ − 5
val clean_tac: Proof.context -> int -> tactic
+ − 6
val procedure_tac: Proof.context -> thm -> int -> tactic
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 7
val lift_tac: Proof.context -> thm -> int -> tactic
758
+ − 8
val quotient_tac: Proof.context -> int -> tactic
+ − 9
end;
+ − 10
+ − 11
structure Quotient_Tacs: QUOTIENT_TACS =
+ − 12
struct
+ − 13
762
+ − 14
open Quotient_Info;
+ − 15
open Quotient_Term;
+ − 16
769
d89851ebac9b
cleaned a bit calculate_inst a bit; eta-contraction seems to be not necessary? (all examples go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 17
(* Since HOL_basic_ss is too "big" for us, we *)
d89851ebac9b
cleaned a bit calculate_inst a bit; eta-contraction seems to be not necessary? (all examples go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 18
(* need to set up our own minimal simpset. *)
758
+ − 19
fun mk_minimal_ss ctxt =
+ − 20
Simplifier.context ctxt empty_ss
+ − 21
setsubgoaler asm_simp_tac
+ − 22
setmksimps (mksimps [])
+ − 23
769
d89851ebac9b
cleaned a bit calculate_inst a bit; eta-contraction seems to be not necessary? (all examples go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 24
(* various helper fuctions *)
758
+ − 25
769
d89851ebac9b
cleaned a bit calculate_inst a bit; eta-contraction seems to be not necessary? (all examples go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 26
(* composition of two theorems, used in map *)
758
+ − 27
fun OF1 thm1 thm2 = thm2 RS thm1
+ − 28
+ − 29
(* makes sure a subgoal is solved *)
+ − 30
fun SOLVES' tac = tac THEN_ALL_NEW (K no_tac)
+ − 31
+ − 32
(* prints warning, if goal is unsolved *)
+ − 33
fun WARN (tac, msg) i st =
+ − 34
case Seq.pull ((SOLVES' tac) i st) of
+ − 35
NONE => (warning msg; Seq.single st)
+ − 36
| seqcell => Seq.make (fn () => seqcell)
+ − 37
+ − 38
fun RANGE_WARN xs = RANGE (map WARN xs)
+ − 39
+ − 40
fun atomize_thm thm =
+ − 41
let
+ − 42
val thm' = Thm.freezeT (forall_intr_vars thm)
+ − 43
val thm'' = ObjectLogic.atomize (cprop_of thm')
+ − 44
in
+ − 45
@{thm equal_elim_rule1} OF [thm'', thm']
+ − 46
end
+ − 47
+ − 48
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 49
(*********************)
758
+ − 50
(* Regularize Tactic *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 51
(*********************)
758
+ − 52
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 53
(* solvers for equivp and quotient assumptions *)
758
+ − 54
fun equiv_tac ctxt =
+ − 55
REPEAT_ALL_NEW (resolve_tac (equiv_rules_get ctxt))
+ − 56
+ − 57
fun equiv_solver_tac ss = equiv_tac (Simplifier.the_context ss)
+ − 58
val equiv_solver = Simplifier.mk_solver' "Equivalence goal solver" equiv_solver_tac
+ − 59
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 60
(* test whether DETERM makes any difference *)
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 61
fun quotient_tac ctxt = SOLVES'
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 62
(REPEAT_ALL_NEW (FIRST'
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 63
[rtac @{thm identity_quotient},
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 64
resolve_tac (quotient_rules_get ctxt)]))
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 65
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 66
fun quotient_solver_tac ss = quotient_tac (Simplifier.the_context ss)
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 67
val quotient_solver = Simplifier.mk_solver' "Quotient goal solver" quotient_solver_tac
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 68
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 69
fun solve_quotient_assm ctxt thm =
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 70
case Seq.pull (quotient_tac ctxt 1 thm) of
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 71
SOME (t, _) => t
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 72
| _ => error "solve_quotient_assm failed. Maybe a quotient_thm is missing"
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 73
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 74
758
+ − 75
fun prep_trm thy (x, (T, t)) =
+ − 76
(cterm_of thy (Var (x, T)), cterm_of thy t)
+ − 77
+ − 78
fun prep_ty thy (x, (S, ty)) =
+ − 79
(ctyp_of thy (TVar (x, S)), ctyp_of thy ty)
+ − 80
772
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 81
fun get_match_inst thy pat trm =
758
+ − 82
let
+ − 83
val univ = Unify.matchers thy [(pat, trm)]
772
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 84
val SOME (env, _) = Seq.pull univ (* raises BIND, if no unifier *)
758
+ − 85
val tenv = Vartab.dest (Envir.term_env env)
+ − 86
val tyenv = Vartab.dest (Envir.type_env env)
+ − 87
in
+ − 88
(map (prep_ty thy) tyenv, map (prep_trm thy) tenv)
+ − 89
end
+ − 90
771
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 91
(* calculates the instantiations for te lemmas *)
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 92
(* ball_reg_eqv_range and bex_reg_eqv_range *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 93
fun calculate_inst ctxt ball_bex_thm redex R1 R2 =
758
+ − 94
let
771
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 95
fun get_lhs thm = fst (Logic.dest_equals (Thm.concl_of thm))
758
+ − 96
val thy = ProofContext.theory_of ctxt
771
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 97
val typ_inst1 = map (SOME o ctyp_of thy) [domain_type (fastype_of R2)]
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 98
val trm_inst1 = map (SOME o cterm_of thy) [R2, R1]
772
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 99
val thm' = Drule.instantiate' typ_inst1 trm_inst1 ball_bex_thm (* raises TYPE *)
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 100
val inst2 = get_match_inst thy (get_lhs thm') redex
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 101
val thm'' = Drule.instantiate inst2 thm' (* raises THM *)
758
+ − 102
in
771
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 103
SOME thm''
758
+ − 104
end
771
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 105
handle _ => NONE
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 106
(* FIXME/TODO: !!!CLEVER CODE!!! *)
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 107
(* FIXME/TODO: What is the place where the exception is raised, *)
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 108
(* FIXME/TODO: and which exception is it? *)
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 109
(* FIXME/TODO: Can one not find out from the types of R1 or R2, *)
b2231990b059
simplified calculate_instance; worked around some clever code; clever code is unfortunately still there...needs to be removed
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 110
(* FIXME/TODO: or from their form, when NONE should be returned? *)
758
+ − 111
+ − 112
fun ball_bex_range_simproc ss redex =
+ − 113
let
+ − 114
val ctxt = Simplifier.the_context ss
+ − 115
in
772
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 116
case redex of
758
+ − 117
(Const (@{const_name "Ball"}, _) $ (Const (@{const_name "Respects"}, _) $
+ − 118
(Const (@{const_name "fun_rel"}, _) $ R1 $ R2)) $ _) =>
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 119
calculate_inst ctxt @{thm ball_reg_eqv_range[THEN eq_reflection]} redex R1 R2
758
+ − 120
+ − 121
| (Const (@{const_name "Bex"}, _) $ (Const (@{const_name "Respects"}, _) $
+ − 122
(Const (@{const_name "fun_rel"}, _) $ R1 $ R2)) $ _) =>
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 123
calculate_inst ctxt @{thm bex_reg_eqv_range[THEN eq_reflection]} redex R1 R2
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 124
758
+ − 125
| _ => NONE
+ − 126
end
+ − 127
+ − 128
(* 0. preliminary simplification step according to *)
+ − 129
(* thm ball_reg_eqv bex_reg_eqv babs_reg_eqv *)
+ − 130
(* ball_reg_eqv_range bex_reg_eqv_range *)
+ − 131
(* *)
+ − 132
(* 1. eliminating simple Ball/Bex instances *)
+ − 133
(* thm ball_reg_right bex_reg_left *)
+ − 134
(* *)
+ − 135
(* 2. monos *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 136
(* *)
758
+ − 137
(* 3. commutation rules for ball and bex *)
+ − 138
(* thm ball_all_comm bex_ex_comm *)
+ − 139
(* *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 140
(* 4. then rel-equalities, which need to be *)
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 141
(* instantiated with the followig theorem *)
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 142
(* to avoid loops: *)
758
+ − 143
(* thm eq_imp_rel *)
+ − 144
(* *)
+ − 145
(* 5. then simplification like 0 *)
+ − 146
(* *)
+ − 147
(* finally jump back to 1 *)
+ − 148
+ − 149
fun regularize_tac ctxt =
+ − 150
let
+ − 151
val thy = ProofContext.theory_of ctxt
772
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 152
val ball_pat = @{term "Ball (Respects (R1 ===> R2)) P"}
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 153
val bex_pat = @{term "Bex (Respects (R1 ===> R2)) P"}
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 154
val simproc = Simplifier.simproc_i thy "" [ball_pat, bex_pat] (K (ball_bex_range_simproc))
758
+ − 155
val simpset = (mk_minimal_ss ctxt)
+ − 156
addsimps @{thms ball_reg_eqv bex_reg_eqv babs_reg_eqv babs_simp}
772
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 157
addsimprocs [simproc]
a95f6bb081cf
on the hunt for what condition raises which exception in the CLEVER CODE of calculate_inst
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 158
addSolver equiv_solver addSolver quotient_solver
758
+ − 159
val eq_eqvs = map (OF1 @{thm eq_imp_rel}) (equiv_rules_get ctxt)
+ − 160
in
+ − 161
simp_tac simpset THEN'
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 162
REPEAT_ALL_NEW (CHANGED o FIRST'
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 163
[resolve_tac @{thms ball_reg_right bex_reg_left},
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 164
resolve_tac (Inductive.get_monos ctxt),
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 165
resolve_tac @{thms ball_all_comm bex_ex_comm},
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 166
resolve_tac eq_eqvs,
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 167
simp_tac simpset])
758
+ − 168
end
+ − 169
+ − 170
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 171
(********************)
758
+ − 172
(* Injection Tactic *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 173
(********************)
758
+ − 174
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 175
(* Looks for Quot_True assumtions, and in case its parameter *)
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 176
(* is an application, it returns the function and the argument. *)
758
+ − 177
fun find_qt_asm asms =
+ − 178
let
+ − 179
fun find_fun trm =
+ − 180
case trm of
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 181
(Const(@{const_name Trueprop}, _) $ (Const (@{const_name Quot_True}, _) $ _)) => true
758
+ − 182
| _ => false
+ − 183
in
+ − 184
case find_first find_fun asms of
+ − 185
SOME (_ $ (_ $ (f $ a))) => SOME (f, a)
+ − 186
| _ => NONE
+ − 187
end
+ − 188
+ − 189
fun quot_true_simple_conv ctxt fnctn ctrm =
+ − 190
case (term_of ctrm) of
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 191
(Const (@{const_name Quot_True}, _) $ x) =>
758
+ − 192
let
+ − 193
val fx = fnctn x;
+ − 194
val thy = ProofContext.theory_of ctxt;
+ − 195
val cx = cterm_of thy x;
+ − 196
val cfx = cterm_of thy fx;
+ − 197
val cxt = ctyp_of thy (fastype_of x);
+ − 198
val cfxt = ctyp_of thy (fastype_of fx);
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 199
val thm = Drule.instantiate' [SOME cxt, SOME cfxt] [SOME cx, SOME cfx] @{thm QT_imp}
758
+ − 200
in
+ − 201
Conv.rewr_conv thm ctrm
+ − 202
end
+ − 203
+ − 204
fun quot_true_conv ctxt fnctn ctrm =
+ − 205
case (term_of ctrm) of
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 206
(Const (@{const_name Quot_True}, _) $ _) =>
758
+ − 207
quot_true_simple_conv ctxt fnctn ctrm
+ − 208
| _ $ _ => Conv.comb_conv (quot_true_conv ctxt fnctn) ctrm
+ − 209
| Abs _ => Conv.abs_conv (fn (_, ctxt) => quot_true_conv ctxt fnctn) ctxt ctrm
+ − 210
| _ => Conv.all_conv ctrm
+ − 211
+ − 212
fun quot_true_tac ctxt fnctn =
+ − 213
CONVERSION
+ − 214
((Conv.params_conv ~1 (fn ctxt =>
+ − 215
(Conv.prems_conv ~1 (quot_true_conv ctxt fnctn)))) ctxt)
+ − 216
+ − 217
fun dest_comb (f $ a) = (f, a)
+ − 218
fun dest_bcomb ((_ $ l) $ r) = (l, r)
+ − 219
+ − 220
(* TODO: Can this be done easier? *)
+ − 221
fun unlam t =
+ − 222
case t of
+ − 223
(Abs a) => snd (Term.dest_abs a)
+ − 224
| _ => unlam (Abs("", domain_type (fastype_of t), (incr_boundvars 1 t) $ (Bound 0)))
+ − 225
+ − 226
fun dest_fun_type (Type("fun", [T, S])) = (T, S)
+ − 227
| dest_fun_type _ = error "dest_fun_type"
+ − 228
+ − 229
val bare_concl = HOLogic.dest_Trueprop o Logic.strip_assums_concl
+ − 230
+ − 231
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 232
(* We apply apply_rsp only in case if the type needs lifting. *)
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 233
(* This is the case if the type of the data in the Quot_True *)
758
+ − 234
(* assumption is different from the corresponding type in the goal *)
+ − 235
val apply_rsp_tac =
+ − 236
Subgoal.FOCUS (fn {concl, asms, context,...} =>
+ − 237
let
+ − 238
val bare_concl = HOLogic.dest_Trueprop (term_of concl)
+ − 239
val qt_asm = find_qt_asm (map term_of asms)
+ − 240
in
+ − 241
case (bare_concl, qt_asm) of
+ − 242
(R2 $ (f $ x) $ (g $ y), SOME (qt_fun, qt_arg)) =>
+ − 243
if (fastype_of qt_fun) = (fastype_of f)
+ − 244
then no_tac
+ − 245
else
+ − 246
let
+ − 247
val ty_x = fastype_of x
+ − 248
val ty_b = fastype_of qt_arg
+ − 249
val ty_f = range_type (fastype_of f)
+ − 250
val thy = ProofContext.theory_of context
+ − 251
val ty_inst = map (SOME o (ctyp_of thy)) [ty_x, ty_b, ty_f]
+ − 252
val t_inst = map (SOME o (cterm_of thy)) [R2, f, g, x, y];
+ − 253
val inst_thm = Drule.instantiate' ty_inst ([NONE, NONE, NONE] @ t_inst) @{thm apply_rsp}
+ − 254
in
+ − 255
(rtac inst_thm THEN' quotient_tac context) 1
+ − 256
end
+ − 257
| _ => no_tac
+ − 258
end)
+ − 259
+ − 260
fun equals_rsp_tac R ctxt =
+ − 261
let
+ − 262
val ty = domain_type (fastype_of R);
+ − 263
val thy = ProofContext.theory_of ctxt
+ − 264
val thm = Drule.instantiate'
+ − 265
[SOME (ctyp_of thy ty)] [SOME (cterm_of thy R)] @{thm equals_rsp}
+ − 266
in
+ − 267
rtac thm THEN' quotient_tac ctxt
+ − 268
end
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 269
(* Are they raised by instantiate'? *)
758
+ − 270
handle THM _ => K no_tac
+ − 271
| TYPE _ => K no_tac
+ − 272
| TERM _ => K no_tac
+ − 273
+ − 274
+ − 275
fun rep_abs_rsp_tac ctxt =
+ − 276
SUBGOAL (fn (goal, i) =>
+ − 277
case (bare_concl goal) of
+ − 278
(rel $ _ $ (rep $ (abs $ _))) =>
+ − 279
(let
+ − 280
val thy = ProofContext.theory_of ctxt;
+ − 281
val (ty_a, ty_b) = dest_fun_type (fastype_of abs);
+ − 282
val ty_inst = map (SOME o (ctyp_of thy)) [ty_a, ty_b];
+ − 283
val t_inst = map (SOME o (cterm_of thy)) [rel, abs, rep];
+ − 284
val inst_thm = Drule.instantiate' ty_inst t_inst @{thm rep_abs_rsp}
+ − 285
in
+ − 286
(rtac inst_thm THEN' quotient_tac ctxt) i
+ − 287
end
+ − 288
handle THM _ => no_tac | TYPE _ => no_tac)
+ − 289
| _ => no_tac)
+ − 290
+ − 291
+ − 292
(* FIXME /TODO needs to be adapted *)
+ − 293
(*
+ − 294
To prove that the regularised theorem implies the abs/rep injected,
+ − 295
we try:
+ − 296
+ − 297
1) theorems 'trans2' from the appropriate QUOT_TYPE
+ − 298
2) remove lambdas from both sides: lambda_rsp_tac
+ − 299
3) remove Ball/Bex from the right hand side
+ − 300
4) use user-supplied RSP theorems
+ − 301
5) remove rep_abs from the right side
+ − 302
6) reflexivity of equality
+ − 303
7) split applications of lifted type (apply_rsp)
+ − 304
8) split applications of non-lifted type (cong_tac)
+ − 305
9) apply extentionality
+ − 306
A) reflexivity of the relation
+ − 307
B) assumption
+ − 308
(Lambdas under respects may have left us some assumptions)
+ − 309
C) proving obvious higher order equalities by simplifying fun_rel
+ − 310
(not sure if it is still needed?)
+ − 311
D) unfolding lambda on one side
+ − 312
E) simplifying (= ===> =) for simpler respectfulness
+ − 313
*)
+ − 314
+ − 315
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 316
fun injection_match_tac ctxt = SUBGOAL (fn (goal, i) =>
758
+ − 317
(case (bare_concl goal) of
+ − 318
(* (R1 ===> R2) (%x...) (%x...) ----> [|R1 x y|] ==> R2 (...x) (...y) *)
+ − 319
(Const (@{const_name fun_rel}, _) $ _ $ _) $ (Abs _) $ (Abs _)
+ − 320
=> rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
+ − 321
+ − 322
(* (op =) (Ball...) (Ball...) ----> (op =) (...) (...) *)
+ − 323
| (Const (@{const_name "op ="},_) $
+ − 324
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 325
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _))
+ − 326
=> rtac @{thm ball_rsp} THEN' dtac @{thm QT_all}
+ − 327
+ − 328
(* (R1 ===> op =) (Ball...) (Ball...) ----> [|R1 x y|] ==> (Ball...x) = (Ball...y) *)
+ − 329
| (Const (@{const_name fun_rel}, _) $ _ $ _) $
+ − 330
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 331
(Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
+ − 332
=> rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
+ − 333
+ − 334
(* (op =) (Bex...) (Bex...) ----> (op =) (...) (...) *)
+ − 335
| Const (@{const_name "op ="},_) $
+ − 336
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 337
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
+ − 338
=> rtac @{thm bex_rsp} THEN' dtac @{thm QT_ex}
+ − 339
+ − 340
(* (R1 ===> op =) (Bex...) (Bex...) ----> [|R1 x y|] ==> (Bex...x) = (Bex...y) *)
+ − 341
| (Const (@{const_name fun_rel}, _) $ _ $ _) $
+ − 342
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 343
(Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
+ − 344
=> rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
+ − 345
+ − 346
| (_ $
+ − 347
(Const(@{const_name Babs},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
+ − 348
(Const(@{const_name Babs},_) $ (Const (@{const_name Respects}, _) $ _) $ _))
+ − 349
=> rtac @{thm babs_rsp} THEN' RANGE [quotient_tac ctxt]
+ − 350
+ − 351
| Const (@{const_name "op ="},_) $ (R $ _ $ _) $ (_ $ _ $ _) =>
+ − 352
(rtac @{thm refl} ORELSE'
+ − 353
(equals_rsp_tac R ctxt THEN' RANGE [
+ − 354
quot_true_tac ctxt (fst o dest_bcomb), quot_true_tac ctxt (snd o dest_bcomb)]))
+ − 355
+ − 356
(* reflexivity of operators arising from Cong_tac *)
+ − 357
| Const (@{const_name "op ="},_) $ _ $ _ => rtac @{thm refl}
+ − 358
+ − 359
(* respectfulness of constants; in particular of a simple relation *)
+ − 360
| _ $ (Const _) $ (Const _) (* fun_rel, list_rel, etc but not equality *)
+ − 361
=> resolve_tac (rsp_rules_get ctxt) THEN_ALL_NEW quotient_tac ctxt
+ − 362
+ − 363
(* R (...) (Rep (Abs ...)) ----> R (...) (...) *)
+ − 364
(* observe fun_map *)
+ − 365
| _ $ _ $ _
+ − 366
=> (rtac @{thm quot_rel_rsp} THEN_ALL_NEW quotient_tac ctxt)
+ − 367
ORELSE' rep_abs_rsp_tac ctxt
+ − 368
+ − 369
| _ => K no_tac
+ − 370
) i)
+ − 371
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 372
fun injection_step_tac ctxt rel_refl =
758
+ − 373
FIRST' [
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 374
injection_match_tac ctxt,
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 375
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 376
(* R (t $ ...) (t' $ ...) ----> apply_rsp provided type of t needs lifting *)
758
+ − 377
apply_rsp_tac ctxt THEN'
+ − 378
RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)],
+ − 379
+ − 380
(* (op =) (t $ ...) (t' $ ...) ----> Cong provided type of t does not need lifting *)
+ − 381
(* merge with previous tactic *)
+ − 382
Cong_Tac.cong_tac @{thm cong} THEN'
+ − 383
RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)],
+ − 384
+ − 385
(* (op =) (%x...) (%y...) ----> (op =) (...) (...) *)
+ − 386
rtac @{thm ext} THEN' quot_true_tac ctxt unlam,
+ − 387
+ − 388
(* resolving with R x y assumptions *)
+ − 389
atac,
+ − 390
+ − 391
(* reflexivity of the basic relations *)
+ − 392
(* R ... ... *)
+ − 393
resolve_tac rel_refl]
+ − 394
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 395
fun injection_tac ctxt =
758
+ − 396
let
+ − 397
val rel_refl = map (OF1 @{thm equivp_reflp}) (equiv_rules_get ctxt)
+ − 398
in
768
e9e205b904e2
get_fun needed change to cope with "('a fset) fset" types...this needs composition (op o); now id_simps contains also id_o and o_id, and map_id is also added in QuotList.thy; regularize and cleaning needed to be hacked (indicated by "HACK")...THIS NEEDS ATTENTION!!!; except two lemmas in IntEx, all examples go through; added considerable material to FSet3; tuned FIXME-TODO
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 399
simp_tac ((mk_minimal_ss ctxt) addsimps (id_simps_get ctxt)) (* HACK? *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 400
THEN' injection_step_tac ctxt rel_refl
758
+ − 401
end
+ − 402
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 403
fun all_injection_tac ctxt =
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 404
REPEAT_ALL_NEW (injection_tac ctxt)
758
+ − 405
+ − 406
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 407
(***************************)
758
+ − 408
(* Cleaning of the Theorem *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 409
(***************************)
758
+ − 410
+ − 411
(* expands all fun_maps, except in front of bound variables *)
+ − 412
fun fun_map_simple_conv xs ctrm =
+ − 413
case (term_of ctrm) of
+ − 414
((Const (@{const_name "fun_map"}, _) $ _ $ _) $ h $ _) =>
+ − 415
if (member (op=) xs h)
+ − 416
then Conv.all_conv ctrm
+ − 417
else Conv.rewr_conv @{thm fun_map.simps[THEN eq_reflection]} ctrm
+ − 418
| _ => Conv.all_conv ctrm
+ − 419
+ − 420
fun fun_map_conv xs ctxt ctrm =
+ − 421
case (term_of ctrm) of
+ − 422
_ $ _ => (Conv.comb_conv (fun_map_conv xs ctxt) then_conv
+ − 423
fun_map_simple_conv xs) ctrm
+ − 424
| Abs _ => Conv.abs_conv (fn (x, ctxt) => fun_map_conv ((term_of x)::xs) ctxt) ctxt ctrm
+ − 425
| _ => Conv.all_conv ctrm
+ − 426
+ − 427
fun fun_map_tac ctxt = CONVERSION (fun_map_conv [] ctxt)
+ − 428
+ − 429
fun mk_abs u i t =
+ − 430
if incr_boundvars i u aconv t then Bound i
+ − 431
else (case t of
+ − 432
t1 $ t2 => (mk_abs u i t1) $ (mk_abs u i t2)
+ − 433
| Abs (s, T, t') => Abs (s, T, mk_abs u (i + 1) t')
+ − 434
| Bound j => if i = j then error "make_inst" else t
+ − 435
| _ => t)
+ − 436
+ − 437
fun make_inst lhs t =
+ − 438
let
+ − 439
val _ $ (Abs (_, _, (_ $ ((f as Var (_, Type ("fun", [T, _]))) $ u)))) = lhs;
+ − 440
val _ $ (Abs (_, _, (_ $ g))) = t;
+ − 441
in
+ − 442
(f, Abs ("x", T, mk_abs u 0 g))
+ − 443
end
+ − 444
+ − 445
fun make_inst_id lhs t =
+ − 446
let
+ − 447
val _ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u)) = lhs;
+ − 448
val _ $ (Abs (_, _, g)) = t;
+ − 449
in
+ − 450
(f, Abs ("x", T, mk_abs u 0 g))
+ − 451
end
+ − 452
+ − 453
(* Simplifies a redex using the 'lambda_prs' theorem. *)
+ − 454
(* First instantiates the types and known subterms. *)
+ − 455
(* Then solves the quotient assumptions to get Rep2 and Abs1 *)
+ − 456
(* Finally instantiates the function f using make_inst *)
+ − 457
(* If Rep2 is identity then the pattern is simpler and *)
+ − 458
(* make_inst_id is used *)
+ − 459
fun lambda_prs_simple_conv ctxt ctrm =
+ − 460
case (term_of ctrm) of
+ − 461
(Const (@{const_name fun_map}, _) $ r1 $ a2) $ (Abs _) =>
+ − 462
(let
+ − 463
val thy = ProofContext.theory_of ctxt
+ − 464
val (ty_b, ty_a) = dest_fun_type (fastype_of r1)
+ − 465
val (ty_c, ty_d) = dest_fun_type (fastype_of a2)
+ − 466
val tyinst = map (SOME o (ctyp_of thy)) [ty_a, ty_b, ty_c, ty_d]
+ − 467
val tinst = [NONE, NONE, SOME (cterm_of thy r1), NONE, SOME (cterm_of thy a2)]
770
+ − 468
val lpi = Drule.instantiate' tyinst tinst @{thm lambda_prs[THEN eq_reflection]}
+ − 469
val te = solve_quotient_assm ctxt (solve_quotient_assm ctxt lpi)
758
+ − 470
val ts = MetaSimplifier.rewrite_rule (id_simps_get ctxt) te
+ − 471
val make_inst = if ty_c = ty_d then make_inst_id else make_inst
+ − 472
val (insp, inst) = make_inst (term_of (Thm.lhs_of ts)) (term_of ctrm)
+ − 473
val ti = Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) ts
+ − 474
in
+ − 475
Conv.rewr_conv ti ctrm
+ − 476
end
+ − 477
handle _ => Conv.all_conv ctrm)
+ − 478
| _ => Conv.all_conv ctrm
+ − 479
+ − 480
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 481
fun lambda_prs_conv ctxt = More_Conv.top_conv lambda_prs_simple_conv ctxt
758
+ − 482
fun lambda_prs_tac ctxt = CONVERSION (lambda_prs_conv ctxt)
+ − 483
+ − 484
+ − 485
(* 1. folding of definitions and preservation lemmas; *)
+ − 486
(* and simplification with *)
+ − 487
(* thm babs_prs all_prs ex_prs *)
+ − 488
(* *)
+ − 489
(* 2. unfolding of ---> in front of everything, except *)
+ − 490
(* bound variables (this prevents lambda_prs from *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 491
(* becoming stuck) *)
758
+ − 492
(* thm fun_map.simps *)
+ − 493
(* *)
+ − 494
(* 3. simplification with *)
+ − 495
(* thm lambda_prs *)
+ − 496
(* *)
+ − 497
(* 4. simplification with *)
+ − 498
(* thm Quotient_abs_rep Quotient_rel_rep id_simps *)
+ − 499
(* *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 500
(* 5. test for refl *)
758
+ − 501
768
e9e205b904e2
get_fun needed change to cope with "('a fset) fset" types...this needs composition (op o); now id_simps contains also id_o and o_id, and map_id is also added in QuotList.thy; regularize and cleaning needed to be hacked (indicated by "HACK")...THIS NEEDS ATTENTION!!!; except two lemmas in IntEx, all examples go through; added considerable material to FSet3; tuned FIXME-TODO
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 502
fun clean_tac_aux lthy =
758
+ − 503
let
+ − 504
val thy = ProofContext.theory_of lthy;
+ − 505
val defs = map (Thm.varifyT o symmetric o #def) (qconsts_dest thy)
+ − 506
(* FIXME: why is the Thm.varifyT needed: example where it fails is LamEx *)
+ − 507
+ − 508
val thms1 = defs @ (prs_rules_get lthy) @ @{thms babs_prs all_prs ex_prs}
+ − 509
val thms2 = @{thms Quotient_abs_rep Quotient_rel_rep} @ (id_simps_get lthy)
+ − 510
fun simps thms = (mk_minimal_ss lthy) addsimps thms addSolver quotient_solver
+ − 511
in
+ − 512
EVERY' [simp_tac (simps thms1),
+ − 513
fun_map_tac lthy,
+ − 514
lambda_prs_tac lthy,
+ − 515
simp_tac (simps thms2),
+ − 516
TRY o rtac refl]
+ − 517
end
+ − 518
768
e9e205b904e2
get_fun needed change to cope with "('a fset) fset" types...this needs composition (op o); now id_simps contains also id_o and o_id, and map_id is also added in QuotList.thy; regularize and cleaning needed to be hacked (indicated by "HACK")...THIS NEEDS ATTENTION!!!; except two lemmas in IntEx, all examples go through; added considerable material to FSet3; tuned FIXME-TODO
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 519
fun clean_tac lthy = REPEAT o CHANGED o (clean_tac_aux lthy) (* HACK?? *)
758
+ − 520
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 521
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 522
(********************************************************)
758
+ − 523
(* Tactic for Genralisation of Free Variables in a Goal *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 524
(********************************************************)
758
+ − 525
+ − 526
fun inst_spec ctrm =
+ − 527
Drule.instantiate' [SOME (ctyp_of_term ctrm)] [NONE, SOME ctrm] @{thm spec}
+ − 528
+ − 529
fun inst_spec_tac ctrms =
+ − 530
EVERY' (map (dtac o inst_spec) ctrms)
+ − 531
+ − 532
fun all_list xs trm =
+ − 533
fold (fn (x, T) => fn t' => HOLogic.mk_all (x, T, t')) xs trm
+ − 534
+ − 535
fun apply_under_Trueprop f =
+ − 536
HOLogic.dest_Trueprop #> f #> HOLogic.mk_Trueprop
+ − 537
+ − 538
fun gen_frees_tac ctxt =
+ − 539
SUBGOAL (fn (concl, i) =>
+ − 540
let
+ − 541
val thy = ProofContext.theory_of ctxt
+ − 542
val vrs = Term.add_frees concl []
+ − 543
val cvrs = map (cterm_of thy o Free) vrs
+ − 544
val concl' = apply_under_Trueprop (all_list vrs) concl
+ − 545
val goal = Logic.mk_implies (concl', concl)
+ − 546
val rule = Goal.prove ctxt [] [] goal
+ − 547
(K (EVERY1 [inst_spec_tac (rev cvrs), atac]))
+ − 548
in
+ − 549
rtac rule i
+ − 550
end)
+ − 551
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 552
(**********************************************)
758
+ − 553
(* The General Shape of the Lifting Procedure *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 554
(**********************************************)
758
+ − 555
+ − 556
(* - A is the original raw theorem *)
+ − 557
(* - B is the regularized theorem *)
+ − 558
(* - C is the rep/abs injected version of B *)
+ − 559
(* - D is the lifted theorem *)
+ − 560
(* *)
+ − 561
(* - 1st prem is the regularization step *)
+ − 562
(* - 2nd prem is the rep/abs injection step *)
+ − 563
(* - 3rd prem is the cleaning part *)
+ − 564
(* *)
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 565
(* the Quot_True premise in 2 records the lifted theorem *)
758
+ − 566
+ − 567
val lifting_procedure =
+ − 568
@{lemma "[|A;
+ − 569
A --> B;
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 570
Quot_True D ==> B = C;
758
+ − 571
C = D|] ==> D"
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 572
by (simp add: Quot_True_def)}
758
+ − 573
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 574
fun lift_match_error ctxt str rtrm qtrm =
758
+ − 575
let
+ − 576
val rtrm_str = Syntax.string_of_term ctxt rtrm
+ − 577
val qtrm_str = Syntax.string_of_term ctxt qtrm
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 578
val msg = cat_lines [enclose "[" "]" str, "The quotient theorem", qtrm_str,
758
+ − 579
"", "does not match with original theorem", rtrm_str]
+ − 580
in
+ − 581
error msg
+ − 582
end
+ − 583
+ − 584
fun procedure_inst ctxt rtrm qtrm =
+ − 585
let
+ − 586
val thy = ProofContext.theory_of ctxt
+ − 587
val rtrm' = HOLogic.dest_Trueprop rtrm
+ − 588
val qtrm' = HOLogic.dest_Trueprop qtrm
776
d1064fa29424
renamed get_fun to absrep_fun; introduced explicit checked versions of the term functions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 589
val reg_goal = regularize_trm_chk ctxt (rtrm', qtrm')
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 590
handle (LIFT_MATCH str) => lift_match_error ctxt str rtrm qtrm
776
d1064fa29424
renamed get_fun to absrep_fun; introduced explicit checked versions of the term functions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 591
val inj_goal = inj_repabs_trm_chk ctxt (reg_goal, qtrm')
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 592
handle (LIFT_MATCH str) => lift_match_error ctxt str rtrm qtrm
758
+ − 593
in
+ − 594
Drule.instantiate' []
+ − 595
[SOME (cterm_of thy rtrm'),
+ − 596
SOME (cterm_of thy reg_goal),
+ − 597
NONE,
+ − 598
SOME (cterm_of thy inj_goal)] lifting_procedure
+ − 599
end
+ − 600
+ − 601
+ − 602
(* the tactic leaves three subgoals to be proved *)
+ − 603
fun procedure_tac ctxt rthm =
+ − 604
ObjectLogic.full_atomize_tac
+ − 605
THEN' gen_frees_tac ctxt
+ − 606
THEN' CSUBGOAL (fn (goal, i) =>
+ − 607
let
+ − 608
val rthm' = atomize_thm rthm
+ − 609
val rule = procedure_inst ctxt (prop_of rthm') (term_of goal)
+ − 610
in
+ − 611
(rtac rule THEN' rtac rthm') i
+ − 612
end)
+ − 613
+ − 614
+ − 615
(* Automatic Proofs *)
+ − 616
+ − 617
val msg1 = "Regularize proof failed."
+ − 618
val msg2 = cat_lines ["Injection proof failed.",
+ − 619
"This is probably due to missing respects lemmas.",
+ − 620
"Try invoking the injection method manually to see",
+ − 621
"which lemmas are missing."]
+ − 622
val msg3 = "Cleaning proof failed."
+ − 623
+ − 624
fun lift_tac ctxt rthm =
+ − 625
procedure_tac ctxt rthm
+ − 626
THEN' RANGE_WARN
+ − 627
[(regularize_tac ctxt, msg1),
773
d6acae26d027
tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 628
(all_injection_tac ctxt, msg2),
758
+ − 629
(clean_tac ctxt, msg3)]
+ − 630
762
+ − 631
end; (* structure *)