-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: HashMap.toList_insert_perm_of_not_mem #6304
base: master
Are you sure you want to change the base?
Changes from all commits
27f3fd1
dcebe8f
a8bb5bd
53d95cd
b234016
53f2d78
9153fdb
66f41a2
e1e720f
1b4b64d
4b904f7
b4acd69
53d4e75
118864b
67ce085
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -701,6 +701,30 @@ theorem distinct_keys [EquivBEq α] [LawfulHashable α] : | |
m.keys.Pairwise (fun a b => (a == b) = false) := | ||
DHashMap.distinct_keys | ||
|
||
@[simp] | ||
theorem toList_inner : | ||
m.inner.toList = m.toList.map fun ⟨k, v⟩ => ⟨k, v⟩ := by | ||
simp [DHashMap.toList, toList, DHashMap.Const.toList, | ||
DHashMap.Internal.Raw.toList_eq_toListModel, DHashMap.Internal.Raw.Const.toList_eq_toListModel, | ||
DHashMap.Internal.Const.toListModel, Function.comp_def] | ||
|
||
@[simp] | ||
theorem toList_map_fst : | ||
m.toList.map Prod.fst = m.keys := by | ||
simpa using DHashMap.toList_map_fst (m := m.1) | ||
|
||
@[simp] theorem insert_inner [EquivBEq α] [LawfulHashable α] {k : α} {v : β} : | ||
m.inner.insert k v = (m.insert k v).inner := rfl | ||
|
||
open List in | ||
theorem toList_insert_perm_of_not_mem [EquivBEq α] [LawfulHashable α] | ||
(k : α) (v : β) (h' : ¬k ∈ m) : | ||
(m.insert k v).toList ~ (k, v) :: m.toList := by | ||
have t := DHashMap.toList_insert_perm_of_not_mem (β := fun _ => β) k v h' | ||
simp at t | ||
replace t := Perm.map (fun x : (_ : α) × β => (x.fst, x.snd)) t | ||
simpa [Function.comp_def] using t | ||
Comment on lines
+719
to
+726
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way this is supposed to work is that you prove To give more details:
namespace Const
variable {β : Type v} (m : Raw₀ α (fun _ => β))
open _root_.List in
theorem Const.toList_insert_perm_of_not_contains [EquivBEq α] [LawfulHashable α] (h : m.1.WF) {k : α} {v : β} :
m.contains k = false → Raw.Const.toList (m.insert k v).1 ~ (k, v) :: (Raw.Const.toList m.1) := by
simp_to_model
exact fun h => by simp [insertEntry_of_containsKey_eq_false h]
end Const in the bottom of I should add that this still isn't perfect; it would be even better to prove |
||
|
||
end | ||
|
||
end Std.HashMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is how I had envisioned this working: you prove
and add
← `(perm_of_perm)
tocongrNames
. Then this lemma is proved like this:To spell it out explicitly: after
simp_to_model
, it should always be possible togeneralize toListModel m.1.buckets = l
so thatm
is then no longer present in the goal.