56 val lhs_of = #2 o dest_red; |
56 val lhs_of = #2 o dest_red; |
57 val rhs_of = #3 o dest_red; |
57 val rhs_of = #3 o dest_red; |
58 |
58 |
59 (*** Indexing and filtering of theorems ***) |
59 (*** Indexing and filtering of theorems ***) |
60 |
60 |
61 fun eq_brl ((b1,th1),(b2,th2)) = b1=b2 andalso eq_thm(th1,th2); |
61 fun eq_brl ((b1,th1),(b2,th2)) = b1=b2 andalso Drule.eq_thm_prop(th1,th2); |
62 |
62 |
63 (*insert a thm in a discrimination net by its lhs*) |
63 (*insert a thm in a discrimination net by its lhs*) |
64 fun lhs_insert_thm (th,net) = |
64 fun lhs_insert_thm (th,net) = |
65 Net.insert_term((lhs_of (concl_of th), (false,th)), net, eq_brl) |
65 Net.insert_term((lhs_of (concl_of th), (false,th)), net, eq_brl) |
66 handle Net.INSERT => net; |
66 handle Net.INSERT => net; |
242 |
242 |
243 (** Insertion of congruences, rewrites and case splits **) |
243 (** Insertion of congruences, rewrites and case splits **) |
244 |
244 |
245 (*insert a thm in a thm net*) |
245 (*insert a thm in a thm net*) |
246 fun insert_thm_warn (th,net) = |
246 fun insert_thm_warn (th,net) = |
247 Net.insert_term((concl_of th, th), net, eq_thm) |
247 Net.insert_term((concl_of th, th), net, Drule.eq_thm_prop) |
248 handle Net.INSERT => |
248 handle Net.INSERT => |
249 (writeln"\nDuplicate rewrite or congruence rule:"; print_thm th; |
249 (writeln"\nDuplicate rewrite or congruence rule:"; print_thm th; |
250 net); |
250 net); |
251 |
251 |
252 val insert_thms = foldr insert_thm_warn; |
252 val insert_thms = foldr insert_thm_warn; |
287 |
287 |
288 (** Deletion of congruences and rewrites **) |
288 (** Deletion of congruences and rewrites **) |
289 |
289 |
290 (*delete a thm from a thm net*) |
290 (*delete a thm from a thm net*) |
291 fun delete_thm_warn (th,net) = |
291 fun delete_thm_warn (th,net) = |
292 Net.delete_term((concl_of th, th), net, eq_thm) |
292 Net.delete_term((concl_of th, th), net, Drule.eq_thm_prop) |
293 handle Net.DELETE => |
293 handle Net.DELETE => |
294 (writeln"\nNo such rewrite or congruence rule:"; print_thm th; |
294 (writeln"\nNo such rewrite or congruence rule:"; print_thm th; |
295 net); |
295 net); |
296 |
296 |
297 val delete_thms = foldr delete_thm_warn; |
297 val delete_thms = foldr delete_thm_warn; |
298 |
298 |
299 fun op delcongs(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net, |
299 fun op delcongs(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net, |
300 splits,split_consts}, thms) = |
300 splits,split_consts}, thms) = |
301 let val congs' = foldl (gen_rem eq_thm) (congs,thms) |
301 let val congs' = foldl (gen_rem Drule.eq_thm_prop) (congs,thms) |
302 in SS{auto_tac=auto_tac, congs= congs', |
302 in SS{auto_tac=auto_tac, congs= congs', |
303 cong_net= delete_thms(map mk_trans thms,cong_net), |
303 cong_net= delete_thms(map mk_trans thms,cong_net), |
304 mk_simps= normed_rews congs', simps=simps, simp_net=simp_net, |
304 mk_simps= normed_rews congs', simps=simps, simp_net=simp_net, |
305 splits=splits,split_consts=split_consts} |
305 splits=splits,split_consts=split_consts} |
306 end; |
306 end; |
307 |
307 |
308 fun delrew(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net, |
308 fun delrew(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net, |
309 splits,split_consts}, thm) = |
309 splits,split_consts}, thm) = |
310 let fun find((p as (th,ths))::ps',ps) = |
310 let fun find((p as (th,ths))::ps',ps) = |
311 if eq_thm(thm,th) then (ths,ps@ps') else find(ps',p::ps) |
311 if Drule.eq_thm_prop(thm,th) then (ths,ps@ps') else find(ps',p::ps) |
312 | find([],simps') = (writeln"\nNo such rewrite or congruence rule:"; |
312 | find([],simps') = (writeln"\nNo such rewrite or congruence rule:"; |
313 print_thm thm; |
313 print_thm thm; |
314 ([],simps')) |
314 ([],simps')) |
315 val (thms,simps') = find(simps,[]) |
315 val (thms,simps') = find(simps,[]) |
316 in SS{auto_tac=auto_tac, congs=congs, cong_net=cong_net, mk_simps=mk_simps, |
316 in SS{auto_tac=auto_tac, congs=congs, cong_net=cong_net, mk_simps=mk_simps, |