Skip to content

Commit e45969a

Browse files
committed
chore: end of day
1 parent fcb0151 commit e45969a

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

src/Std/Data/Internal/List/Associative.lean

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,40 +3128,33 @@ theorem length_right_le_length_insertSmallerList [BEq α] [EquivBEq α]
31283128
. apply le_of_lt h
31293129
. simp only [length_le_length_insertList]
31303130

3131-
theorem getEntry?_insertListIfNew_of_same_elem [BEq α] [PartialEquivBEq α] [LawfulBEq α] {l t : List ((a : α) × β a)} {k : α} {v : β k} (not_contains: containsKey k l = false):
3132-
getEntry? k (insertListIfNew (⟨k, v⟩ :: l) t) = .some ⟨k, v⟩ := by
3133-
induction t generalizing l
3134-
case nil => simp [insertListIfNew]
3135-
case cons h t ih =>
3136-
unfold insertListIfNew
3137-
by_cases (k = h.fst)
3138-
case pos h_eq =>
3139-
simp [h_eq, insertEntryIfNew]
3140-
replace ih := @ih l
3141-
simp [h_eq] at ih
3142-
apply ih
3143-
simp [←h_eq, not_contains]
3144-
case neg h_neg =>
3145-
simp [insertEntryIfNew]
3146-
have : (k == h.fst) = false := by simp only [beq_eq_false_iff_ne, ne_eq, h_neg,
3147-
not_false_eq_true]
3131+
theorem getEntry?_insertListIfNew [BEq α] [PartialEquivBEq α] [LawfulBEq α] {l toInsert : List ((a : α) × β a)}
3132+
{k : α} :
3133+
getEntry? k (insertListIfNew l toInsert) =
3134+
(getEntry? k l).or (getEntry? k toInsert) := by
3135+
induction toInsert generalizing l with
3136+
| nil => simp [insertListIfNew]
3137+
| cons hd tl ih =>
3138+
simp only [insertListIfNew, ih, getEntry?_insertEntryIfNew]
3139+
cases hhd : hd.fst == k
3140+
. have := @getEntry?_cons α β _ tl hd.fst k hd.snd
31483141
simp [this]
3149-
by_cases containsKey h.fst l = true
3150-
case pos h_contains =>
3151-
simp [h_contains]
3152-
apply ih
3153-
exact not_contains
3154-
case neg h_not_contains =>
3155-
simp at h_not_contains
3156-
simp [h_not_contains]
3157-
have := @ih (⟨h.fst,h.snd⟩ :: l)
3158-
have not_contains_bigger := @containsKey_cons α β _ l h.fst k h.snd
3159-
simp [not_contains_bigger, not_contains] at this
3160-
rw [Eq.comm] at h_neg
3161-
specialize this h_neg
3162-
sorry
3163-
3142+
simp only [hhd, cond_false]
3143+
. cases hc : containsKey hd.fst l
3144+
. simp only [Bool.not_false, Bool.and_self, ↓reduceIte, Option.some_or]
3145+
rw [getEntry?_eq_none.2]
3146+
. simp only [Option.none_or]
3147+
rw [←@getEntry?_congr _ _ _ _ (hd :: tl) hd.fst k hhd]
3148+
simp [@getEntry?_cons_self _ _ _ _ tl hd.fst hd.snd]
3149+
. simp only [←containsKey_congr hhd, hc]
3150+
. simp only [Bool.not_true, Bool.and_false, Bool.false_eq_true, ↓reduceIte]
3151+
rw [containsKey_congr hhd, containsKey_eq_isSome_getEntry?] at hc
3152+
obtain ⟨v, hv⟩ := Option.isSome_iff_exists.1 hc
3153+
simp [hv]
31643154

3155+
theorem getEntry?_insertListIfNew_of_same_elem [BEq α] [PartialEquivBEq α] [LawfulBEq α] {l t : List ((a : α) × β a)} {k : α} {v : β k}:
3156+
getEntry? k (insertListIfNew (⟨k, v⟩ :: l) t) = .some ⟨k, v⟩ := by
3157+
simp [getEntry?_insertListIfNew]
31653158

31663159
theorem getEntry?_insertListIfNew_of_contains_eq_false_right [BEq α] [PartialEquivBEq α] [LawfulBEq α]
31673160
{l toInsert : List ((a : α) × β a)} {k : α}
@@ -3176,7 +3169,7 @@ theorem getEntry?_insertListIfNew_of_contains_eq_false_right [BEq α] [PartialEq
31763169
rw [h_eq]
31773170
rw [h_eq] at not_contains
31783171
simp only [@insertEntryIfNew_of_containsKey_eq_false α β _ l h.fst h.snd not_contains]
3179-
simp only [getEntry?_insertListIfNew_of_same_elem not_contains]
3172+
simp only [getEntry?_insertListIfNew_of_same_elem]
31803173
simp [getEntry?]
31813174
case neg h_ne =>
31823175
have := @getEntry?_cons_of_false α β _ t h.fst k h.snd (by simp; rw [Eq.comm]; exact h_ne)

0 commit comments

Comments
 (0)