-
Notifications
You must be signed in to change notification settings - Fork 713
feat: add a lemma relating minKey? and min? for DTreeMap
#11528
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
base: master
Are you sure you want to change the base?
Changes from all commits
4681ef7
188ae17
9e0564e
56f6a0f
e2cb93a
011430e
da62529
f20623a
1ef1f4e
6e28b54
aa18394
09d346b
d071ff9
5c955e4
bf2979a
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 |
|---|---|---|
|
|
@@ -3690,6 +3690,11 @@ theorem contains_minKey? [TransCmp cmp] {km} : | |
| t.contains km := | ||
| Impl.contains_minKey? t.wf | ||
|
|
||
| theorem minKey?_eq_min?_keys [TransCmp cmp] [Min α] | ||
| [LE α] [LawfulOrderCmp cmp] [LawfulOrderMin α] [LawfulOrderLeftLeaningMin α] [LawfulEqCmp cmp] : | ||
| t.minKey? = t.keys.min? := | ||
|
Member
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. How hard would it to add also |
||
| Impl.minKey?_eq_min?_keys t.wf | ||
|
|
||
| theorem minKey?_mem [TransCmp cmp] {km} : | ||
| (hkm : t.minKey? = some km) → | ||
| km ∈ t:= | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ public import Std.Data.Internal.List.Defs | |
| import all Std.Data.Internal.List.Defs | ||
| public import Init.Data.Order.Ord | ||
| import Init.Data.Subtype.Order | ||
| public import Init.Data.Order.ClassesExtra | ||
| public import Init.Data.Order.LemmasExtra | ||
|
|
||
| public section | ||
|
|
||
|
|
@@ -8249,6 +8251,29 @@ theorem containsKey_minKey? [Ord α] [TransOrd α] [BEq α] [LawfulBEqOrd α] {l | |
| obtain ⟨e, ⟨hm, _⟩, rfl⟩ := hkm | ||
| exact containsKey_of_mem hm | ||
|
|
||
| theorem minKey?_eq_min?_keys [Ord α] [TransOrd α] | ||
|
Member
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. I guess we also want everything for |
||
| [LawfulEqOrd α] [LE α] [LawfulOrderOrd α] [Min α] | ||
| [LawfulOrderLeftLeaningMin α] (l : List ((a : α) × β a)) : | ||
| minKey? l = (List.keys l).min? := by | ||
| have : IsLinearOrder α := IsLinearOrder.of_ord | ||
| rw [keys_eq_map] | ||
| induction l with | ||
| | nil => simp [minKey?_of_isEmpty] | ||
| | cons h t ih => | ||
| rw [minKey?, minEntry?_cons, minEntry?, Option.map_some, List.map_cons, List.min?_cons] | ||
| split | ||
| · simp only [← ih, minKey?, minEntry?, Option.map_none, Option.elim_none, *] | ||
| · simp only [Option.some.injEq, ← ih, minKey?, minEntry?, *, min, Option.map_some, | ||
| Option.elim_some] | ||
| split | ||
| · rw [LawfulOrderLeftLeaningMin.min_eq_left _ _ <| | ||
| (LawfulOrderOrd.isLE_compare _ _).1 ‹_›] | ||
| · rename_i w _ hyp | ||
| simp only [Bool.not_eq_true, Ordering.isLE_eq_false] at hyp | ||
| simp only [Commutative.comm h.fst w.fst] | ||
| rw [LawfulOrderLeftLeaningMin.min_eq_left _ _ <| | ||
| (LawfulOrderOrd.isGE_compare _ _).1 (Ordering.isGE_of_eq_gt hyp)] | ||
|
|
||
| theorem minKey?_eraseKey_eq_iff_beq_minKey?_eq_false [Ord α] [TransOrd α] [BEq α] [LawfulBEqOrd α] | ||
| {k} {l : List ((a : α) × β a)} (hd : DistinctKeys l) : | ||
| minKey? (eraseKey k l) = minKey? l ↔ ∀ {km}, minKey? l = some km → (k == km) = false := by | ||
|
|
||
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.
I think this would be nice to have as a
simplemma in the reverse direction, called justmin?_keys.