author | wenzelm |
Mon, 25 Oct 2021 17:26:27 +0200 | |
changeset 74576 | 0b43d42cfde7 |
parent 74560 | 5c8177fd1295 |
permissions | -rw-r--r-- |
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
1 |
(* Title: Pure/conv.ML |
32843
c8f5a7c8353f
moved cache_conv to src/Pure/conv.ML, use Thm.cterm_cache;
wenzelm
parents:
30136
diff
changeset
|
2 |
Author: Amine Chaieb, TU Muenchen |
36936
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
3 |
Author: Sascha Boehme, TU Muenchen |
32843
c8f5a7c8353f
moved cache_conv to src/Pure/conv.ML, use Thm.cterm_cache;
wenzelm
parents:
30136
diff
changeset
|
4 |
Author: Makarius |
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
5 |
|
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
6 |
Conversions: primitive equality reasoning. |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
7 |
*) |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
8 |
|
22937 | 9 |
infix 1 then_conv; |
10 |
infix 0 else_conv; |
|
23169 | 11 |
|
30136
6a874aedb964
Made then_conv and else_conv available as infix operations.
boehmes
parents:
29606
diff
changeset
|
12 |
signature BASIC_CONV = |
6a874aedb964
Made then_conv and else_conv available as infix operations.
boehmes
parents:
29606
diff
changeset
|
13 |
sig |
6a874aedb964
Made then_conv and else_conv available as infix operations.
boehmes
parents:
29606
diff
changeset
|
14 |
val then_conv: conv * conv -> conv |
6a874aedb964
Made then_conv and else_conv available as infix operations.
boehmes
parents:
29606
diff
changeset
|
15 |
val else_conv: conv * conv -> conv |
6a874aedb964
Made then_conv and else_conv available as infix operations.
boehmes
parents:
29606
diff
changeset
|
16 |
end; |
6a874aedb964
Made then_conv and else_conv available as infix operations.
boehmes
parents:
29606
diff
changeset
|
17 |
|
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
18 |
signature CONV = |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
19 |
sig |
30136
6a874aedb964
Made then_conv and else_conv available as infix operations.
boehmes
parents:
29606
diff
changeset
|
20 |
include BASIC_CONV |
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
21 |
val no_conv: conv |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
22 |
val all_conv: conv |
22926 | 23 |
val first_conv: conv list -> conv |
24 |
val every_conv: conv list -> conv |
|
22937 | 25 |
val try_conv: conv -> conv |
26 |
val repeat_conv: conv -> conv |
|
74560 | 27 |
val changed_conv: conv -> conv |
28 |
val repeat_changed_conv: conv -> conv |
|
32843
c8f5a7c8353f
moved cache_conv to src/Pure/conv.ML, use Thm.cterm_cache;
wenzelm
parents:
30136
diff
changeset
|
29 |
val cache_conv: conv -> conv |
26571 | 30 |
val abs_conv: (cterm * Proof.context -> conv) -> Proof.context -> conv |
22926 | 31 |
val combination_conv: conv -> conv -> conv |
32 |
val comb_conv: conv -> conv |
|
33 |
val arg_conv: conv -> conv |
|
34 |
val fun_conv: conv -> conv |
|
35 |
val arg1_conv: conv -> conv |
|
36 |
val fun2_conv: conv -> conv |
|
23034 | 37 |
val binop_conv: conv -> conv |
36936
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
38 |
val binder_conv: (cterm * Proof.context -> conv) -> Proof.context -> conv |
26571 | 39 |
val forall_conv: (cterm * Proof.context -> conv) -> Proof.context -> conv |
40 |
val implies_conv: conv -> conv -> conv |
|
41 |
val implies_concl_conv: conv -> conv |
|
42 |
val rewr_conv: thm -> conv |
|
36936
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
43 |
val rewrs_conv: thm list -> conv |
74545 | 44 |
val bottom_rewrs_conv: thm list -> Proof.context -> conv |
45 |
val top_rewrs_conv: thm list -> Proof.context -> conv |
|
46 |
val top_sweep_rewrs_conv: thm list -> Proof.context -> conv |
|
36936
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
47 |
val sub_conv: (Proof.context -> conv) -> Proof.context -> conv |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
48 |
val bottom_conv: (Proof.context -> conv) -> Proof.context -> conv |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
49 |
val top_conv: (Proof.context -> conv) -> Proof.context -> conv |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
50 |
val top_sweep_conv: (Proof.context -> conv) -> Proof.context -> conv |
26571 | 51 |
val params_conv: int -> (Proof.context -> conv) -> Proof.context -> conv |
52 |
val prems_conv: int -> conv -> conv |
|
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
53 |
val concl_conv: int -> conv -> conv |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
54 |
val fconv_rule: conv -> thm -> thm |
23583
00751df1f98c
else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents:
23534
diff
changeset
|
55 |
val gconv_rule: conv -> int -> thm -> thm |
22905
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 |
|
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
58 |
structure Conv: CONV = |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
59 |
struct |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
60 |
|
32843
c8f5a7c8353f
moved cache_conv to src/Pure/conv.ML, use Thm.cterm_cache;
wenzelm
parents:
30136
diff
changeset
|
61 |
(* basic conversionals *) |
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
62 |
|
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
63 |
fun no_conv _ = raise CTERM ("no conversion", []); |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
64 |
val all_conv = Thm.reflexive; |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
65 |
|
22937 | 66 |
fun (cv1 then_conv cv2) ct = |
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
67 |
let |
22926 | 68 |
val eq1 = cv1 ct; |
69 |
val eq2 = cv2 (Thm.rhs_of eq1); |
|
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
70 |
in |
23596 | 71 |
if Thm.is_reflexive eq1 then eq2 |
72 |
else if Thm.is_reflexive eq2 then eq1 |
|
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
73 |
else Thm.transitive eq1 eq2 |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
74 |
end; |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
75 |
|
22937 | 76 |
fun (cv1 else_conv cv2) ct = |
23583
00751df1f98c
else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents:
23534
diff
changeset
|
77 |
(cv1 ct |
00751df1f98c
else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents:
23534
diff
changeset
|
78 |
handle THM _ => cv2 ct |
00751df1f98c
else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents:
23534
diff
changeset
|
79 |
| CTERM _ => cv2 ct |
00751df1f98c
else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents:
23534
diff
changeset
|
80 |
| TERM _ => cv2 ct |
00751df1f98c
else_conv: only handle THM | CTERM | TERM | TYPE;
wenzelm
parents:
23534
diff
changeset
|
81 |
| TYPE _ => cv2 ct); |
22926 | 82 |
|
22937 | 83 |
fun first_conv cvs = fold_rev (curry op else_conv) cvs no_conv; |
84 |
fun every_conv cvs = fold_rev (curry op then_conv) cvs all_conv; |
|
22926 | 85 |
|
22937 | 86 |
fun try_conv cv = cv else_conv all_conv; |
87 |
fun repeat_conv cv ct = try_conv (cv then_conv repeat_conv cv) ct; |
|
22926 | 88 |
|
74560 | 89 |
fun changed_conv conv ct = |
90 |
let val th = conv ct |
|
91 |
in if Thm.is_reflexive th then raise CTERM ("changed_conv", [ct]) else th end; |
|
92 |
||
93 |
val repeat_changed_conv = repeat_conv o changed_conv; |
|
94 |
||
74270 | 95 |
fun cache_conv (cv: conv) = Ctermtab.cterm_cache cv; |
32843
c8f5a7c8353f
moved cache_conv to src/Pure/conv.ML, use Thm.cterm_cache;
wenzelm
parents:
30136
diff
changeset
|
96 |
|
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
97 |
|
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
98 |
|
22926 | 99 |
(** Pure conversions **) |
100 |
||
101 |
(* lambda terms *) |
|
102 |
||
24834
5684cbf8c895
abs_conv/forall_conv: proper context (avoid gensym);
wenzelm
parents:
23656
diff
changeset
|
103 |
fun abs_conv cv ctxt ct = |
23587 | 104 |
(case Thm.term_of ct of |
74525
c960bfcb91db
discontinued Term.dest_abs / Logic.dest_all, which are officially superseded by Variable.dest_abs etc., but there are also Term.dest_abs_global to recover existing tools easily;
wenzelm
parents:
74518
diff
changeset
|
105 |
Abs (a, _, _) => |
23596 | 106 |
let |
74525
c960bfcb91db
discontinued Term.dest_abs / Logic.dest_all, which are officially superseded by Variable.dest_abs etc., but there are also Term.dest_abs_global to recover existing tools easily;
wenzelm
parents:
74518
diff
changeset
|
107 |
val ((v, ct'), ctxt') = Variable.dest_abs_cterm ct ctxt; |
26571 | 108 |
val eq = cv (v, ctxt') ct'; |
74525
c960bfcb91db
discontinued Term.dest_abs / Logic.dest_all, which are officially superseded by Variable.dest_abs etc., but there are also Term.dest_abs_global to recover existing tools easily;
wenzelm
parents:
74518
diff
changeset
|
109 |
in if Thm.is_reflexive eq then all_conv ct else Thm.abstract_rule a v eq end |
22926 | 110 |
| _ => raise CTERM ("abs_conv", [ct])); |
111 |
||
112 |
fun combination_conv cv1 cv2 ct = |
|
113 |
let val (ct1, ct2) = Thm.dest_comb ct |
|
114 |
in Thm.combination (cv1 ct1) (cv2 ct2) end; |
|
115 |
||
116 |
fun comb_conv cv = combination_conv cv cv; |
|
117 |
fun arg_conv cv = combination_conv all_conv cv; |
|
118 |
fun fun_conv cv = combination_conv cv all_conv; |
|
119 |
||
120 |
val arg1_conv = fun_conv o arg_conv; |
|
121 |
val fun2_conv = fun_conv o fun_conv; |
|
122 |
||
23034 | 123 |
fun binop_conv cv = combination_conv (arg_conv cv) cv; |
22926 | 124 |
|
36936
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
125 |
fun binder_conv cv ctxt = arg_conv (abs_conv cv ctxt); |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
126 |
|
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
127 |
|
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
128 |
(* subterm structure *) |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
129 |
|
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
130 |
(*cf. SUB_CONV in HOL*) |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
131 |
fun sub_conv conv ctxt = |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
132 |
comb_conv (conv ctxt) else_conv |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
133 |
abs_conv (conv o snd) ctxt else_conv |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
134 |
all_conv; |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
135 |
|
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
136 |
(*cf. BOTTOM_CONV in HOL*) |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
137 |
fun bottom_conv conv ctxt ct = |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
138 |
(sub_conv (bottom_conv conv) ctxt then_conv conv ctxt) ct; |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
139 |
|
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
140 |
(*cf. TOP_CONV in HOL*) |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
141 |
fun top_conv conv ctxt ct = |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
142 |
(conv ctxt then_conv sub_conv (top_conv conv) ctxt) ct; |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
143 |
|
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
144 |
(*cf. TOP_SWEEP_CONV in HOL*) |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
145 |
fun top_sweep_conv conv ctxt ct = |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
146 |
(conv ctxt else_conv sub_conv (top_sweep_conv conv) ctxt) ct; |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
147 |
|
23169 | 148 |
|
26571 | 149 |
(* primitive logic *) |
150 |
||
151 |
fun forall_conv cv ctxt ct = |
|
152 |
(case Thm.term_of ct of |
|
56245 | 153 |
Const ("Pure.all", _) $ Abs _ => arg_conv (abs_conv cv ctxt) ct |
26571 | 154 |
| _ => raise CTERM ("forall_conv", [ct])); |
155 |
||
156 |
fun implies_conv cv1 cv2 ct = |
|
157 |
(case Thm.term_of ct of |
|
56245 | 158 |
Const ("Pure.imp", _) $ _ $ _ => combination_conv (arg_conv cv1) cv2 ct |
26571 | 159 |
| _ => raise CTERM ("implies_conv", [ct])); |
160 |
||
161 |
fun implies_concl_conv cv ct = |
|
162 |
(case Thm.term_of ct of |
|
56245 | 163 |
Const ("Pure.imp", _) $ _ $ _ => arg_conv cv ct |
26571 | 164 |
| _ => raise CTERM ("implies_concl_conv", [ct])); |
165 |
||
166 |
||
74545 | 167 |
(* rewrite steps *) |
50639 | 168 |
|
74545 | 169 |
(*cf. REWR_CONV in HOL*) |
26571 | 170 |
fun rewr_conv rule ct = |
171 |
let |
|
59586 | 172 |
val rule1 = Thm.incr_indexes (Thm.maxidx_of_cterm ct + 1) rule; |
26571 | 173 |
val lhs = Thm.lhs_of rule1; |
174 |
val rule2 = Thm.rename_boundvars (Thm.term_of lhs) (Thm.term_of ct) rule1; |
|
49974
791157a4179a
ensured that rewr_conv rule t = "t == u" literally not just modulo beta-eta
nipkow
parents:
43333
diff
changeset
|
175 |
val rule3 = |
791157a4179a
ensured that rewr_conv rule t = "t == u" literally not just modulo beta-eta
nipkow
parents:
43333
diff
changeset
|
176 |
Thm.instantiate (Thm.match (lhs, ct)) rule2 |
50639 | 177 |
handle Pattern.MATCH => raise CTERM ("rewr_conv", [lhs, ct]); |
49974
791157a4179a
ensured that rewr_conv rule t = "t == u" literally not just modulo beta-eta
nipkow
parents:
43333
diff
changeset
|
178 |
val rule4 = |
50639 | 179 |
if Thm.lhs_of rule3 aconvc ct then rule3 |
49974
791157a4179a
ensured that rewr_conv rule t = "t == u" literally not just modulo beta-eta
nipkow
parents:
43333
diff
changeset
|
180 |
else |
791157a4179a
ensured that rewr_conv rule t = "t == u" literally not just modulo beta-eta
nipkow
parents:
43333
diff
changeset
|
181 |
let val ceq = Thm.dest_fun2 (Thm.cprop_of rule3) |
50639 | 182 |
in rule3 COMP Thm.trivial (Thm.mk_binop ceq ct (Thm.rhs_of rule3)) end; |
183 |
in Thm.transitive rule4 (Thm.beta_conversion true (Thm.rhs_of rule4)) end; |
|
26571 | 184 |
|
36936
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
185 |
fun rewrs_conv rules = first_conv (map rewr_conv rules); |
c52d1c130898
incorporated further conversions and conversionals, after some minor tuning;
wenzelm
parents:
32843
diff
changeset
|
186 |
|
74545 | 187 |
fun bottom_rewrs_conv rewrs = bottom_conv (K (try_conv (rewrs_conv rewrs))); |
188 |
fun top_rewrs_conv rewrs = top_conv (K (try_conv (rewrs_conv rewrs))); |
|
189 |
fun top_sweep_rewrs_conv rewrs = top_sweep_conv (K (rewrs_conv rewrs)); |
|
190 |
||
26571 | 191 |
|
192 |
(* conversions on HHF rules *) |
|
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
193 |
|
67721 | 194 |
(*rewrite B in \<And>x1 ... xn. B*) |
26571 | 195 |
fun params_conv n cv ctxt ct = |
27332 | 196 |
if n <> 0 andalso Logic.is_all (Thm.term_of ct) |
26571 | 197 |
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
|
198 |
else cv ctxt ct; |
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
199 |
|
67721 | 200 |
(*rewrite the A's in A1 \<Longrightarrow> ... \<Longrightarrow> An \<Longrightarrow> B*) |
26571 | 201 |
fun prems_conv 0 _ ct = all_conv ct |
202 |
| prems_conv n cv ct = |
|
203 |
(case try Thm.dest_implies ct of |
|
204 |
NONE => all_conv ct |
|
205 |
| SOME (A, B) => Drule.imp_cong_rule (cv A) (prems_conv (n - 1) cv B)); |
|
206 |
||
67721 | 207 |
(*rewrite B in A1 \<Longrightarrow> ... \<Longrightarrow> An \<Longrightarrow> B*) |
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
208 |
fun concl_conv 0 cv ct = cv ct |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
209 |
| concl_conv n cv ct = |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
210 |
(case try Thm.dest_implies ct of |
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
211 |
NONE => cv ct |
22926 | 212 |
| 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
|
213 |
|
23596 | 214 |
|
26571 | 215 |
(* conversions as inference rules *) |
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
216 |
|
23596 | 217 |
(*forward conversion, cf. FCONV_RULE in LCF*) |
218 |
fun fconv_rule cv th = |
|
219 |
let val eq = cv (Thm.cprop_of th) in |
|
220 |
if Thm.is_reflexive eq then th |
|
221 |
else Thm.equal_elim eq th |
|
222 |
end; |
|
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
223 |
|
23596 | 224 |
(*goal conversion*) |
225 |
fun gconv_rule cv i th = |
|
226 |
(case try (Thm.cprem_of th) i of |
|
227 |
SOME ct => |
|
228 |
let val eq = cv ct in |
|
229 |
if Thm.is_reflexive eq then th |
|
230 |
else Drule.with_subgoal i (fconv_rule (arg1_conv (K eq))) th |
|
231 |
end |
|
232 |
| 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
|
233 |
|
22905
dab6a898b47c
Conversions: primitive equality reasoning (from drule.ML);
wenzelm
parents:
diff
changeset
|
234 |
end; |
30136
6a874aedb964
Made then_conv and else_conv available as infix operations.
boehmes
parents:
29606
diff
changeset
|
235 |
|
32843
c8f5a7c8353f
moved cache_conv to src/Pure/conv.ML, use Thm.cterm_cache;
wenzelm
parents:
30136
diff
changeset
|
236 |
structure Basic_Conv: BASIC_CONV = Conv; |
c8f5a7c8353f
moved cache_conv to src/Pure/conv.ML, use Thm.cterm_cache;
wenzelm
parents:
30136
diff
changeset
|
237 |
open Basic_Conv; |