Theorem: List.countP_mono_left
File: .lake/packages/batteries/Batteries/Data/List/Count.lean

tactic: induction l with
| nil => apply Nat.le_refl
| cons a l ihl =>
  rw [forall_mem_cons] at h
  have ⟨ha, hl⟩ := h
  simp [countP_cons]
  cases h : p a
  . simp
    apply Nat.le_trans ?_ (Nat.le_add_right _ _)
    apply ihl hl
  . simp [ha h]
    apply ihl hl
state_before: α : Type u_1
p q : α → Bool
l : List α
h : ∀ (x : α), x ∈ l → p x = true → q x = true
⊢ countP p l ≤ countP q l
state_after: no goals

tactic: apply Nat.le_refl
state_before: case nil
α : Type u_1
p q : α → Bool
h : ∀ (x : α), x ∈ [] → p x = true → q x = true
⊢ countP p [] ≤ countP q []
state_after: no goals

tactic: rw [forall_mem_cons] at h
state_before: case cons
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h : ∀ (x : α), x ∈ a :: l → p x = true → q x = true
⊢ countP p (a :: l) ≤ countP q (a :: l)
state_after: case cons
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
⊢ countP p (a :: l) ≤ countP q (a :: l)

tactic: have ⟨ha, hl⟩ := h
state_before: case cons
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
⊢ countP p (a :: l) ≤ countP q (a :: l)
state_after: case cons
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
⊢ countP p (a :: l) ≤ countP q (a :: l)

tactic: simp [countP_cons]
state_before: case cons
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
⊢ countP p (a :: l) ≤ countP q (a :: l)
state_after: case cons
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
⊢ (countP p l + if p a = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0

tactic: cases h : p a
state_before: case cons
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
⊢ (countP p l + if p a = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0
state_after: case cons.false
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = false
⊢ (countP p l + if false = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0

case cons.true
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = true
⊢ (countP p l + if true = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0

tactic: . simp
  apply Nat.le_trans ?_ (Nat.le_add_right _ _)
  apply ihl hl
state_before: case cons.false
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = false
⊢ (countP p l + if false = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0

case cons.true
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = true
⊢ (countP p l + if true = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0
state_after: case cons.true
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = true
⊢ (countP p l + if true = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0

tactic: . simp [ha h]
  apply ihl hl
state_before: case cons.true
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = true
⊢ (countP p l + if true = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0
state_after: no goals

tactic: simp
state_before: case cons.false
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = false
⊢ (countP p l + if false = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0
state_after: case cons.false
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = false
⊢ countP p l ≤ countP q l + if q a = true then 1 else 0

tactic: apply Nat.le_trans ?_ (Nat.le_add_right _ _)
state_before: case cons.false
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = false
⊢ countP p l ≤ countP q l + if q a = true then 1 else 0
state_after: α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = false
⊢ countP p l ≤ countP q l

tactic: apply ihl hl
state_before: α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = false
⊢ countP p l ≤ countP q l
state_after: no goals

tactic: simp [ha h]
state_before: case cons.true
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = true
⊢ (countP p l + if true = true then 1 else 0) ≤ countP q l + if q a = true then 1 else 0
state_after: case cons.true
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = true
⊢ countP p l ≤ countP q l

tactic: apply ihl hl
state_before: case cons.true
α : Type u_1
p q : α → Bool
a : α
l : List α
ihl : (∀ (x : α), x ∈ l → p x = true → q x = true) → countP p l ≤ countP q l
h✝ : (p a = true → q a = true) ∧ ∀ (x : α), x ∈ l → p x = true → q x = true
ha : p a = true → q a = true
hl : ∀ (x : α), x ∈ l → p x = true → q x = true
h : p a = true
⊢ countP p l ≤ countP q l
state_after: no goals