428 val concl = Drule.strip_imp_concl (Thm.cprop_of thm); |
428 val concl = Drule.strip_imp_concl (Thm.cprop_of thm); |
429 val (lhs, rhs) = Drule.dest_equals concl handle TERM _ => |
429 val (lhs, rhs) = Drule.dest_equals concl handle TERM _ => |
430 raise SIMPLIFIER ("Rewrite rule not a meta-equality", thm); |
430 raise SIMPLIFIER ("Rewrite rule not a meta-equality", thm); |
431 val (_, elhs) = Drule.dest_equals (Thm.cprop_of (Thm.eta_conversion lhs)); |
431 val (_, elhs) = Drule.dest_equals (Thm.cprop_of (Thm.eta_conversion lhs)); |
432 val elhs = if term_of elhs aconv term_of lhs then lhs else elhs; (*share identical copies*) |
432 val elhs = if term_of elhs aconv term_of lhs then lhs else elhs; (*share identical copies*) |
433 val erhs = Pattern.eta_contract (term_of rhs); |
433 val erhs = Envir.eta_contract (term_of rhs); |
434 val perm = |
434 val perm = |
435 var_perm (term_of elhs, erhs) andalso |
435 var_perm (term_of elhs, erhs) andalso |
436 not (term_of elhs aconv erhs) andalso |
436 not (term_of elhs aconv erhs) andalso |
437 not (is_Var (term_of elhs)); |
437 not (is_Var (term_of elhs)); |
438 in (thy, prems, term_of lhs, elhs, term_of rhs, perm) end; |
438 in (thy, prems, term_of lhs, elhs, term_of rhs, perm) end; |
549 fun add_cong (ss, thm) = ss |> |
549 fun add_cong (ss, thm) = ss |> |
550 map_simpset2 (fn (congs, procs, mk_rews, termless, subgoal_tac, loop_tacs, solvers) => |
550 map_simpset2 (fn (congs, procs, mk_rews, termless, subgoal_tac, loop_tacs, solvers) => |
551 let |
551 let |
552 val (lhs, _) = Drule.dest_equals (Drule.strip_imp_concl (Thm.cprop_of thm)) |
552 val (lhs, _) = Drule.dest_equals (Drule.strip_imp_concl (Thm.cprop_of thm)) |
553 handle TERM _ => raise SIMPLIFIER ("Congruence not a meta-equality", thm); |
553 handle TERM _ => raise SIMPLIFIER ("Congruence not a meta-equality", thm); |
554 (*val lhs = Pattern.eta_contract lhs;*) |
554 (*val lhs = Envir.eta_contract lhs;*) |
555 val a = valOf (cong_name (head_of (term_of lhs))) handle Option => |
555 val a = valOf (cong_name (head_of (term_of lhs))) handle Option => |
556 raise SIMPLIFIER ("Congruence must start with a constant or free variable", thm); |
556 raise SIMPLIFIER ("Congruence must start with a constant or free variable", thm); |
557 val (alist, weak) = congs; |
557 val (alist, weak) = congs; |
558 val alist2 = overwrite_warn (alist, (a, {lhs = lhs, thm = thm})) |
558 val alist2 = overwrite_warn (alist, (a, {lhs = lhs, thm = thm})) |
559 ("Overwriting congruence rule for " ^ quote a); |
559 ("Overwriting congruence rule for " ^ quote a); |
563 fun del_cong (ss, thm) = ss |> |
563 fun del_cong (ss, thm) = ss |> |
564 map_simpset2 (fn (congs, procs, mk_rews, termless, subgoal_tac, loop_tacs, solvers) => |
564 map_simpset2 (fn (congs, procs, mk_rews, termless, subgoal_tac, loop_tacs, solvers) => |
565 let |
565 let |
566 val (lhs, _) = Logic.dest_equals (Thm.concl_of thm) handle TERM _ => |
566 val (lhs, _) = Logic.dest_equals (Thm.concl_of thm) handle TERM _ => |
567 raise SIMPLIFIER ("Congruence not a meta-equality", thm); |
567 raise SIMPLIFIER ("Congruence not a meta-equality", thm); |
568 (*val lhs = Pattern.eta_contract lhs;*) |
568 (*val lhs = Envir.eta_contract lhs;*) |
569 val a = valOf (cong_name (head_of lhs)) handle Option => |
569 val a = valOf (cong_name (head_of lhs)) handle Option => |
570 raise SIMPLIFIER ("Congruence must start with a constant", thm); |
570 raise SIMPLIFIER ("Congruence must start with a constant", thm); |
571 val (alist, _) = congs; |
571 val (alist, _) = congs; |
572 val alist2 = List.filter (fn (x, _) => x <> a) alist; |
572 val alist2 = List.filter (fn (x, _) => x <> a) alist; |
573 val weak2 = alist2 |> List.mapPartial (fn (a, {thm, ...}: cong) => |
573 val weak2 = alist2 |> List.mapPartial (fn (a, {thm, ...}: cong) => |