Theorem: Primrec.nat_div
File: Mathlib/Computability/Primrec.lean

tactic: refine of_graph ⟨_, fst, fun p => Nat.div_le_self _ _⟩ ?_
state_before: α : Type ?u.161626
β : Type ?u.161629
γ : Type ?u.161632
δ : Type ?u.161635
σ : Type ?u.161638
inst✝⁴ : Primcodable α
inst✝³ : Primcodable β
inst✝² : Primcodable γ
inst✝¹ : Primcodable δ
inst✝ : Primcodable σ
⊢ Primrec₂ fun x x_1 => x / x_1

tactic: have : PrimrecRel fun (a : ℕ × ℕ) (b : ℕ) => (a.2 = 0 ∧ b = 0) ∨
    (0 < a.2 ∧ b * a.2 ≤ a.1 ∧ a.1 < (b + 1) * a.2) :=
  PrimrecPred.or
    (.and (const 0 |> Primrec.eq.comp (fst |> snd.comp)) (const 0 |> Primrec.eq.comp snd))
    (.and (nat_lt.comp (const 0) (fst |> snd.comp)) <|
        .and (nat_le.comp (nat_mul.comp snd (fst |> snd.comp)) (fst |> fst.comp))
        (nat_lt.comp (fst.comp fst) (nat_mul.comp (Primrec.succ.comp snd) (snd.comp fst))))
state_before: α : Type ?u.161626
β : Type ?u.161629
γ : Type ?u.161632
δ : Type ?u.161635
σ : Type ?u.161638
inst✝⁴ : Primcodable α
inst✝³ : Primcodable β
inst✝² : Primcodable γ
inst✝¹ : Primcodable δ
inst✝ : Primcodable σ
⊢ PrimrecRel fun a b => (fun x x_1 => x / x_1) a.fst a.snd = b

tactic: refine this.of_eq ?_
state_before: α : Type ?u.161626
β : Type ?u.161629
γ : Type ?u.161632
δ : Type ?u.161635
σ : Type ?u.161638
inst✝⁴ : Primcodable α
inst✝³ : Primcodable β
inst✝² : Primcodable γ
inst✝¹ : Primcodable δ
inst✝ : Primcodable σ
this : PrimrecRel fun a b => a.snd = 0 ∧ b = 0 ∨ 0 < a.snd ∧ b * a.snd ≤ a.fst ∧ a.fst < (b + 1) * a.snd
⊢ PrimrecRel fun a b => (fun x x_1 => x / x_1) a.fst a.snd = b

tactic: rintro ⟨a, k⟩ q
state_before: α : Type ?u.161626
β : Type ?u.161629
γ : Type ?u.161632
δ : Type ?u.161635
σ : Type ?u.161638
inst✝⁴ : Primcodable α
inst✝³ : Primcodable β
inst✝² : Primcodable γ
inst✝¹ : Primcodable δ
inst✝ : Primcodable σ
this : PrimrecRel fun a b => a.snd = 0 ∧ b = 0 ∨ 0 < a.snd ∧ b * a.snd ≤ a.fst ∧ a.fst < (b + 1) * a.snd
⊢ ∀ (a : ℕ × ℕ) (b : ℕ),
    a.snd = 0 ∧ b = 0 ∨ 0 < a.snd ∧ b * a.snd ≤ a.fst ∧ a.fst < (b + 1) * a.snd ↔ (fun x x_1 => x / x_1) a.fst a.snd = b

tactic: if H : k = 0 then simp [H, eq_comm]
else
  have : q * k ≤ a ∧ a < (q + 1) * k ↔ q = a / k := by
    rw [le_antisymm_iff, ← (@Nat.lt_succ _ q), Nat.le_div_iff_mul_le' (Nat.pos_of_ne_zero H),
        Nat.div_lt_iff_lt_mul' (Nat.pos_of_ne_zero H)]
  simpa [H, zero_lt_iff, eq_comm (b := q)]
state_before: case mk
α : Type ?u.161626
β : Type ?u.161629
γ : Type ?u.161632
δ : Type ?u.161635
σ : Type ?u.161638
inst✝⁴ : Primcodable α
inst✝³ : Primcodable β
inst✝² : Primcodable γ
inst✝¹ : Primcodable δ
inst✝ : Primcodable σ
this : PrimrecRel fun a b => a.snd = 0 ∧ b = 0 ∨ 0 < a.snd ∧ b * a.snd ≤ a.fst ∧ a.fst < (b + 1) * a.snd
a k q : ℕ
⊢ (a, k).snd = 0 ∧ q = 0 ∨ 0 < (a, k).snd ∧ q * (a, k).snd ≤ (a, k).fst ∧ (a, k).fst < (q + 1) * (a, k).snd ↔
    (fun x x_1 => x / x_1) (a, k).fst (a, k).snd = q

tactic: simp [H, eq_comm]
state_before: α : Type ?u.161626
β : Type ?u.161629
γ : Type ?u.161632
δ : Type ?u.161635
σ : Type ?u.161638
inst✝⁴ : Primcodable α
inst✝³ : Primcodable β
inst✝² : Primcodable γ
inst✝¹ : Primcodable δ
inst✝ : Primcodable σ
this : PrimrecRel fun a b => a.snd = 0 ∧ b = 0 ∨ 0 < a.snd ∧ b * a.snd ≤ a.fst ∧ a.fst < (b + 1) * a.snd
a k q : ℕ
H : k = 0
⊢ (a, k).snd = 0 ∧ q = 0 ∨ 0 < (a, k).snd ∧ q * (a, k).snd ≤ (a, k).fst ∧ (a, k).fst < (q + 1) * (a, k).snd ↔
    (fun x x_1 => x / x_1) (a, k).fst (a, k).snd = q

tactic: have : q * k ≤ a ∧ a < (q + 1) * k ↔ q = a / k := by
  rw [le_antisymm_iff, ← (@Nat.lt_succ _ q), Nat.le_div_iff_mul_le' (Nat.pos_of_ne_zero H),
      Nat.div_lt_iff_lt_mul' (Nat.pos_of_ne_zero H)]
state_before: α : Type ?u.161626
β : Type ?u.161629
γ : Type ?u.161632
δ : Type ?u.161635
σ : Type ?u.161638
inst✝⁴ : Primcodable α
inst✝³ : Primcodable β
inst✝² : Primcodable γ
inst✝¹ : Primcodable δ
inst✝ : Primcodable σ
this : PrimrecRel fun a b => a.snd = 0 ∧ b = 0 ∨ 0 < a.snd ∧ b * a.snd ≤ a.fst ∧ a.fst < (b + 1) * a.snd
a k q : ℕ
H : ¬k = 0
⊢ (a, k).snd = 0 ∧ q = 0 ∨ 0 < (a, k).snd ∧ q * (a, k).snd ≤ (a, k).fst ∧ (a, k).fst < (q + 1) * (a, k).snd ↔
    (fun x x_1 => x / x_1) (a, k).fst (a, k).snd = q

tactic: simpa [H, zero_lt_iff, eq_comm (b := q)]
state_before: α : Type ?u.161626
β : Type ?u.161629
γ : Type ?u.161632
δ : Type ?u.161635
σ : Type ?u.161638
inst✝⁴ : Primcodable α
inst✝³ : Primcodable β
inst✝² : Primcodable γ
inst✝¹ : Primcodable δ
inst✝ : Primcodable σ
this✝ : PrimrecRel fun a b => a.snd = 0 ∧ b = 0 ∨ 0 < a.snd ∧ b * a.snd ≤ a.fst ∧ a.fst < (b + 1) * a.snd
a k q : ℕ
H : ¬k = 0
this : q * k ≤ a ∧ a < (q + 1) * k ↔ q = a / k
⊢ (a, k).snd = 0 ∧ q = 0 ∨ 0 < (a, k).snd ∧ q * (a, k).snd ≤ (a, k).fst ∧ (a, k).fst < (q + 1) * (a, k).snd ↔
    (fun x x_1 => x / x_1) (a, k).fst (a, k).snd = q

tactic: rw [le_antisymm_iff, ← (@Nat.lt_succ _ q), Nat.le_div_iff_mul_le' (Nat.pos_of_ne_zero H),
    Nat.div_lt_iff_lt_mul' (Nat.pos_of_ne_zero H)]
state_before: α : Type ?u.161626
β : Type ?u.161629
γ : Type ?u.161632
δ : Type ?u.161635
σ : Type ?u.161638
inst✝⁴ : Primcodable α
inst✝³ : Primcodable β
inst✝² : Primcodable γ
inst✝¹ : Primcodable δ
inst✝ : Primcodable σ
this : PrimrecRel fun a b => a.snd = 0 ∧ b = 0 ∨ 0 < a.snd ∧ b * a.snd ≤ a.fst ∧ a.fst < (b + 1) * a.snd
a k q : ℕ
H : ¬k = 0
⊢ q * k ≤ a ∧ a < (q + 1) * k ↔ q = a / k