equal
deleted
inserted
replaced
565 |
565 |
566 (*folding should handle critical pairs! E.g. K == Inl(0), S == Inr(Inl(0)) |
566 (*folding should handle critical pairs! E.g. K == Inl(0), S == Inr(Inl(0)) |
567 Returns longest lhs first to avoid folding its subexpressions.*) |
567 Returns longest lhs first to avoid folding its subexpressions.*) |
568 fun sort_lhs_depths defs = |
568 fun sort_lhs_depths defs = |
569 let val keylist = AList.make (term_depth o lhs_of_thm) defs |
569 let val keylist = AList.make (term_depth o lhs_of_thm) defs |
570 val keys = distinct (sort (rev_order o int_ord) (map #2 keylist)) |
570 val keys = gen_distinct (op =) (sort (rev_order o int_ord) (map #2 keylist)) |
571 in map (AList.find (op =) keylist) keys end; |
571 in map (AList.find (op =) keylist) keys end; |
572 |
572 |
573 val rev_defs = sort_lhs_depths o map symmetric; |
573 val rev_defs = sort_lhs_depths o map symmetric; |
574 |
574 |
575 fun fold_rule defs thm = Library.foldl (fn (th, ds) => rewrite_rule ds th) (thm, rev_defs defs); |
575 fun fold_rule defs thm = Library.foldl (fn (th, ds) => rewrite_rule ds th) (thm, rev_defs defs); |