l3lab/ntp-mathlib huggingface dataset:
theorem SL2_inv_expl_det (A : SL(2, R)) :
    det ![![A.1 1 1, -A.1 0 1], ![-A.1 1 0, A.1 0 0]] = 1 := by
  rw [Matrix.det_fin_two, mul_comm]
  simp only [cons_val_zero, cons_val_one, head_cons, mul_neg, neg_mul, neg_neg]
  

Proof state:
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
A : SL(2, R)
⊢ ↑A 0 0 * ↑A 1 1 - ↑A 0 1 * ↑A 1 0 = 1

Next tactic:
have := A.2
theorem SL2_inv_expl_det (A : SL(2, R)) :
    det ![![A.1 1 1, -A.1 0 1], ![-A.1 1 0, A.1 0 0]] = 1 := by
  rw [Matrix.det_fin_two, mul_comm]
  simp only [cons_val_zero, cons_val_one, head_cons, mul_neg, neg_mul, neg_neg]
  have := A.2
  

Proof state:
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
A : SL(2, R)
this : det ↑A = 1
⊢ ↑A 0 0 * ↑A 1 1 - ↑A 0 1 * ↑A 1 0 = 1

Next tactic:
rw [Matrix.det_fin_two] at this
theorem SL2_inv_expl_det (A : SL(2, R)) :
    det ![![A.1 1 1, -A.1 0 1], ![-A.1 1 0, A.1 0 0]] = 1 := by
  rw [Matrix.det_fin_two, mul_comm]
  simp only [cons_val_zero, cons_val_one, head_cons, mul_neg, neg_mul, neg_neg]
  have := A.2
  rw [Matrix.det_fin_two] at this
  

Proof state:
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
A : SL(2, R)
this : ↑A 0 0 * ↑A 1 1 - ↑A 0 1 * ↑A 1 0 = 1
⊢ ↑A 0 0 * ↑A 1 1 - ↑A 0 1 * ↑A 1 0 = 1

Next tactic:
convert this
theorem SL2_inv_expl (A : SL(2, R)) :
    A⁻¹ = ⟨![![A.1 1 1, -A.1 0 1], ![-A.1 1 0, A.1 0 0]], SL2_inv_expl_det A⟩ := by
  

Proof state:
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
A : SL(2, R)
⊢ A⁻¹ =
    { val := ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]],
      property := (_ : det ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]] = 1) }

Next tactic:
ext
theorem SL2_inv_expl (A : SL(2, R)) :
    A⁻¹ = ⟨![![A.1 1 1, -A.1 0 1], ![-A.1 1 0, A.1 0 0]], SL2_inv_expl_det A⟩ := by
  ext
  

Proof state:
case a
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
A : SL(2, R)
i✝ j✝ : Fin 2
⊢ ↑A⁻¹ i✝ j✝ =
    ↑{ val := ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]],
          property := (_ : det ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]] = 1) }
      i✝ j✝

Next tactic:
have := Matrix.adjugate_fin_two A.1
theorem SL2_inv_expl (A : SL(2, R)) :
    A⁻¹ = ⟨![![A.1 1 1, -A.1 0 1], ![-A.1 1 0, A.1 0 0]], SL2_inv_expl_det A⟩ := by
  ext
  have := Matrix.adjugate_fin_two A.1
  

Proof state:
case a
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
A : SL(2, R)
i✝ j✝ : Fin 2
this : adjugate ↑A = of ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]]
⊢ ↑A⁻¹ i✝ j✝ =
    ↑{ val := ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]],
          property := (_ : det ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]] = 1) }
      i✝ j✝

Next tactic:
rw [coe_inv, this]
theorem SL2_inv_expl (A : SL(2, R)) :
    A⁻¹ = ⟨![![A.1 1 1, -A.1 0 1], ![-A.1 1 0, A.1 0 0]], SL2_inv_expl_det A⟩ := by
  ext
  have := Matrix.adjugate_fin_two A.1
  rw [coe_inv, this]
  

Proof state:
case a
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
A : SL(2, R)
i✝ j✝ : Fin 2
this : adjugate ↑A = of ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]]
⊢ of ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]] i✝ j✝ =
    ↑{ val := ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]],
          property := (_ : det ![![↑A 1 1, -↑A 0 1], ![-↑A 1 0, ↑A 0 0]] = 1) }
      i✝ j✝

Next tactic:
rfl
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by 

Proof state:
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
a b c d : R
hdet : a * d - b * c = 1
⊢ det (of ![![a, b], ![c, d]]) = 1

Next tactic:
rwa [det_fin_two_of]
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  

Proof state:
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
g : SL(2, R)
⊢ P g

Next tactic:
obtain ⟨m, hm⟩ := g
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  

Proof state:
case mk
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
⊢ P { val := m, property := hm }

Next tactic:
convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm)
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by 

Proof state:
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
⊢ m 0 0 * m 1 1 - m 0 1 * m 1 0 = 1

Next tactic:
rwa [det_fin_two] at hm
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm)
  

Proof state:
case h.e'_1.h.e'_3
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
⊢ m = of ![![m 0 0, m 0 1], ![m 1 0, m 1 1]]

Next tactic:
ext i j
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm)
  ext i j; 

Proof state:
case h.e'_1.h.e'_3.a.h
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
i j : Fin 2
⊢ m i j = of ![![m 0 0, m 0 1], ![m 1 0, m 1 1]] i j

Next tactic:
fin_cases i
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm)
  ext i j; fin_cases i <;> 

Proof state:
case h.e'_1.h.e'_3.a.h.head
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
j : Fin 2
⊢ m { val := 0, isLt := (_ : 0 < 2) } j = of ![![m 0 0, m 0 1], ![m 1 0, m 1 1]] { val := 0, isLt := (_ : 0 < 2) } j

Next tactic:
fin_cases j
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm)
  ext i j; fin_cases i <;> 

Proof state:
case h.e'_1.h.e'_3.a.h.tail.head
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
j : Fin 2
⊢ m { val := 1, isLt := (_ : (fun a => a < 2) 1) } j =
    of ![![m 0 0, m 0 1], ![m 1 0, m 1 1]] { val := 1, isLt := (_ : (fun a => a < 2) 1) } j

Next tactic:
fin_cases j
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm)
  ext i j; fin_cases i <;> fin_cases j <;> 

Proof state:
case h.e'_1.h.e'_3.a.h.head.head
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
⊢ m { val := 0, isLt := (_ : 0 < 2) } { val := 0, isLt := (_ : 0 < 2) } =
    of ![![m 0 0, m 0 1], ![m 1 0, m 1 1]] { val := 0, isLt := (_ : 0 < 2) } { val := 0, isLt := (_ : 0 < 2) }

Next tactic:
rfl
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm)
  ext i j; fin_cases i <;> fin_cases j <;> 

Proof state:
case h.e'_1.h.e'_3.a.h.head.tail.head
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
⊢ m { val := 0, isLt := (_ : 0 < 2) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } =
    of ![![m 0 0, m 0 1], ![m 1 0, m 1 1]] { val := 0, isLt := (_ : 0 < 2) }
      { val := 1, isLt := (_ : (fun a => a < 2) 1) }

Next tactic:
rfl
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm)
  ext i j; fin_cases i <;> fin_cases j <;> 

Proof state:
case h.e'_1.h.e'_3.a.h.tail.head.head
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
⊢ m { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 0, isLt := (_ : 0 < 2) } =
    of ![![m 0 0, m 0 1], ![m 1 0, m 1 1]] { val := 1, isLt := (_ : (fun a => a < 2) 1) }
      { val := 0, isLt := (_ : 0 < 2) }

Next tactic:
rfl
theorem fin_two_induction (P : SL(2, R) → Prop)
    (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩)
    (g : SL(2, R)) : P g := by
  obtain ⟨m, hm⟩ := g
  convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm)
  ext i j; fin_cases i <;> fin_cases j <;> 

Proof state:
case h.e'_1.h.e'_3.a.h.tail.head.tail.head
n : Type u
inst✝³ : DecidableEq n
inst✝² : Fintype n
R : Type v
inst✝¹ : CommRing R
S : Type u_1
inst✝ : CommRing S
P : SL(2, R) → Prop
h :
  ∀ (a b c d : R) (hdet : a * d - b * c = 1),
    P { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) }
m : Matrix (Fin 2) (Fin 2) R
hm : det m = 1
⊢ m { val := 1, isLt := (_ : (fun a => a < 2) 1) } { val := 1, isLt := (_ : (fun a => a < 2) 1) } =
    of ![![m 0 0, m 0 1], ![m 1 0, m 1 1]] { val := 1, isLt := (_ : (fun a => a < 2) 1) }
      { val := 1, isLt := (_ : (fun a => a < 2) 1) }

Next tactic:
rfl
theorem fin_two_exists_eq_mk_of_apply_zero_one_eq_zero {R : Type*} [Field R] (g : SL(2, R))
    (hg : (g : Matrix (Fin 2) (Fin 2) R) 1 0 = 0) :
    ∃ (a b : R) (h : a ≠ 0), g = (⟨!![a, b; 0, a⁻¹], by 

Proof state:
n : Type u
inst✝⁴ : DecidableEq n
inst✝³ : Fintype n
R✝ : Type v
inst✝² : CommRing R✝
S : Type u_1
inst✝¹ : CommRing S
R : Type u_2
inst✝ : Field R
g : SL(2, R)
hg : ↑g 1 0 = 0
a b : R
h : a ≠ 0
⊢ det (of ![![a, b], ![0, a⁻¹]]) = 1

Next tactic:
simp [h]
theorem fin_two_exists_eq_mk_of_apply_zero_one_eq_zero {R : Type*} [Field R] (g : SL(2, R))
    (hg : (g : Matrix (Fin 2) (Fin 2) R) 1 0 = 0) :
    ∃ (a b : R) (h : a ≠ 0), g = (⟨!![a, b; 0, a⁻¹], by simp [h]⟩ : SL(2, R)) := by
  

Proof state:
n : Type u
inst✝⁴ : DecidableEq n
inst✝³ : Fintype n
R✝ : Type v
inst✝² : CommRing R✝
S : Type u_1
inst✝¹ : CommRing S
R : Type u_2
inst✝ : Field R
g : SL(2, R)
hg : ↑g 1 0 = 0
⊢ ∃ a b, ∃ (h : a ≠ 0), g = { val := of ![![a, b], ![0, a⁻¹]], property := (_ : det (of ![![a, b], ![0, a⁻¹]]) = 1) }

Next tactic:
induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h_det
theorem fin_two_exists_eq_mk_of_apply_zero_one_eq_zero {R : Type*} [Field R] (g : SL(2, R))
    (hg : (g : Matrix (Fin 2) (Fin 2) R) 1 0 = 0) :
    ∃ (a b : R) (h : a ≠ 0), g = (⟨!![a, b; 0, a⁻¹], by simp [h]⟩ : SL(2, R)) := by
  induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h_det
  

Proof state:
case h
n : Type u
inst✝⁴ : DecidableEq n
inst✝³ : Fintype n
R✝ : Type v
inst✝² : CommRing R✝
S : Type u_1
inst✝¹ : CommRing S
R : Type u_2
inst✝ : Field R
a b c d : R
h_det : a * d - b * c = 1
hg : ↑{ val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) } 1 0 = 0
⊢ ∃ a_1 b_1,
    ∃ (h : a_1 ≠ 0),
      { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) } =
        { val := of ![![a_1, b_1], ![0, a_1⁻¹]], property := (_ : det (of ![![a_1, b_1], ![0, a_1⁻¹]]) = 1) }

Next tactic:
replace hg : c = 0 := by simpa using hg
theorem fin_two_exists_eq_mk_of_apply_zero_one_eq_zero {R : Type*} [Field R] (g : SL(2, R))
    (hg : (g : Matrix (Fin 2) (Fin 2) R) 1 0 = 0) :
    ∃ (a b : R) (h : a ≠ 0), g = (⟨!![a, b; 0, a⁻¹], by simp [h]⟩ : SL(2, R)) := by
  induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h_det
  replace hg : c = 0 := by 

Proof state:
n : Type u
inst✝⁴ : DecidableEq n
inst✝³ : Fintype n
R✝ : Type v
inst✝² : CommRing R✝
S : Type u_1
inst✝¹ : CommRing S
R : Type u_2
inst✝ : Field R
a b c d : R
h_det : a * d - b * c = 1
hg : ↑{ val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) } 1 0 = 0
⊢ c = 0

Next tactic:
simpa using hg
theorem fin_two_exists_eq_mk_of_apply_zero_one_eq_zero {R : Type*} [Field R] (g : SL(2, R))
    (hg : (g : Matrix (Fin 2) (Fin 2) R) 1 0 = 0) :
    ∃ (a b : R) (h : a ≠ 0), g = (⟨!![a, b; 0, a⁻¹], by simp [h]⟩ : SL(2, R)) := by
  induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h_det
  replace hg : c = 0 := by simpa using hg
  

Proof state:
case h
n : Type u
inst✝⁴ : DecidableEq n
inst✝³ : Fintype n
R✝ : Type v
inst✝² : CommRing R✝
S : Type u_1
inst✝¹ : CommRing S
R : Type u_2
inst✝ : Field R
a b c d : R
h_det : a * d - b * c = 1
hg : c = 0
⊢ ∃ a_1 b_1,
    ∃ (h : a_1 ≠ 0),
      { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) } =
        { val := of ![![a_1, b_1], ![0, a_1⁻¹]], property := (_ : det (of ![![a_1, b_1], ![0, a_1⁻¹]]) = 1) }

Next tactic:
have had : a * d = 1 := by rwa [hg, mul_zero, sub_zero] at h_det
theorem fin_two_exists_eq_mk_of_apply_zero_one_eq_zero {R : Type*} [Field R] (g : SL(2, R))
    (hg : (g : Matrix (Fin 2) (Fin 2) R) 1 0 = 0) :
    ∃ (a b : R) (h : a ≠ 0), g = (⟨!![a, b; 0, a⁻¹], by simp [h]⟩ : SL(2, R)) := by
  induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h_det
  replace hg : c = 0 := by simpa using hg
  have had : a * d = 1 := by 

Proof state:
n : Type u
inst✝⁴ : DecidableEq n
inst✝³ : Fintype n
R✝ : Type v
inst✝² : CommRing R✝
S : Type u_1
inst✝¹ : CommRing S
R : Type u_2
inst✝ : Field R
a b c d : R
h_det : a * d - b * c = 1
hg : c = 0
⊢ a * d = 1

Next tactic:
rwa [hg, mul_zero, sub_zero] at h_det
theorem fin_two_exists_eq_mk_of_apply_zero_one_eq_zero {R : Type*} [Field R] (g : SL(2, R))
    (hg : (g : Matrix (Fin 2) (Fin 2) R) 1 0 = 0) :
    ∃ (a b : R) (h : a ≠ 0), g = (⟨!![a, b; 0, a⁻¹], by simp [h]⟩ : SL(2, R)) := by
  induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h_det
  replace hg : c = 0 := by simpa using hg
  have had : a * d = 1 := by rwa [hg, mul_zero, sub_zero] at h_det
  

Proof state:
case h
n : Type u
inst✝⁴ : DecidableEq n
inst✝³ : Fintype n
R✝ : Type v
inst✝² : CommRing R✝
S : Type u_1
inst✝¹ : CommRing S
R : Type u_2
inst✝ : Field R
a b c d : R
h_det : a * d - b * c = 1
hg : c = 0
had : a * d = 1
⊢ ∃ a_1 b_1,
    ∃ (h : a_1 ≠ 0),
      { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) } =
        { val := of ![![a_1, b_1], ![0, a_1⁻¹]], property := (_ : det (of ![![a_1, b_1], ![0, a_1⁻¹]]) = 1) }

Next tactic:
refine' ⟨a, b, left_ne_zero_of_mul_eq_one had, _⟩
theorem fin_two_exists_eq_mk_of_apply_zero_one_eq_zero {R : Type*} [Field R] (g : SL(2, R))
    (hg : (g : Matrix (Fin 2) (Fin 2) R) 1 0 = 0) :
    ∃ (a b : R) (h : a ≠ 0), g = (⟨!![a, b; 0, a⁻¹], by simp [h]⟩ : SL(2, R)) := by
  induction' g using Matrix.SpecialLinearGroup.fin_two_induction with a b c d h_det
  replace hg : c = 0 := by simpa using hg
  have had : a * d = 1 := by rwa [hg, mul_zero, sub_zero] at h_det
  refine' ⟨a, b, left_ne_zero_of_mul_eq_one had, _⟩
  

Proof state:
case h
n : Type u
inst✝⁴ : DecidableEq n
inst✝³ : Fintype n
R✝ : Type v
inst✝² : CommRing R✝
S : Type u_1
inst✝¹ : CommRing S
R : Type u_2
inst✝ : Field R
a b c d : R
h_det : a * d - b * c = 1
hg : c = 0
had : a * d = 1
⊢ { val := of ![![a, b], ![c, d]], property := (_ : det (of ![![a, b], ![c, d]]) = 1) } =
    { val := of ![![a, b], ![0, a⁻¹]], property := (_ : det (of ![![a, b], ![0, a⁻¹]]) = 1) }

Next tactic:
simp_rw [eq_inv_of_mul_eq_one_right had, hg]
/-- The matrix `S = [[0, -1], [1, 0]]` as an element of `SL(2, ℤ)`.

This element acts naturally on the Euclidean plane as a rotation about the origin by `π / 2`.

This element also acts naturally on the hyperbolic plane as rotation about `i` by `π`. It
represents the Mobiüs transformation `z ↦ -1/z` and is an involutive elliptic isometry. -/
def S : SL(2, ℤ) :=
  ⟨!![0, -1; 1, 0], by 

Proof state:
⊢ det (of ![![0, -1], ![1, 0]]) = 1

Next tactic:
norm_num [Matrix.det_fin_two_of]
/-- The matrix `T = [[1, 1], [0, 1]]` as an element of `SL(2, ℤ)` -/
def T : SL(2, ℤ) :=
  ⟨!![1, 1; 0, 1], by 

Proof state:
⊢ det (of ![![1, 1], ![0, 1]]) = 1

Next tactic:
norm_num [Matrix.det_fin_two_of]
theorem coe_T_inv : ↑ₘT⁻¹ = !![1, -1; 0, 1] := by 

Proof state:
⊢ ↑T⁻¹ = of ![![1, -1], ![0, 1]]

Next tactic:
simp [coe_inv, coe_T, adjugate_fin_two]
theorem coe_T_zpow (n : ℤ) : ↑ₘ(T ^ n) = !![1, n; 0, 1] := by
  

Proof state:
n : ℤ
⊢ ↑(T ^ n) = of ![![1, n], ![0, 1]]

Next tactic:
induction' n using Int.induction_on with n h n h
theorem coe_T_zpow (n : ℤ) : ↑ₘ(T ^ n) = !![1, n; 0, 1] := by
  induction' n using Int.induction_on with n h n h
  · 

Proof state:
case hz
⊢ ↑(T ^ 0) = of ![![1, 0], ![0, 1]]

Next tactic:
rw [zpow_zero, coe_one, Matrix.one_fin_two]
theorem coe_T_zpow (n : ℤ) : ↑ₘ(T ^ n) = !![1, n; 0, 1] := by
  induction' n using Int.induction_on with n h n h
  · rw [zpow_zero, coe_one, Matrix.one_fin_two]
  · 

Proof state:
case hp
n : ℕ
h : ↑(T ^ ↑n) = of ![![1, ↑n], ![0, 1]]
⊢ ↑(T ^ (↑n + 1)) = of ![![1, ↑n + 1], ![0, 1]]

Next tactic:
simp_rw [zpow_add, zpow_one, coe_mul, h, coe_T, Matrix.mul_fin_two]
theorem coe_T_zpow (n : ℤ) : ↑ₘ(T ^ n) = !![1, n; 0, 1] := by
  induction' n using Int.induction_on with n h n h
  · rw [zpow_zero, coe_one, Matrix.one_fin_two]
  · simp_rw [zpow_add, zpow_one, coe_mul, h, coe_T, Matrix.mul_fin_two]
    

Proof state:
case hp
n : ℕ
h : ↑(T ^ ↑n) = of ![![1, ↑n], ![0, 1]]
⊢ of ![![1 * 1 + ↑n * 0, 1 * 1 + ↑n * 1], ![0 * 1 + 1 * 0, 0 * 1 + 1 * 1]] = of ![![1, ↑n + 1], ![0, 1]]

Next tactic:
congrm !![_, ?_; _, _]
theorem coe_T_zpow (n : ℤ) : ↑ₘ(T ^ n) = !![1, n; 0, 1] := by
  induction' n using Int.induction_on with n h n h
  · rw [zpow_zero, coe_one, Matrix.one_fin_two]
  · simp_rw [zpow_add, zpow_one, coe_mul, h, coe_T, Matrix.mul_fin_two]
    congrm !![_, ?_; _, _]
    

Proof state:
case hp
n : ℕ
h : ↑(T ^ ↑n) = of ![![1, ↑n], ![0, 1]]
⊢ 1 * 1 + ↑n * 1 = ↑n + 1

Next tactic:
rw [mul_one, mul_one, add_comm]
theorem coe_T_zpow (n : ℤ) : ↑ₘ(T ^ n) = !![1, n; 0, 1] := by
  induction' n using Int.induction_on with n h n h
  · rw [zpow_zero, coe_one, Matrix.one_fin_two]
  · simp_rw [zpow_add, zpow_one, coe_mul, h, coe_T, Matrix.mul_fin_two]
    congrm !![_, ?_; _, _]
    rw [mul_one, mul_one, add_comm]
  · 

Proof state:
case hn
n : ℕ
h : ↑(T ^ (-↑n)) = of ![![1, -↑n], ![0, 1]]
⊢ ↑(T ^ (-↑n - 1)) = of ![![1, -↑n - 1], ![0, 1]]

Next tactic:
simp_rw [zpow_sub, zpow_one, coe_mul, h, coe_T_inv, Matrix.mul_fin_two]
theorem coe_T_zpow (n : ℤ) : ↑ₘ(T ^ n) = !![1, n; 0, 1] := by
  induction' n using Int.induction_on with n h n h
  · rw [zpow_zero, coe_one, Matrix.one_fin_two]
  · simp_rw [zpow_add, zpow_one, coe_mul, h, coe_T, Matrix.mul_fin_two]
    congrm !![_, ?_; _, _]
    rw [mul_one, mul_one, add_comm]
  · simp_rw [zpow_sub, zpow_one, coe_mul, h, coe_T_inv, Matrix.mul_fin_two]
    

Proof state:
case hn
n : ℕ
h : ↑(T ^ (-↑n)) = of ![![1, -↑n], ![0, 1]]
⊢ of ![![1 * 1 + -↑n * 0, 1 * -1 + -↑n * 1], ![0 * 1 + 1 * 0, 0 * -1 + 1 * 1]] = of ![![1, -↑n - 1], ![0, 1]]

Next tactic:
congrm !![?_, ?_; _, _]
theorem coe_T_zpow (n : ℤ) : ↑ₘ(T ^ n) = !![1, n; 0, 1] := by
  induction' n using Int.induction_on with n h n h
  · rw [zpow_zero, coe_one, Matrix.one_fin_two]
  · simp_rw [zpow_add, zpow_one, coe_mul, h, coe_T, Matrix.mul_fin_two]
    congrm !![_, ?_; _, _]
    rw [mul_one, mul_one, add_comm]
  · simp_rw [zpow_sub, zpow_one, coe_mul, h, coe_T_inv, Matrix.mul_fin_two]
    congrm !![?_, ?_; _, _] <;> 

Proof state:
case hn.refine_1
n : ℕ
h : ↑(T ^ (-↑n)) = of ![![1, -↑n], ![0, 1]]
⊢ 1 * 1 + -↑n * 0 = 1

Next tactic:
ring
theorem coe_T_zpow (n : ℤ) : ↑ₘ(T ^ n) = !![1, n; 0, 1] := by
  induction' n using Int.induction_on with n h n h
  · rw [zpow_zero, coe_one, Matrix.one_fin_two]
  · simp_rw [zpow_add, zpow_one, coe_mul, h, coe_T, Matrix.mul_fin_two]
    congrm !![_, ?_; _, _]
    rw [mul_one, mul_one, add_comm]
  · simp_rw [zpow_sub, zpow_one, coe_mul, h, coe_T_inv, Matrix.mul_fin_two]
    congrm !![?_, ?_; _, _] <;> 

Proof state:
case hn.refine_2
n : ℕ
h : ↑(T ^ (-↑n)) = of ![![1, -↑n], ![0, 1]]
⊢ 1 * -1 + -↑n * 1 = -↑n - 1

Next tactic:
ring
@[simp]
theorem T_pow_mul_apply_one (n : ℤ) (g : SL(2, ℤ)) : ↑ₘ(T ^ n * g) 1 = ↑ₘg 1 := by
  

Proof state:
n : ℤ
g : SL(2, ℤ)
⊢ ↑(T ^ n * g) 1 = ↑g 1

Next tactic:
ext j
@[simp]
theorem T_pow_mul_apply_one (n : ℤ) (g : SL(2, ℤ)) : ↑ₘ(T ^ n * g) 1 = ↑ₘg 1 := by
  ext j
  

Proof state:
case h
n : ℤ
g : SL(2, ℤ)
j : Fin 2
⊢ ↑(T ^ n * g) 1 j = ↑g 1 j

Next tactic:
simp [coe_T_zpow, Matrix.vecMul, Matrix.dotProduct, Fin.sum_univ_succ, vecTail]
@[simp]
theorem T_mul_apply_one (g : SL(2, ℤ)) : ↑ₘ(T * g) 1 = ↑ₘg 1 := by
  

Proof state:
g : SL(2, ℤ)
⊢ ↑(T * g) 1 = ↑g 1

Next tactic:
simpa using T_pow_mul_apply_one 1 g
@[simp]
theorem T_inv_mul_apply_one (g : SL(2, ℤ)) : ↑ₘ(T⁻¹ * g) 1 = ↑ₘg 1 := by
  

Proof state:
g : SL(2, ℤ)
⊢ ↑(T⁻¹ * g) 1 = ↑g 1

Next tactic:
simpa using T_pow_mul_apply_one (-1) g