Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 9451087

Browse files
committed
refactor(*): move in list lemmas, adapt to change in list.union
1 parent aa78466 commit 9451087

File tree

8 files changed

+356
-411
lines changed

8 files changed

+356
-411
lines changed

data/hash_map.lean

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ begin
185185
exact ⟨list.nodup.ndnil, λ_, false.elim⟩,
186186
simp[array.iterate_aux, list.map_append], exact
187187
let ⟨nd, al⟩ := IH (le_of_lt h) in
188-
list.nodup_append_of_nodup_of_nodup_of_disjoint nd (v.nodup _ _) $ λa m1 m2,
188+
⟨list.nodup_append nd (v.nodup _ _) $ λa m1 m2,
189189
let ⟨⟨a', b⟩, m1, e1⟩ := list.exists_of_mem_map m1 in
190190
let ⟨⟨a'', b'⟩, m2, e2⟩ := list.exists_of_mem_map m2 in
191191
match a', a'', b, b', m1, m2, e1, e2 with ._, ._, b, b', m1, m2, rfl, rfl :=
@@ -319,14 +319,11 @@ section
319319
have nd' : ((u ++ v2 ++ w).map sigma.fst).nodup, begin
320320
rw [list.map_append, list.map_append] at nd,
321321
rw [list.map_append, list.map_append],
322-
have ndu : (u.map sigma.fst).nodup := list.nodup_of_nodup_append_left (list.nodup_of_nodup_append_left nd),
323-
have ndv1 : (v1.map sigma.fst).nodup := list.nodup_of_nodup_append_right (list.nodup_of_nodup_append_left nd),
324-
have ndw : (w.map sigma.fst).nodup := list.nodup_of_nodup_append_right nd,
325-
have djuw : (u.map sigma.fst).disjoint (w.map sigma.fst) :=
326-
list.disjoint_of_disjoint_append_left_left (list.disjoint_of_nodup_append nd),
327-
exact list.nodup_append_of_nodup_of_nodup_of_disjoint
328-
(list.nodup_append_of_nodup_of_nodup_of_disjoint ndu hvnd djuv)
329-
ndw (list.disjoint_append_of_disjoint_left djuw djwv.comm)
322+
have ndu := list.nodup_of_nodup_append_left (list.nodup_of_nodup_append_left nd),
323+
have ndw := list.nodup_of_nodup_append_right nd,
324+
have djuw := list.disjoint_of_disjoint_append_left_left (list.disjoint_of_nodup_append nd),
325+
exact list.nodup_append (list.nodup_append ndu hvnd djuv)
326+
ndw (list.disjoint_append_of_disjoint_left djuw djwv.symm)
330327
end,
331328
begin
332329
rw [e, calc s + (u ++ v1 ++ w).length + v2.length - v1.length
@@ -495,7 +492,7 @@ theorem not_contains_empty (hash_fn : α → nat) (n a) :
495492
¬ (@mk_hash_map α _ β hash_fn n).contains a :=
496493
by apply bool_iff_false.2; dsimp [contains]; rw [find_empty]; refl
497494

498-
theorem insert_theorem (hash_fn : α → nat) {n n'}
495+
theorem insert_lemma (hash_fn : α → nat) {n n'}
499496
{bkts : bucket_array α β n} {sz} (v : valid hash_fn bkts sz) :
500497
valid hash_fn (bkts.foldl (mk_array _ [] : bucket_array α β n') (reinsert_aux hash_fn)) sz :=
501498
suffices ∀ (l : list Σ a, β a),
@@ -520,7 +517,7 @@ end,
520517
apply IH _ _ v',
521518
simp,
522519
have nd' := list.nodup_of_nodup_cons nd,
523-
apply list.nodup_append_of_nodup_of_nodup_of_disjoint
520+
apply list.nodup_append
524521
(list.nodup_of_nodup_append_left nd')
525522
(v'.as_list_nodup _),
526523
exact λa m1 m2,
@@ -568,7 +565,7 @@ let n' : ℕ+ := ⟨n.1 * 2, mul_pos n.2 dec_trivial⟩,
568565
size := size',
569566
nbuckets := n',
570567
buckets := buckets'',
571-
is_valid := insert_theorem _ valid' }
568+
is_valid := insert_lemma _ valid' }
572569

573570
theorem mem_insert : Π (m : hash_map α β) (a b a' b'),
574571
sigma.mk a' b' ∈ (m.insert a b).entries ↔
@@ -701,7 +698,7 @@ match (by apply_instance : decidable (contains_aux a bkt)) with
701698
append_of_modify u' [⟨a, b⟩] [] _ hl' hfl', v.as_list_nodup _ with
702699
| ._, ._, ⟨u, w, rfl, rfl⟩, nd' := by simp; simp at nd'; exact
703700
⟨λhm, ⟨λe, match a', e, b', hm with ._, rfl, b', hm := by {
704-
rw [← list.mem_append_iff] at hm;
701+
rw [← list.mem_append] at hm;
705702
have hm := list.mem_map sigma.fst hm;
706703
rw list.map_append at hm;
707704
exact list.not_mem_of_nodup_cons (list.nodup_head nd') hm }

0 commit comments

Comments
 (0)