Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
f59fa7d
Initial `getEntry` work
wkrozowski Oct 31, 2025
5911740
end of day push
wkrozowski Oct 31, 2025
e44545c
push intermediate changes
wkrozowski Nov 3, 2025
cb7ac1d
end of day push
wkrozowski Nov 3, 2025
b54f683
chore: push lemma about `getEntry`
wkrozowski Nov 4, 2025
037c5b8
foldl model
wkrozowski Nov 4, 2025
cd12c0a
chore: intermediate work
wkrozowski Nov 4, 2025
2239c23
Massive lemma is done
wkrozowski Nov 5, 2025
8b8f3bb
refactor
wkrozowski Nov 5, 2025
02226fc
WF lemma is now working
wkrozowski Nov 5, 2025
69669c6
chore : the wf variant works
wkrozowski Nov 5, 2025
439e242
chore add lemmas
wkrozowski Nov 5, 2025
a7c71fa
more lemmas
wkrozowski Nov 5, 2025
725689c
all get lemmas are done
wkrozowski Nov 6, 2025
64a7891
getKey? lemmas are done
wkrozowski Nov 6, 2025
9298608
Add const lemmas
wkrozowski Nov 6, 2025
c7d1e13
Remove sorried proof
wkrozowski Nov 6, 2025
3bf6ad4
push unfinished work
wkrozowski Nov 6, 2025
20bd320
Prove length lemma
wkrozowski Nov 7, 2025
8bf7034
push changes
wkrozowski Nov 7, 2025
db949a8
Finish sublemma
wkrozowski Nov 7, 2025
8c035db
add wf predicate
wkrozowski Nov 7, 2025
ad46950
Add getEntry?/getEntry lemmas
wkrozowski Nov 7, 2025
247fb58
Add getEntry! and getEntryD
wkrozowski Nov 10, 2025
5b6274d
fix naming
wkrozowski Nov 10, 2025
8a80729
push what i have
wkrozowski Nov 11, 2025
804fba0
Cleanup old fold
wkrozowski Nov 11, 2025
5411489
Add isEmpty lemma
wkrozowski Nov 12, 2025
86f2b74
add size lemma
wkrozowski Nov 12, 2025
bae20a2
fix simp_to_model
wkrozowski Nov 12, 2025
be0de57
cleanup
wkrozowski Nov 12, 2025
0228303
Further cleanup
wkrozowski Nov 12, 2025
d6253e8
add getEntry to publicly exposed DHashMap
wkrozowski Nov 12, 2025
3f011be
Merge branch 'wojciech/hashmap_getEntry' into wojciech/hashmap_inters…
wkrozowski Nov 12, 2025
fb2e980
Fix WF issues
wkrozowski Nov 12, 2025
05e9752
Fix comments
wkrozowski Nov 12, 2025
4d7e70e
Merge branch 'wojciech/hashmap_getEntry' into wojciech/hashmap_inters…
wkrozowski Nov 12, 2025
cfd6372
cleanup by applying Markus' suggestion
wkrozowski Nov 12, 2025
3b74c67
fix deleted code
wkrozowski Nov 12, 2025
8693512
renaming
wkrozowski Nov 12, 2025
dbfe831
rename size lemma
wkrozowski Nov 12, 2025
a6c2a75
Add Raw DHashMap inter lemmas
wkrozowski Nov 12, 2025
95fab3b
Add DHashMap lemmas
wkrozowski Nov 13, 2025
81efbee
Add basic support for HashMap raw
wkrozowski Nov 13, 2025
3bf6d39
reorganise things in the files
wkrozowski Nov 13, 2025
a6fcc76
Add const lemmas
wkrozowski Nov 13, 2025
2c2a986
Add inter lemmas
wkrozowski Nov 13, 2025
b5a421b
Add hashSet lemmas
wkrozowski Nov 13, 2025
8be273f
Slight reorganisation
wkrozowski Nov 13, 2025
8b7cfa1
Add `eraseMany` and `wf_eraseMany`
wkrozowski Nov 13, 2025
3766be5
Add Raw.erase
wkrozowski Nov 13, 2025
a9c0b35
Add further sublemmas
wkrozowski Nov 13, 2025
922beb5
add new correspondence lemma
wkrozowski Nov 14, 2025
b652b7b
add to list model
wkrozowski Nov 14, 2025
ed7b23a
add lemmas
wkrozowski Nov 14, 2025
7f45903
chore: add sublemmas
wkrozowski Nov 14, 2025
b1435c1
further progress on lemmas
wkrozowski Nov 14, 2025
002545f
push intermediate work
wkrozowski Nov 14, 2025
0b840ad
push
wkrozowski Nov 14, 2025
d33bb5f
Update src/Std/Data/Internal/List/Associative.lean
wkrozowski Nov 14, 2025
ae0385b
Update src/Std/Data/DHashMap/Basic.lean
wkrozowski Nov 14, 2025
7aa501b
Update src/Std/Data/DHashMap/Lemmas.lean
wkrozowski Nov 14, 2025
d3cb462
Fix WF
wkrozowski Nov 14, 2025
3bde3f9
Fix docstrings
wkrozowski Nov 14, 2025
66304f9
Fix simp attributes
wkrozowski Nov 14, 2025
75885a4
Remove unnecessary List prefix
wkrozowski Nov 14, 2025
6a0ddf9
resolve merge issues
wkrozowski Nov 15, 2025
dac309f
fixes
wkrozowski Nov 15, 2025
b56b1bb
fix compilation
wkrozowski Nov 15, 2025
6303bdc
chore: remove untrue lemma
wkrozowski Nov 15, 2025
fa51969
More set difference lemmas
wkrozowski Nov 17, 2025
07b32d6
Finish remaining intersection lemma
wkrozowski Nov 17, 2025
173a923
Merge branch 'master' into wojciech/hashmap_intersection4
wkrozowski Nov 17, 2025
3e6ed8d
Rename sublemmas
wkrozowski Nov 17, 2025
5e30864
Merge branch 'wojciech/hashmap_intersection4' into wojciech/hashmap_d…
wkrozowski Nov 17, 2025
1d45840
Rename `eraseMany` to `eraseManyEntries`
wkrozowski Nov 17, 2025
ff2445c
Merge branch 'master' into wojciech/hashmap_diff2
wkrozowski Nov 18, 2025
6b5dba1
Apply Markus' suggestion
wkrozowski Nov 18, 2025
ac3049f
Untrack files added by accident
wkrozowski Nov 18, 2025
c19e2b7
Add lemmas
wkrozowski Nov 18, 2025
150f3cb
Add all lemmas
wkrozowski Nov 18, 2025
8bd0307
Fix notation for WF lemmas
wkrozowski Nov 19, 2025
1689034
save what I have so far
wkrozowski Nov 20, 2025
496f2c4
Merge branch 'master' into wojciech/hashmap_diff2
wkrozowski Nov 21, 2025
0e2c1d8
refactor progress
wkrozowski Nov 21, 2025
bf29a9b
further progress
wkrozowski Nov 21, 2025
54fb119
Further progress
wkrozowski Nov 21, 2025
c3ce644
Refactor progress
wkrozowski Nov 21, 2025
12e76c7
Lemmas pass
wkrozowski Nov 21, 2025
005b5e7
Clean up `Associative.lean`
wkrozowski Nov 21, 2025
318b54f
Fix typo
wkrozowski Nov 21, 2025
eb88d10
finish renaming
wkrozowski Nov 27, 2025
824946f
Merge branch 'master' into wojciech/hashmap_diff2
wkrozowski Nov 27, 2025
8f760c2
add congr lemmas
wkrozowski Nov 27, 2025
2a84bba
push changes
wkrozowski Nov 27, 2025
842461e
Fix toModel
wkrozowski Nov 27, 2025
8752a33
Get the internal lemmas working
wkrozowski Nov 27, 2025
3eb1945
Non-Raw lemmas are working
wkrozowski Nov 27, 2025
f3c432f
DTreeMap.Raw lemmas
wkrozowski Nov 27, 2025
28b4424
Add TreeMap lemmas
wkrozowski Nov 27, 2025
294f4fd
Add the remaining TreeSet lemmas
wkrozowski Nov 27, 2025
9bab334
add wf lemmas to raw variants
wkrozowski Nov 27, 2025
5516ccd
Add Raw TreeSet lemmas
wkrozowski Nov 27, 2025
4beb885
Merge branch 'master' into wojciech/treemap_diff2
wkrozowski Nov 27, 2025
fe2ca73
Add operations
wkrozowski Nov 27, 2025
934dd80
Add lemmas
wkrozowski Nov 27, 2025
e2bd487
rename lemmas
wkrozowski Dec 1, 2025
b027d05
Merge branch 'wojciech/treemap_diff2' into wojciech/extdtreemap_diff2
wkrozowski Dec 1, 2025
8049f9a
Merge branch 'master' into wojciech/extdtreemap_diff2
wkrozowski Dec 1, 2025
a34a832
Merge branch 'master' into wojciech/extdtreemap_diff2
wkrozowski Dec 4, 2025
801774a
Merge branch 'master' into wojciech/extdtreemap_diff2
wkrozowski Dec 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Std/Data/ExtDTreeMap/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,17 @@ def inter [TransCmp cmp] (m₁ m₂ : ExtDTreeMap α β cmp) : ExtDTreeMap α β

instance [TransCmp cmp] : Inter (ExtDTreeMap α β cmp) := ⟨inter⟩

@[inline, inherit_doc DTreeMap.diff]
def diff [TransCmp cmp] (m₁ m₂ : ExtDTreeMap α β cmp) : ExtDTreeMap α β cmp := lift₂ (fun x y : DTreeMap α β cmp => mk (x.diff y))
(fun a b c d equiv₁ equiv₂ => by
simp only [DTreeMap.diff_eq, mk'.injEq]
apply Quotient.sound
apply DTreeMap.Equiv.diff_congr
. exact equiv₁
. exact equiv₂) m₁ m₂

instance [TransCmp cmp] : SDiff (ExtDTreeMap α β cmp) := ⟨diff⟩

instance [TransCmp cmp] [Repr α] [(a : α) → Repr (β a)] : Repr (ExtDTreeMap α β cmp) where
reprPrec m prec := Repr.addAppParen ("Std.ExtDTreeMap.ofList " ++ repr m.toList) prec

Expand Down
316 changes: 316 additions & 0 deletions src/Std/Data/ExtDTreeMap/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2979,6 +2979,322 @@ theorem get!_inter_of_not_mem_left [TransCmp cmp] [Inhabited β]

end Const

section Diff

variable {t₁ t₂ : ExtDTreeMap α β cmp}

@[simp]
theorem diff_eq [TransCmp cmp] : t₁.diff t₂ = t₁ \ t₂ := by
simp only [SDiff.sdiff]

/- contains -/
@[simp]
theorem contains_diff [TransCmp cmp] {k : α} :
(t₁ \ t₂).contains k = (t₁.contains k && !t₂.contains k) :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.contains_diff

/- mem -/
@[simp]
theorem mem_diff_iff [TransCmp cmp] {k : α} :
k ∈ t₁ \ t₂ ↔ k ∈ t₁ ∧ k ∉ t₂ :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.mem_diff_iff

theorem not_mem_diff_of_not_mem_left [TransCmp cmp]
{k : α} (h : ¬k ∈ t₁) :
¬k ∈ t₁ \ t₂ := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.not_mem_diff_of_not_mem_left h

theorem not_mem_diff_of_mem_right [TransCmp cmp]
{k : α} (h : k ∈ t₂) :
¬k ∈ t₁ \ t₂ := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.not_mem_diff_of_mem_right h

/- get? -/
theorem get?_diff [TransCmp cmp] [LawfulEqCmp cmp] {k : α} :
(t₁ \ t₂).get? k =
if k ∈ t₂ then none else t₁.get? k :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.get?_diff

theorem get?_diff_of_not_mem_right [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} (h : ¬k ∈ t₂) :
(t₁ \ t₂).get? k = t₁.get? k := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.get?_diff_of_not_mem_right h

theorem get?_diff_of_not_mem_left [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} (h : ¬k ∈ t₁) :
(t₁ \ t₂).get? k = none := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.get?_diff_of_not_mem_left h

theorem get?_diff_of_mem_right [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} (h : k ∈ t₂) :
(t₁ \ t₂).get? k = none := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.get?_diff_of_mem_right h

/- get -/
theorem get_diff [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} {h_mem : k ∈ t₁ \ t₂} :
(t₁ \ t₂).get k h_mem =
t₁.get k (mem_diff_iff.1 h_mem).1 := by
induction t₁ with
| mk a =>
induction t₂ with
| mk b =>
apply DTreeMap.get_diff

/- getD -/
theorem getD_diff [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} {fallback : β k} :
(t₁ \ t₂).getD k fallback =
if k ∈ t₂ then fallback else t₁.getD k fallback :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.getD_diff

theorem getD_diff_of_not_mem_right [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} {fallback : β k} (h : ¬k ∈ t₂) :
(t₁ \ t₂).getD k fallback = t₁.getD k fallback := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getD_diff_of_not_mem_right h

theorem getD_diff_of_mem_right [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} {fallback : β k} (h : k ∈ t₂) :
(t₁ \ t₂).getD k fallback = fallback := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getD_diff_of_mem_right h

theorem getD_diff_of_not_mem_left [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} {fallback : β k} (h : ¬k ∈ t₁) :
(t₁ \ t₂).getD k fallback = fallback := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getD_diff_of_not_mem_left h

/- get! -/
theorem get!_diff [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} [Inhabited (β k)] :
(t₁ \ t₂).get! k =
if k ∈ t₂ then default else t₁.get! k :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.get!_diff

theorem get!_diff_of_not_mem_right [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} [Inhabited (β k)] (h : ¬k ∈ t₂) :
(t₁ \ t₂).get! k = t₁.get! k := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.get!_diff_of_not_mem_right h

theorem get!_diff_of_mem_right [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} [Inhabited (β k)] (h : k ∈ t₂) :
(t₁ \ t₂).get! k = default := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.get!_diff_of_mem_right h

theorem get!_diff_of_not_mem_left [TransCmp cmp] [LawfulEqCmp cmp]
{k : α} [Inhabited (β k)] (h : ¬k ∈ t₁) :
(t₁ \ t₂).get! k = default := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.get!_diff_of_not_mem_left h

/- getKey? -/
theorem getKey?_diff [TransCmp cmp] {k : α} :
(t₁ \ t₂).getKey? k =
if k ∈ t₂ then none else t₁.getKey? k :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.getKey?_diff

theorem getKey?_diff_of_not_mem_right [TransCmp cmp]
{k : α} (h : ¬k ∈ t₂) :
(t₁ \ t₂).getKey? k = t₁.getKey? k := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getKey?_diff_of_not_mem_right h

theorem getKey?_diff_of_not_mem_left [TransCmp cmp]
{k : α} (h : ¬k ∈ t₁) :
(t₁ \ t₂).getKey? k = none := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getKey?_diff_of_not_mem_left h

theorem getKey?_diff_of_mem_right [TransCmp cmp]
{k : α} (h : k ∈ t₂) :
(t₁ \ t₂).getKey? k = none := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getKey?_diff_of_mem_right h

/- getKey -/
theorem getKey_diff [TransCmp cmp]
{k : α} {h_mem : k ∈ t₁ \ t₂} :
(t₁ \ t₂).getKey k h_mem =
t₁.getKey k (mem_diff_iff.1 h_mem).1 := by
induction t₁ with
| mk a =>
induction t₂ with
| mk b =>
apply DTreeMap.getKey_diff

/- getKeyD -/
theorem getKeyD_diff [TransCmp cmp] {k fallback : α} :
(t₁ \ t₂).getKeyD k fallback =
if k ∈ t₂ then fallback else t₁.getKeyD k fallback :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.getKeyD_diff

theorem getKeyD_diff_of_not_mem_right [TransCmp cmp] {k fallback : α} (h : ¬k ∈ t₂) :
(t₁ \ t₂).getKeyD k fallback = t₁.getKeyD k fallback := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getKeyD_diff_of_not_mem_right h

theorem getKeyD_diff_of_mem_right [TransCmp cmp] {k fallback : α} (h : k ∈ t₂) :
(t₁ \ t₂).getKeyD k fallback = fallback := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getKeyD_diff_of_mem_right h

theorem getKeyD_diff_of_not_mem_left [TransCmp cmp] {k fallback : α} (h : ¬k ∈ t₁) :
(t₁ \ t₂).getKeyD k fallback = fallback := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getKeyD_diff_of_not_mem_left h

/- getKey! -/
theorem getKey!_diff [Inhabited α] [TransCmp cmp] {k : α} :
(t₁ \ t₂).getKey! k =
if k ∈ t₂ then default else t₁.getKey! k :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.getKey!_diff

theorem getKey!_diff_of_not_mem_right [Inhabited α] [TransCmp cmp]
{k : α} (h : ¬k ∈ t₂) :
(t₁ \ t₂).getKey! k = t₁.getKey! k := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getKey!_diff_of_not_mem_right h

theorem getKey!_diff_of_mem_right [Inhabited α] [TransCmp cmp]
{k : α} (h : k ∈ t₂) :
(t₁ \ t₂).getKey! k = default := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getKey!_diff_of_mem_right h

theorem getKey!_diff_of_not_mem_left [Inhabited α] [TransCmp cmp]
{k : α} (h : ¬k ∈ t₁) :
(t₁ \ t₂).getKey! k = default := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.getKey!_diff_of_not_mem_left h

/- size -/
theorem size_diff_le_size_left [TransCmp cmp] :
(t₁ \ t₂).size ≤ t₁.size :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.size_diff_le_size_left

theorem size_diff_eq_size_left [TransCmp cmp]
(h : ∀ (a : α), a ∈ t₁ → a ∉ t₂) :
(t₁ \ t₂).size = t₁.size := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.size_diff_eq_size_left h

theorem size_diff_add_size_inter_eq_size_left [TransCmp cmp] :
(t₁ \ t₂).size + (t₁ ∩ t₂).size = t₁.size :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.size_diff_add_size_inter_eq_size_left

/- isEmpty -/
@[simp]
theorem isEmpty_diff_left [TransCmp cmp] (h : t₁.isEmpty) :
(t₁ \ t₂).isEmpty = true := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.isEmpty_diff_left h

theorem isEmpty_diff_iff [TransCmp cmp] :
(t₁ \ t₂).isEmpty ↔ ∀ k, k ∈ t₁ → k ∈ t₂ :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.isEmpty_diff_iff

end Diff

namespace Const

variable {β : Type v} {t₁ t₂ : ExtDTreeMap α (fun _ => β) cmp}

/- get? -/
theorem get?_diff [TransCmp cmp] {k : α} :
Const.get? (t₁ \ t₂) k =
if k ∈ t₂ then none else Const.get? t₁ k :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.Const.get?_diff

theorem get?_diff_of_not_mem_right [TransCmp cmp]
{k : α} (h : ¬k ∈ t₂) :
Const.get? (t₁ \ t₂) k = Const.get? t₁ k := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.Const.get?_diff_of_not_mem_right h

theorem get?_diff_of_not_mem_left [TransCmp cmp]
{k : α} (h : ¬k ∈ t₁) :
Const.get? (t₁ \ t₂) k = none := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.Const.get?_diff_of_not_mem_left h

theorem get?_diff_of_mem_right [TransCmp cmp]
{k : α} (h : k ∈ t₂) :
Const.get? (t₁ \ t₂) k = none := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.Const.get?_diff_of_mem_right h

/- get -/
theorem get_diff [TransCmp cmp]
{k : α} {h_mem : k ∈ t₁ \ t₂} :
Const.get (t₁ \ t₂) k h_mem =
Const.get t₁ k (mem_diff_iff.1 h_mem).1 := by
induction t₁ with
| mk a =>
induction t₂ with
| mk b =>
apply DTreeMap.Const.get_diff

/- getD -/
theorem getD_diff [TransCmp cmp]
{k : α} {fallback : β} :
Const.getD (t₁ \ t₂) k fallback =
if k ∈ t₂ then fallback else Const.getD t₁ k fallback :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.Const.getD_diff

theorem getD_diff_of_not_mem_right [TransCmp cmp]
{k : α} {fallback : β} (h : ¬k ∈ t₂) :
Const.getD (t₁ \ t₂) k fallback = Const.getD t₁ k fallback := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.Const.getD_diff_of_not_mem_right h

theorem getD_diff_of_mem_right [TransCmp cmp]
{k : α} {fallback : β} (h : k ∈ t₂) :
Const.getD (t₁ \ t₂) k fallback = fallback := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.Const.getD_diff_of_mem_right h

theorem getD_diff_of_not_mem_left [TransCmp cmp]
{k : α} {fallback : β} (h : ¬k ∈ t₁) :
Const.getD (t₁ \ t₂) k fallback = fallback := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.Const.getD_diff_of_not_mem_left h

/- get! -/
theorem get!_diff [TransCmp cmp] [Inhabited β]
{k : α} :
Const.get! (t₁ \ t₂) k =
if k ∈ t₂ then default else Const.get! t₁ k :=
t₁.inductionOn₂ t₂ fun _ _ => DTreeMap.Const.get!_diff

theorem get!_diff_of_not_mem_right [TransCmp cmp] [Inhabited β]
{k : α} (h : ¬k ∈ t₂) :
Const.get! (t₁ \ t₂) k = Const.get! t₁ k := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.Const.get!_diff_of_not_mem_right h

theorem get!_diff_of_mem_right [TransCmp cmp] [Inhabited β]
{k : α} (h : k ∈ t₂) :
Const.get! (t₁ \ t₂) k = default := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.Const.get!_diff_of_mem_right h

theorem get!_diff_of_not_mem_left [TransCmp cmp] [Inhabited β]
{k : α} (h : ¬k ∈ t₁) :
Const.get! (t₁ \ t₂) k = default := by
revert h
exact t₁.inductionOn₂ t₂ fun _ _ h => DTreeMap.Const.get!_diff_of_not_mem_left h

end Const

section Alter

theorem alter_eq_empty_iff_erase_eq_empty [TransCmp cmp] [LawfulEqCmp cmp] {k : α}
Expand Down
5 changes: 5 additions & 0 deletions src/Std/Data/ExtTreeMap/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,11 @@ def inter [TransCmp cmp] (t₁ t₂ : ExtTreeMap α β cmp) : ExtTreeMap α β c

instance [TransCmp cmp] : Inter (ExtTreeMap α β cmp) := ⟨inter⟩

@[inline, inherit_doc ExtDTreeMap.diff]
def diff [TransCmp cmp] (t₁ t₂ : ExtTreeMap α β cmp) : ExtTreeMap α β cmp := ⟨ExtDTreeMap.diff t₁.inner t₂.inner⟩

instance [TransCmp cmp] : SDiff (ExtTreeMap α β cmp) := ⟨diff⟩

@[inline, inherit_doc ExtDTreeMap.eraseMany]
def eraseMany [TransCmp cmp] {ρ} [ForIn Id ρ α] (t : ExtTreeMap α β cmp) (l : ρ) : ExtTreeMap α β cmp :=
⟨t.inner.eraseMany l⟩
Expand Down
Loading
Loading