l3lab/ntp-mathlib huggingface dataset:
theorem _root_.Odd.not_two_dvd_nat (h : Odd n) : ¬(2 ∣ n) := by
  

Proof state:
m n : ℕ
h : Odd n
⊢ ¬2 ∣ n

Next tactic:
rwa [← even_iff_two_dvd, ← odd_iff_not_even]
theorem isCompl_even_odd : IsCompl { n : ℕ | Even n } { n | Odd n } := by
  

Proof state:
m n : ℕ
⊢ IsCompl {n | Even n} {n | Odd n}

Next tactic:
simp only [← Set.compl_setOf, isCompl_compl, odd_iff_not_even]
theorem even_xor_odd (n : ℕ) : Xor' (Even n) (Odd n) := by
  

Proof state:
m n✝ n : ℕ
⊢ Xor' (Even n) (Odd n)

Next tactic:
simp [Xor', odd_iff_not_even, Decidable.em (Even n)]
theorem even_or_odd' (n : ℕ) : ∃ k, n = 2 * k ∨ n = 2 * k + 1 := by
  

Proof state:
m n✝ n : ℕ
⊢ ∃ k, n = 2 * k ∨ n = 2 * k + 1

Next tactic:
simpa only [← two_mul, exists_or, Odd, Even] using even_or_odd n
theorem even_xor_odd' (n : ℕ) : ∃ k, Xor' (n = 2 * k) (n = 2 * k + 1) := by
  

Proof state:
m n✝ n : ℕ
⊢ ∃ k, Xor' (n = 2 * k) (n = 2 * k + 1)

Next tactic:
rcases even_or_odd n with (⟨k, rfl⟩ | ⟨k, rfl⟩)
theorem even_xor_odd' (n : ℕ) : ∃ k, Xor' (n = 2 * k) (n = 2 * k + 1) := by
  rcases even_or_odd n with (⟨k, rfl⟩ | ⟨k, rfl⟩) <;> 

Proof state:
case inl.intro
m n k : ℕ
⊢ ∃ k_1, Xor' (k + k = 2 * k_1) (k + k = 2 * k_1 + 1)

Next tactic:
use k
theorem even_xor_odd' (n : ℕ) : ∃ k, Xor' (n = 2 * k) (n = 2 * k + 1) := by
  rcases even_or_odd n with (⟨k, rfl⟩ | ⟨k, rfl⟩) <;> 

Proof state:
case inr.intro
m n k : ℕ
⊢ ∃ k_1, Xor' (2 * k + 1 = 2 * k_1) (2 * k + 1 = 2 * k_1 + 1)

Next tactic:
use k
theorem even_xor_odd' (n : ℕ) : ∃ k, Xor' (n = 2 * k) (n = 2 * k + 1) := by
  rcases even_or_odd n with (⟨k, rfl⟩ | ⟨k, rfl⟩) <;> use k
  · 

Proof state:
case h
m n k : ℕ
⊢ Xor' (k + k = 2 * k) (k + k = 2 * k + 1)

Next tactic:
simpa only [← two_mul, eq_self_iff_true, xor_true] using (succ_ne_self (2 * k)).symm
theorem even_xor_odd' (n : ℕ) : ∃ k, Xor' (n = 2 * k) (n = 2 * k + 1) := by
  rcases even_or_odd n with (⟨k, rfl⟩ | ⟨k, rfl⟩) <;> use k
  · simpa only [← two_mul, eq_self_iff_true, xor_true] using (succ_ne_self (2 * k)).symm
  · 

Proof state:
case h
m n k : ℕ
⊢ Xor' (2 * k + 1 = 2 * k) (2 * k + 1 = 2 * k + 1)

Next tactic:
simpa only [xor_true, xor_comm] using (succ_ne_self _)
theorem mod_two_add_add_odd_mod_two (m : ℕ) {n : ℕ} (hn : Odd n) : m % 2 + (m + n) % 2 = 1 :=
  ((even_or_odd m).elim fun hm => by 

Proof state:
m✝ n✝ m n : ℕ
hn : Odd n
hm : Even m
⊢ m % 2 + (m + n) % 2 = 1

Next tactic:
rw [even_iff.1 hm, odd_iff.1 (hm.add_odd hn)]
theorem mod_two_add_add_odd_mod_two (m : ℕ) {n : ℕ} (hn : Odd n) : m % 2 + (m + n) % 2 = 1 :=
  ((even_or_odd m).elim fun hm => by rw [even_iff.1 hm, odd_iff.1 (hm.add_odd hn)]) fun hm => by
    

Proof state:
m✝ n✝ m n : ℕ
hn : Odd n
hm : Odd m
⊢ m % 2 + (m + n) % 2 = 1

Next tactic:
rw [odd_iff.1 hm, even_iff.1 (hm.add_odd hn)]
@[simp]
theorem succ_mod_two_add_mod_two (m : ℕ) : (m + 1) % 2 + m % 2 = 1 := by
  

Proof state:
m✝ n m : ℕ
⊢ (m + 1) % 2 + m % 2 = 1

Next tactic:
rw [add_comm, mod_two_add_succ_mod_two]
@[parity_simps]
theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
  

Proof state:
m n : ℕ
⊢ Even (m + n) ↔ (Even m ↔ Even n)

Next tactic:
cases' mod_two_eq_zero_or_one m with h₁ h₁
@[parity_simps]
theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> 

Proof state:
case inl
m n : ℕ
h₁ : m % 2 = 0
⊢ Even (m + n) ↔ (Even m ↔ Even n)

Next tactic:
cases' mod_two_eq_zero_or_one n with h₂ h₂
@[parity_simps]
theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> 

Proof state:
case inr
m n : ℕ
h₁ : m % 2 = 1
⊢ Even (m + n) ↔ (Even m ↔ Even n)

Next tactic:
cases' mod_two_eq_zero_or_one n with h₂ h₂
@[parity_simps]
theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> cases' mod_two_eq_zero_or_one n with h₂ h₂ <;>
    

Proof state:
case inl.inl
m n : ℕ
h₁ : m % 2 = 0
h₂ : n % 2 = 0
⊢ Even (m + n) ↔ (Even m ↔ Even n)

Next tactic:
simp [even_iff, h₁, h₂, Nat.add_mod]
@[parity_simps]
theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> cases' mod_two_eq_zero_or_one n with h₂ h₂ <;>
    

Proof state:
case inl.inr
m n : ℕ
h₁ : m % 2 = 0
h₂ : n % 2 = 1
⊢ Even (m + n) ↔ (Even m ↔ Even n)

Next tactic:
simp [even_iff, h₁, h₂, Nat.add_mod]
@[parity_simps]
theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> cases' mod_two_eq_zero_or_one n with h₂ h₂ <;>
    

Proof state:
case inr.inl
m n : ℕ
h₁ : m % 2 = 1
h₂ : n % 2 = 0
⊢ Even (m + n) ↔ (Even m ↔ Even n)

Next tactic:
simp [even_iff, h₁, h₂, Nat.add_mod]
@[parity_simps]
theorem even_add : Even (m + n) ↔ (Even m ↔ Even n) := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> cases' mod_two_eq_zero_or_one n with h₂ h₂ <;>
    

Proof state:
case inr.inr
m n : ℕ
h₁ : m % 2 = 1
h₂ : n % 2 = 1
⊢ Even (m + n) ↔ (Even m ↔ Even n)

Next tactic:
simp [even_iff, h₁, h₂, Nat.add_mod]
theorem even_add' : Even (m + n) ↔ (Odd m ↔ Odd n) := by
  

Proof state:
m n : ℕ
⊢ Even (m + n) ↔ (Odd m ↔ Odd n)

Next tactic:
rw [even_add, even_iff_not_odd, even_iff_not_odd, not_iff_not]
@[parity_simps]
theorem even_add_one : Even (n + 1) ↔ ¬Even n := by 

Proof state:
m n : ℕ
⊢ Even (n + 1) ↔ ¬Even n

Next tactic:
simp [even_add]
theorem succ_mod_two_eq_zero_iff {m : ℕ} : (m + 1) % 2 = 0 ↔ m % 2 = 1 := by
  

Proof state:
m✝ n m : ℕ
⊢ (m + 1) % 2 = 0 ↔ m % 2 = 1

Next tactic:
simp [← Nat.even_iff, ← Nat.not_even_iff, parity_simps]
theorem succ_mod_two_eq_one_iff {m : ℕ} : (m + 1) % 2 = 1 ↔ m % 2 = 0 := by
  

Proof state:
m✝ n m : ℕ
⊢ (m + 1) % 2 = 1 ↔ m % 2 = 0

Next tactic:
simp [← Nat.even_iff, ← Nat.not_even_iff, parity_simps]
set_option linter.deprecated false in
@[simp]
theorem not_even_bit1 (n : ℕ) : ¬Even (bit1 n) := by 

Proof state:
m n✝ n : ℕ
⊢ ¬Even (bit1 n)

Next tactic:
simp [bit1, parity_simps]
theorem two_not_dvd_two_mul_add_one (n : ℕ) : ¬2 ∣ 2 * n + 1 := by 

Proof state:
m n✝ n : ℕ
⊢ ¬2 ∣ 2 * n + 1

Next tactic:
simp [add_mod]
@[parity_simps]
theorem even_sub (h : n ≤ m) : Even (m - n) ↔ (Even m ↔ Even n) := by
  

Proof state:
m n : ℕ
h : n ≤ m
⊢ Even (m - n) ↔ (Even m ↔ Even n)

Next tactic:
conv_rhs => rw [← tsub_add_cancel_of_le h, even_add]
@[parity_simps]
theorem even_sub (h : n ≤ m) : Even (m - n) ↔ (Even m ↔ Even n) := by
  conv_rhs => 

Proof state:
m n : ℕ
h : n ≤ m
| Even m ↔ Even n

Next tactic:
rw [← tsub_add_cancel_of_le h, even_add]
@[parity_simps]
theorem even_sub (h : n ≤ m) : Even (m - n) ↔ (Even m ↔ Even n) := by
  conv_rhs => rw [← tsub_add_cancel_of_le h, even_add]
  

Proof state:
m n : ℕ
h : n ≤ m
⊢ Even (m - n) ↔ ((Even (m - n) ↔ Even n) ↔ Even n)

Next tactic:
by_cases h : Even n
@[parity_simps]
theorem even_sub (h : n ≤ m) : Even (m - n) ↔ (Even m ↔ Even n) := by
  conv_rhs => rw [← tsub_add_cancel_of_le h, even_add]
  by_cases h : Even n <;> 

Proof state:
case pos
m n : ℕ
h✝ : n ≤ m
h : Even n
⊢ Even (m - n) ↔ ((Even (m - n) ↔ Even n) ↔ Even n)

Next tactic:
simp [h]
@[parity_simps]
theorem even_sub (h : n ≤ m) : Even (m - n) ↔ (Even m ↔ Even n) := by
  conv_rhs => rw [← tsub_add_cancel_of_le h, even_add]
  by_cases h : Even n <;> 

Proof state:
case neg
m n : ℕ
h✝ : n ≤ m
h : ¬Even n
⊢ Even (m - n) ↔ ((Even (m - n) ↔ Even n) ↔ Even n)

Next tactic:
simp [h]
theorem even_sub' (h : n ≤ m) : Even (m - n) ↔ (Odd m ↔ Odd n) := by
  

Proof state:
m n : ℕ
h : n ≤ m
⊢ Even (m - n) ↔ (Odd m ↔ Odd n)

Next tactic:
rw [even_sub h, even_iff_not_odd, even_iff_not_odd, not_iff_not]
theorem Odd.sub_odd (hm : Odd m) (hn : Odd n) : Even (m - n) :=
  (le_total n m).elim (fun h => by 

Proof state:
m n : ℕ
hm : Odd m
hn : Odd n
h : n ≤ m
⊢ Even (m - n)

Next tactic:
simp only [even_sub' h, *]
theorem Odd.sub_odd (hm : Odd m) (hn : Odd n) : Even (m - n) :=
  (le_total n m).elim (fun h => by simp only [even_sub' h, *]) fun h => by
    

Proof state:
m n : ℕ
hm : Odd m
hn : Odd n
h : m ≤ n
⊢ Even (m - n)

Next tactic:
simp only [tsub_eq_zero_iff_le.mpr h, even_zero]
@[parity_simps]
theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
  

Proof state:
m n : ℕ
⊢ Even (m * n) ↔ Even m ∨ Even n

Next tactic:
cases' mod_two_eq_zero_or_one m with h₁ h₁
@[parity_simps]
theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> 

Proof state:
case inl
m n : ℕ
h₁ : m % 2 = 0
⊢ Even (m * n) ↔ Even m ∨ Even n

Next tactic:
cases' mod_two_eq_zero_or_one n with h₂ h₂
@[parity_simps]
theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> 

Proof state:
case inr
m n : ℕ
h₁ : m % 2 = 1
⊢ Even (m * n) ↔ Even m ∨ Even n

Next tactic:
cases' mod_two_eq_zero_or_one n with h₂ h₂
@[parity_simps]
theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> cases' mod_two_eq_zero_or_one n with h₂ h₂ <;>
    

Proof state:
case inl.inl
m n : ℕ
h₁ : m % 2 = 0
h₂ : n % 2 = 0
⊢ Even (m * n) ↔ Even m ∨ Even n

Next tactic:
simp [even_iff, h₁, h₂, Nat.mul_mod]
@[parity_simps]
theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> cases' mod_two_eq_zero_or_one n with h₂ h₂ <;>
    

Proof state:
case inl.inr
m n : ℕ
h₁ : m % 2 = 0
h₂ : n % 2 = 1
⊢ Even (m * n) ↔ Even m ∨ Even n

Next tactic:
simp [even_iff, h₁, h₂, Nat.mul_mod]
@[parity_simps]
theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> cases' mod_two_eq_zero_or_one n with h₂ h₂ <;>
    

Proof state:
case inr.inl
m n : ℕ
h₁ : m % 2 = 1
h₂ : n % 2 = 0
⊢ Even (m * n) ↔ Even m ∨ Even n

Next tactic:
simp [even_iff, h₁, h₂, Nat.mul_mod]
@[parity_simps]
theorem even_mul : Even (m * n) ↔ Even m ∨ Even n := by
  cases' mod_two_eq_zero_or_one m with h₁ h₁ <;> cases' mod_two_eq_zero_or_one n with h₂ h₂ <;>
    

Proof state:
case inr.inr
m n : ℕ
h₁ : m % 2 = 1
h₂ : n % 2 = 1
⊢ Even (m * n) ↔ Even m ∨ Even n

Next tactic:
simp [even_iff, h₁, h₂, Nat.mul_mod]
theorem odd_mul : Odd (m * n) ↔ Odd m ∧ Odd n := by 

Proof state:
m n : ℕ
⊢ Odd (m * n) ↔ Odd m ∧ Odd n

Next tactic:
simp [not_or, even_mul]
/-- If `m` and `n` are natural numbers, then the natural number `m^n` is even
if and only if `m` is even and `n` is positive. -/
@[parity_simps] theorem even_pow : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by
  

Proof state:
m n : ℕ
⊢ Even (m ^ n) ↔ Even m ∧ n ≠ 0

Next tactic:
induction' n with n ih
/-- If `m` and `n` are natural numbers, then the natural number `m^n` is even
if and only if `m` is even and `n` is positive. -/
@[parity_simps] theorem even_pow : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by
  induction' n with n ih <;> 

Proof state:
case zero
m n : ℕ
⊢ Even (m ^ zero) ↔ Even m ∧ zero ≠ 0

Next tactic:
simp (config := { contextual := true }) [*, pow_succ', even_mul]
/-- If `m` and `n` are natural numbers, then the natural number `m^n` is even
if and only if `m` is even and `n` is positive. -/
@[parity_simps] theorem even_pow : Even (m ^ n) ↔ Even m ∧ n ≠ 0 := by
  induction' n with n ih <;> 

Proof state:
case succ
m n✝ n : ℕ
ih : Even (m ^ n) ↔ Even m ∧ n ≠ 0
⊢ Even (m ^ succ n) ↔ Even m ∧ succ n ≠ 0

Next tactic:
simp (config := { contextual := true }) [*, pow_succ', even_mul]
theorem even_div : Even (m / n) ↔ m % (2 * n) / n = 0 := by
  

Proof state:
m n : ℕ
⊢ Even (m / n) ↔ m % (2 * n) / n = 0

Next tactic:
rw [even_iff_two_dvd, dvd_iff_mod_eq_zero, Nat.div_mod_eq_mod_mul_div, mul_comm]
@[parity_simps] theorem odd_add : Odd (m + n) ↔ (Odd m ↔ Even n) := by
  

Proof state:
m n : ℕ
⊢ Odd (m + n) ↔ (Odd m ↔ Even n)

Next tactic:
rw [odd_iff_not_even, even_add, not_iff, odd_iff_not_even]
theorem odd_add' : Odd (m + n) ↔ (Odd n ↔ Even m) := by 

Proof state:
m n : ℕ
⊢ Odd (m + n) ↔ (Odd n ↔ Even m)

Next tactic:
rw [add_comm, odd_add]
theorem ne_of_odd_add (h : Odd (m + n)) : m ≠ n := fun hnot => by 

Proof state:
m n : ℕ
h : Odd (m + n)
hnot : m = n
⊢ False

Next tactic:
simp [hnot] at h
@[parity_simps] theorem odd_sub (h : n ≤ m) : Odd (m - n) ↔ (Odd m ↔ Even n) := by
  

Proof state:
m n : ℕ
h : n ≤ m
⊢ Odd (m - n) ↔ (Odd m ↔ Even n)

Next tactic:
rw [odd_iff_not_even, even_sub h, not_iff, odd_iff_not_even]
theorem odd_sub' (h : n ≤ m) : Odd (m - n) ↔ (Odd n ↔ Even m) := by
  

Proof state:
m n : ℕ
h : n ≤ m
⊢ Odd (m - n) ↔ (Odd n ↔ Even m)

Next tactic:
rw [odd_iff_not_even, even_sub h, not_iff, not_iff_comm, odd_iff_not_even]
theorem even_mul_succ_self (n : ℕ) : Even (n * (n + 1)) := by
  

Proof state:
m n✝ n : ℕ
⊢ Even (n * (n + 1))

Next tactic:
rw [even_mul, even_add_one]
theorem even_mul_succ_self (n : ℕ) : Even (n * (n + 1)) := by
  rw [even_mul, even_add_one]
  

Proof state:
m n✝ n : ℕ
⊢ Even n ∨ ¬Even n

Next tactic:
exact em _
theorem two_mul_div_two_add_one_of_odd (h : Odd n) : 2 * (n / 2) + 1 = n := by
  

Proof state:
m n : ℕ
h : Odd n
⊢ 2 * (n / 2) + 1 = n

Next tactic:
rw [← odd_iff.mp h, div_add_mod]
theorem div_two_mul_two_add_one_of_odd (h : Odd n) : n / 2 * 2 + 1 = n := by
  

Proof state:
m n : ℕ
h : Odd n
⊢ n / 2 * 2 + 1 = n

Next tactic:
rw [← odd_iff.mp h, div_add_mod']
theorem one_add_div_two_mul_two_of_odd (h : Odd n) : 1 + n / 2 * 2 = n := by
  

Proof state:
m n : ℕ
h : Odd n
⊢ 1 + n / 2 * 2 = n

Next tactic:
rw [← odd_iff.mp h, mod_add_div']
theorem bit0_div_two : bit0 n / 2 = n := by
  

Proof state:
m n : ℕ
⊢ bit0 n / 2 = n

Next tactic:
rw [← Nat.bit0_eq_bit0, bit0_eq_two_mul, two_mul_div_two_of_even (even_bit0 n)]
theorem bit1_div_two : bit1 n / 2 = n := by
  

Proof state:
m n : ℕ
⊢ bit1 n / 2 = n

Next tactic:
rw [← Nat.bit1_eq_bit1, bit1, bit0_eq_two_mul, Nat.two_mul_div_two_add_one_of_odd (odd_bit1 n)]
@[simp]
theorem bit0_div_bit0 : bit0 n / bit0 m = n / m := by
  

Proof state:
m n : ℕ
⊢ bit0 n / bit0 m = n / m

Next tactic:
rw [bit0_eq_two_mul m, ← Nat.div_div_eq_div_mul, bit0_div_two]
@[simp]
theorem bit1_div_bit0 : bit1 n / bit0 m = n / m := by
  

Proof state:
m n : ℕ
⊢ bit1 n / bit0 m = n / m

Next tactic:
rw [bit0_eq_two_mul, ← Nat.div_div_eq_div_mul, bit1_div_two]
@[simp]
theorem bit0_mod_bit0 : bit0 n % bit0 m = bit0 (n % m) := by
  

Proof state:
m n : ℕ
⊢ bit0 n % bit0 m = bit0 (n % m)

Next tactic:
rw [bit0_eq_two_mul n, bit0_eq_two_mul m, bit0_eq_two_mul (n % m), Nat.mul_mod_mul_left]
@[simp]
theorem bit1_mod_bit0 : bit1 n % bit0 m = bit1 (n % m) := by
  

Proof state:
m n : ℕ
⊢ bit1 n % bit0 m = bit1 (n % m)

Next tactic:
have h₁ := congr_arg bit1 (Nat.div_add_mod n m)
@[simp]
theorem bit1_mod_bit0 : bit1 n % bit0 m = bit1 (n % m) := by
  have h₁ := congr_arg bit1 (Nat.div_add_mod n m)
  -- `∀ m n : ℕ, bit0 m * n = bit0 (m * n)` seems to be missing...
  

Proof state:
m n : ℕ
h₁ : bit1 (m * (n / m) + n % m) = bit1 n
⊢ bit1 n % bit0 m = bit1 (n % m)

Next tactic:
rw [bit1_add, bit0_eq_two_mul, ← mul_assoc, ← bit0_eq_two_mul] at h₁
@[simp]
theorem bit1_mod_bit0 : bit1 n % bit0 m = bit1 (n % m) := by
  have h₁ := congr_arg bit1 (Nat.div_add_mod n m)
  -- `∀ m n : ℕ, bit0 m * n = bit0 (m * n)` seems to be missing...
  rw [bit1_add, bit0_eq_two_mul, ← mul_assoc, ← bit0_eq_two_mul] at h₁
  

Proof state:
m n : ℕ
h₁ : bit0 m * (n / m) + bit1 (n % m) = bit1 n
⊢ bit1 n % bit0 m = bit1 (n % m)

Next tactic:
have h₂ := Nat.div_add_mod (bit1 n) (bit0 m)
@[simp]
theorem bit1_mod_bit0 : bit1 n % bit0 m = bit1 (n % m) := by
  have h₁ := congr_arg bit1 (Nat.div_add_mod n m)
  -- `∀ m n : ℕ, bit0 m * n = bit0 (m * n)` seems to be missing...
  rw [bit1_add, bit0_eq_two_mul, ← mul_assoc, ← bit0_eq_two_mul] at h₁
  have h₂ := Nat.div_add_mod (bit1 n) (bit0 m)
  

Proof state:
m n : ℕ
h₁ : bit0 m * (n / m) + bit1 (n % m) = bit1 n
h₂ : bit0 m * (bit1 n / bit0 m) + bit1 n % bit0 m = bit1 n
⊢ bit1 n % bit0 m = bit1 (n % m)

Next tactic:
rw [bit1_div_bit0] at h₂
@[simp]
theorem bit1_mod_bit0 : bit1 n % bit0 m = bit1 (n % m) := by
  have h₁ := congr_arg bit1 (Nat.div_add_mod n m)
  -- `∀ m n : ℕ, bit0 m * n = bit0 (m * n)` seems to be missing...
  rw [bit1_add, bit0_eq_two_mul, ← mul_assoc, ← bit0_eq_two_mul] at h₁
  have h₂ := Nat.div_add_mod (bit1 n) (bit0 m)
  rw [bit1_div_bit0] at h₂
  

Proof state:
m n : ℕ
h₁ : bit0 m * (n / m) + bit1 (n % m) = bit1 n
h₂ : bit0 m * (n / m) + bit1 n % bit0 m = bit1 n
⊢ bit1 n % bit0 m = bit1 (n % m)

Next tactic:
exact add_left_cancel (h₂.trans h₁.symm)
example (m n : ℕ) (h : Even m) : ¬Even (n + 3) ↔ Even (m ^ 2 + m + n) := by
  

Proof state:
m✝ n✝ m n : ℕ
h : Even m
⊢ ¬Even (n + 3) ↔ Even (m ^ 2 + m + n)

Next tactic:
simp [*, two_ne_zero, parity_simps]
example : ¬Even 25394535 := by 

Proof state:
m n : ℕ
⊢ ¬Even 25394535

Next tactic:
decide
theorem iterate_bit0 (hf : Involutive f) (n : ℕ) : f^[bit0 n] = id := by
  

Proof state:
α : Type u_1
f : α → α
n✝ : ℕ
hf : Involutive f
n : ℕ
⊢ f^[bit0 n] = id

Next tactic:
rw [bit0, ← two_mul, iterate_mul, involutive_iff_iter_2_eq_id.1 hf, iterate_id]
theorem iterate_bit1 (hf : Involutive f) (n : ℕ) : f^[bit1 n] = f := by
  

Proof state:
α : Type u_1
f : α → α
n✝ : ℕ
hf : Involutive f
n : ℕ
⊢ f^[bit1 n] = f

Next tactic:
rw [bit1, ← succ_eq_add_one, iterate_succ, hf.iterate_bit0, comp.left_id]
theorem iterate_two_mul (hf : Involutive f) (n : ℕ) : f^[2 * n] = id := by
  

Proof state:
α : Type u_1
f : α → α
n✝ : ℕ
hf : Involutive f
n : ℕ
⊢ f^[2 * n] = id

Next tactic:
rw [iterate_mul, involutive_iff_iter_2_eq_id.1 hf, iterate_id]
theorem iterate_even (hf : Involutive f) (hn : Even n) : f^[n] = id := by
  

Proof state:
α : Type u_1
f : α → α
n : ℕ
hf : Involutive f
hn : Even n
⊢ f^[n] = id

Next tactic:
rcases hn with ⟨m, rfl⟩
theorem iterate_even (hf : Involutive f) (hn : Even n) : f^[n] = id := by
  rcases hn with ⟨m, rfl⟩
  

Proof state:
case intro
α : Type u_1
f : α → α
hf : Involutive f
m : ℕ
⊢ f^[m + m] = id

Next tactic:
rw [← two_mul, hf.iterate_two_mul]
theorem iterate_odd (hf : Involutive f) (hn : Odd n) : f^[n] = f := by
  

Proof state:
α : Type u_1
f : α → α
n : ℕ
hf : Involutive f
hn : Odd n
⊢ f^[n] = f

Next tactic:
rcases hn with ⟨m, rfl⟩
theorem iterate_odd (hf : Involutive f) (hn : Odd n) : f^[n] = f := by
  rcases hn with ⟨m, rfl⟩
  

Proof state:
case intro
α : Type u_1
f : α → α
hf : Involutive f
m : ℕ
⊢ f^[2 * m + 1] = f

Next tactic:
rw [iterate_add, hf.iterate_two_mul, comp.left_id, iterate_one]
theorem iterate_eq_self (hf : Involutive f) (hne : f ≠ id) : f^[n] = f ↔ Odd n :=
  ⟨fun H => odd_iff_not_even.2 fun hn => hne <| by 

Proof state:
α : Type u_1
f : α → α
n : ℕ
hf : Involutive f
hne : f ≠ id
H : f^[n] = f
hn : Even n
⊢ f = id

Next tactic:
rwa [hf.iterate_even hn, eq_comm] at H
theorem iterate_eq_id (hf : Involutive f) (hne : f ≠ id) : f^[n] = id ↔ Even n :=
  ⟨fun H => even_iff_not_odd.2 fun hn => hne <| by 

Proof state:
α : Type u_1
f : α → α
n : ℕ
hf : Involutive f
hne : f ≠ id
H : f^[n] = id
hn : Odd n
⊢ f = id

Next tactic:
rwa [hf.iterate_odd hn] at H
/-- `2` is not a factor of an odd natural number. -/
theorem Odd.ne_two_of_dvd_nat {m n : ℕ} (hn : Odd n) (hm : m ∣ n) : m ≠ 2 := by
  

Proof state:
R : Type u_1
inst✝¹ : Monoid R
inst✝ : HasDistribNeg R
n✝ m n : ℕ
hn : Odd n
hm : m ∣ n
⊢ m ≠ 2

Next tactic:
rintro rfl
/-- `2` is not a factor of an odd natural number. -/
theorem Odd.ne_two_of_dvd_nat {m n : ℕ} (hn : Odd n) (hm : m ∣ n) : m ≠ 2 := by
  rintro rfl
  

Proof state:
R : Type u_1
inst✝¹ : Monoid R
inst✝ : HasDistribNeg R
n✝ n : ℕ
hn : Odd n
hm : 2 ∣ n
⊢ False

Next tactic:
exact absurd (hn.of_dvd_nat hm) (by decide)
/-- `2` is not a factor of an odd natural number. -/
theorem Odd.ne_two_of_dvd_nat {m n : ℕ} (hn : Odd n) (hm : m ∣ n) : m ≠ 2 := by
  rintro rfl
  exact absurd (hn.of_dvd_nat hm) (by 

Proof state:
R : Type u_1
inst✝¹ : Monoid R
inst✝ : HasDistribNeg R
n✝ n : ℕ
hn : Odd n
hm : 2 ∣ n
⊢ ¬Odd 2

Next tactic:
decide
theorem _root_.Finset.esymm_map_val {σ} (f : σ → R) (s : Finset σ) (n : ℕ) :
    (s.val.map f).esymm n = (s.powersetCard n).sum fun t => t.prod f := by
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
σ : Type u_2
f : σ → R
s : Finset σ
n : ℕ
⊢ esymm (map f s.val) n = ∑ t in Finset.powersetCard n s, Finset.prod t f

Next tactic:
simp only [esymm, powersetCard_map, ← Finset.map_val_val_powersetCard, map_map]
theorem _root_.Finset.esymm_map_val {σ} (f : σ → R) (s : Finset σ) (n : ℕ) :
    (s.val.map f).esymm n = (s.powersetCard n).sum fun t => t.prod f := by
  simp only [esymm, powersetCard_map, ← Finset.map_val_val_powersetCard, map_map]
  

Proof state:
R : Type u_1
inst✝ : CommSemiring R
σ : Type u_2
f : σ → R
s : Finset σ
n : ℕ
⊢ sum (map ((fun x => prod x) ∘ (fun x => map f x) ∘ Finset.val) (Finset.powersetCard n s).val) =
    ∑ t in Finset.powersetCard n s, Finset.prod t f

Next tactic:
rfl
/-- The subalgebra of symmetric `MvPolynomial`s. -/
def symmetricSubalgebra [CommSemiring R] : Subalgebra R (MvPolynomial σ R) where
  carrier := setOf IsSymmetric
  algebraMap_mem' r e := rename_C e r
  mul_mem' ha hb e := by 

Proof state:
σ : Type u_1
R : Type u_2
τ : Type u_3
S : Type u_4
inst✝ : CommSemiring R
a✝ b✝ : MvPolynomial σ R
ha : a✝ ∈ setOf IsSymmetric
hb : b✝ ∈ setOf IsSymmetric
e : Perm σ
⊢ (rename ⇑e) (a✝ * b✝) = a✝ * b✝

Next tactic:
rw [AlgHom.map_mul, ha, hb]
/-- The subalgebra of symmetric `MvPolynomial`s. -/
def symmetricSubalgebra [CommSemiring R] : Subalgebra R (MvPolynomial σ R) where
  carrier := setOf IsSymmetric
  algebraMap_mem' r e := rename_C e r
  mul_mem' ha hb e := by rw [AlgHom.map_mul, ha, hb]
  add_mem' ha hb e := by 

Proof state:
σ : Type u_1
R : Type u_2
τ : Type u_3
S : Type u_4
inst✝ : CommSemiring R
a✝ b✝ : MvPolynomial σ R
ha :
  a✝ ∈
    {
          toSubsemigroup :=
            { carrier := setOf IsSymmetric,
              mul_mem' :=
                (_ :
                  ∀ {a b : MvPolynomial σ R},
                    a ∈ setOf IsSymmetric → b ∈ setOf IsSymmetric → ∀ (e : Perm σ), (rename ⇑e) (a * b) = a * b) },
          one_mem' := (_ : 1 ∈ setOf IsSymmetric) }.toSubsemigroup.carrier
hb :
  b✝ ∈
    {
          toSubsemigroup :=
            { carrier := setOf IsSymmetric,
              mul_mem' :=
                (_ :
                  ∀ {a b : MvPolynomial σ R},
                    a ∈ setOf IsSymmetric → b ∈ setOf IsSymmetric → ∀ (e : Perm σ), (rename ⇑e) (a * b) = a * b) },
          one_mem' := (_ : 1 ∈ setOf IsSymmetric) }.toSubsemigroup.carrier
e : Perm σ
⊢ (rename ⇑e) (a✝ + b✝) = a✝ + b✝

Next tactic:
rw [AlgHom.map_add, ha, hb]
@[simp]
theorem map (hφ : IsSymmetric φ) (f : R →+* S) : IsSymmetric (map f φ) := fun e => by
  

Proof state:
σ : Type u_1
R : Type u_2
τ : Type u_3
S : Type u_4
inst✝¹ : CommSemiring R
inst✝ : CommSemiring S
φ ψ : MvPolynomial σ R
hφ : IsSymmetric φ
f : R →+* S
e : Perm σ
⊢ (rename ⇑e) ((MvPolynomial.map f) φ) = (MvPolynomial.map f) φ

Next tactic:
rw [← map_rename, hφ]
/-- The `n`th elementary symmetric `MvPolynomial σ R` is obtained by evaluating the
`n`th elementary symmetric at the `Multiset` of the monomials -/
theorem esymm_eq_multiset_esymm : esymm σ R = (Finset.univ.val.map X).esymm := by
  

Proof state:
σ : Type u_1
R : Type u_2
τ : Type u_3
S : Type u_4
inst✝³ : CommSemiring R
inst✝² : CommSemiring S
inst✝¹ : Fintype σ
inst✝ : Fintype τ
⊢ esymm σ R = Multiset.esymm (Multiset.map X univ.val)

Next tactic:
refine' funext fun n => (Finset.esymm_map_val X _ n).symm
theorem aeval_esymm_eq_multiset_esymm [Algebra R S] (f : σ → S) (n : ℕ) :
    aeval f (esymm σ R n) = (Finset.univ.val.map f).esymm n := by
  

Proof state:
σ : Type u_1
R : Type u_2
τ : Type u_3
S : Type u_4
inst✝⁴ : CommSemiring R
inst✝³ : CommSemiring S
inst✝² : Fintype σ
inst✝¹ : Fintype τ
inst✝ : Algebra R S
f : σ → S
n : ℕ
⊢ (aeval f) (esymm σ R n) = Multiset.esymm (Multiset.map f univ.val) n

Next tactic:
simp_rw [esymm, aeval_sum, aeval_prod, aeval_X, Finset.esymm_map_val]
/-- We can define `esymm σ R n` as a sum over explicit monomials -/
theorem esymm_eq_sum_monomial (n : ℕ) :
    esymm σ R n = ∑ t in powersetCard n univ, monomial (∑ i in t, Finsupp.single i 1) 1 := by
  

Proof state:
σ : Type u_1
R : Type u_2
τ : Type u_3
S : Type u_4
inst✝³ : CommSemiring R
inst✝² : CommSemiring S
inst✝¹ : Fintype σ
inst✝ : Fintype τ
n : ℕ
⊢ esymm σ R n = ∑ t in powersetCard n univ, (monomial (∑ i in t, fun₀ | i => 1)) 1

Next tactic:
simp_rw [monomial_sum_one]