# HG changeset patch # User desharna # Date 1637836418 -3600 # Node ID 825cd198d85cb8c7cb990b293fad48cb459aec7e # Parent b61bd2c12de33999811106ae82bbc042e71b4bd6 renamed Multiset.multp and Multiset.multeqp diff -r b61bd2c12de3 -r 825cd198d85c NEWS --- a/NEWS Wed Nov 17 16:13:00 2021 +0100 +++ b/NEWS Thu Nov 25 11:33:38 2021 +0100 @@ -7,6 +7,12 @@ New in this Isabelle version ---------------------------- +*** HOL *** + +* Theory "HOL-Library.Multiset": consolidated operation and fact namesd + multp ~> multp_code + multeqp ~> multeqp_code + Minor INCOMPATIBILITY. New in Isabelle2021-1 (December 2021) diff -r b61bd2c12de3 -r 825cd198d85c src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Wed Nov 17 16:13:00 2021 +0100 +++ b/src/HOL/Library/Multiset.thy Thu Nov 25 11:33:38 2021 +0100 @@ -4,6 +4,7 @@ Author: Jasmin Blanchette, Inria, LORIA, MPII Author: Dmitriy Traytel, TU Muenchen Author: Mathias Fleury, MPII + Author: Martin Desharnais, MPI-INF Saarbruecken *) section \(Finite) Multisets\ @@ -3063,22 +3064,22 @@ Predicate variants of \mult\ and the reflexive closure of \mult\, which are executable whenever the given predicate \P\ is. Together with the standard code equations for \(\#\) and \(-\) this should yield quadratic - (with respect to calls to \P\) implementations of \multp\ and \multeqp\. + (with respect to calls to \P\) implementations of \multp_code\ and \multeqp_code\. \ -definition multp :: "('a \ 'a \ bool) \ 'a multiset \ 'a multiset \ bool" where - "multp P N M = +definition multp_code :: "('a \ 'a \ bool) \ 'a multiset \ 'a multiset \ bool" where + "multp_code P N M = (let Z = M \# N; X = M - Z in X \ {#} \ (let Y = N - Z in (\y \ set_mset Y. \x \ set_mset X. P y x)))" -definition multeqp :: "('a \ 'a \ bool) \ 'a multiset \ 'a multiset \ bool" where - "multeqp P N M = +definition multeqp_code :: "('a \ 'a \ bool) \ 'a multiset \ 'a multiset \ bool" where + "multeqp_code P N M = (let Z = M \# N; X = M - Z; Y = N - Z in (\y \ set_mset Y. \x \ set_mset X. P y x))" -lemma multp_iff: +lemma multp_code_iff: assumes "irrefl R" and "trans R" and [simp]: "\x y. P x y \ (x, y) \ R" - shows "multp P N M \ (N, M) \ mult R" (is "?L \ ?R") + shows "multp_code P N M \ (N, M) \ mult R" (is "?L \ ?R") proof - have *: "M \# N + (N - M \# N) = N" "M \# N + (M - M \# N) = M" "(M - M \# N) \# (N - M \# N) = {#}" by (auto simp flip: count_inject) @@ -3086,29 +3087,29 @@ proof assume ?L thus ?R using one_step_implies_mult[of "M - M \# N" "N - M \# N" R "M \# N"] * - by (auto simp: multp_def Let_def) + by (auto simp: multp_code_def Let_def) next { fix I J K :: "'a multiset" assume "(I + J) \# (I + K) = {#}" then have "I = {#}" by (metis inter_union_distrib_right union_eq_empty) } note [dest!] = this assume ?R thus ?L using mult_implies_one_step[OF assms(2), of "N - M \# N" "M - M \# N"] - mult_cancel_max[OF assms(2,1), of "N" "M"] * by (auto simp: multp_def) + mult_cancel_max[OF assms(2,1), of "N" "M"] * by (auto simp: multp_code_def) qed qed -lemma multeqp_iff: +lemma multeqp_code_iff: assumes "irrefl R" and "trans R" and "\x y. P x y \ (x, y) \ R" - shows "multeqp P N M \ (N, M) \ (mult R)\<^sup>=" + shows "multeqp_code P N M \ (N, M) \ (mult R)\<^sup>=" proof - { assume "N \ M" "M - M \# N = {#}" then obtain y where "count N y \ count M y" by (auto simp flip: count_inject) then have "\y. count M y < count N y" using \M - M \# N = {#}\ by (auto simp flip: count_inject dest!: le_neq_implies_less fun_cong[of _ _ y]) } - then have "multeqp P N M \ multp P N M \ N = M" - by (auto simp: multeqp_def multp_def Let_def in_diff_count) - thus ?thesis using multp_iff[OF assms] by simp + then have "multeqp_code P N M \ multp_code P N M \ N = M" + by (auto simp: multeqp_code_def multp_code_def Let_def in_diff_count) + thus ?thesis using multp_code_iff[OF assms] by simp qed