src/FOLP/simp.ML
changeset 33245 65232054ffd0
parent 33063 4d462963a7db
child 33317 b4534348b8fd
equal deleted inserted replaced
33244:db230399f890 33245:65232054ffd0
   252     (writeln ("Duplicate rewrite or congruence rule:\n" ^
   252     (writeln ("Duplicate rewrite or congruence rule:\n" ^
   253         Display.string_of_thm_without_context th); 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 thm (SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}) =
   258 let val thms = mk_simps thm
   258 let val thms = mk_simps thm
   259 in SS{auto_tac=auto_tac,congs=congs, cong_net=cong_net, mk_simps=mk_simps,
   259 in SS{auto_tac=auto_tac,congs=congs, cong_net=cong_net, mk_simps=mk_simps,
   260       simps = (thm,thms)::simps, simp_net = insert_thms thms simp_net}
   260       simps = (thm,thms)::simps, simp_net = insert_thms thms simp_net}
   261 end;
   261 end;
   262 
   262 
   263 val op addrews = Library.foldl addrew;
   263 fun ss addrews thms = fold addrew thms ss;
   264 
   264 
   265 fun op addcongs(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}, thms) =
   265 fun op addcongs(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}, thms) =
   266 let val congs' = thms @ congs;
   266 let val congs' = thms @ congs;
   267 in SS{auto_tac=auto_tac, congs= congs',
   267 in SS{auto_tac=auto_tac, congs= congs',
   268       cong_net= insert_thms (map mk_trans thms) cong_net,
   268       cong_net= insert_thms (map mk_trans thms) cong_net,
   285 in SS{auto_tac=auto_tac, congs= congs',
   285 in SS{auto_tac=auto_tac, congs= congs',
   286       cong_net= delete_thms (map mk_trans thms) cong_net,
   286       cong_net= delete_thms (map mk_trans thms) cong_net,
   287       mk_simps= normed_rews congs', simps=simps, simp_net=simp_net}
   287       mk_simps= normed_rews congs', simps=simps, simp_net=simp_net}
   288 end;
   288 end;
   289 
   289 
   290 fun delrew(SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}, thm) =
   290 fun delrew thm (SS{auto_tac,congs,cong_net,mk_simps,simps,simp_net}) =
   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') =
   293       | find([],simps') =
   294           (writeln ("No such rewrite or congruence rule:\n" ^
   294           (writeln ("No such rewrite or congruence rule:\n" ^
   295               Display.string_of_thm_without_context thm); ([], 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 
   301 val op delrews = Library.foldl delrew;
   301 fun ss delrews thms = fold delrew thms ss;
   302 
   302 
   303 
   303 
   304 fun op setauto(SS{congs,cong_net,mk_simps,simps,simp_net,...}, auto_tac) =
   304 fun op setauto(SS{congs,cong_net,mk_simps,simps,simp_net,...}, auto_tac) =
   305     SS{auto_tac=auto_tac, congs=congs, cong_net=cong_net, mk_simps=mk_simps,
   305     SS{auto_tac=auto_tac, congs=congs, cong_net=cong_net, mk_simps=mk_simps,
   306        simps=simps, simp_net=simp_net};
   306        simps=simps, simp_net=simp_net};