fun mk_sum plus [] = raise Assoc_fail
| mk_sum plus tms = foldr1 (fn (x, y) => plus $ x $ y) tms;
(*Separate the literals from the other terms being combined*) fun sift_terms plus (t, (lits,others)) = if Data.is_numeral t then (t::lits, others) (*new literal*) else
(case t of
(f as Const _) $ x $ y => if f = plus then sift_terms plus (x, sift_terms plus (y, (lits,others))) else (lits, t::others) (*arbitrary summand*)
| _ => (lits, t::others));
(*A simproc to combine all literals in a associative nest*) fun proc ctxt lhs = let val plus = (case lhs of f $ _ $ _ => f | _ => error "Assoc_fold: bad pattern") val (lits, others) = sift_terms plus (lhs, ([],[])) val _ = length lits < 2 andalso raise Assoc_fail (*we can't reduce the number of terms*) val rhs = plus $ mk_sum plus lits $ mk_sum plus others val th =
Goal.prove ctxt [] [] (Logic.mk_equals (lhs, rhs)) (fn _ =>
resolve_tac ctxt [Data.eq_reflection] 1THEN
simp_tac (put_simpset Data.assoc_ss ctxt) 1) in SOME th endhandle Assoc_fail => NONE;
end;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-30)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.