I think it would be useful to add the following lemma to the List
theory:
lemma count_append: "count_list (xs @ ys) z = count_list xs z + count_list ys z"
by (induct xs) simp_all
Use multisets instead of lists count (mset xs) z
Thanks, @Mathias Fleury, for your answer. That definitely is a workaround, however the List
theory already includes a count_list
function which avoids the overhead of creating a temporary multiset out of a list. There are some basic lemmas about count_list
already, but surprisingly there is no lemma relating count_list
and @
in the style of Multiset.count_union
. That's why I think adding a count_append
lemma as above is a good idea.
This is already part of List.thy
in the development version of Isabelle.
It was added back in March.
The next release will be soon so you can just add the lemma temporarily to your theory and then remove it when upgrading to the new version.
Last updated: Dec 21 2024 at 12:33 UTC