-- Mathlib/.lake/packages/lean4/src/lean/Init/Internal/Order/Lemmas.lean
theorem monotone_findSomeM?
    (f : γ → α → m (Option β)) (xs : List α) (hmono : monotone f) :
    monotone (fun x => xs.findSomeM? (f x))

Proof state:
case nil
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
⊢ monotone fun x => List.findSomeM? (f x) []

Tactic:
apply monotone_const

Result:
no goals

Proof state:
case cons.hmono₂.h
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ ∀ (y : Option β),
    monotone fun x =>
      match y with
      | some b => pure (some b)
      | none => List.findSomeM? (f x) tail✝

Tactic:
intro y

Result:
case cons.hmono₂.h
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
y : Option β
⊢ monotone fun x =>
    match y with
    | some b => pure (some b)
    | none => List.findSomeM? (f x) tail✝

Proof state:
case cons.hmono₂.h.none
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ monotone fun x =>
    match none with
    | some b => pure (some b)
    | none => List.findSomeM? (f x) tail✝

Tactic:
apply ih

Result:
no goals

Proof state:
case cons.hmono₁
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ monotone fun x => f x head✝

Tactic:
apply monotone_apply

Result:
case cons.hmono₁.h
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ monotone f

Proof state:
case cons.hmono₁.h
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ monotone f

Tactic:
apply hmono

Result:
no goals

Proof state:
case cons.hmono₂.h.some
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
val✝ : β
⊢ monotone fun x =>
    match some val✝ with
    | some b => pure (some b)
    | none => List.findSomeM? (f x) tail✝

Tactic:
apply monotone_const

Result:
no goals

Proof state:
case cons.hmono₂
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ monotone fun x __do_lift =>
    match __do_lift with
    | some b => pure (some b)
    | none => List.findSomeM? (f x) tail✝

Tactic:
apply monotone_of_monotone_apply

Result:
case cons.hmono₂.h
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ ∀ (y : Option β),
    monotone fun x =>
      match y with
      | some b => pure (some b)
      | none => List.findSomeM? (f x) tail✝

Proof state:
case cons.hmono₂.h
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
y : Option β
⊢ monotone fun x =>
    match y with
    | some b => pure (some b)
    | none => List.findSomeM? (f x) tail✝

Tactic:
cases y

Result:
case cons.hmono₂.h.none
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ monotone fun x =>
    match none with
    | some b => pure (some b)
    | none => List.findSomeM? (f x) tail✝

case cons.hmono₂.h.some
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
val✝ : β
⊢ monotone fun x =>
    match some val✝ with
    | some b => pure (some b)
    | none => List.findSomeM? (f x) tail✝

Proof state:
case cons
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ monotone fun x => List.findSomeM? (f x) (head✝ :: tail✝)

Tactic:
apply monotone_bind

Result:
case cons.hmono₁
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ monotone fun x => f x head✝

case cons.hmono₂
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
f : γ → α → m (Option β)
hmono : monotone f
head✝ : α
tail✝ : List α
ih : monotone fun x => List.findSomeM? (f x) tail✝
⊢ monotone fun x __do_lift =>
    match __do_lift with
    | some b => pure (some b)
    | none => List.findSomeM? (f x) tail✝