-- Mathlib/.lake/packages/lean4/src/lean/Init/Internal/Order/Lemmas.lean
theorem monotone_mapM (xs : Array α) (f : γ → α → m β) (hmono : monotone f) :
    monotone (fun x => xs.mapM (f x))

Proof state:
case hmono₁
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i✝ : Nat
r✝ : Array β
h✝ : i✝ < xs.size
ih : ∀ (__do_lift : β), monotone fun x => Array.mapM.map (f x) xs (i✝ + 1) (r✝.push __do_lift)
⊢ monotone fun x => f x xs[i✝]

Tactic:
apply monotone_apply

Result:
case hmono₁.h
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i✝ : Nat
r✝ : Array β
h✝ : i✝ < xs.size
ih : ∀ (__do_lift : β), monotone fun x => Array.mapM.map (f x) xs (i✝ + 1) (r✝.push __do_lift)
⊢ monotone f

Proof state:
case case2
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i✝ : Nat
r✝ : Array β
h✝ : ¬i✝ < xs.size
⊢ monotone fun x => Array.mapM.map (f x) xs i✝ r✝

Tactic:
case case2 =>
  unfold Array.mapM.map
  simp only [↓reduceDIte, *]
  apply monotone_const

Result:
no goals

Proof state:
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i : Nat
r : Array β
⊢ monotone fun x => Array.mapM.map (f x) xs i r

Tactic:
induction i, r using Array.mapM.map.induct xs

Result:
case case1
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i✝ : Nat
r✝ : Array β
h✝ : i✝ < xs.size
ih1✝ : ∀ (__do_lift : β), monotone fun x => Array.mapM.map (f x) xs (i✝ + 1) (r✝.push __do_lift)
⊢ monotone fun x => Array.mapM.map (f x) xs i✝ r✝

case case2
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i✝ : Nat
r✝ : Array β
h✝ : ¬i✝ < xs.size
⊢ monotone fun x => Array.mapM.map (f x) xs i✝ r✝

Proof state:
case hmono₁.h
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i✝ : Nat
r✝ : Array β
h✝ : i✝ < xs.size
ih : ∀ (__do_lift : β), monotone fun x => Array.mapM.map (f x) xs (i✝ + 1) (r✝.push __do_lift)
⊢ monotone f

Tactic:
apply hmono

Result:
no goals

Proof state:
case hmono₂.h
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i✝ : Nat
r✝ : Array β
h✝ : i✝ < xs.size
ih : ∀ (__do_lift : β), monotone fun x => Array.mapM.map (f x) xs (i✝ + 1) (r✝.push __do_lift)
y : γ
⊢ ∀ (y : β), monotone fun x => Array.mapM.map (f x) xs (i✝ + 1) (r✝.push y)

Tactic:
apply ih

Result:
no goals

Proof state:
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
this : ∀ (i : Nat) (r : Array β), monotone fun x => Array.mapM.map (f x) xs i r
⊢ monotone fun x => Array.mapM (f x) xs

Tactic:
apply this

Result:
no goals

Proof state:
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i✝ : Nat
r✝ : Array β
h✝ : ¬i✝ < xs.size
⊢ monotone fun x => Array.mapM.map (f x) xs i✝ r✝

Tactic:
unfold Array.mapM.map

Result:
m : Type u → Type v
inst✝³ : Monad m
inst✝² : (α : Type u) → PartialOrder (m α)
inst✝¹ : MonoBind m
α β : Type u
γ : Type w
inst✝ : PartialOrder γ
xs : Array α
f : γ → α → m β
hmono : monotone f
i✝ : Nat
r✝ : Array β
h✝ : ¬i✝ < xs.size
⊢ monotone fun x =>
    if hlt : i✝ < xs.size then do
      let __do_lift ← f x xs[i✝]
      Array.mapM.map (f x) xs (i✝ + 1) (r✝.push __do_lift)
    else pure r✝