Quot/quotient_tacs.ML
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 26 Jan 2010 09:28:32 +0100
changeset 930 68c1f378a70a
parent 920 dae99175f584
child 939 ce774af6b964
permissions -rw-r--r--
All eq_reflections apart from the one of 'id_apply' can be removed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
signature QUOTIENT_TACS =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
sig
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
     3
  val regularize_tac: Proof.context -> int -> tactic
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
     4
  val injection_tac: Proof.context -> int -> tactic
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
     5
  val all_injection_tac: Proof.context -> int -> tactic
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
     6
  val clean_tac: Proof.context -> int -> tactic
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
     7
  val procedure_tac: Proof.context -> thm -> int -> tactic
896
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
     8
  val lift_tac: Proof.context -> thm list -> int -> tactic
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
     9
  val quotient_tac: Proof.context -> int -> tactic
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
    10
  val quot_true_tac: Proof.context -> (term -> term) -> int -> tactic
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
end;
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
structure Quotient_Tacs: QUOTIENT_TACS =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
struct
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
762
baac4639ecef avoided global "open"s - replaced by local "open"s
Christian Urban <urbanc@in.tum.de>
parents: 761
diff changeset
    16
open Quotient_Info;
baac4639ecef avoided global "open"s - replaced by local "open"s
Christian Urban <urbanc@in.tum.de>
parents: 761
diff changeset
    17
open Quotient_Term;
baac4639ecef avoided global "open"s - replaced by local "open"s
Christian Urban <urbanc@in.tum.de>
parents: 761
diff changeset
    18
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
    19
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
    20
(** various helper fuctions **)
802
Christian Urban <urbanc@in.tum.de>
parents: 789
diff changeset
    21
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>
parents: 768
diff changeset
    22
(* 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>
parents: 768
diff changeset
    23
(* need to set up our own minimal simpset.    *)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
fun  mk_minimal_ss ctxt =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  Simplifier.context ctxt empty_ss
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
    setsubgoaler asm_simp_tac
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
    setmksimps (mksimps [])
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
785
Christian Urban <urbanc@in.tum.de>
parents: 781
diff changeset
    29
(* composition of two theorems, used in maps *)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
fun OF1 thm1 thm2 = thm2 RS thm1
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
802
Christian Urban <urbanc@in.tum.de>
parents: 789
diff changeset
    32
(* prints a warning, if the subgoal is not solved *)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
fun WARN (tac, msg) i st =
857
0ce025c02ef3 added SOLVED' which is now part of Isabelle....must be removed eventually
Christian Urban <urbanc@in.tum.de>
parents: 853
diff changeset
    34
 case Seq.pull ((SOLVED' tac) i st) of
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
     NONE    => (warning msg; Seq.single st)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
   | seqcell => Seq.make (fn () => seqcell)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
802
Christian Urban <urbanc@in.tum.de>
parents: 789
diff changeset
    38
fun RANGE_WARN tacs = RANGE (map WARN tacs)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
fun atomize_thm thm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
let
804
Christian Urban <urbanc@in.tum.de>
parents: 802
diff changeset
    42
  val thm' = Thm.freezeT (forall_intr_vars thm) (* FIXME/TODO: is this proper Isar-technology? *)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  val thm'' = ObjectLogic.atomize (cprop_of thm')
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  @{thm equal_elim_rule1} OF [thm'', thm']
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
    49
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
    50
(*** Regularize Tactic ***)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
    52
(** solvers for equivp and quotient assumptions **)
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
    53
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
    54
fun equiv_tac ctxt =
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  REPEAT_ALL_NEW (resolve_tac (equiv_rules_get ctxt))
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
fun equiv_solver_tac ss = equiv_tac (Simplifier.the_context ss)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
val equiv_solver = Simplifier.mk_solver' "Equivalence goal solver" equiv_solver_tac
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
870
2a19e0a37131 Remove SOLVED from quotient_tac. Move atomize_eqv to 'Unused'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 866
diff changeset
    60
fun quotient_tac ctxt =
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>
parents: 772
diff changeset
    61
  (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>
parents: 772
diff changeset
    62
    [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>
parents: 772
diff changeset
    63
     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>
parents: 772
diff changeset
    64
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>
parents: 772
diff changeset
    65
fun quotient_solver_tac ss = quotient_tac (Simplifier.the_context ss)
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
    66
val quotient_solver =
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
    67
  Simplifier.mk_solver' "Quotient goal solver" quotient_solver_tac
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>
parents: 772
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>
parents: 772
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>
parents: 772
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>
parents: 772
diff changeset
    71
    SOME (t, _) => t
802
Christian Urban <urbanc@in.tum.de>
parents: 789
diff changeset
    72
  | _ => error "Solve_quotient_assm failed. Possibly a quotient theorem is missing."
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>
parents: 772
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>
parents: 772
diff changeset
    74
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
fun prep_trm thy (x, (T, t)) =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
  (cterm_of thy (Var (x, T)), cterm_of thy t)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
fun prep_ty thy (x, (S, ty)) =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
  (ctyp_of thy (TVar (x, S)), ctyp_of thy ty)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    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>
parents: 771
diff changeset
    81
fun get_match_inst thy pat trm =
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
  val univ = Unify.matchers thy [(pat, trm)]
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
    84
  val SOME (env, _) = Seq.pull univ             (* raises BIND, if no unifier *)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
  val tenv = Vartab.dest (Envir.term_env env)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
  val tyenv = Vartab.dest (Envir.type_env env)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
  (map (prep_ty thy) tyenv, map (prep_trm thy) tenv)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
837
116c7a30e0a2 Changing exceptions to 'try', part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 828
diff changeset
    91
(* Calculates the instantiations for the lemmas:
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
    92
837
116c7a30e0a2 Changing exceptions to 'try', part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 828
diff changeset
    93
      ball_reg_eqv_range and bex_reg_eqv_range
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
    94
837
116c7a30e0a2 Changing exceptions to 'try', part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 828
diff changeset
    95
   Since the left-hand-side contains a non-pattern '?P (f ?x)'
116c7a30e0a2 Changing exceptions to 'try', part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 828
diff changeset
    96
   we rely on unification/instantiation to check whether the
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
    97
   theorem applies and return NONE if it doesn't. 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
    98
*)
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>
parents: 772
diff changeset
    99
fun calculate_inst ctxt ball_bex_thm redex R1 R2 =
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
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>
parents: 770
diff changeset
   101
  fun get_lhs thm = fst (Logic.dest_equals (Thm.concl_of thm))
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
  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>
parents: 770
diff changeset
   103
  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>
parents: 770
diff changeset
   104
  val trm_inst1 = map (SOME o cterm_of thy) [R2, R1]
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
in
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   106
  case try (Drule.instantiate' typ_inst1 trm_inst1) ball_bex_thm of
837
116c7a30e0a2 Changing exceptions to 'try', part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 828
diff changeset
   107
    NONE => NONE
116c7a30e0a2 Changing exceptions to 'try', part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 828
diff changeset
   108
  | SOME thm' =>
116c7a30e0a2 Changing exceptions to 'try', part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 828
diff changeset
   109
      (case try (get_match_inst thy (get_lhs thm')) redex of
116c7a30e0a2 Changing exceptions to 'try', part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 828
diff changeset
   110
        NONE => NONE
116c7a30e0a2 Changing exceptions to 'try', part 1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 828
diff changeset
   111
      | SOME inst2 => try (Drule.instantiate inst2) thm')
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
fun ball_bex_range_simproc ss redex =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
  val ctxt = Simplifier.the_context ss
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
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>
parents: 771
diff changeset
   118
  case redex of
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
    (Const (@{const_name "Ball"}, _) $ (Const (@{const_name "Respects"}, _) $ 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
      (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>
parents: 772
diff changeset
   121
        calculate_inst ctxt @{thm ball_reg_eqv_range[THEN eq_reflection]} redex R1 R2
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
  | (Const (@{const_name "Bex"}, _) $ (Const (@{const_name "Respects"}, _) $ 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
      (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>
parents: 772
diff changeset
   125
        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>
parents: 772
diff changeset
   126
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
  | _ => NONE
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   130
(* Regularize works as follows:
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   131
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   132
  0. preliminary simplification step according to
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   133
     ball_reg_eqv bex_reg_eqv babs_reg_eqv ball_reg_eqv_range bex_reg_eqv_range
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   134
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   135
  1. eliminating simple Ball/Bex instances (ball_reg_right bex_reg_left)
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   136
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   137
  2. monos
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   139
  3. commutation rules for ball and bex (ball_all_comm bex_ex_comm)
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   140
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   141
  4. then rel-equalities, which need to be instantiated with 'eq_imp_rel'
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   142
     to avoid loops
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   143
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   144
  5. then simplification like 0
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   145
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   146
  finally jump back to 1 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   147
*)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
fun regularize_tac ctxt =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
  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>
parents: 771
diff changeset
   151
  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>
parents: 771
diff changeset
   152
  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>
parents: 771
diff changeset
   153
  val simproc = Simplifier.simproc_i thy "" [ball_pat, bex_pat] (K (ball_bex_range_simproc))
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
  val simpset = (mk_minimal_ss ctxt) 
845
9531fafc0daa removed 3 hacks.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 844
diff changeset
   155
                       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>
parents: 771
diff changeset
   156
                       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>
parents: 771
diff changeset
   157
                       addSolver equiv_solver addSolver quotient_solver
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
  val eq_eqvs = map (OF1 @{thm eq_imp_rel}) (equiv_rules_get ctxt)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
  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>
parents: 772
diff changeset
   161
  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>
parents: 772
diff changeset
   162
    [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>
parents: 772
diff changeset
   163
     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>
parents: 772
diff changeset
   164
     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>
parents: 772
diff changeset
   165
     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>
parents: 772
diff changeset
   166
     simp_tac simpset])
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   170
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   171
(*** Injection Tactic ***)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   173
(* Looks for Quot_True assumtions, and in case its parameter
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   174
   is an application, it returns the function and the argument. 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   175
*)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
fun find_qt_asm asms =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   178
  fun find_fun trm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   179
    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>
parents: 772
diff changeset
   180
      (Const(@{const_name Trueprop}, _) $ (Const (@{const_name Quot_True}, _) $ _)) => true
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   181
    | _ => false
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   182
in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
 case find_first find_fun asms of
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   184
   SOME (_ $ (_ $ (f $ a))) => SOME (f, a)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   185
 | _ => NONE
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   186
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   187
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   188
fun quot_true_simple_conv ctxt fnctn ctrm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   189
  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>
parents: 772
diff changeset
   190
    (Const (@{const_name Quot_True}, _) $ x) =>
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
    let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   192
      val fx = fnctn x;
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   193
      val thy = ProofContext.theory_of ctxt;
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   194
      val cx = cterm_of thy x;
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
      val cfx = cterm_of thy fx;
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
      val cxt = ctyp_of thy (fastype_of x);
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
      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>
parents: 772
diff changeset
   198
      val thm = Drule.instantiate' [SOME cxt, SOME cfxt] [SOME cx, SOME cfx] @{thm QT_imp}
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
    in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
      Conv.rewr_conv thm ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   201
    end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   202
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   203
fun quot_true_conv ctxt fnctn ctrm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   204
  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>
parents: 772
diff changeset
   205
    (Const (@{const_name Quot_True}, _) $ _) =>
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   206
      quot_true_simple_conv ctxt fnctn ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   207
  | _ $ _ => Conv.comb_conv (quot_true_conv ctxt fnctn) ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   208
  | Abs _ => Conv.abs_conv (fn (_, ctxt) => quot_true_conv ctxt fnctn) ctxt ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   209
  | _ => Conv.all_conv ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   211
fun quot_true_tac ctxt fnctn = 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   212
   CONVERSION
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   213
    ((Conv.params_conv ~1 (fn ctxt =>
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   214
       (Conv.prems_conv ~1 (quot_true_conv ctxt fnctn)))) ctxt)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   215
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   216
fun dest_comb (f $ a) = (f, a) 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   217
fun dest_bcomb ((_ $ l) $ r) = (l, r) 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   218
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   219
fun unlam t =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   220
  case t of
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   221
    (Abs a) => snd (Term.dest_abs a)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   222
  | _ => unlam (Abs("", domain_type (fastype_of t), (incr_boundvars 1 t) $ (Bound 0)))
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   223
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   224
fun dest_fun_type (Type("fun", [T, S])) = (T, S)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   225
  | dest_fun_type _ = error "dest_fun_type"
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   226
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   227
val bare_concl = HOLogic.dest_Trueprop o Logic.strip_assums_concl
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   228
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   229
(* We apply apply_rsp only in case if the type needs lifting.
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   230
   This is the case if the type of the data in the Quot_True
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   231
   assumption is different from the corresponding type in the goal. 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   232
*)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   233
val apply_rsp_tac =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   234
  Subgoal.FOCUS (fn {concl, asms, context,...} =>
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   235
  let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   236
    val bare_concl = HOLogic.dest_Trueprop (term_of concl)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   237
    val qt_asm = find_qt_asm (map term_of asms)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   238
  in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   239
    case (bare_concl, qt_asm) of
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   240
      (R2 $ (f $ x) $ (g $ y), SOME (qt_fun, qt_arg)) =>
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   241
         if (fastype_of qt_fun) = (fastype_of f)
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   242
         then no_tac
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   243
         else
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   244
           let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   245
             val ty_x = fastype_of x
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   246
             val ty_b = fastype_of qt_arg
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   247
             val ty_f = range_type (fastype_of f)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   248
             val thy = ProofContext.theory_of context
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   249
             val ty_inst = map (SOME o (ctyp_of thy)) [ty_x, ty_b, ty_f]
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   250
             val t_inst = map (SOME o (cterm_of thy)) [R2, f, g, x, y];
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   251
             val inst_thm = Drule.instantiate' ty_inst
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   252
               ([NONE, NONE, NONE] @ t_inst) @{thm apply_rsp}
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   253
           in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   254
             (rtac inst_thm THEN' quotient_tac context) 1
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   255
           end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   256
    | _ => no_tac
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   257
  end)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   258
842
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   259
(* Instantiates and applies 'equals_rsp'. Since the theorem is
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   260
   complex we rely on instantiation to tell us if it applies 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   261
*)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   262
fun equals_rsp_tac R ctxt =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   263
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   264
  val thy = ProofContext.theory_of ctxt
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   265
in
842
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   266
  case try (cterm_of thy) R of (* There can be loose bounds in R *)
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   267
    SOME ctm =>
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   268
      let
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   269
        val ty = domain_type (fastype_of R)
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   270
      in
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   271
        case try (Drule.instantiate' [SOME (ctyp_of thy ty)]
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   272
          [SOME (cterm_of thy R)]) @{thm equals_rsp} of
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   273
          SOME thm => rtac thm THEN' quotient_tac ctxt
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   274
        | NONE => K no_tac
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   275
      end
0332d0df2fc9 Removed exception handling from equals_rsp_tac.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 839
diff changeset
   276
  | _ => K no_tac
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   277
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   278
847
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   279
fun rep_abs_rsp_tac ctxt =
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   280
  SUBGOAL (fn (goal, i) =>
847
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   281
    case (try bare_concl goal) of
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   282
      SOME (rel $ _ $ (rep $ (abs $ _))) =>
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   283
        let
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   284
          val thy = ProofContext.theory_of ctxt;
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   285
          val (ty_a, ty_b) = dest_fun_type (fastype_of abs);
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   286
          val ty_inst = map (SOME o (ctyp_of thy)) [ty_a, ty_b];
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   287
        in
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   288
          case try (map (SOME o (cterm_of thy))) [rel, abs, rep] of
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   289
            SOME t_inst =>
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   290
              (case try (Drule.instantiate' ty_inst t_inst) @{thm rep_abs_rsp} of
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   291
                SOME inst_thm => (rtac inst_thm THEN' quotient_tac ctxt) i
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   292
              | NONE => no_tac)
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   293
          | NONE => no_tac
b89707cd030f No more exception handling in rep_abs_rsp_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 846
diff changeset
   294
        end
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   295
    | _ => no_tac)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   296
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   297
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   298
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   299
(* Injection means to prove that the regularised theorem implies 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   300
   the abs/rep injected one.
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   301
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   302
   The deterministic part:
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   303
    - remove lambdas from both sides
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   304
    - prove Ball/Bex/Babs equalities using ball_rsp, bex_rsp, babs_rsp
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   305
    - prove Ball/Bex relations unfolding fun_rel_id
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   306
    - reflexivity of equality
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   307
    - prove equality of relations using equals_rsp
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   308
    - use user-supplied RSP theorems
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   309
    - solve 'relation of relations' goals using quot_rel_rsp
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   310
    - remove rep_abs from the right side
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   311
      (Lambdas under respects may have left us some assumptions)
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   312
 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   313
   Then in order:
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   314
    - split applications of lifted type (apply_rsp)
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   315
    - split applications of non-lifted type (cong_tac)
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   316
    - apply extentionality
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   317
    - assumption
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   318
    - reflexivity of the relation
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   319
*)
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>
parents: 772
diff changeset
   320
fun injection_match_tac ctxt = SUBGOAL (fn (goal, i) =>
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   321
(case (bare_concl goal) of
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   322
    (* (R1 ===> R2) (%x...) (%x...) ----> [|R1 x y|] ==> R2 (...x) (...y) *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   323
  (Const (@{const_name fun_rel}, _) $ _ $ _) $ (Abs _) $ (Abs _)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   324
      => rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   325
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   326
    (* (op =) (Ball...) (Ball...) ----> (op =) (...) (...) *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   327
| (Const (@{const_name "op ="},_) $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   328
    (Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   329
    (Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _))
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   330
      => rtac @{thm ball_rsp} THEN' dtac @{thm QT_all}
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   331
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   332
    (* (R1 ===> op =) (Ball...) (Ball...) ----> [|R1 x y|] ==> (Ball...x) = (Ball...y) *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   333
| (Const (@{const_name fun_rel}, _) $ _ $ _) $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   334
    (Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   335
    (Const(@{const_name Ball},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   336
      => rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   337
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   338
    (* (op =) (Bex...) (Bex...) ----> (op =) (...) (...) *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   339
| Const (@{const_name "op ="},_) $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   340
    (Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   341
    (Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   342
      => rtac @{thm bex_rsp} THEN' dtac @{thm QT_ex}
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   343
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   344
    (* (R1 ===> op =) (Bex...) (Bex...) ----> [|R1 x y|] ==> (Bex...x) = (Bex...y) *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   345
| (Const (@{const_name fun_rel}, _) $ _ $ _) $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   346
    (Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   347
    (Const(@{const_name Bex},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   348
      => rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   349
908
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   350
| Const (@{const_name "op ="},_) $
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   351
    (Const(@{const_name Bex1},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   352
    (Const(@{const_name Bex1},_) $ (Const (@{const_name Respects}, _) $ _) $ _)
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   353
      => rtac @{thm bex1_rsp} THEN' dtac @{thm QT_ex1}
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   354
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   355
(* TODO: Check why less _ are needed then in EX/ALL cases *)
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   356
| (Const (@{const_name fun_rel}, _) $ _ $ _) $
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   357
    (Const(@{const_name Bex1},_) $ (Const (@{const_name Respects}, _) $ _)) $
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   358
    (Const(@{const_name Bex1},_) $ (Const (@{const_name Respects}, _) $ _))
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   359
      => rtac @{thm fun_rel_id} THEN' quot_true_tac ctxt unlam
1bf4337919d3 Bexeq definition, Ex1_prs lemma, Bex1_rsp lemma, compiles.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 906
diff changeset
   360
911
95ee248b3832 Automatic injection of Bexeq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 910
diff changeset
   361
| (Const (@{const_name fun_rel}, _) $ _ $ _) $
95ee248b3832 Automatic injection of Bexeq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 910
diff changeset
   362
    (Const(@{const_name Bexeq},_) $ _) $ (Const(@{const_name Bexeq},_) $ _)
95ee248b3832 Automatic injection of Bexeq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 910
diff changeset
   363
      => rtac @{thm bexeq_rsp} THEN' quotient_tac ctxt
95ee248b3832 Automatic injection of Bexeq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 910
diff changeset
   364
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   365
| (_ $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   366
    (Const(@{const_name Babs},_) $ (Const (@{const_name Respects}, _) $ _) $ _) $
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   367
    (Const(@{const_name Babs},_) $ (Const (@{const_name Respects}, _) $ _) $ _))
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   368
      => rtac @{thm babs_rsp} THEN' RANGE [quotient_tac ctxt]
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   369
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   370
| Const (@{const_name "op ="},_) $ (R $ _ $ _) $ (_ $ _ $ _) => 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   371
   (rtac @{thm refl} ORELSE'
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   372
    (equals_rsp_tac R ctxt THEN' RANGE [
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   373
       quot_true_tac ctxt (fst o dest_bcomb), quot_true_tac ctxt (snd o dest_bcomb)]))
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   374
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   375
    (* reflexivity of operators arising from Cong_tac *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   376
| Const (@{const_name "op ="},_) $ _ $ _ => rtac @{thm refl}
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   377
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   378
   (* respectfulness of constants; in particular of a simple relation *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   379
| _ $ (Const _) $ (Const _)  (* fun_rel, list_rel, etc but not equality *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   380
    => resolve_tac (rsp_rules_get ctxt) THEN_ALL_NEW quotient_tac ctxt
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   381
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   382
    (* R (...) (Rep (Abs ...)) ----> R (...) (...) *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   383
    (* observe fun_map *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   384
| _ $ _ $ _
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   385
    => (rtac @{thm quot_rel_rsp} THEN_ALL_NEW quotient_tac ctxt) 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   386
       ORELSE' rep_abs_rsp_tac ctxt
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   387
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   388
| _ => K no_tac
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   389
) i)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   390
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>
parents: 772
diff changeset
   391
fun injection_step_tac ctxt rel_refl =
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   392
 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>
parents: 772
diff changeset
   393
    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>
parents: 772
diff changeset
   394
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   395
    (* R (t $ ...) (t' $ ...) ----> apply_rsp   provided type of t needs lifting *)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   396
    apply_rsp_tac ctxt THEN'
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   397
                 RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)],
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   398
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   399
    (* (op =) (t $ ...) (t' $ ...) ----> Cong   provided type of t does not need lifting *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   400
    (* merge with previous tactic *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   401
    Cong_Tac.cong_tac @{thm cong} THEN'
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   402
                 RANGE [quot_true_tac ctxt (fst o dest_comb), quot_true_tac ctxt (snd o dest_comb)],
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   403
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   404
    (* (op =) (%x...) (%y...) ----> (op =) (...) (...) *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   405
    rtac @{thm ext} THEN' quot_true_tac ctxt unlam,
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   406
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   407
    (* resolving with R x y assumptions *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   408
    atac,
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   409
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   410
    (* reflexivity of the basic relations *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   411
    (* R ... ... *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   412
    resolve_tac rel_refl]
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   413
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>
parents: 772
diff changeset
   414
fun injection_tac ctxt =
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   415
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   416
  val rel_refl = map (OF1 @{thm equivp_reflp}) (equiv_rules_get ctxt)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   417
in
845
9531fafc0daa removed 3 hacks.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 844
diff changeset
   418
  injection_step_tac ctxt rel_refl
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   419
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   420
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>
parents: 772
diff changeset
   421
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>
parents: 772
diff changeset
   422
  REPEAT_ALL_NEW (injection_tac ctxt)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   423
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   424
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   425
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   426
(*** Cleaning of the Theorem ***)
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   427
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   428
(* expands all fun_maps, except in front of the bound variables listed in xs *)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   429
fun fun_map_simple_conv xs ctrm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   430
  case (term_of ctrm) of
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   431
    ((Const (@{const_name "fun_map"}, _) $ _ $ _) $ h $ _) =>
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   432
        if (member (op=) xs h)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   433
        then Conv.all_conv ctrm
913
b1f55dd64481 Changed fun_map and rel_map to definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 911
diff changeset
   434
        else Conv.rewr_conv @{thm fun_map_def[THEN eq_reflection]} ctrm 
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   435
  | _ => Conv.all_conv ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   436
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   437
fun fun_map_conv xs ctxt ctrm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   438
  case (term_of ctrm) of
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   439
      _ $ _ => (Conv.comb_conv (fun_map_conv xs ctxt) then_conv
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   440
                fun_map_simple_conv xs) ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   441
    | Abs _ => Conv.abs_conv (fn (x, ctxt) => fun_map_conv ((term_of x)::xs) ctxt) ctxt ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   442
    | _ => Conv.all_conv ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   443
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   444
fun fun_map_tac ctxt = CONVERSION (fun_map_conv [] ctxt)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   445
785
Christian Urban <urbanc@in.tum.de>
parents: 781
diff changeset
   446
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   447
fun mk_abs u i t =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   448
  if incr_boundvars i u aconv t then Bound i
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   449
  else (case t of
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   450
     t1 $ t2 => (mk_abs u i t1) $ (mk_abs u i t2)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   451
   | Abs (s, T, t') => Abs (s, T, mk_abs u (i + 1) t')
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   452
   | Bound j => if i = j then error "make_inst" else t
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   453
   | _ => t)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   454
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   455
fun make_inst lhs t =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   456
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   457
  val _ $ (Abs (_, _, (_ $ ((f as Var (_, Type ("fun", [T, _]))) $ u)))) = lhs;
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   458
  val _ $ (Abs (_, _, (_ $ g))) = t;
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   459
in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   460
  (f, Abs ("x", T, mk_abs u 0 g))
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   461
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   462
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   463
fun make_inst_id lhs t =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   464
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   465
  val _ $ (Abs (_, _, (f as Var (_, Type ("fun", [T, _]))) $ u)) = lhs;
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   466
  val _ $ (Abs (_, _, g)) = t;
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   467
in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   468
  (f, Abs ("x", T, mk_abs u 0 g))
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   469
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   470
846
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   471
(* Simplifies a redex using the 'lambda_prs' theorem.
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   472
   First instantiates the types and known subterms.
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   473
   Then solves the quotient assumptions to get Rep2 and Abs1
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   474
   Finally instantiates the function f using make_inst
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   475
   If Rep2 is an identity then the pattern is simpler and
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   476
   make_inst_id is used 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   477
*)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   478
fun lambda_prs_simple_conv ctxt ctrm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   479
  case (term_of ctrm) of
846
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   480
    (Const (@{const_name fun_map}, _) $ r1 $ a2) $ (Abs _) =>
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   481
      let
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   482
        val thy = ProofContext.theory_of ctxt
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   483
        val (ty_b, ty_a) = dest_fun_type (fastype_of r1)
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   484
        val (ty_c, ty_d) = dest_fun_type (fastype_of a2)
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   485
        val tyinst = map (SOME o (ctyp_of thy)) [ty_a, ty_b, ty_c, ty_d]
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   486
        val tinst = [NONE, NONE, SOME (cterm_of thy r1), NONE, SOME (cterm_of thy a2)]
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   487
        val lpi = Drule.instantiate' tyinst tinst @{thm lambda_prs[THEN eq_reflection]}
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   488
        val te = solve_quotient_assm ctxt (solve_quotient_assm ctxt lpi)
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   489
        val ts = MetaSimplifier.rewrite_rule (id_simps_get ctxt) te
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   490
        val (insp, inst) =
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   491
          if ty_c = ty_d
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   492
          then make_inst_id (term_of (Thm.lhs_of ts)) (term_of ctrm)
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   493
          else make_inst (term_of (Thm.lhs_of ts)) (term_of ctrm)
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   494
        val ti = Drule.instantiate ([], [(cterm_of thy insp, cterm_of thy inst)]) ts
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   495
      in
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   496
        Conv.rewr_conv ti ctrm
9a0a0b92e8fe handle all is no longer necessary in lambda_prs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 845
diff changeset
   497
      end
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   498
  | _ => Conv.all_conv ctrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   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>
parents: 772
diff changeset
   500
fun lambda_prs_conv ctxt = More_Conv.top_conv lambda_prs_simple_conv ctxt
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   501
fun lambda_prs_tac ctxt = CONVERSION (lambda_prs_conv ctxt)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   502
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   503
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   504
(* Cleaning consists of:
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   505
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   506
  1. folding of definitions and preservation lemmas;
910
b91782991dc8 Automatic cleaning of Bexeq<->Ex1 theorems.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 908
diff changeset
   507
     and simplification with babs_prs all_prs ex_prs ex1_prs
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   508
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   509
  2. unfolding of ---> in front of everything, except
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   510
     bound variables
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   511
     (this prevents lambda_prs from becoming stuck)
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   512
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   513
  3. simplification with lambda_prs
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   514
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   515
  4. simplification with Quotient_abs_rep Quotient_rel_rep id_simps
910
b91782991dc8 Automatic cleaning of Bexeq<->Ex1 theorems.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 908
diff changeset
   516
     and ex1_prs (since it may need lambdas to be folded).
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   517
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   518
  5. test for refl 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   519
*)
845
9531fafc0daa removed 3 hacks.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 844
diff changeset
   520
fun clean_tac lthy =
785
Christian Urban <urbanc@in.tum.de>
parents: 781
diff changeset
   521
let
871
4163fe3dbf8c produce defs with lthy, like prs and ids
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 870
diff changeset
   522
  val defs = map (Thm.varifyT o symmetric o #def) (qconsts_dest lthy)
802
Christian Urban <urbanc@in.tum.de>
parents: 789
diff changeset
   523
  (* FIXME: why is the Thm.varifyT needed: example where it fails is LamEx *)
789
Christian Urban <urbanc@in.tum.de>
parents: 785
diff changeset
   524
  val prs = prs_rules_get lthy
Christian Urban <urbanc@in.tum.de>
parents: 785
diff changeset
   525
  val ids = id_simps_get lthy
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   526
789
Christian Urban <urbanc@in.tum.de>
parents: 785
diff changeset
   527
  fun mk_simps thms = (mk_minimal_ss lthy) addsimps thms addSolver quotient_solver
910
b91782991dc8 Automatic cleaning of Bexeq<->Ex1 theorems.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 908
diff changeset
   528
  val ss1 = mk_simps (defs @ prs @ @{thms babs_prs all_prs ex_prs ex1_prs})
930
68c1f378a70a All eq_reflections apart from the one of 'id_apply' can be removed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 920
diff changeset
   529
  val ss2 = mk_simps (@{thms Quotient_abs_rep Quotient_rel_rep ex1_prs} @ ids)
785
Christian Urban <urbanc@in.tum.de>
parents: 781
diff changeset
   530
in
789
Christian Urban <urbanc@in.tum.de>
parents: 785
diff changeset
   531
  EVERY' [simp_tac ss1,
785
Christian Urban <urbanc@in.tum.de>
parents: 781
diff changeset
   532
          fun_map_tac lthy,
Christian Urban <urbanc@in.tum.de>
parents: 781
diff changeset
   533
          lambda_prs_tac lthy,
789
Christian Urban <urbanc@in.tum.de>
parents: 785
diff changeset
   534
          simp_tac ss2,
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   535
          TRY o rtac refl]
785
Christian Urban <urbanc@in.tum.de>
parents: 781
diff changeset
   536
end
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   537
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>
parents: 772
diff changeset
   538
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   539
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   540
(** Tactic for Generalising Free Variables in a Goal **)
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   541
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   542
fun inst_spec ctrm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   543
   Drule.instantiate' [SOME (ctyp_of_term ctrm)] [NONE, SOME ctrm] @{thm spec}
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   544
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   545
fun inst_spec_tac ctrms =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   546
  EVERY' (map (dtac o inst_spec) ctrms)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   547
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   548
fun all_list xs trm = 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   549
  fold (fn (x, T) => fn t' => HOLogic.mk_all (x, T, t')) xs trm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   550
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   551
fun apply_under_Trueprop f = 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   552
  HOLogic.dest_Trueprop #> f #> HOLogic.mk_Trueprop
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   553
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   554
fun gen_frees_tac ctxt =
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   555
  SUBGOAL (fn (concl, i) =>
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   556
    let
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   557
      val thy = ProofContext.theory_of ctxt
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   558
      val vrs = Term.add_frees concl []
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   559
      val cvrs = map (cterm_of thy o Free) vrs
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   560
      val concl' = apply_under_Trueprop (all_list vrs) concl
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   561
      val goal = Logic.mk_implies (concl', concl)
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   562
      val rule = Goal.prove ctxt [] [] goal
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   563
        (K (EVERY1 [inst_spec_tac (rev cvrs), atac]))
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   564
    in
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   565
      rtac rule i
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   566
    end)
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   567
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   568
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   569
(** The General Shape of the Lifting Procedure **)
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   570
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   571
(* - A is the original raw theorem
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   572
   - B is the regularized theorem
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   573
   - C is the rep/abs injected version of B
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   574
   - D is the lifted theorem
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   575
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   576
   - 1st prem is the regularization step
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   577
   - 2nd prem is the rep/abs injection step
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   578
   - 3rd prem is the cleaning part
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   579
858
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   580
   the Quot_True premise in 2nd records the lifted theorem 
Christian Urban <urbanc@in.tum.de>
parents: 857
diff changeset
   581
*)
853
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   582
val lifting_procedure_thm =
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   583
  @{lemma  "[|A;
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   584
              A --> B;
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   585
              Quot_True D ==> B = C;
3fd1365f5729 More indenting, bracket removing and comment restructuring.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 848
diff changeset
   586
              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>
parents: 772
diff changeset
   587
      by (simp add: Quot_True_def)}
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   588
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>
parents: 772
diff changeset
   589
fun lift_match_error ctxt str rtrm qtrm =
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   590
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   591
  val rtrm_str = Syntax.string_of_term ctxt rtrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   592
  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>
parents: 772
diff changeset
   593
  val msg = cat_lines [enclose "[" "]" str, "The quotient theorem", qtrm_str, 
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   594
    "", "does not match with original theorem", rtrm_str]
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   595
in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   596
  error msg
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   597
end
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   598
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   599
fun procedure_inst ctxt rtrm qtrm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   600
let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   601
  val thy = ProofContext.theory_of ctxt
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   602
  val rtrm' = HOLogic.dest_Trueprop rtrm
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   603
  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>
parents: 775
diff changeset
   604
  val reg_goal = regularize_trm_chk ctxt (rtrm', qtrm')
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   605
    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>
parents: 775
diff changeset
   606
  val inj_goal = inj_repabs_trm_chk ctxt (reg_goal, qtrm')
848
0eb018699f46 Cleaning comments, indentation etc in quotient_tacs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 847
diff changeset
   607
    handle (LIFT_MATCH str) => lift_match_error ctxt str rtrm qtrm
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   608
in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   609
  Drule.instantiate' []
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   610
    [SOME (cterm_of thy rtrm'),
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   611
     SOME (cterm_of thy reg_goal),
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   612
     NONE,
802
Christian Urban <urbanc@in.tum.de>
parents: 789
diff changeset
   613
     SOME (cterm_of thy inj_goal)] lifting_procedure_thm
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   614
end
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   615
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   616
(* the tactic leaves three subgoals to be proved *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   617
fun procedure_tac ctxt rthm =
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   618
  ObjectLogic.full_atomize_tac
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   619
  THEN' gen_frees_tac ctxt
785
Christian Urban <urbanc@in.tum.de>
parents: 781
diff changeset
   620
  THEN' SUBGOAL (fn (goal, i) =>
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   621
    let
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   622
      val rthm' = atomize_thm rthm
785
Christian Urban <urbanc@in.tum.de>
parents: 781
diff changeset
   623
      val rule = procedure_inst ctxt (prop_of rthm') goal
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   624
    in
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   625
      (rtac rule THEN' rtac rthm') i
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   626
    end)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   627
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   628
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   629
(* Automatic Proofs *)
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   630
896
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   631
val msg1 = "The regularize proof failed."
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   632
val msg2 = cat_lines ["The injection proof failed.", 
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   633
                      "This is probably due to missing respects lemmas.",
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   634
                      "Try invoking the injection method manually to see", 
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   635
                      "which lemmas are missing."]
896
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   636
val msg3 = "The cleaning proof failed."
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   637
896
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   638
fun lift_tac ctxt rthms =
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   639
let
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   640
  fun mk_tac rthm = 
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   641
    procedure_tac ctxt rthm
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   642
    THEN' RANGE_WARN 
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   643
      [(regularize_tac ctxt, msg1),
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   644
       (all_injection_tac ctxt, msg2),
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   645
       (clean_tac ctxt, msg3)]
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   646
in
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   647
  simp_tac (mk_minimal_ss ctxt) (* unfolding multiple &&& *)  
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   648
  THEN' RANGE (map mk_tac rthms)
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 871
diff changeset
   649
end
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   650
814
cd3fa86be45f Sledgehammer bug.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 804
diff changeset
   651
end; (* structure *)