Skip to content

Commit 851d4e7

Browse files
committed
Merge branch 'wojciech/hashmap_beq2' into wojciech/hashmap_deceq
2 parents fb951bf + a269546 commit 851d4e7

File tree

5 files changed

+11
-25
lines changed

5 files changed

+11
-25
lines changed

src/Init/Data/List/Perm.lean

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,10 @@ theorem sum_nat {l₁ l₂ : List Nat} (h : l₁ ~ l₂) : l₁.sum = l₂.sum :
602602
| trans _ _ ih₁ ih₂ => simp [ih₁, ih₂]
603603

604604
theorem all_eq {l₁ l₂ : List α} {f : α → Bool} (hp : l₁.Perm l₂) : l₁.all f = l₂.all f := by
605-
rw [Bool.eq_iff_iff, Bool.eq_iff_iff, List.all_eq_true, List.all_eq_true]
606-
simp only [iff_true]
607-
constructor
608-
· intro hyp e mem
609-
exact hyp e (@Perm.mem_iff _ e l₁ l₂ hp |>.2 mem)
610-
· intro hyp e mem
611-
exact hyp e (@Perm.mem_iff _ e l₂ l₁ hp.symm |>.2 mem)
605+
rw [Bool.eq_iff_iff]; simp [hp.mem_iff]
606+
607+
theorem any_eq {l₁ l₂ : List α} {f : α → Bool} (hp : l₁.Perm l₂) : l₁.any f = l₂.any f := by
608+
rw [Bool.eq_iff_iff]; simp [hp.mem_iff]
612609

613610
grind_pattern Perm.sum_nat => l₁ ~ l₂, l₁.sum
614611
grind_pattern Perm.sum_nat => l₁ ~ l₂, l₂.sum

src/Std/Data/DHashMap/Internal/Defs.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ def beq [BEq α] [LawfulBEq α] [Hashable α] [∀ k, BEq (β k)] (m₁ m₂ : R
498498
@[inline] def diff [BEq α] [Hashable α] (m₁ m₂ : Raw₀ α β) : Raw₀ α β :=
499499
if m₁.1.size ≤ m₂.1.size then m₁.filter (fun k _ => !m₂.contains k) else (eraseManyEntries m₁ m₂.1).1
500500

501+
501502
section
502503

503504
variable {β : Type v}

src/Std/Data/DHashMap/Internal/Raw.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ theorem beq_eq [BEq α] [Hashable α] [LawfulBEq α] [∀ k, BEq (β k)] {m₁ m
159159
simp [Raw.beq, h₁.size_buckets_pos, h₂.size_buckets_pos]
160160

161161
theorem Const.beq_eq {β : Type v} [BEq α] [Hashable α] [BEq β] {m₁ m₂ : Raw α (fun _ => β)} (h₁ : m₁.WF) (h₂ : m₂.WF) :
162-
Raw.Const.beq m₁ m₂ = Raw₀.Const.beq ⟨m₁, h₁.size_buckets_pos⟩ ⟨m₂, h₂.size_buckets_pos⟩ := by
162+
Raw.Const.beq m₁ m₂ = Raw₀.Const.beq ⟨m₁, h₁.size_buckets_pos⟩ ⟨m₂, h₂.size_buckets_pos⟩ := by
163163
simp [Raw.Const.beq, h₁.size_buckets_pos, h₂.size_buckets_pos]
164-
164+
165165
theorem diff_eq [BEq α] [Hashable α] {m₁ m₂ : Raw α β} (h₁ : m₁.WF) (h₂ : m₂.WF) :
166166
m₁.diff m₂ = Raw₀.diff ⟨m₁, h₁.size_buckets_pos⟩ ⟨m₂, h₂.size_buckets_pos⟩ := by
167167
simp [Raw.diff, h₁.size_buckets_pos, h₂.size_buckets_pos]

src/Std/Data/DHashMap/Internal/RawLemmas.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,6 +2613,7 @@ theorem Const.equiv_of_beq [LawfulBEq α] [BEq β] [LawfulBEq β] (h₁ : m₁.v
26132613
theorem Const.Equiv.beq_congr [EquivBEq α] [LawfulHashable α] {m₃ m₄ : Raw₀ α (fun _ => β)} [BEq β] (h₁ : m₁.val.WF) (h₂ : m₂.val.WF) (h₃ : m₃.val.WF) (h₄ : m₄.val.WF) :
26142614
m₁.1.Equiv m₃.1 → m₂.1.Equiv m₄.1 → Const.beq m₁ m₂ = Const.beq m₃ m₄ := by
26152615
simp_to_model using List.Const.beqModel_congr
2616+
26162617
end
26172618

26182619
section Union

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7695,29 +7695,16 @@ theorem beqModel_congr [BEq α] [LawfulBEq α] [∀ k, BEq (β k)] {l₁ l₂ l
76957695
(hl : DistinctKeys l₂) (p₁ : l₁.Perm l₃) (p₂ : l₂.Perm l₄) : beqModel l₁ l₂ = beqModel l₃ l₄ := by
76967696
simp only [beqModel, ne_eq, ite_not, Bool.if_false_right, Perm.length_eq p₁, Perm.length_eq p₂]
76977697
suffices h : (l₁.all fun x => getValueCast? x.fst l₂ == some x.snd) = (l₃.all fun x => getValueCast? x.fst l₄ == some x.snd) by simp [h]
7698-
conv =>
7699-
lhs
7700-
rhs
7701-
ext x
7702-
rw [getValueCast?_of_perm hl p₂]
7703-
apply List.Perm.all_eq p₁
7698+
simp [getValueCast?_of_perm hl p₂, List.Perm.all_eq p₁]
77047699

77057700
theorem Const.beqModel_congr {β : Type v} [BEq α] [EquivBEq α] [BEq β] {l₁ l₂ l₃ l₄ : List ((_ : α) × β)}
77067701
(hl : DistinctKeys l₂) (p₁ : l₁.Perm l₃) (p₂ : l₂.Perm l₄) : beqModel l₁ l₂ = beqModel l₃ l₄ := by
77077702
simp only [beqModel, ne_eq, ite_not, Bool.if_false_right, Perm.length_eq p₁, Perm.length_eq p₂]
77087703
suffices h : (l₁.all fun x => getValue? x.fst l₂ == some x.snd) = (l₃.all fun x => getValue? x.fst l₄ == some x.snd) by simp [h]
7709-
conv =>
7710-
lhs
7711-
rhs
7712-
ext x
7713-
rw [getValue?_of_perm hl p₂]
7714-
apply List.Perm.all_eq p₁
7704+
simp [getValue?_of_perm hl p₂, List.Perm.all_eq p₁]
77157705

77167706
theorem beqModel_eq_constBeqModel {β : Type v} [BEq α] [LawfulBEq α] [BEq β] {l₁ l₂ : List ((_ : α) × β)} : beqModel l₁ l₂ = Const.beqModel l₁ l₂ := by
7717-
rw [beqModel, Const.beqModel]
7718-
congr
7719-
ext x
7720-
rw [getValue?_eq_getValueCast?]
7707+
simp [beqModel, Const.beqModel, getValue?_eq_getValueCast?]
77217708

77227709
theorem Const.perm_of_beqModel {β : Type v} [BEq α] [LawfulBEq α] [BEq β] [LawfulBEq β] {l₁ l₂ : List ((_ : α) × β)} (hl₁ : DistinctKeys l₁) (hl₂ : DistinctKeys l₂) :
77237710
beqModel l₁ l₂ → l₁.Perm l₂ := by

0 commit comments

Comments
 (0)