Zulip Chat Archive
Stream: Is there code for X?
Topic: List.Perm_diff_append_of_Subperm ??
Malvin Gattinger (Oct 12 2024 at 20:14):
Is there a lemma like this or an easy proof? I've been running in circles between multisets, list counts and (sub)permutations for a bit :thinking:
import Mathlib
theorem List.Perm_diff_append_of_Subperm {α} [DecidableEq α] {L M : List α} (h : M.Subperm L) :
L.Perm (L.diff M ++ M) := by
sorry
Eric Wieser (Oct 12 2024 at 20:16):
To me that looks like one that would be easiest in the multiset spelling
Malvin Gattinger (Oct 12 2024 at 20:17):
Yes, got it. Probably can be done shorter I guess.
import Mathlib
theorem Multiset_diff_append_of_le [DecidableEq α] {R Rcond Rnew : List α} :
Multiset.ofList (R.diff Rcond ++ Rnew)
= Multiset.ofList R - Multiset.ofList Rcond + Multiset.ofList Rnew := by
rw [@Multiset.coe_sub]
rw [Multiset.coe_add]
theorem List.Perm_diff_append_of_Subperm {α} [DecidableEq α] {L M : List α} (h : M.Subperm L) :
L.Perm (L.diff M ++ M) := by
rw [perm_iff_count]
intro φ
rw [← Multiset.coe_count, ← Multiset.coe_count]
rw [@Multiset_diff_append_of_le α _ L M M]
rw [tsub_add_cancel_of_le h]
Eric Wieser (Oct 12 2024 at 22:26):
tsub_add_cancel_of_le
is the key step here, you can probably golf things around it
Last updated: May 02 2025 at 03:31 UTC