Zulip Chat Archive

Stream: new members

Topic: naming a value that is trapped inside some other hypothesis


Michael (Feb 26 2026 at 23:59):

I have a function that returns a value based in part on something obtained from Exists.choose.

I apply that function and get a Prop variable that is represented as bother_function.choosexb \in \mathrm{other\_function} \,\,\cdots\mathrm{.choose} \,\,\, x

I'd like to isolate that ⋯.choose value (contained in the Prop variable) and give it a name, so that I can apply Exists.choose_spec and otherwise manipulate it. How do I do that?

Aaron Liu (Feb 27 2026 at 00:00):

there's generalize_proofs in mathlib batteries

Snir Broshi (Feb 27 2026 at 00:02):

Do you mean set foo := s.choose?
Can you create a #mwe?

Michael (Feb 27 2026 at 00:51):

import Mathlib.Data.Nat.Basic
import Mathlib.Order.Basic

section

theorem archimedes : ( n : ,  m, m > n) := by
  intro n
  exists n.succ
  apply LT.lt.gt
  apply Nat.lt_succ_iff.mpr
  exact Nat.le_refl n

example : 1 = 1 := by
  let plus_something := fun (n : )  by
    let something := Exists.choose (archimedes n)
    exact n + something
  let x := plus_something 4
  have hx : x = plus_something 4 := by rfl
  unfold plus_something at hx
  have h1 : 3 + x > 10 := by
    rw [hx] -- 3 + (4 + ⋯.choose) > 10
    -- I need to show that "⋯.choose" > 3,
    -- which will be easier if I can name it
    --
    -- I want something like:
    -- let y := "⋯.choose"
    -- have hy : y > 4 := by apply Exists.choose_spec
    -- simp
    sorry
  rfl

end

Eric Wieser (Feb 27 2026 at 00:59):

I would guess you want to start with

import Mathlib.Data.Nat.Basic
import Mathlib.Order.Basic
import Mathlib.Tactic.Choose

section

theorem archimedes : ( n : ,  m, m > n) := by
  sorry -- what you already have is fine

example : 1 = 1 := by
  choose arch h_arch using archimedes
  let plus_something := fun (n : )  n + arch n

Michael (Feb 27 2026 at 01:02):

there's not a way to assign a name to a value?

Eric Wieser (Feb 27 2026 at 01:04):

I'm more making the claim that you probably don't want to end up in the position where that question is relevant in the first place

Aaron Liu (Feb 27 2026 at 01:38):

Michael said:

import Mathlib.Data.Nat.Basic
import Mathlib.Order.Basic

section

theorem archimedes : ( n : ,  m, m > n) := by
  intro n
  exists n.succ
  apply LT.lt.gt
  apply Nat.lt_succ_iff.mpr
  exact Nat.le_refl n

example : 1 = 1 := by
  let plus_something := fun (n : )  by
    let something := Exists.choose (archimedes n)
    exact n + something
  let x := plus_something 4
  have hx : x = plus_something 4 := by rfl
  unfold plus_something at hx
  have h1 : 3 + x > 10 := by
    rw [hx] -- 3 + (4 + ⋯.choose) > 10
    -- I need to show that "⋯.choose" > 3,
    -- which will be easier if I can name it
    --
    -- I want something like:
    -- let y := "⋯.choose"
    -- have hy : y > 4 := by apply Exists.choose_spec
    -- simp
    sorry
  rfl

end

here we go

import Mathlib.Data.Nat.Basic
import Mathlib.Order.Basic
import Batteries.Tactic.GeneralizeProofs

section

theorem archimedes : ( n : ,  m, m > n) := by
  intro n
  exists n.succ
  apply LT.lt.gt
  apply Nat.lt_succ_iff.mpr
  exact Nat.le_refl n

example : 1 = 1 := by
  let plus_something := fun (n : )  by
    let something := Exists.choose (archimedes n)
    exact n + something
  let x := plus_something 4
  have hx : x = plus_something 4 := by rfl
  unfold plus_something at hx
  have h1 : 3 + x > 10 := by
    rw [hx] -- 3 + (4 + ⋯.choose) > 10
    -- I need to show that "⋯.choose" > 3,
    -- which will be easier if I can name it
    --
    -- I want something like:
    -- let y := "⋯.choose"
    -- have hy : y > 4 := by apply Exists.choose_spec
    -- simp
    generalize_proofs h at hx
    let y := h.choose
    have hy : y > 4 := by apply Exists.choose_spec
    simp
    sorry
  rfl

end

Last updated: Feb 28 2026 at 14:05 UTC