src/Pure/conv.ML
author wenzelm
Mon, 07 Apr 2008 21:25:22 +0200
changeset 26571 114da911bc41
parent 26130 03a7cfed5e9e
child 27332 94790a9620c3
permissions -rw-r--r--
abs_conv: extra argument for bound variable; renamed iterated forall_conv to params_conv; added forall_conv, implies_conv, implies_concl_conv, rewr_conv;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/conv.ML
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
     3
    Author:     Amine Chaieb and Makarius
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
     4
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
     5
Conversions: primitive equality reasoning.
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
     6
*)
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
     7
22937
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
     8
infix 1 then_conv;
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
     9
infix 0 else_conv;
23169
37091da05d8e moved aconvc to more_thm.ML;
wenzelm
parents: 23034
diff changeset
    10
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    11
signature CONV =
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    12
sig
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    13
  val no_conv: conv
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    14
  val all_conv: conv
22937
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    15
  val then_conv: conv * conv -> conv
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    16
  val else_conv: conv * conv -> conv
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    17
  val first_conv: conv list -> conv
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    18
  val every_conv: conv list -> conv
22937
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    19
  val try_conv: conv -> conv
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    20
  val repeat_conv: conv -> conv
26571
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
    21
  val abs_conv: (cterm * Proof.context -> conv) -> Proof.context -> conv
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    22
  val combination_conv: conv -> conv -> conv
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    23
  val comb_conv: conv -> conv
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    24
  val arg_conv: conv -> conv
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    25
  val fun_conv: conv -> conv
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    26
  val arg1_conv: conv -> conv
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    27
  val fun2_conv: conv -> conv
23034
b3a6815754d6 added binop_conv, aconvc
chaieb
parents: 22937
diff changeset
    28
  val binop_conv: conv -> conv
26571
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
    29
  val forall_conv: (cterm * Proof.context -> conv) -> Proof.context -> conv
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
    30
  val implies_conv: conv -> conv -> conv
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
    31
  val implies_concl_conv: conv -> conv
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
    32
  val rewr_conv: thm -> conv
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
    33
  val params_conv: int -> (Proof.context -> conv) -> Proof.context -> conv
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
    34
  val prems_conv: int -> conv -> conv
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    35
  val concl_conv: int -> conv -> conv
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    36
  val fconv_rule: conv -> thm -> thm
23583
00751df1f98c else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents: 23534
diff changeset
    37
  val gconv_rule: conv -> int -> thm -> thm
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    38
end;
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    39
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    40
structure Conv: CONV =
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    41
struct
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    42
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    43
(* conversionals *)
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    44
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    45
fun no_conv _ = raise CTERM ("no conversion", []);
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    46
val all_conv = Thm.reflexive;
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    47
22937
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    48
fun (cv1 then_conv cv2) ct =
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    49
  let
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    50
    val eq1 = cv1 ct;
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    51
    val eq2 = cv2 (Thm.rhs_of eq1);
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    52
  in
23596
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
    53
    if Thm.is_reflexive eq1 then eq2
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
    54
    else if Thm.is_reflexive eq2 then eq1
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    55
    else Thm.transitive eq1 eq2
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    56
  end;
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    57
22937
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    58
fun (cv1 else_conv cv2) ct =
23583
00751df1f98c else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents: 23534
diff changeset
    59
  (cv1 ct
00751df1f98c else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents: 23534
diff changeset
    60
    handle THM _ => cv2 ct
00751df1f98c else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents: 23534
diff changeset
    61
      | CTERM _ => cv2 ct
00751df1f98c else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents: 23534
diff changeset
    62
      | TERM _ => cv2 ct
00751df1f98c else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents: 23534
diff changeset
    63
      | TYPE _ => cv2 ct);
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    64
22937
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    65
fun first_conv cvs = fold_rev (curry op else_conv) cvs no_conv;
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    66
fun every_conv cvs = fold_rev (curry op then_conv) cvs all_conv;
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    67
22937
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    68
fun try_conv cv = cv else_conv all_conv;
08cf9aaf3aa1 unified names: foo_conv;
wenzelm
parents: 22926
diff changeset
    69
fun repeat_conv cv ct = try_conv (cv then_conv repeat_conv cv) ct;
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    70
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    71
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
    72
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    73
(** Pure conversions **)
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    74
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    75
(* lambda terms *)
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    76
24834
5684cbf8c895 abs_conv/forall_conv: proper context (avoid gensym);
wenzelm
parents: 23656
diff changeset
    77
fun abs_conv cv ctxt ct =
23587
wenzelm
parents: 23583
diff changeset
    78
  (case Thm.term_of ct of
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    79
    Abs (x, _, _) =>
23596
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
    80
      let
24834
5684cbf8c895 abs_conv/forall_conv: proper context (avoid gensym);
wenzelm
parents: 23656
diff changeset
    81
        val ([u], ctxt') = Variable.variant_fixes ["u"] ctxt;
5684cbf8c895 abs_conv/forall_conv: proper context (avoid gensym);
wenzelm
parents: 23656
diff changeset
    82
        val (v, ct') = Thm.dest_abs (SOME u) ct;
26571
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
    83
        val eq = cv (v, ctxt') ct';
23596
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
    84
      in if Thm.is_reflexive eq then all_conv ct else Thm.abstract_rule x v eq end
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    85
  | _ => raise CTERM ("abs_conv", [ct]));
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    86
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    87
fun combination_conv cv1 cv2 ct =
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    88
  let val (ct1, ct2) = Thm.dest_comb ct
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    89
  in Thm.combination (cv1 ct1) (cv2 ct2) end;
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    90
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    91
fun comb_conv cv = combination_conv cv cv;
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    92
fun arg_conv cv = combination_conv all_conv cv;
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    93
fun fun_conv cv = combination_conv cv all_conv;
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    94
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    95
val arg1_conv = fun_conv o arg_conv;
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    96
val fun2_conv = fun_conv o fun_conv;
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    97
23034
b3a6815754d6 added binop_conv, aconvc
chaieb
parents: 22937
diff changeset
    98
fun binop_conv cv = combination_conv (arg_conv cv) cv;
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
    99
23169
37091da05d8e moved aconvc to more_thm.ML;
wenzelm
parents: 23034
diff changeset
   100
26571
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   101
(* primitive logic *)
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   102
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   103
fun forall_conv cv ctxt ct =
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   104
  (case Thm.term_of ct of
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   105
    Const ("all", _) $ Abs _ => arg_conv (abs_conv cv ctxt) ct
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   106
  | _ => raise CTERM ("forall_conv", [ct]));
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   107
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   108
fun implies_conv cv1 cv2 ct =
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   109
  (case Thm.term_of ct of
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   110
    Const ("==>", _) $ _ $ _ => combination_conv (arg_conv cv1) cv2 ct
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   111
  | _ => raise CTERM ("implies_conv", [ct]));
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   112
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   113
fun implies_concl_conv cv ct =
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   114
  (case Thm.term_of ct of
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   115
    Const ("==>", _) $ _ $ _ => arg_conv cv ct
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   116
  | _ => raise CTERM ("implies_concl_conv", [ct]));
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   117
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   118
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   119
(* single rewrite step, cf. REWR_CONV in HOL *)
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   120
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   121
fun rewr_conv rule ct =
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   122
  let
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   123
    val rule1 = Thm.incr_indexes (#maxidx (Thm.rep_cterm ct) + 1) rule;
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   124
    val lhs = Thm.lhs_of rule1;
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   125
    val rule2 = Thm.rename_boundvars (Thm.term_of lhs) (Thm.term_of ct) rule1;
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   126
  in
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   127
    Drule.instantiate (Thm.match (lhs, ct)) rule2
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   128
      handle Pattern.MATCH => raise CTERM ("rewr_conv", [lhs, ct])
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   129
  end;
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   130
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   131
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   132
(* conversions on HHF rules *)
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   133
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   134
(*rewrite B in !!x1 ... xn. B*)
26571
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   135
fun params_conv n cv ctxt ct =
23596
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   136
  if n <> 0 andalso can Logic.dest_all (Thm.term_of ct)
26571
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   137
  then arg_conv (abs_conv (params_conv (n - 1) cv o #2) ctxt) ct
24834
5684cbf8c895 abs_conv/forall_conv: proper context (avoid gensym);
wenzelm
parents: 23656
diff changeset
   138
  else cv ctxt ct;
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   139
26571
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   140
(*rewrite the A's in A1 ==> ... ==> An ==> B*)
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   141
fun prems_conv 0 _ ct = all_conv ct
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   142
  | prems_conv n cv ct =
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   143
      (case try Thm.dest_implies ct of
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   144
        NONE => all_conv ct
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   145
      | SOME (A, B) => Drule.imp_cong_rule (cv A) (prems_conv (n - 1) cv B));
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   146
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   147
(*rewrite B in A1 ==> ... ==> An ==> B*)
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   148
fun concl_conv 0 cv ct = cv ct
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   149
  | concl_conv n cv ct =
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   150
      (case try Thm.dest_implies ct of
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   151
        NONE => cv ct
22926
fb6917e426da more conversions;
wenzelm
parents: 22905
diff changeset
   152
      | SOME (A, B) => Drule.imp_cong_rule (all_conv A) (concl_conv (n - 1) cv B));
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   153
23596
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   154
26571
114da911bc41 abs_conv: extra argument for bound variable;
wenzelm
parents: 26130
diff changeset
   155
(* conversions as inference rules *)
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   156
23596
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   157
(*forward conversion, cf. FCONV_RULE in LCF*)
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   158
fun fconv_rule cv th =
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   159
  let val eq = cv (Thm.cprop_of th) in
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   160
    if Thm.is_reflexive eq then th
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   161
    else Thm.equal_elim eq th
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   162
  end;
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   163
23596
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   164
(*goal conversion*)
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   165
fun gconv_rule cv i th =
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   166
  (case try (Thm.cprem_of th) i of
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   167
    SOME ct =>
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   168
      let val eq = cv ct in
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   169
        if Thm.is_reflexive eq then th
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   170
        else Drule.with_subgoal i (fconv_rule (arg1_conv (K eq))) th
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   171
      end
f8381a95c49c moved type conv to thm.ML;
wenzelm
parents: 23587
diff changeset
   172
  | NONE => raise THM ("gconv_rule", i, [th]));
23411
c524900454f3 Added eta_conv and eta-expansion conversion: waiting for it to be in thm.ML; exported is_refl
chaieb
parents: 23169
diff changeset
   173
22905
dab6a898b47c Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff changeset
   174
end;