l3lab/ntp-mathlib huggingface dataset:
/-- A relation is well-founded iff every principal segment of it is well-founded.

In this lemma we use `Subrel` to indicate its principal segments because it's usually more
convenient to use.
-/
theorem wellFounded_iff_wellFounded_subrel {β : Type*} {s : β → β → Prop} [IsTrans β s] :
    WellFounded s ↔ ∀ b, WellFounded (Subrel s { b' | s b' b }) := by
  refine'
    ⟨fun wf b => ⟨fun b' => ((PrincipalSeg.ofElement _ b).acc b').mpr (wf.apply b')⟩, fun wf =>
      ⟨fun b => Acc.intro _ fun b' hb' => _⟩⟩
  let f := PrincipalSeg.ofElement s b
  

Proof state:
α : Type u_1
β✝ : Type u_2
γ : Type u_3
r : α → α → Prop
s✝ : β✝ → β✝ → Prop
t : γ → γ → Prop
β : Type u_4
s : β → β → Prop
inst✝ : IsTrans β s
wf : ∀ (b : β), WellFounded (Subrel s {b' | s b' b})
b b' : β
hb' : s b' b
f : Subrel s {b_1 | s b_1 b} ≺i s := PrincipalSeg.ofElement s b
⊢ Acc s b'

Next tactic:
obtain ⟨b', rfl⟩ := f.down.mp ((PrincipalSeg.ofElement_top s b).symm ▸ hb' : s b' f.top)
/-- A relation is well-founded iff every principal segment of it is well-founded.

In this lemma we use `Subrel` to indicate its principal segments because it's usually more
convenient to use.
-/
theorem wellFounded_iff_wellFounded_subrel {β : Type*} {s : β → β → Prop} [IsTrans β s] :
    WellFounded s ↔ ∀ b, WellFounded (Subrel s { b' | s b' b }) := by
  refine'
    ⟨fun wf b => ⟨fun b' => ((PrincipalSeg.ofElement _ b).acc b').mpr (wf.apply b')⟩, fun wf =>
      ⟨fun b => Acc.intro _ fun b' hb' => _⟩⟩
  let f := PrincipalSeg.ofElement s b
  obtain ⟨b', rfl⟩ := f.down.mp ((PrincipalSeg.ofElement_top s b).symm ▸ hb' : s b' f.top)
  

Proof state:
case intro
α : Type u_1
β✝ : Type u_2
γ : Type u_3
r : α → α → Prop
s✝ : β✝ → β✝ → Prop
t : γ → γ → Prop
β : Type u_4
s : β → β → Prop
inst✝ : IsTrans β s
wf : ∀ (b : β), WellFounded (Subrel s {b' | s b' b})
b : β
f : Subrel s {b_1 | s b_1 b} ≺i s := PrincipalSeg.ofElement s b
b' : ↑{b_1 | s b_1 b}
hb' : s (f.toRelEmbedding b') b
⊢ Acc s (f.toRelEmbedding b')

Next tactic:
exact (f.acc b').mp ((wf b).apply b')
/-- To an initial segment taking values in a well order, one can associate either a principal
segment (if the range is not everything, hence one can take as top the minimum of the complement
of the range) or an order isomorphism (if the range is everything). -/
noncomputable def InitialSeg.ltOrEq [IsWellOrder β s] (f : r ≼i s) : Sum (r ≺i s) (r ≃r s) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ≼i s
⊢ (r ≺i s) ⊕ (r ≃r s)

Next tactic:
by_cases h : Surjective f
/-- To an initial segment taking values in a well order, one can associate either a principal
segment (if the range is not everything, hence one can take as top the minimum of the complement
of the range) or an order isomorphism (if the range is everything). -/
noncomputable def InitialSeg.ltOrEq [IsWellOrder β s] (f : r ≼i s) : Sum (r ≺i s) (r ≃r s) := by
  by_cases h : Surjective f
  · 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ≼i s
h : Surjective ⇑f
⊢ (r ≺i s) ⊕ (r ≃r s)

Next tactic:
exact Sum.inr (RelIso.ofSurjective f h)
/-- To an initial segment taking values in a well order, one can associate either a principal
segment (if the range is not everything, hence one can take as top the minimum of the complement
of the range) or an order isomorphism (if the range is everything). -/
noncomputable def InitialSeg.ltOrEq [IsWellOrder β s] (f : r ≼i s) : Sum (r ≺i s) (r ≃r s) := by
  by_cases h : Surjective f
  · exact Sum.inr (RelIso.ofSurjective f h)
  · 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ≼i s
h : ¬Surjective ⇑f
⊢ (r ≺i s) ⊕ (r ≃r s)

Next tactic:
have h' : _ := (InitialSeg.eq_or_principal f).resolve_left h
/-- To an initial segment taking values in a well order, one can associate either a principal
segment (if the range is not everything, hence one can take as top the minimum of the complement
of the range) or an order isomorphism (if the range is everything). -/
noncomputable def InitialSeg.ltOrEq [IsWellOrder β s] (f : r ≼i s) : Sum (r ≺i s) (r ≃r s) := by
  by_cases h : Surjective f
  · exact Sum.inr (RelIso.ofSurjective f h)
  · have h' : _ := (InitialSeg.eq_or_principal f).resolve_left h
    

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ≼i s
h : ¬Surjective ⇑f
h' : ∃ b, ∀ (x : β), s x b ↔ ∃ y, f y = x
⊢ (r ≺i s) ⊕ (r ≃r s)

Next tactic:
exact Sum.inl ⟨f, Classical.choose h', Classical.choose_spec h'⟩
@[simp]
theorem InitialSeg.leLT_apply [IsWellOrder β s] [IsTrans γ t] (f : r ≼i s) (g : s ≺i t) (a : α) :
    (f.leLT g) a = g (f a) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝¹ : IsWellOrder β s
inst✝ : IsTrans γ t
f : r ≼i s
g : s ≺i t
a : α
⊢ (leLT f g).toRelEmbedding a = g.toRelEmbedding (f a)

Next tactic:
delta InitialSeg.leLT
@[simp]
theorem InitialSeg.leLT_apply [IsWellOrder β s] [IsTrans γ t] (f : r ≼i s) (g : s ≺i t) (a : α) :
    (f.leLT g) a = g (f a) := by
  delta InitialSeg.leLT; 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝¹ : IsWellOrder β s
inst✝ : IsTrans γ t
f : r ≼i s
g : s ≺i t
a : α
⊢ (match ltOrEq f with
        | Sum.inl f' => PrincipalSeg.trans f' g
        | Sum.inr f' => PrincipalSeg.equivLT f' g).toRelEmbedding
      a =
    g.toRelEmbedding (f a)

Next tactic:
cases' h : f.ltOrEq with f' f'
@[simp]
theorem InitialSeg.leLT_apply [IsWellOrder β s] [IsTrans γ t] (f : r ≼i s) (g : s ≺i t) (a : α) :
    (f.leLT g) a = g (f a) := by
  delta InitialSeg.leLT; cases' h : f.ltOrEq with f' f'
  · 

Proof state:
case inl
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝¹ : IsWellOrder β s
inst✝ : IsTrans γ t
f : r ≼i s
g : s ≺i t
a : α
f' : r ≺i s
h : ltOrEq f = Sum.inl f'
⊢ (match Sum.inl f' with
        | Sum.inl f' => PrincipalSeg.trans f' g
        | Sum.inr f' => PrincipalSeg.equivLT f' g).toRelEmbedding
      a =
    g.toRelEmbedding (f a)

Next tactic:
simp only [PrincipalSeg.trans_apply, f.ltOrEq_apply_left]
@[simp]
theorem InitialSeg.leLT_apply [IsWellOrder β s] [IsTrans γ t] (f : r ≼i s) (g : s ≺i t) (a : α) :
    (f.leLT g) a = g (f a) := by
  delta InitialSeg.leLT; cases' h : f.ltOrEq with f' f'
  · simp only [PrincipalSeg.trans_apply, f.ltOrEq_apply_left]
  · 

Proof state:
case inr
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝¹ : IsWellOrder β s
inst✝ : IsTrans γ t
f : r ≼i s
g : s ≺i t
a : α
f' : r ≃r s
h : ltOrEq f = Sum.inr f'
⊢ (match Sum.inr f' with
        | Sum.inl f' => PrincipalSeg.trans f' g
        | Sum.inr f' => PrincipalSeg.equivLT f' g).toRelEmbedding
      a =
    g.toRelEmbedding (f a)

Next tactic:
simp only [PrincipalSeg.equivLT_apply, f.ltOrEq_apply_right]
/-- Given an order embedding into a well order, collapse the order embedding by filling the
gaps, to obtain an initial segment. Here, we construct the collapsed order embedding pointwise,
but the proof of the fact that it is an initial segment will be given in `collapse`. -/
noncomputable def collapseF [IsWellOrder β s] (f : r ↪r s) : ∀ a, { b // ¬s (f a) b } :=
  (RelEmbedding.wellFounded f <| IsWellFounded.wf).fix fun a IH => by
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
IH : (y : α) → r y a → { b // ¬s (f y) b }
⊢ { b // ¬s (f a) b }

Next tactic:
let S := { b | ∀ a h, s (IH a h).1 b }
/-- Given an order embedding into a well order, collapse the order embedding by filling the
gaps, to obtain an initial segment. Here, we construct the collapsed order embedding pointwise,
but the proof of the fact that it is an initial segment will be given in `collapse`. -/
noncomputable def collapseF [IsWellOrder β s] (f : r ↪r s) : ∀ a, { b // ¬s (f a) b } :=
  (RelEmbedding.wellFounded f <| IsWellFounded.wf).fix fun a IH => by
    let S := { b | ∀ a h, s (IH a h).1 b }
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
IH : (y : α) → r y a → { b // ¬s (f y) b }
S : Set β := {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b}
⊢ { b // ¬s (f a) b }

Next tactic:
have : f a ∈ S := fun a' h =>
      ((trichotomous _ _).resolve_left fun h' =>
            (IH a' h).2 <| _root_.trans (f.map_rel_iff.2 h) h').resolve_left
        fun h' => (IH a' h).2 <| h' ▸ f.map_rel_iff.2 h
/-- Given an order embedding into a well order, collapse the order embedding by filling the
gaps, to obtain an initial segment. Here, we construct the collapsed order embedding pointwise,
but the proof of the fact that it is an initial segment will be given in `collapse`. -/
noncomputable def collapseF [IsWellOrder β s] (f : r ↪r s) : ∀ a, { b // ¬s (f a) b } :=
  (RelEmbedding.wellFounded f <| IsWellFounded.wf).fix fun a IH => by
    let S := { b | ∀ a h, s (IH a h).1 b }
    have : f a ∈ S := fun a' h =>
      ((trichotomous _ _).resolve_left fun h' =>
            (IH a' h).2 <| _root_.trans (f.map_rel_iff.2 h) h').resolve_left
        fun h' => (IH a' h).2 <| h' ▸ f.map_rel_iff.2 h
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
IH : (y : α) → r y a → { b // ¬s (f y) b }
S : Set β := {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b}
this : f a ∈ S
⊢ { b // ¬s (f a) b }

Next tactic:
exact ⟨_, IsWellFounded.wf.not_lt_min _ ⟨_, this⟩ this⟩
theorem collapseF.lt [IsWellOrder β s] (f : r ↪r s) {a : α} :
    ∀ {a'}, r a' a → s (collapseF f a').1 (collapseF f a).1 := @fun a => by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a✝ a : α
⊢ r a a✝ → s ↑(collapseF f a) ↑(collapseF f a✝)

Next tactic:
revert a
theorem collapseF.lt [IsWellOrder β s] (f : r ↪r s) {a : α} :
    ∀ {a'}, r a' a → s (collapseF f a').1 (collapseF f a).1 := @fun a => by
  revert a
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
⊢ ∀ (a_1 : α), r a_1 a → s ↑(collapseF f a_1) ↑(collapseF f a)

Next tactic:
show (collapseF f a).1 ∈ { b | ∀ (a') (_ : r a' a), s (collapseF f a').1 b }
theorem collapseF.lt [IsWellOrder β s] (f : r ↪r s) {a : α} :
    ∀ {a'}, r a' a → s (collapseF f a').1 (collapseF f a).1 := @fun a => by
  revert a
  show (collapseF f a).1 ∈ { b | ∀ (a') (_ : r a' a), s (collapseF f a').1 b }
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
⊢ ↑(collapseF f a) ∈ {b | ∀ (a' : α), r a' a → s (↑(collapseF f a')) b}

Next tactic:
unfold collapseF
theorem collapseF.lt [IsWellOrder β s] (f : r ↪r s) {a : α} :
    ∀ {a'}, r a' a → s (collapseF f a').1 (collapseF f a).1 := @fun a => by
  revert a
  show (collapseF f a).1 ∈ { b | ∀ (a') (_ : r a' a), s (collapseF f a').1 b }
  unfold collapseF; 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
⊢ ↑(WellFounded.fix (_ : WellFounded r)
        (fun a IH =>
          let S := {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b};
          let_fun this := (_ : ∀ (a' : α) (h : r a' a), s (↑(IH a' h)) (f a));
          { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
            property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) })
        a) ∈
    {b |
      ∀ (a' : α),
        r a' a →
          s
            (↑(WellFounded.fix (_ : WellFounded r)
                (fun a IH =>
                  let S := {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b};
                  let_fun this := (_ : ∀ (a' : α) (h : r a' a), s (↑(IH a' h)) (f a));
                  { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
                    property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) })
                a'))
            b}

Next tactic:
rw [WellFounded.fix_eq]
theorem collapseF.lt [IsWellOrder β s] (f : r ↪r s) {a : α} :
    ∀ {a'}, r a' a → s (collapseF f a').1 (collapseF f a).1 := @fun a => by
  revert a
  show (collapseF f a).1 ∈ { b | ∀ (a') (_ : r a' a), s (collapseF f a').1 b }
  unfold collapseF; rw [WellFounded.fix_eq]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
⊢ ↑(let S :=
        {b |
          ∀ (a_1 : α) (h : r a_1 a),
            s
              (↑((fun y x =>
                    WellFounded.fix (_ : WellFounded r)
                      (fun a IH =>
                        let S := {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b};
                        let_fun this := (_ : ∀ (a' : α) (h : r a' a), s (↑(IH a' h)) (f a));
                        { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
                          property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) })
                      y)
                  a_1 h))
              b};
      let_fun this :=
        (_ :
          ∀ (a' : α),
            r a' a →
              s
                (↑(WellFounded.fix (_ : WellFounded r)
                    (fun a IH =>
                      let S := {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b};
                      let_fun this := (_ : ∀ (a' : α) (h : r a' a), s (↑(IH a' h)) (f a));
                      { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
                        property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) })
                    a'))
                (f a));
      { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
        property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) }) ∈
    {b |
      ∀ (a' : α),
        r a' a →
          s
            (↑(WellFounded.fix (_ : WellFounded r)
                (fun a IH =>
                  let S := {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b};
                  let_fun this := (_ : ∀ (a' : α) (h : r a' a), s (↑(IH a' h)) (f a));
                  { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
                    property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) })
                a'))
            b}

Next tactic:
dsimp only
theorem collapseF.lt [IsWellOrder β s] (f : r ↪r s) {a : α} :
    ∀ {a'}, r a' a → s (collapseF f a').1 (collapseF f a).1 := @fun a => by
  revert a
  show (collapseF f a).1 ∈ { b | ∀ (a') (_ : r a' a), s (collapseF f a').1 b }
  unfold collapseF; rw [WellFounded.fix_eq]
  dsimp only
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
⊢ WellFounded.min (_ : WellFounded s)
      {b |
        ∀ (a_1 : α),
          r a_1 a →
            s
              (↑(WellFounded.fix (_ : WellFounded r)
                  (fun a IH =>
                    {
                      val :=
                        WellFounded.min (_ : WellFounded s) {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}
                          (_ : ∃ x, x ∈ {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}),
                      property :=
                        (_ :
                          ¬s (f a)
                              (WellFounded.min (_ : WellFounded s) {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}
                                (_ : ∃ x, x ∈ {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}))) })
                  a_1))
              b}
      (_ :
        ∃ x,
          x ∈
            {b |
              ∀ (a_1 : α),
                r a_1 a →
                  s
                    (↑(WellFounded.fix (_ : WellFounded r)
                        (fun a IH =>
                          {
                            val :=
                              WellFounded.min (_ : WellFounded s) {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}
                                (_ : ∃ x, x ∈ {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}),
                            property :=
                              (_ :
                                ¬s (f a)
                                    (WellFounded.min (_ : WellFounded s)
                                      {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}
                                      (_ : ∃ x, x ∈ {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}))) })
                        a_1))
                    b}) ∈
    {b |
      ∀ (a' : α),
        r a' a →
          s
            (↑(WellFounded.fix (_ : WellFounded r)
                (fun a IH =>
                  {
                    val :=
                      WellFounded.min (_ : WellFounded s) {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b}
                        (_ : ∃ x, x ∈ {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b}),
                    property :=
                      (_ :
                        ¬s (f a)
                            (WellFounded.min (_ : WellFounded s) {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b}
                              (_ : ∃ x, x ∈ {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b}))) })
                a'))
            b}

Next tactic:
apply WellFounded.min_mem _ _
theorem collapseF.not_lt [IsWellOrder β s] (f : r ↪r s) (a : α) {b}
    (h : ∀ a' (_ : r a' a), s (collapseF f a').1 b) : ¬s b (collapseF f a).1 := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
b : β
h : ∀ (a' : α), r a' a → s (↑(collapseF f a')) b
⊢ ¬s b ↑(collapseF f a)

Next tactic:
unfold collapseF
theorem collapseF.not_lt [IsWellOrder β s] (f : r ↪r s) (a : α) {b}
    (h : ∀ a' (_ : r a' a), s (collapseF f a').1 b) : ¬s b (collapseF f a).1 := by
  unfold collapseF; 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
b : β
h : ∀ (a' : α), r a' a → s (↑(collapseF f a')) b
⊢ ¬s b
      ↑(WellFounded.fix (_ : WellFounded r)
          (fun a IH =>
            let S := {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b};
            let_fun this := (_ : ∀ (a' : α) (h : r a' a), s (↑(IH a' h)) (f a));
            { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
              property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) })
          a)

Next tactic:
rw [WellFounded.fix_eq]
theorem collapseF.not_lt [IsWellOrder β s] (f : r ↪r s) (a : α) {b}
    (h : ∀ a' (_ : r a' a), s (collapseF f a').1 b) : ¬s b (collapseF f a).1 := by
  unfold collapseF; rw [WellFounded.fix_eq]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
b : β
h : ∀ (a' : α), r a' a → s (↑(collapseF f a')) b
⊢ ¬s b
      ↑(let S :=
          {b |
            ∀ (a_1 : α) (h : r a_1 a),
              s
                (↑((fun y x =>
                      WellFounded.fix (_ : WellFounded r)
                        (fun a IH =>
                          let S := {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b};
                          let_fun this := (_ : ∀ (a' : α) (h : r a' a), s (↑(IH a' h)) (f a));
                          { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
                            property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) })
                        y)
                    a_1 h))
                b};
        let_fun this :=
          (_ :
            ∀ (a' : α),
              r a' a →
                s
                  (↑(WellFounded.fix (_ : WellFounded r)
                      (fun a IH =>
                        let S := {b | ∀ (a_1 : α) (h : r a_1 a), s (↑(IH a_1 h)) b};
                        let_fun this := (_ : ∀ (a' : α) (h : r a' a), s (↑(IH a' h)) (f a));
                        { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
                          property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) })
                      a'))
                  (f a));
        { val := WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S),
          property := (_ : ¬s (f a) (WellFounded.min (_ : WellFounded s) S (_ : ∃ x, x ∈ S))) })

Next tactic:
dsimp only
theorem collapseF.not_lt [IsWellOrder β s] (f : r ↪r s) (a : α) {b}
    (h : ∀ a' (_ : r a' a), s (collapseF f a').1 b) : ¬s b (collapseF f a).1 := by
  unfold collapseF; rw [WellFounded.fix_eq]
  dsimp only
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
r : α → α → Prop
s : β → β → Prop
t : γ → γ → Prop
inst✝ : IsWellOrder β s
f : r ↪r s
a : α
b : β
h : ∀ (a' : α), r a' a → s (↑(collapseF f a')) b
⊢ ¬s b
      (WellFounded.min (_ : WellFounded s)
        {b |
          ∀ (a_1 : α),
            r a_1 a →
              s
                (↑(WellFounded.fix (_ : WellFounded r)
                    (fun a IH =>
                      {
                        val :=
                          WellFounded.min (_ : WellFounded s) {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}
                            (_ : ∃ x, x ∈ {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}),
                        property :=
                          (_ :
                            ¬s (f a)
                                (WellFounded.min (_ : WellFounded s) {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}
                                  (_ : ∃ x, x ∈ {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}))) })
                    a_1))
                b}
        (_ :
          ∃ x,
            x ∈
              {b |
                ∀ (a_1 : α),
                  r a_1 a →
                    s
                      (↑(WellFounded.fix (_ : WellFounded r)
                          (fun a IH =>
                            {
                              val :=
                                WellFounded.min (_ : WellFounded s) {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}
                                  (_ : ∃ x, x ∈ {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}),
                              property :=
                                (_ :
                                  ¬s (f a)
                                      (WellFounded.min (_ : WellFounded s)
                                        {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}
                                        (_ : ∃ x, x ∈ {b | ∀ (a_2 : α) (h : r a_2 a), s (↑(IH a_2 h)) b}))) })
                          a_1))
                      b}))

Next tactic:
exact WellFounded.not_lt_min _ _ _ h