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