[GOAL]
α : Type u_1
l l₁ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₂ : List α
⊢ [] <+ []
[PROOFSTEP]
rfl
[GOAL]
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a : α
l₁ l₂ t : List α
s : t <+ l₁
e : t ++ l₂ = l₁ ∪ l₂
h : a ∈ l₁ ∪ l₂
⊢ t ++ l₂ = a :: l₁ ∪ l₂
[PROOFSTEP]
simp only [e, cons_union, insert_of_mem h]
[GOAL]
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a : α
l₁ l₂ t : List α
s : t <+ l₁
e : t ++ l₂ = l₁ ∪ l₂
h : ¬a ∈ l₁ ∪ l₂
⊢ a :: t ++ l₂ = a :: l₁ ∪ l₂
[PROOFSTEP]
simp only [cons_append, cons_union, e, insert_of_not_mem h]
[GOAL]
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
⊢ (∀ (x : α), x ∈ l₁ ∪ l₂ → p x) ↔ (∀ (x : α), x ∈ l₁ → p x) ∧ ∀ (x : α), x ∈ l₂ → p x
[PROOFSTEP]
simp only [mem_union_iff, or_imp, forall_and]
[GOAL]
α : Type u_1
l l₁✝ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₁ : List α
h : a ∈ l₂
⊢ (a :: l₁) ∩ l₂ = a :: l₁ ∩ l₂
[PROOFSTEP]
simp only [Inter.inter, List.inter, filter_cons_of_pos, h]
[GOAL]
α : Type u_1
l l₁✝ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₁ : List α
h : ¬a ∈ l₂
⊢ (a :: l₁) ∩ l₂ = l₁ ∩ l₂
[PROOFSTEP]
simp only [Inter.inter, List.inter, filter_cons_of_neg, h]
[GOAL]
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
h : a ∈ l₁ ∩ l₂
⊢ a ∈ l₂
[PROOFSTEP]
simpa using of_mem_filter h
[GOAL]
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
h₁ : a ∈ l₁
h₂ : a ∈ l₂
⊢ decide (a ∈ l₂) = true
[PROOFSTEP]
simpa using h₂
[GOAL]
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
⊢ l₁ ∩ l₂ = [] ↔ Disjoint l₁ l₂
[PROOFSTEP]
simp only [eq_nil_iff_forall_not_mem, mem_inter_iff, not_and]
[GOAL]
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
⊢ (∀ (a : α), a ∈ l₁ → ¬a ∈ l₂) ↔ Disjoint l₁ l₂
[PROOFSTEP]
rfl
[GOAL]
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
xs ys : List α
⊢ List.inter xs (reverse ys) = List.inter xs ys
[PROOFSTEP]
simp only [List.inter, mem_reverse]
[GOAL]
α : Type u_1
l✝ l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l : List α
⊢ List.bagInter [] l = []
[PROOFSTEP]
cases l
[GOAL]
case nil
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
⊢ List.bagInter [] [] = []
[PROOFSTEP]
rfl
[GOAL]
case cons
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
head✝ : α
tail✝ : List α
⊢ List.bagInter [] (head✝ :: tail✝) = []
[PROOFSTEP]
rfl
[GOAL]
α : Type u_1
l✝ l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l : List α
⊢ List.bagInter l [] = []
[PROOFSTEP]
cases l
[GOAL]
case nil
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
⊢ List.bagInter [] [] = []
[PROOFSTEP]
rfl
[GOAL]
case cons
α : Type u_1
l l₁ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
head✝ : α
tail✝ : List α
⊢ List.bagInter (head✝ :: tail✝) [] = []
[PROOFSTEP]
rfl
[GOAL]
α : Type u_1
l l₁✝ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₁ : List α
h : a ∈ l₂
⊢ List.bagInter (a :: l₁) l₂ = a :: List.bagInter l₁ (List.erase l₂ a)
[PROOFSTEP]
cases l₂
[GOAL]
case nil
α : Type u_1
l l₁✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₁ : List α
h : a ∈ []
⊢ List.bagInter (a :: l₁) [] = a :: List.bagInter l₁ (List.erase [] a)
[PROOFSTEP]
exact if_pos h
[GOAL]
case cons
α : Type u_1
l l₁✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₁ : List α
head✝ : α
tail✝ : List α
h : a ∈ head✝ :: tail✝
⊢ List.bagInter (a :: l₁) (head✝ :: tail✝) = a :: List.bagInter l₁ (List.erase (head✝ :: tail✝) a)
[PROOFSTEP]
simp only [List.bagInter, if_pos (elem_eq_true_of_mem h)]
[GOAL]
α : Type u_1
l l₁✝ l₂ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₁ : List α
h : ¬a ∈ l₂
⊢ List.bagInter (a :: l₁) l₂ = List.bagInter l₁ l₂
[PROOFSTEP]
cases l₂
[GOAL]
case nil
α : Type u_1
l l₁✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₁ : List α
h : ¬a ∈ []
⊢ List.bagInter (a :: l₁) [] = List.bagInter l₁ []
[PROOFSTEP]
simp only [bagInter_nil]
[GOAL]
case cons
α : Type u_1
l l₁✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₁ : List α
head✝ : α
tail✝ : List α
h : ¬a ∈ head✝ :: tail✝
⊢ List.bagInter (a :: l₁) (head✝ :: tail✝) = List.bagInter l₁ (head✝ :: tail✝)
[PROOFSTEP]
simp only [erase_of_not_mem h, List.bagInter, if_neg (mt mem_of_elem_eq_true h)]
[GOAL]
α : Type u_1
l l₁ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a : α
l₂ : List α
⊢ a ∈ List.bagInter [] l₂ ↔ a ∈ [] ∧ a ∈ l₂
[PROOFSTEP]
simp only [nil_bagInter, not_mem_nil, false_and_iff]
[GOAL]
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
⊢ a ∈ List.bagInter (b :: l₁) l₂ ↔ a ∈ b :: l₁ ∧ a ∈ l₂
[PROOFSTEP]
by_cases h : b ∈ l₂
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
h : b ∈ l₂
⊢ a ∈ List.bagInter (b :: l₁) l₂ ↔ a ∈ b :: l₁ ∧ a ∈ l₂
[PROOFSTEP]
rw [cons_bagInter_of_pos _ h, mem_cons, mem_cons, mem_bagInter]
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
h : b ∈ l₂
⊢ a = b ∨ a ∈ l₁ ∧ a ∈ List.erase l₂ b ↔ (a = b ∨ a ∈ l₁) ∧ a ∈ l₂
[PROOFSTEP]
by_cases ba : a = b
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
h : b ∈ l₂
ba : a = b
⊢ a = b ∨ a ∈ l₁ ∧ a ∈ List.erase l₂ b ↔ (a = b ∨ a ∈ l₁) ∧ a ∈ l₂
[PROOFSTEP]
simp only [ba, h, eq_self_iff_true, true_or_iff, true_and_iff]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
h : b ∈ l₂
ba : ¬a = b
⊢ a = b ∨ a ∈ l₁ ∧ a ∈ List.erase l₂ b ↔ (a = b ∨ a ∈ l₁) ∧ a ∈ l₂
[PROOFSTEP]
simp only [mem_erase_of_ne ba, ba, false_or_iff]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
h : ¬b ∈ l₂
⊢ a ∈ List.bagInter (b :: l₁) l₂ ↔ a ∈ b :: l₁ ∧ a ∈ l₂
[PROOFSTEP]
rw [cons_bagInter_of_neg _ h, mem_bagInter, mem_cons, or_and_right]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
h : ¬b ∈ l₂
⊢ a ∈ l₁ ∧ a ∈ l₂ ↔ a = b ∧ a ∈ l₂ ∨ a ∈ l₁ ∧ a ∈ l₂
[PROOFSTEP]
symm
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
h : ¬b ∈ l₂
⊢ a = b ∧ a ∈ l₂ ∨ a ∈ l₁ ∧ a ∈ l₂ ↔ a ∈ l₁ ∧ a ∈ l₂
[PROOFSTEP]
apply or_iff_right_of_imp
[GOAL]
case neg.ha
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
h : ¬b ∈ l₂
⊢ a = b ∧ a ∈ l₂ → a ∈ l₁ ∧ a ∈ l₂
[PROOFSTEP]
rintro ⟨rfl, h'⟩
[GOAL]
case neg.ha.intro
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a : α
l₁ l₂ : List α
h' : a ∈ l₂
h : ¬a ∈ l₂
⊢ a ∈ l₁ ∧ a ∈ l₂
[PROOFSTEP]
exact h.elim h'
[GOAL]
α : Type u_1
l l₁ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a : α
l₂ : List α
⊢ count a (List.bagInter [] l₂) = min (count a []) (count a l₂)
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
l l₁✝ l₂ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a : α
l₁ : List α
⊢ count a (List.bagInter l₁ []) = min (count a l₁) (count a [])
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
⊢ count a (List.bagInter (b :: l₁) l₂) = min (count a (b :: l₁)) (count a l₂)
[PROOFSTEP]
by_cases hb : b ∈ l₂
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : b ∈ l₂
⊢ count a (List.bagInter (b :: l₁) l₂) = min (count a (b :: l₁)) (count a l₂)
[PROOFSTEP]
rw [cons_bagInter_of_pos _ hb, count_cons', count_cons', count_bagInter, count_erase, ← min_add_add_right]
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : b ∈ l₂
⊢ min (count a l₁ + if a = b then 1 else 0) ((count a l₂ - if a = b then 1 else 0) + if a = b then 1 else 0) =
    min (count a l₁ + if a = b then 1 else 0) (count a l₂)
[PROOFSTEP]
by_cases ab : a = b
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : b ∈ l₂
ab : a = b
⊢ min (count a l₁ + if a = b then 1 else 0) ((count a l₂ - if a = b then 1 else 0) + if a = b then 1 else 0) =
    min (count a l₁ + if a = b then 1 else 0) (count a l₂)
[PROOFSTEP]
rw [if_pos ab, @tsub_add_cancel_of_le]
[GOAL]
case pos.h
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : b ∈ l₂
ab : a = b
⊢ 1 ≤ count a l₂
[PROOFSTEP]
rwa [succ_le_iff, count_pos, ab]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : b ∈ l₂
ab : ¬a = b
⊢ min (count a l₁ + if a = b then 1 else 0) ((count a l₂ - if a = b then 1 else 0) + if a = b then 1 else 0) =
    min (count a l₁ + if a = b then 1 else 0) (count a l₂)
[PROOFSTEP]
rw [if_neg ab, tsub_zero, add_zero, add_zero]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : ¬b ∈ l₂
⊢ count a (List.bagInter (b :: l₁) l₂) = min (count a (b :: l₁)) (count a l₂)
[PROOFSTEP]
rw [cons_bagInter_of_neg _ hb, count_bagInter]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : ¬b ∈ l₂
⊢ min (count a l₁) (count a l₂) = min (count a (b :: l₁)) (count a l₂)
[PROOFSTEP]
by_cases ab : a = b
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : ¬b ∈ l₂
ab : a = b
⊢ min (count a l₁) (count a l₂) = min (count a (b :: l₁)) (count a l₂)
[PROOFSTEP]
rw [← ab] at hb
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : ¬a ∈ l₂
ab : a = b
⊢ min (count a l₁) (count a l₂) = min (count a (b :: l₁)) (count a l₂)
[PROOFSTEP]
rw [count_eq_zero.2 hb, min_zero, min_zero]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a✝ : α
inst✝ : DecidableEq α
a b : α
l₁ l₂ : List α
hb : ¬b ∈ l₂
ab : ¬a = b
⊢ min (count a l₁) (count a l₂) = min (count a (b :: l₁)) (count a l₂)
[PROOFSTEP]
rw [count_cons_of_ne ab]
[GOAL]
α : Type u_1
l l₁ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₂ : List α
⊢ List.bagInter [] l₂ <+ []
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
⊢ List.bagInter (b :: l₁) l₂ <+ b :: l₁
[PROOFSTEP]
by_cases h : b ∈ l₂
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
h : b ∈ l₂
⊢ List.bagInter (b :: l₁) l₂ <+ b :: l₁
[PROOFSTEP]
simp only [h, cons_bagInter_of_pos, cons_bagInter_of_neg, not_false_iff]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
h : ¬b ∈ l₂
⊢ List.bagInter (b :: l₁) l₂ <+ b :: l₁
[PROOFSTEP]
simp only [h, cons_bagInter_of_pos, cons_bagInter_of_neg, not_false_iff]
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
h : b ∈ l₂
⊢ b :: List.bagInter l₁ (List.erase l₂ b) <+ b :: l₁
[PROOFSTEP]
exact (bagInter_sublist_left _ _).cons_cons _
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
h : ¬b ∈ l₂
⊢ List.bagInter l₁ l₂ <+ b :: l₁
[PROOFSTEP]
apply sublist_cons_of_sublist
[GOAL]
case neg.a
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
h : ¬b ∈ l₂
⊢ List.bagInter l₁ l₂ <+ l₁
[PROOFSTEP]
apply bagInter_sublist_left
[GOAL]
α : Type u_1
l l₁ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
l₂ : List α
⊢ List.bagInter [] l₂ = [] ↔ [] ∩ l₂ = []
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
⊢ List.bagInter (b :: l₁) l₂ = [] ↔ (b :: l₁) ∩ l₂ = []
[PROOFSTEP]
by_cases h : b ∈ l₂
[GOAL]
case pos
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
h : b ∈ l₂
⊢ List.bagInter (b :: l₁) l₂ = [] ↔ (b :: l₁) ∩ l₂ = []
[PROOFSTEP]
simp [h]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
h : ¬b ∈ l₂
⊢ List.bagInter (b :: l₁) l₂ = [] ↔ (b :: l₁) ∩ l₂ = []
[PROOFSTEP]
simp [h]
[GOAL]
case neg
α : Type u_1
l l₁✝ l₂✝ : List α
p : α → Prop
a : α
inst✝ : DecidableEq α
b : α
l₁ l₂ : List α
h : ¬b ∈ l₂
⊢ List.bagInter l₁ l₂ = [] ↔ l₁ ∩ l₂ = []
[PROOFSTEP]
exact bagInter_nil_iff_inter_nil l₁ l₂