l3lab/ntp-mathlib huggingface dataset:
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
⊢ ∀ (x : F (α ::: Fix F α)),
    (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
          x =
        (TypeVec.id ::: _root_.id) <$$> x →
      (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) (mk x)).fst = _root_.id (mk x)

Next tactic:
intro x' ih
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    (TypeVec.id ::: _root_.id) <$$> x'
⊢ (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) (mk x')).fst = _root_.id (mk x')

Next tactic:
rw [Fix.rec_eq]
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    (TypeVec.id ::: _root_.id) <$$> x'
⊢ {
        fst :=
          mk
            ((TypeVec.id ::: Sigma.fst) <$$>
              (TypeVec.id ::: rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$> x'),
        snd :=
          g
            ((TypeVec.id ::: rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$>
              x') }.fst =
    _root_.id (mk x')

Next tactic:
dsimp
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    (TypeVec.id ::: _root_.id) <$$> x'
⊢ mk
      ((TypeVec.id ::: Sigma.fst) <$$>
        (TypeVec.id ::: rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$> x') =
    mk x'

Next tactic:
simp? [appendFun_id_id] at ih says
      simp only [appendFun_id_id, MvFunctor.id_map] at ih
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    simp? [appendFun_id_id] at ih says
      

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    (TypeVec.id ::: _root_.id) <$$> x'
⊢ mk
      ((TypeVec.id ::: Sigma.fst) <$$>
        (TypeVec.id ::: rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$> x') =
    mk x'

Next tactic:
simp only [appendFun_id_id, MvFunctor.id_map] at ih
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    simp? [appendFun_id_id] at ih says
      simp only [appendFun_id_id, MvFunctor.id_map] at ih
    

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    x'
⊢ mk
      ((TypeVec.id ::: Sigma.fst) <$$>
        (TypeVec.id ::: rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$> x') =
    mk x'

Next tactic:
congr
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    simp? [appendFun_id_id] at ih says
      simp only [appendFun_id_id, MvFunctor.id_map] at ih
    congr
    

Proof state:
case e_x
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    x'
⊢ (TypeVec.id ::: Sigma.fst) <$$>
      (TypeVec.id ::: rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$> x' =
    x'

Next tactic:
conv =>
      rhs
      rw [← ih]
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    simp? [appendFun_id_id] at ih says
      simp only [appendFun_id_id, MvFunctor.id_map] at ih
    congr
    conv =>
      

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    x'
| (TypeVec.id ::: Sigma.fst) <$$>
      (TypeVec.id ::: rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$> x' =
    x'

Next tactic:
rhs
      rw [← ih]
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    simp? [appendFun_id_id] at ih says
      simp only [appendFun_id_id, MvFunctor.id_map] at ih
    congr
    conv =>
      

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    x'
| (TypeVec.id ::: Sigma.fst) <$$>
      (TypeVec.id ::: rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$> x' =
    x'

Next tactic:
rhs
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    simp? [appendFun_id_id] at ih says
      simp only [appendFun_id_id, MvFunctor.id_map] at ih
    congr
    conv =>
      rhs
      

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    x'
| x'

Next tactic:
rw [← ih]
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    simp? [appendFun_id_id] at ih says
      simp only [appendFun_id_id, MvFunctor.id_map] at ih
    congr
    conv =>
      rhs
      rw [← ih]
    

Proof state:
case e_x
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    x'
⊢ (TypeVec.id ::: Sigma.fst) <$$>
      (TypeVec.id ::: rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$> x' =
    (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x'

Next tactic:
rw [MvFunctor.map_map, ← appendFun_comp, id_comp]
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    simp? [appendFun_id_id] at ih says
      simp only [appendFun_id_id, MvFunctor.id_map] at ih
    congr
    conv =>
      rhs
      rw [← ih]
    rw [MvFunctor.map_map, ← appendFun_comp, id_comp]
    

Proof state:
case e_x
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
x' : F (α ::: Fix F α)
ih :
  (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x' =
    x'
⊢ (TypeVec.id ::: Sigma.fst ∘ rec fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) <$$> x' =
    (TypeVec.id ::: fun x => (rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x).fst) <$$>
      x'

Next tactic:
simp only [Function.comp]
/-- Dependent recursor for `fix F` -/
def Fix.drec {β : Fix F α → Type u}
    (g : ∀ x : F (α ::: Sigma β), β (Fix.mk <| (id ::: Sigma.fst) <$$> x)) (x : Fix F α) : β x :=
  let y := @Fix.rec _ F _ _ α (Sigma β) (fun i => ⟨_, g i⟩) x
  have : x = y.1 := by
    symm
    dsimp
    apply Fix.ind_rec _ id _ x
    intro x' ih
    rw [Fix.rec_eq]
    dsimp
    simp? [appendFun_id_id] at ih says
      simp only [appendFun_id_id, MvFunctor.id_map] at ih
    congr
    conv =>
      rhs
      rw [← ih]
    rw [MvFunctor.map_map, ← appendFun_comp, id_comp]
    simp only [Function.comp]
  cast (by 

Proof state:
n : ℕ
F : TypeVec.{u} (n + 1) → Type u
inst✝ : MvFunctor F
q : MvQPF F
α : TypeVec.{u} n
β : Fix F α → Type u
g : (x : F (α ::: Sigma β)) → β (mk ((TypeVec.id ::: Sigma.fst) <$$> x))
x : Fix F α
y : Sigma β := rec (fun i => { fst := mk ((TypeVec.id ::: Sigma.fst) <$$> i), snd := g i }) x
this : x = y.fst
⊢ β y.fst = β x

Next tactic:
rw [this]
theorem subset_range_enumerate {s : Set α} (h : s.Countable) (default : α) :
    s ⊆ range (enumerateCountable h default) := fun x hx =>
  ⟨@Encodable.encode s h.toEncodable ⟨x, hx⟩, by
    

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
h : Set.Countable s
default x : α
hx : x ∈ s
⊢ enumerateCountable h default (encode { val := x, property := hx }) = x

Next tactic:
letI := h.toEncodable
theorem subset_range_enumerate {s : Set α} (h : s.Countable) (default : α) :
    s ⊆ range (enumerateCountable h default) := fun x hx =>
  ⟨@Encodable.encode s h.toEncodable ⟨x, hx⟩, by
    letI := h.toEncodable
    

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
h : Set.Countable s
default x : α
hx : x ∈ s
this : Encodable ↑s := Countable.toEncodable h
⊢ enumerateCountable h default (encode { val := x, property := hx }) = x

Next tactic:
simp [enumerateCountable, Encodable.encodek]
theorem countable_iff_exists_subset_range [Nonempty α] {s : Set α} :
    s.Countable ↔ ∃ f : ℕ → α, s ⊆ range f :=
  ⟨fun h => by
    

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : Nonempty α
s : Set α
h : Set.Countable s
⊢ ∃ f, s ⊆ range f

Next tactic:
inhabit α
theorem countable_iff_exists_subset_range [Nonempty α] {s : Set α} :
    s.Countable ↔ ∃ f : ℕ → α, s ⊆ range f :=
  ⟨fun h => by
    inhabit α
    

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : Nonempty α
s : Set α
h : Set.Countable s
inhabited_h : Inhabited α
⊢ ∃ f, s ⊆ range f

Next tactic:
exact ⟨enumerateCountable h default, subset_range_enumerate _ _⟩
/-- If `s : Set α` is a nonempty countable set, then there exists a map
`f : ℕ → α` such that `s = range f`. -/
theorem Countable.exists_eq_range {s : Set α} (hc : s.Countable) (hs : s.Nonempty) :
    ∃ f : ℕ → α, s = range f := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hc : Set.Countable s
hs : Set.Nonempty s
⊢ ∃ f, s = range f

Next tactic:
rcases hc.exists_surjective hs with ⟨f, hf⟩
/-- If `s : Set α` is a nonempty countable set, then there exists a map
`f : ℕ → α` such that `s = range f`. -/
theorem Countable.exists_eq_range {s : Set α} (hc : s.Countable) (hs : s.Nonempty) :
    ∃ f : ℕ → α, s = range f := by
  rcases hc.exists_surjective hs with ⟨f, hf⟩
  

Proof state:
case intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hc : Set.Countable s
hs : Set.Nonempty s
f : ℕ → ↑s
hf : Surjective f
⊢ ∃ f, s = range f

Next tactic:
refine' ⟨(↑) ∘ f, _⟩
/-- If `s : Set α` is a nonempty countable set, then there exists a map
`f : ℕ → α` such that `s = range f`. -/
theorem Countable.exists_eq_range {s : Set α} (hc : s.Countable) (hs : s.Nonempty) :
    ∃ f : ℕ → α, s = range f := by
  rcases hc.exists_surjective hs with ⟨f, hf⟩
  refine' ⟨(↑) ∘ f, _⟩
  

Proof state:
case intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hc : Set.Countable s
hs : Set.Nonempty s
f : ℕ → ↑s
hf : Surjective f
⊢ s = range (Subtype.val ∘ f)

Next tactic:
rw [hf.range_comp, Subtype.range_coe]
theorem Countable.image {s : Set α} (hs : s.Countable) (f : α → β) : (f '' s).Countable := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hs : Set.Countable s
f : α → β
⊢ Set.Countable (f '' s)

Next tactic:
rw [image_eq_range]
theorem Countable.image {s : Set α} (hs : s.Countable) (f : α → β) : (f '' s).Countable := by
  rw [image_eq_range]
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hs : Set.Countable s
f : α → β
⊢ Set.Countable (range fun x => f ↑x)

Next tactic:
haveI := hs.to_subtype
theorem Countable.image {s : Set α} (hs : s.Countable) (f : α → β) : (f '' s).Countable := by
  rw [image_eq_range]
  haveI := hs.to_subtype
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
s : Set α
hs : Set.Countable s
f : α → β
this : Countable ↑s
⊢ Set.Countable (range fun x => f ↑x)

Next tactic:
apply countable_range
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
⊢ (∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤) ↔ ∃ S, Set.Countable S ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤

Next tactic:
constructor
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · 

Proof state:
case mp
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
⊢ (∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤) → ∃ S, Set.Countable S ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤

Next tactic:
rintro ⟨s, hps, hs⟩
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    

Proof state:
case mp.intro.intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
s : ℕ → α
hps : ∀ (n : ℕ), p (s n)
hs : ⨆ n, s n = ⊤
⊢ ∃ S, Set.Countable S ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤

Next tactic:
refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    

Proof state:
case mp.intro.intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
s : ℕ → α
hps : ∀ (n : ℕ), p (s n)
hs : ⨆ n, s n = ⊤
⊢ sSup (range s) = ⊤

Next tactic:
rwa [sSup_range]
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    rwa [sSup_range]
  · 

Proof state:
case mpr
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
⊢ (∃ S, Set.Countable S ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤) → ∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤

Next tactic:
rintro ⟨S, hSc, hps, hS⟩
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    rwa [sSup_range]
  · rintro ⟨S, hSc, hps, hS⟩
    

Proof state:
case mpr.intro.intro.intro
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
S : Set α
hSc : Set.Countable S
hps : ∀ s ∈ S, p s
hS : sSup S = ⊤
⊢ ∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤

Next tactic:
rcases eq_empty_or_nonempty S with (rfl | hne)
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    rwa [sSup_range]
  · rintro ⟨S, hSc, hps, hS⟩
    rcases eq_empty_or_nonempty S with (rfl | hne)
    · 

Proof state:
case mpr.intro.intro.intro.inl
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
hSc : Set.Countable ∅
hps : ∀ s ∈ ∅, p s
hS : sSup ∅ = ⊤
⊢ ∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤

Next tactic:
rw [sSup_empty] at hS
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    rwa [sSup_range]
  · rintro ⟨S, hSc, hps, hS⟩
    rcases eq_empty_or_nonempty S with (rfl | hne)
    · rw [sSup_empty] at hS
      

Proof state:
case mpr.intro.intro.intro.inl
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
hSc : Set.Countable ∅
hps : ∀ s ∈ ∅, p s
hS : ⊥ = ⊤
⊢ ∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤

Next tactic:
haveI := subsingleton_of_bot_eq_top hS
theorem exists_seq_iSup_eq_top_iff_countable [CompleteLattice α] {p : α → Prop} (h : ∃ x, p x) :
    (∃ s : ℕ → α, (∀ n, p (s n)) ∧ ⨆ n, s n = ⊤) ↔
      ∃ S : Set α, S.Countable ∧ (∀ s ∈ S, p s) ∧ sSup S = ⊤ := by
  constructor
  · rintro ⟨s, hps, hs⟩
    refine' ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩
    rwa [sSup_range]
  · rintro ⟨S, hSc, hps, hS⟩
    rcases eq_empty_or_nonempty S with (rfl | hne)
    · rw [sSup_empty] at hS
      haveI := subsingleton_of_bot_eq_top hS
      

Proof state:
case mpr.intro.intro.intro.inl
α : Type u
β : Type v
γ : Type w
ι : Sort x
inst✝ : CompleteLattice α
p : α → Prop
h : ∃ x, p x
hSc : Set.Countable ∅
hps : ∀ s ∈ ∅, p s
hS : ⊥ = ⊤
this : Subsingleton α
⊢ ∃ s, (∀ (n : ℕ), p (s n)) ∧ ⨆ n, s n = ⊤

Next tactic:
rcases h with ⟨x, hx⟩