l3lab/ntp-mathlib huggingface dataset:
theorem exists_succ (x : s) : ∃ n, (x : ℕ) + n + 1 ∈ s :=
  _root_.by_contradiction fun h =>
    have : ∀ (a : ℕ) (_ : a ∈ s), a < succ x := fun a ha =>
      lt_of_not_ge fun hax => h ⟨a - (x + 1), by rwa [add_right_comm, add_tsub_cancel_of_le hax]⟩
    Fintype.false
      ⟨(((Multiset.range (succ x)).filter (· ∈ s)).pmap
            (fun (y : ℕ) (hy : y ∈ s) => Subtype.mk y hy)
            (by simp [-Multiset.range_succ])).toFinset,
        by 

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝ : Infinite ↑s
x : ↑s
h : ¬∃ n, ↑x + n + 1 ∈ s
this : ∀ a ∈ s, a < succ ↑x
⊢ ∀ (x_1 : { y // y ∈ s }),
    x_1 ∈
      Multiset.toFinset
        (Multiset.pmap (fun y hy => { val := y, property := hy })
          (Multiset.filter (fun x => x ∈ s) (Multiset.range (succ ↑x)))
          (_ : ∀ a ∈ Multiset.filter (fun x => x ∈ s) (Multiset.range (succ ↑x)), a ∈ s))

Next tactic:
simpa [Subtype.ext_iff_val, Multiset.mem_filter, -Multiset.range_succ]
theorem succ_le_of_lt {x y : s} (h : y < x) : succ y ≤ x :=
  have hx : ∃ m, (y : ℕ) + m + 1 ∈ s := exists_succ _
  let ⟨k, hk⟩ := Nat.exists_eq_add_of_lt h
  have : Nat.find hx ≤ k := Nat.find_min' _ (hk ▸ x.2)
  show (y : ℕ) + Nat.find hx + 1 ≤ x by
    

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x y : ↑s
h : y < x
hx : ∃ m, ↑y + m + 1 ∈ s
k : ℕ
hk : ↑x = ↑y + k + 1
this : Nat.find hx ≤ k
⊢ ↑y + Nat.find hx + 1 ≤ ↑x

Next tactic:
rw [hk]
theorem succ_le_of_lt {x y : s} (h : y < x) : succ y ≤ x :=
  have hx : ∃ m, (y : ℕ) + m + 1 ∈ s := exists_succ _
  let ⟨k, hk⟩ := Nat.exists_eq_add_of_lt h
  have : Nat.find hx ≤ k := Nat.find_min' _ (hk ▸ x.2)
  show (y : ℕ) + Nat.find hx + 1 ≤ x by
    rw [hk]
    

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x y : ↑s
h : y < x
hx : ∃ m, ↑y + m + 1 ∈ s
k : ℕ
hk : ↑x = ↑y + k + 1
this : Nat.find hx ≤ k
⊢ ↑y + Nat.find hx + 1 ≤ ↑y + k + 1

Next tactic:
exact add_le_add_right (add_le_add_left this _) _
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
⊢ ∃ n, ofNat s n = { val := x✝, property := hx }

Next tactic:
set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by 

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
⊢ ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s

Next tactic:
intros a ha
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; 

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
a : ℕ
ha : a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x)
⊢ a ∈ s

Next tactic:
simpa using (List.mem_filter.mp ha).2
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
⊢ ∃ n, ofNat s n = { val := x✝, property := hx }

Next tactic:
have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
⊢ ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }

Next tactic:
simp [List.mem_filter, Subtype.ext_iff_val, ht]
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
⊢ ∃ n, ofNat s n = { val := x✝, property := hx }

Next tactic:
have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
m : ↑s
hmax : List.maximum t = ↑m
⊢ ↑m < x

Next tactic:
simpa using hmt.mp (List.maximum_mem hmax)
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    

Proof state:
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
⊢ ∃ n, ofNat s n = { val := x✝, property := hx }

Next tactic:
cases' hmax : List.maximum t with m
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    cases' hmax : List.maximum t with m
    · 

Proof state:
case none
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
hmax : List.maximum t = none
⊢ ∃ n, ofNat s n = { val := x✝, property := hx }

Next tactic:
refine ⟨0, le_antisymm bot_le (le_of_not_gt fun h => List.not_mem_nil (⊥ : s) ?_)⟩
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    cases' hmax : List.maximum t with m
    · refine ⟨0, le_antisymm bot_le (le_of_not_gt fun h => List.not_mem_nil (⊥ : s) ?_)⟩
      

Proof state:
case none
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
hmax : List.maximum t = none
h : { val := x✝, property := hx } > ofNat s 0
⊢ ⊥ ∈ []

Next tactic:
rwa [← List.maximum_eq_none.1 hmax, hmt]
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    cases' hmax : List.maximum t with m
    · refine ⟨0, le_antisymm bot_le (le_of_not_gt fun h => List.not_mem_nil (⊥ : s) ?_)⟩
      rwa [← List.maximum_eq_none.1 hmax, hmt]
    

Proof state:
case some
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
m : ↑s
hmax : List.maximum t = some m
⊢ ∃ n, ofNat s n = { val := x✝, property := hx }

Next tactic:
cases' ofNat_surjective_aux m.2 with a ha
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    cases' hmax : List.maximum t with m
    · refine ⟨0, le_antisymm bot_le (le_of_not_gt fun h => List.not_mem_nil (⊥ : s) ?_)⟩
      rwa [← List.maximum_eq_none.1 hmax, hmt]
    cases' ofNat_surjective_aux m.2 with a ha
    

Proof state:
case some.intro
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
m : ↑s
hmax : List.maximum t = some m
a : ℕ
ha : ofNat s a = { val := ↑m, property := (_ : ↑m ∈ s) }
⊢ ∃ n, ofNat s n = { val := x✝, property := hx }

Next tactic:
refine ⟨a + 1, le_antisymm ?_ ?_⟩
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    cases' hmax : List.maximum t with m
    · refine ⟨0, le_antisymm bot_le (le_of_not_gt fun h => List.not_mem_nil (⊥ : s) ?_)⟩
      rwa [← List.maximum_eq_none.1 hmax, hmt]
    cases' ofNat_surjective_aux m.2 with a ha
    refine ⟨a + 1, le_antisymm ?_ ?_⟩ <;> 

Proof state:
case some.intro.refine_1
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
m : ↑s
hmax : List.maximum t = some m
a : ℕ
ha : ofNat s a = { val := ↑m, property := (_ : ↑m ∈ s) }
⊢ ofNat s (a + 1) ≤ { val := x✝, property := hx }

Next tactic:
rw [ofNat]
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    cases' hmax : List.maximum t with m
    · refine ⟨0, le_antisymm bot_le (le_of_not_gt fun h => List.not_mem_nil (⊥ : s) ?_)⟩
      rwa [← List.maximum_eq_none.1 hmax, hmt]
    cases' ofNat_surjective_aux m.2 with a ha
    refine ⟨a + 1, le_antisymm ?_ ?_⟩ <;> 

Proof state:
case some.intro.refine_2
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
m : ↑s
hmax : List.maximum t = some m
a : ℕ
ha : ofNat s a = { val := ↑m, property := (_ : ↑m ∈ s) }
⊢ { val := x✝, property := hx } ≤ ofNat s (a + 1)

Next tactic:
rw [ofNat]
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    cases' hmax : List.maximum t with m
    · refine ⟨0, le_antisymm bot_le (le_of_not_gt fun h => List.not_mem_nil (⊥ : s) ?_)⟩
      rwa [← List.maximum_eq_none.1 hmax, hmt]
    cases' ofNat_surjective_aux m.2 with a ha
    refine ⟨a + 1, le_antisymm ?_ ?_⟩ <;> rw [ofNat]
    · 

Proof state:
case some.intro.refine_1
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
m : ↑s
hmax : List.maximum t = some m
a : ℕ
ha : ofNat s a = { val := ↑m, property := (_ : ↑m ∈ s) }
⊢ succ (ofNat s a) ≤ { val := x✝, property := hx }

Next tactic:
refine succ_le_of_lt ?_
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    cases' hmax : List.maximum t with m
    · refine ⟨0, le_antisymm bot_le (le_of_not_gt fun h => List.not_mem_nil (⊥ : s) ?_)⟩
      rwa [← List.maximum_eq_none.1 hmax, hmt]
    cases' ofNat_surjective_aux m.2 with a ha
    refine ⟨a + 1, le_antisymm ?_ ?_⟩ <;> rw [ofNat]
    · refine succ_le_of_lt ?_
      

Proof state:
case some.intro.refine_1
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
m : ↑s
hmax : List.maximum t = some m
a : ℕ
ha : ofNat s a = { val := ↑m, property := (_ : ↑m ∈ s) }
⊢ ofNat s a < { val := x✝, property := hx }

Next tactic:
rw [ha]
theorem ofNat_surjective_aux : ∀ {x : ℕ} (hx : x ∈ s), ∃ n, ofNat s n = ⟨x, hx⟩
  | x => fun hx => by
    set t : List s :=
      ((List.range x).filter fun y => y ∈ s).pmap
        (fun (y : ℕ) (hy : y ∈ s) => ⟨y, hy⟩)
        (by intros a ha; simpa using (List.mem_filter.mp ha).2) with ht
    have hmt : ∀ {y : s}, y ∈ t ↔ y < ⟨x, hx⟩ := by
      simp [List.mem_filter, Subtype.ext_iff_val, ht]
    have wf : ∀ m : s, List.maximum t = m → ↑m < x := fun m hmax => by
      simpa using hmt.mp (List.maximum_mem hmax)
    cases' hmax : List.maximum t with m
    · refine ⟨0, le_antisymm bot_le (le_of_not_gt fun h => List.not_mem_nil (⊥ : s) ?_)⟩
      rwa [← List.maximum_eq_none.1 hmax, hmt]
    cases' ofNat_surjective_aux m.2 with a ha
    refine ⟨a + 1, le_antisymm ?_ ?_⟩ <;> rw [ofNat]
    · refine succ_le_of_lt ?_
      rw [ha]
      

Proof state:
case some.intro.refine_1
α : Type u_1
β : Type u_2
s : Set ℕ
inst✝¹ : Infinite ↑s
inst✝ : DecidablePred fun x => x ∈ s
x✝ : ℕ
x : ℕ := x✝
hx : x✝ ∈ s
t : List ↑s :=
  List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
    (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
ht :
  t =
    List.pmap (fun y hy => { val := y, property := hy }) (List.filter (fun y => decide (y ∈ s)) (List.range x))
      (_ : ∀ a ∈ List.filter (fun y => decide (y ∈ s)) (List.range x), a ∈ s)
hmt : ∀ {y : ↑s}, y ∈ t ↔ y < { val := x, property := hx }
wf : ∀ (m : ↑s), List.maximum t = ↑m → ↑m < x
m : ↑s
hmax : List.maximum t = some m
a : ℕ
ha : ofNat s a = { val := ↑m, property := (_ : ↑m ∈ s) }
⊢ { val := ↑m, property := (_ : ↑m ∈ s) } < { val := x✝, property := hx }

Next tactic:
exact wf _ hmax