111 (*Get the norm constants from norm_thms*) |
111 (*Get the norm constants from norm_thms*) |
112 val norms = |
112 val norms = |
113 let fun norm thm = |
113 let fun norm thm = |
114 case lhs_of(concl_of thm) of |
114 case lhs_of(concl_of thm) of |
115 Const(n,_)$_ => n |
115 Const(n,_)$_ => n |
116 | _ => (Display.prths normE_thms; error"No constant in lhs of a norm_thm") |
116 | _ => error "No constant in lhs of a norm_thm" |
117 in map norm normE_thms end; |
117 in map norm normE_thms end; |
118 |
118 |
119 fun lhs_is_NORM(thm,i) = case lhs_of_eq i thm of |
119 fun lhs_is_NORM(thm,i) = case lhs_of_eq i thm of |
120 Const(s,_)$_ => s mem norms | _ => false; |
120 Const(s,_)$_ => s mem norms | _ => false; |
121 |
121 |
122 val refl_tac = resolve_tac refl_thms; |
122 val refl_tac = resolve_tac refl_thms; |
123 |
123 |
124 fun find_res thms thm = |
124 fun find_res thms thm = |
125 let fun find [] = (Display.prths thms; error"Check Simp_Data") |
125 let fun find [] = error "Check Simp_Data" |
126 | find(th::thms) = thm RS th handle THM _ => find thms |
126 | find(th::thms) = thm RS th handle THM _ => find thms |
127 in find thms end; |
127 in find thms end; |
128 |
128 |
129 val mk_trans = find_res trans_thms; |
129 val mk_trans = find_res trans_thms; |
130 |
130 |
247 |
247 |
248 (*insert a thm in a thm net*) |
248 (*insert a thm in a thm net*) |
249 fun insert_thm_warn th net = |
249 fun insert_thm_warn th net = |
250 Net.insert_term Thm.eq_thm_prop (concl_of th, th) net |
250 Net.insert_term Thm.eq_thm_prop (concl_of th, th) net |
251 handle Net.INSERT => |
251 handle Net.INSERT => |
252 (writeln"\nDuplicate rewrite or congruence rule:"; Display.print_thm th; |
252 (writeln ("Duplicate rewrite or congruence rule:\n" ^ |
253 net); |
253 Display.string_of_thm_without_context th); net); |
254 |
254 |
255 val insert_thms = fold_rev insert_thm_warn; |
255 val insert_thms = fold_rev insert_thm_warn; |
256 |
256 |
257 fun addrew(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}, thm) = |
257 fun addrew(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}, thm) = |
258 let val thms = mk_simps thm |
258 let val thms = mk_simps thm |
273 |
273 |
274 (*delete a thm from a thm net*) |
274 (*delete a thm from a thm net*) |
275 fun delete_thm_warn th net = |
275 fun delete_thm_warn th net = |
276 Net.delete_term Thm.eq_thm_prop (concl_of th, th) net |
276 Net.delete_term Thm.eq_thm_prop (concl_of th, th) net |
277 handle Net.DELETE => |
277 handle Net.DELETE => |
278 (writeln"\nNo such rewrite or congruence rule:"; Display.print_thm th; |
278 (writeln ("No such rewrite or congruence rule:\n" ^ |
279 net); |
279 Display.string_of_thm_without_context th); net); |
280 |
280 |
281 val delete_thms = fold_rev delete_thm_warn; |
281 val delete_thms = fold_rev delete_thm_warn; |
282 |
282 |
283 fun op delcongs(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}, thms) = |
283 fun op delcongs(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}, thms) = |
284 let val congs' = fold (remove Thm.eq_thm_prop) thms congs |
284 let val congs' = fold (remove Thm.eq_thm_prop) thms congs |
288 end; |
288 end; |
289 |
289 |
290 fun delrew(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}, thm) = |
290 fun delrew(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}, thm) = |
291 let fun find((p as (th,ths))::ps',ps) = |
291 let fun find((p as (th,ths))::ps',ps) = |
292 if Thm.eq_thm_prop(thm,th) then (ths,ps@ps') else find(ps',p::ps) |
292 if Thm.eq_thm_prop(thm,th) then (ths,ps@ps') else find(ps',p::ps) |
293 | find([],simps') = (writeln"\nNo such rewrite or congruence rule:"; |
293 | find([],simps') = |
294 Display.print_thm thm; |
294 (writeln ("No such rewrite or congruence rule:\n" ^ |
295 ([],simps')) |
295 Display.string_of_thm_without_context thm); ([], simps')) |
296 val (thms,simps') = find(simps,[]) |
296 val (thms,simps') = find(simps,[]) |
297 in SS{auto_tac=auto_tac, congs=congs, cong_net=cong_net, mk_simps=mk_simps, |
297 in SS{auto_tac=auto_tac, congs=congs, cong_net=cong_net, mk_simps=mk_simps, |
298 simps = simps', simp_net = delete_thms thms simp_net } |
298 simps = simps', simp_net = delete_thms thms simp_net } |
299 end; |
299 end; |
300 |
300 |
309 (** Inspection of a simpset **) |
309 (** Inspection of a simpset **) |
310 |
310 |
311 fun dest_ss(SS{congs,simps,...}) = (congs, map #1 simps); |
311 fun dest_ss(SS{congs,simps,...}) = (congs, map #1 simps); |
312 |
312 |
313 fun print_ss(SS{congs,simps,...}) = |
313 fun print_ss(SS{congs,simps,...}) = |
314 (writeln"Congruences:"; Display.prths congs; |
314 writeln (cat_lines |
315 writeln"Rewrite Rules:"; Display.prths (map #1 simps); ()); |
315 (["Congruences:"] @ map Display.string_of_thm_without_context congs @ |
|
316 ["Rewrite Rules:"] @ map (Display.string_of_thm_without_context o #1) simps)); |
316 |
317 |
317 |
318 |
318 (* Rewriting with conditionals *) |
319 (* Rewriting with conditionals *) |
319 |
320 |
320 val (case_thms,case_consts) = split_list case_splits; |
321 val (case_thms,case_consts) = split_list case_splits; |
433 val thms = map (trivial o cterm_of(Thm.theory_of_thm thm)) As; |
434 val thms = map (trivial o cterm_of(Thm.theory_of_thm thm)) As; |
434 val new_rws = List.concat(map mk_rew_rules thms); |
435 val new_rws = List.concat(map mk_rew_rules thms); |
435 val rwrls = map mk_trans (List.concat(map mk_rew_rules thms)); |
436 val rwrls = map mk_trans (List.concat(map mk_rew_rules thms)); |
436 val anet' = List.foldr lhs_insert_thm anet rwrls |
437 val anet' = List.foldr lhs_insert_thm anet rwrls |
437 in if !tracing andalso not(null new_rws) |
438 in if !tracing andalso not(null new_rws) |
438 then (writeln"Adding rewrites:"; Display.prths new_rws; ()) |
439 then writeln (cat_lines |
|
440 ("Adding rewrites:" :: map Display.string_of_thm_without_context new_rws)) |
439 else (); |
441 else (); |
440 (ss,thm,anet',anet::ats,cs) |
442 (ss,thm,anet',anet::ats,cs) |
441 end; |
443 end; |
442 |
444 |
443 fun rew(seq,thm,ss,anet,ats,cs, more) = case Seq.pull seq of |
445 fun rew(seq,thm,ss,anet,ats,cs, more) = case Seq.pull seq of |