-- Mathlib/GroupTheory/Perm/Sign.lean
theorem signAux_swap_zero_one' (n : ℕ) : signAux (swap (0 : Fin (n + 2)) 1) = -1 :=
  show _ = ∏ x ∈ {(⟨1, 0⟩ : Σ _ : Fin (n + 2), Fin (n + 2))},
      if (Equiv.swap 0 1) x.1 ≤ swap 0 1 x.2 then (-1 : ℤˣ) else 1 by
    refine Eq.symm (prod_subset (fun ⟨x₁, x₂⟩ => by
      simp +contextual [mem_finPairsLT, Fin.one_pos]) fun a ha₁ ha₂ => ?_)
    rcases a with ⟨a₁, a₂⟩
    replace ha₁ : a₂ < a₁ := mem_finPairsLT.1 ha₁
    dsimp only
    rcases a₁.zero_le.eq_or_lt with (rfl | H)
    · exact absurd a₂.zero_le ha₁.not_le
    rcases a₂.zero_le.eq_or_lt with (rfl | H')
    · simp only [and_true, eq_self_iff_true, heq_iff_eq, mem_singleton, Sigma.mk.inj_iff] at ha₂
      have : 1 < a₁ := lt_of_le_of_ne (Nat.succ_le_of_lt ha₁)
        (Ne.symm (by intro h; apply ha₂; simp [h]))
      have h01 : Equiv.swap (0 : Fin (n + 2)) 1 0 = 1

Proof state:
case mk
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Tactic:
rcases a₁.zero_le.eq_or_lt with (rfl | H)

Result:
case mk.inl
n : ℕ
a₂ : Fin (n + 2)
ha₂ : ⟨0, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < 0
⊢ (if (swap 0 1) 0 ≤ (swap 0 1) a₂ then -1 else 1) = 1

case mk.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Proof state:
case mk.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Tactic:
rcases a₂.zero_le.eq_or_lt with (rfl | H')

Result:
case mk.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₂ : ⟨a₁, 0⟩ ∉ {⟨1, 0⟩}
ha₁ : 0 < a₁
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 0 then -1 else 1) = 1

case mk.inr.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
H' : 0 < a₂
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Proof state:
case mk.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
this : 1 < a₁
h01 : (swap 0 1) 0 = 1
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 0 then -1 else 1) = 1

Tactic:
rw [swap_apply_of_ne_of_ne (ne_of_gt H) ha₂, h01, if_neg this.not_le]

Result:
no goals

Proof state:
case mk.inl
n : ℕ
a₂ : Fin (n + 2)
ha₂ : ⟨0, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < 0
⊢ (if (swap 0 1) 0 ≤ (swap 0 1) a₂ then -1 else 1) = 1

Tactic:
exact absurd a₂.zero_le ha₁.not_le

Result:
no goals

Proof state:
case mk.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₂ : ⟨a₁, 0⟩ ∉ {⟨1, 0⟩}
ha₁ : 0 < a₁
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 0 then -1 else 1) = 1

Tactic:
simp only [and_true, eq_self_iff_true, heq_iff_eq, mem_singleton, Sigma.mk.inj_iff] at ha₂

Result:
case mk.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 0 then -1 else 1) = 1

Proof state:
case mk
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
⊢ (if (swap 0 1) ⟨a₁, a₂⟩.fst ≤ (swap 0 1) ⟨a₁, a₂⟩.snd then -1 else 1) = 1

Tactic:
dsimp only

Result:
case mk
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Proof state:
case mk
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₁ : ⟨a₁, a₂⟩ ∈ finPairsLT (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
⊢ (if (swap 0 1) ⟨a₁, a₂⟩.fst ≤ (swap 0 1) ⟨a₁, a₂⟩.snd then -1 else 1) = 1

Tactic:
replace ha₁ : a₂ < a₁ := mem_finPairsLT.1 ha₁

Result:
case mk
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
⊢ (if (swap 0 1) ⟨a₁, a₂⟩.fst ≤ (swap 0 1) ⟨a₁, a₂⟩.snd then -1 else 1) = 1

Proof state:
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
h : a₁ = 1
⊢ False

Tactic:
apply ha₂

Result:
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
h : a₁ = 1
⊢ a₁ = 1

Proof state:
case mk.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
this : 1 < a₁
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 0 then -1 else 1) = 1

Tactic:
have h01 : Equiv.swap (0 : Fin (n + 2)) 1 0 = 1 := by simp

Result:
case mk.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
this : 1 < a₁
h01 : (swap 0 1) 0 = 1
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 0 then -1 else 1) = 1

Proof state:
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
⊢ a₁ ≠ 1

Tactic:
intro h

Result:
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
h : a₁ = 1
⊢ False

Proof state:
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
h : a₁ = 1
⊢ a₁ = 1

Tactic:
simp [h]

Result:
no goals

Proof state:
case mk.inr.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
H' : 0 < a₂
le : 1 ≤ a₂
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Tactic:
have lt : 1 < a₁ := le.trans_lt ha₁

Result:
case mk.inr.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
H' : 0 < a₂
le : 1 ≤ a₂
lt : 1 < a₁
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Proof state:
n : ℕ
a : (_ : Fin (n + 2)) × Fin (n + 2)
ha₁ : a ∈ finPairsLT (n + 2)
ha₂ : a ∉ {⟨1, 0⟩}
⊢ (if (swap 0 1) a.fst ≤ (swap 0 1) a.snd then -1 else 1) = 1

Tactic:
rcases a with ⟨a₁, a₂⟩

Result:
case mk
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₁ : ⟨a₁, a₂⟩ ∈ finPairsLT (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
⊢ (if (swap 0 1) ⟨a₁, a₂⟩.fst ≤ (swap 0 1) ⟨a₁, a₂⟩.snd then -1 else 1) = 1

Proof state:
case mk.inr.inr.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
H' : 0 < a₂
le : 1 ≤ a₂
lt : 1 < a₁
h01 : (swap 0 1) 1 = 0
lt' : 1 < a₂
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Tactic:
rw [swap_apply_of_ne_of_ne (ne_of_gt H) (ne_of_gt lt),
  swap_apply_of_ne_of_ne (ne_of_gt H') (ne_of_gt lt'), if_neg ha₁.not_le]

Result:
no goals

Proof state:
case mk.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 0 then -1 else 1) = 1

Tactic:
have : 1 < a₁ := lt_of_le_of_ne (Nat.succ_le_of_lt ha₁)
  (Ne.symm (by intro h; apply ha₂; simp [h]))

Result:
case mk.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
this : 1 < a₁
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 0 then -1 else 1) = 1

Proof state:
case mk.inr.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
H' : 0 < a₂
le : 1 ≤ a₂
lt : 1 < a₁
h01 : (swap 0 1) 1 = 0
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Tactic:
rcases le.eq_or_lt with (rfl | lt')

Result:
case mk.inr.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
lt : 1 < a₁
h01 : (swap 0 1) 1 = 0
ha₂ : ⟨a₁, 1⟩ ∉ {⟨1, 0⟩}
ha₁ : 1 < a₁
H' : 0 < 1
le : 1 ≤ 1
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 1 then -1 else 1) = 1

case mk.inr.inr.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
H' : 0 < a₂
le : 1 ≤ a₂
lt : 1 < a₁
h01 : (swap 0 1) 1 = 0
lt' : 1 < a₂
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Proof state:
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
H' : 0 < a₂
le : 1 ≤ a₂
lt : 1 < a₁
⊢ (swap 0 1) 1 = 0

Tactic:
simp only [swap_apply_right]

Result:
no goals

Proof state:
case mk.inr.inr.inl
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
lt : 1 < a₁
h01 : (swap 0 1) 1 = 0
ha₂ : ⟨a₁, 1⟩ ∉ {⟨1, 0⟩}
ha₁ : 1 < a₁
H' : 0 < 1
le : 1 ≤ 1
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) 1 then -1 else 1) = 1

Tactic:
rw [swap_apply_of_ne_of_ne H.ne' lt.ne', h01, if_neg H.not_le]

Result:
no goals

Proof state:
n : ℕ
a₁ : Fin (n + 2)
H : 0 < a₁
ha₁ : 0 < a₁
ha₂ : ¬a₁ = 1
this : 1 < a₁
⊢ (swap 0 1) 0 = 1

Tactic:
simp

Result:
no goals

Proof state:
n : ℕ
x✝ : (_ : Fin (n + 2)) × Fin (n + 2)
x₁ x₂ : Fin (n + 2)
⊢ ⟨x₁, x₂⟩ ∈ {⟨1, 0⟩} → ⟨x₁, x₂⟩ ∈ finPairsLT (n + 2)

Tactic:
simp +contextual [mem_finPairsLT, Fin.one_pos]

Result:
no goals

Proof state:
case mk.inr.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
H' : 0 < a₂
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1

Tactic:
have le : 1 ≤ a₂ := Nat.succ_le_of_lt H'

Result:
case mk.inr.inr
n : ℕ
a₁ a₂ : Fin (n + 2)
ha₂ : ⟨a₁, a₂⟩ ∉ {⟨1, 0⟩}
ha₁ : a₂ < a₁
H : 0 < a₁
H' : 0 < a₂
le : 1 ≤ a₂
⊢ (if (swap 0 1) a₁ ≤ (swap 0 1) a₂ then -1 else 1) = 1