l3lab/ntp-mathlib huggingface dataset:
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> 

Proof state:
case true
x : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (x :: l)
h2 : length l % 2 = 1
this : count (!x) (x :: l) = count x (x :: l)
⊢ count (!true) (x :: l) = count true (x :: l)

Next tactic:
cases x
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    

Proof state:
case false.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
this : count (!false) (false :: l) = count false (false :: l)
⊢ count (!false) (false :: l) = count false (false :: l)

Next tactic:
revert this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    

Proof state:
case false.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
this : count (!true) (true :: l) = count true (true :: l)
⊢ count (!false) (true :: l) = count false (true :: l)

Next tactic:
revert this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    

Proof state:
case true.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
this : count (!false) (false :: l) = count false (false :: l)
⊢ count (!true) (false :: l) = count true (false :: l)

Next tactic:
revert this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    

Proof state:
case true.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
this : count (!true) (true :: l) = count true (true :: l)
⊢ count (!true) (true :: l) = count true (true :: l)

Next tactic:
revert this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> 

Proof state:
case false.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
⊢ count (!false) (false :: l) = count false (false :: l) → count (!false) (false :: l) = count false (false :: l)

Next tactic:
simp only [Bool.not_false, Bool.not_true]
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> 

Proof state:
case false.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
⊢ count (!true) (true :: l) = count true (true :: l) → count (!false) (true :: l) = count false (true :: l)

Next tactic:
simp only [Bool.not_false, Bool.not_true]
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> 

Proof state:
case true.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
⊢ count (!false) (false :: l) = count false (false :: l) → count (!true) (false :: l) = count true (false :: l)

Next tactic:
simp only [Bool.not_false, Bool.not_true]
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> 

Proof state:
case true.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
⊢ count (!true) (true :: l) = count true (true :: l) → count (!true) (true :: l) = count true (true :: l)

Next tactic:
simp only [Bool.not_false, Bool.not_true]
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> 

Proof state:
case false.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
⊢ count true (false :: l) = count false (false :: l) → count true (false :: l) = count false (false :: l)

Next tactic:
intro this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> 

Proof state:
case false.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
⊢ count false (true :: l) = count true (true :: l) → count true (true :: l) = count false (true :: l)

Next tactic:
intro this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> 

Proof state:
case true.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
⊢ count true (false :: l) = count false (false :: l) → count false (false :: l) = count true (false :: l)

Next tactic:
intro this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> 

Proof state:
case true.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
⊢ count false (true :: l) = count true (true :: l) → count false (true :: l) = count true (true :: l)

Next tactic:
intro this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (

Proof state:
case false.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
this : count true (false :: l) = count false (false :: l)
⊢ count true (false :: l) = count false (false :: l)

Next tactic:
try exact this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (try 

Proof state:
case false.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
this : count true (false :: l) = count false (false :: l)
⊢ count true (false :: l) = count false (false :: l)

Next tactic:
exact this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (

Proof state:
case false.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
this : count false (true :: l) = count true (true :: l)
⊢ count true (true :: l) = count false (true :: l)

Next tactic:
try exact this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (try 

Proof state:
case false.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
this : count false (true :: l) = count true (true :: l)
⊢ count true (true :: l) = count false (true :: l)

Next tactic:
exact this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (

Proof state:
case true.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
this : count true (false :: l) = count false (false :: l)
⊢ count false (false :: l) = count true (false :: l)

Next tactic:
try exact this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (try 

Proof state:
case true.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
this : count true (false :: l) = count false (false :: l)
⊢ count false (false :: l) = count true (false :: l)

Next tactic:
exact this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (

Proof state:
case true.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
this : count false (true :: l) = count true (true :: l)
⊢ count false (true :: l) = count true (true :: l)

Next tactic:
try exact this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (try 

Proof state:
case true.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
this : count false (true :: l) = count true (true :: l)
⊢ count false (true :: l) = count true (true :: l)

Next tactic:
exact this
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (try exact this) <;> 

Proof state:
case false.true
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (true :: l)
this : count false (true :: l) = count true (true :: l)
⊢ count true (true :: l) = count false (true :: l)

Next tactic:
exact this.symm
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (try exact this) <;> 

Proof state:
case true.false
l : List Bool
h2 : length l % 2 = 1
hl : Chain' (fun x x_1 => x ≠ x_1) (false :: l)
this : count true (false :: l) = count false (false :: l)
⊢ count false (false :: l) = count true (false :: l)

Next tactic:
exact this.symm
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    count (!b) l = count b l := by
  cases' l with x l
  · rfl
  rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2
  suffices count (!x) (x :: l) = count x (x :: l) by
    -- Porting note: old proof is
    -- cases b <;> cases x <;> try exact this;
    cases b <;> cases x <;>
    revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;>
    (try exact this) <;> exact this.symm
  

Proof state:
case cons
b x : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (x :: l)
h2 : length l % 2 = 1
⊢ count (!x) (x :: l) = count x (x :: l)

Next tactic:
rw [count_cons_of_ne x.not_ne_self, hl.count_not, h2, count_cons_self]
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) :
    count (!b) l ≤ count b l + 1 := by
  

Proof state:
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) l
b : Bool
⊢ count (!b) l ≤ count b l + 1

Next tactic:
cases' l with x l
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) :
    count (!b) l ≤ count b l + 1 := by
  cases' l with x l
  · 

Proof state:
case nil
b : Bool
hl : Chain' (fun x x_1 => x ≠ x_1) []
⊢ count (!b) [] ≤ count b [] + 1

Next tactic:
exact zero_le _
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) :
    count (!b) l ≤ count b l + 1 := by
  cases' l with x l
  · exact zero_le _
  

Proof state:
case cons
b x : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (x :: l)
⊢ count (!b) (x :: l) ≤ count b (x :: l) + 1

Next tactic:
obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em]
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) :
    count (!b) l ≤ count b l + 1 := by
  cases' l with x l
  · exact zero_le _
  obtain rfl | rfl : b = x ∨ b = !x := by 

Proof state:
b x : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (x :: l)
⊢ b = x ∨ b = !x

Next tactic:
simp only [Bool.eq_not_iff, em]
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) :
    count (!b) l ≤ count b l + 1 := by
  cases' l with x l
  · exact zero_le _
  obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em]
  · 

Proof state:
case cons.inl
b : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (b :: l)
⊢ count (!b) (b :: l) ≤ count b (b :: l) + 1

Next tactic:
rw [count_cons_of_ne b.not_ne_self, count_cons_self, hl.count_not, add_assoc]
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) :
    count (!b) l ≤ count b l + 1 := by
  cases' l with x l
  · exact zero_le _
  obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em]
  · rw [count_cons_of_ne b.not_ne_self, count_cons_self, hl.count_not, add_assoc]
    

Proof state:
case cons.inl
b : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (b :: l)
⊢ count b l + length l % 2 ≤ count b l + (1 + 1)

Next tactic:
exact add_le_add_left (Nat.mod_lt _ two_pos).le _
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) :
    count (!b) l ≤ count b l + 1 := by
  cases' l with x l
  · exact zero_le _
  obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em]
  · rw [count_cons_of_ne b.not_ne_self, count_cons_self, hl.count_not, add_assoc]
    exact add_le_add_left (Nat.mod_lt _ two_pos).le _
  · 

Proof state:
case cons.inr
x : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (x :: l)
⊢ count (!!x) (x :: l) ≤ count (!x) (x :: l) + 1

Next tactic:
rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, hl.count_not]
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) :
    count (!b) l ≤ count b l + 1 := by
  cases' l with x l
  · exact zero_le _
  obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em]
  · rw [count_cons_of_ne b.not_ne_self, count_cons_self, hl.count_not, add_assoc]
    exact add_le_add_left (Nat.mod_lt _ two_pos).le _
  · rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, hl.count_not]
    

Proof state:
case cons.inr
x : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (x :: l)
⊢ count x l + 1 ≤ count x l + length l % 2 + 1

Next tactic:
exact add_le_add_right (le_add_right le_rfl) _
theorem two_mul_count_bool_of_even (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) :
    2 * count b l = length l := by
  

Proof state:
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) l
h2 : Even (length l)
b : Bool
⊢ 2 * count b l = length l

Next tactic:
rw [← count_not_add_count l b, hl.count_not_eq_count h2, two_mul]
theorem two_mul_count_bool_eq_ite (hl : Chain' (· ≠ ·) l) (b : Bool) :
    2 * count b l =
      if Even (length l) then length l else
      if Option.some b == l.head? then length l + 1 else length l - 1 := by
  

Proof state:
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) l
b : Bool
⊢ 2 * count b l =
    if Even (length l) then length l else if (some b == head? l) = true then length l + 1 else length l - 1

Next tactic:
by_cases h2 : Even (length l)
theorem two_mul_count_bool_eq_ite (hl : Chain' (· ≠ ·) l) (b : Bool) :
    2 * count b l =
      if Even (length l) then length l else
      if Option.some b == l.head? then length l + 1 else length l - 1 := by
  by_cases h2 : Even (length l)
  · 

Proof state:
case pos
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) l
b : Bool
h2 : Even (length l)
⊢ 2 * count b l =
    if Even (length l) then length l else if (some b == head? l) = true then length l + 1 else length l - 1

Next tactic:
rw [if_pos h2, hl.two_mul_count_bool_of_even h2]
theorem two_mul_count_bool_eq_ite (hl : Chain' (· ≠ ·) l) (b : Bool) :
    2 * count b l =
      if Even (length l) then length l else
      if Option.some b == l.head? then length l + 1 else length l - 1 := by
  by_cases h2 : Even (length l)
  · rw [if_pos h2, hl.two_mul_count_bool_of_even h2]
  · 

Proof state:
case neg
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) l
b : Bool
h2 : ¬Even (length l)
⊢ 2 * count b l =
    if Even (length l) then length l else if (some b == head? l) = true then length l + 1 else length l - 1

Next tactic:
cases' l with x l
theorem two_mul_count_bool_eq_ite (hl : Chain' (· ≠ ·) l) (b : Bool) :
    2 * count b l =
      if Even (length l) then length l else
      if Option.some b == l.head? then length l + 1 else length l - 1 := by
  by_cases h2 : Even (length l)
  · rw [if_pos h2, hl.two_mul_count_bool_of_even h2]
  · cases' l with x l
    · 

Proof state:
case neg.nil
b : Bool
hl : Chain' (fun x x_1 => x ≠ x_1) []
h2 : ¬Even (length [])
⊢ 2 * count b [] =
    if Even (length []) then length [] else if (some b == head? []) = true then length [] + 1 else length [] - 1

Next tactic:
exact (h2 even_zero).elim
theorem two_mul_count_bool_eq_ite (hl : Chain' (· ≠ ·) l) (b : Bool) :
    2 * count b l =
      if Even (length l) then length l else
      if Option.some b == l.head? then length l + 1 else length l - 1 := by
  by_cases h2 : Even (length l)
  · rw [if_pos h2, hl.two_mul_count_bool_of_even h2]
  · cases' l with x l
    · exact (h2 even_zero).elim
    

Proof state:
case neg.cons
b x : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (x :: l)
h2 : ¬Even (length (x :: l))
⊢ 2 * count b (x :: l) =
    if Even (length (x :: l)) then length (x :: l)
    else if (some b == head? (x :: l)) = true then length (x :: l) + 1 else length (x :: l) - 1

Next tactic:
simp only [if_neg h2, count_cons, mul_add, head?, Option.mem_some_iff, @eq_comm _ x]
theorem two_mul_count_bool_eq_ite (hl : Chain' (· ≠ ·) l) (b : Bool) :
    2 * count b l =
      if Even (length l) then length l else
      if Option.some b == l.head? then length l + 1 else length l - 1 := by
  by_cases h2 : Even (length l)
  · rw [if_pos h2, hl.two_mul_count_bool_of_even h2]
  · cases' l with x l
    · exact (h2 even_zero).elim
    simp only [if_neg h2, count_cons, mul_add, head?, Option.mem_some_iff, @eq_comm _ x]
    

Proof state:
case neg.cons
b x : Bool
l : List Bool
hl : Chain' (fun x x_1 => x ≠ x_1) (x :: l)
h2 : ¬Even (length (x :: l))
⊢ (2 * count b l + 2 * if b = x then 1 else 0) =
    if (some b == some x) = true then length (x :: l) + 1 else length (x :: l) - 1

Next tactic:
rw [length_cons, Nat.even_add_one, not_not] at h2