m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
⊢ SatisfiesM (motive (size as)) (foldlM.loop f as (size as) (_ : size as ≤ size as) (size as) 0 init)
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
⊢ SatisfiesM (motive (size as)) (foldlM f init as 0 (size as))
simp [foldlM]
no goals
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
⊢ SatisfiesM (motive (size as)) (foldlM.loop f as (size as) (_ : size as ≤ size as) (size as) 0 init)
exact go (Nat.zero_le _) (Nat.le_refl _) h0
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
i j : Nat
b : β
h₁ : j ≤ size as
h₂ : size as ≤ i + j
H : motive j b
⊢ SatisfiesM (motive (size as))
    (if hlt : j < size as then
      match i with
      | 0 => pure b
      | Nat.succ i' =>
        let_fun this := (_ : j < size as);
        do
        let __do_lift ← f b as[j]
        foldlM.loop f as (size as) (_ : size as ≤ size as) i' (j + 1) __do_lift
    else pure b)
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
i j : Nat
b : β
h₁ : j ≤ size as
h₂ : size as ≤ i + j
H : motive j b
⊢ SatisfiesM (motive (size as)) (foldlM.loop f as (size as) (_ : size as ≤ size as) i j b)
unfold foldlM.loop
case inl
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
i j : Nat
b : β
h₁ : j ≤ size as
h₂ : size as ≤ i + j
H : motive j b
h✝ : j < size as
⊢ SatisfiesM (motive (size as))
    (match i with
    | 0 => pure b
    | Nat.succ i' =>
      let_fun this := (_ : j < size as);
      do
      let __do_lift ← f b as[j]
      foldlM.loop f as (size as) (_ : size as ≤ size as) i' (j + 1) __do_lift)

case inr
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
i j : Nat
b : β
h₁ : j ≤ size as
h₂ : size as ≤ i + j
H : motive j b
h✝ : ¬j < size as
⊢ SatisfiesM (motive (size as)) (pure b)
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
i j : Nat
b : β
h₁ : j ≤ size as
h₂ : size as ≤ i + j
H : motive j b
⊢ SatisfiesM (motive (size as))
    (if hlt : j < size as then
      match i with
      | 0 => pure b
      | Nat.succ i' =>
        let_fun this := (_ : j < size as);
        do
        let __do_lift ← f b as[j]
        foldlM.loop f as (size as) (_ : size as ≤ size as) i' (j + 1) __do_lift
    else pure b)
split
case h_1
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
j : Nat
b : β
h₁ : j ≤ size as
H : motive j b
hj : j < size as
i✝ : Nat
h₂ : size as ≤ 0 + j
⊢ SatisfiesM (motive (size as)) (pure b)

case h_2
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
j : Nat
b : β
h₁ : j ≤ size as
H : motive j b
hj : j < size as
i✝ i'✝ : Nat
h₂ : size as ≤ Nat.succ i'✝ + j
⊢ SatisfiesM (motive (size as))
    (let_fun this := (_ : j < size as);
    do
    let __do_lift ← f b as[j]
    foldlM.loop f as (size as) (_ : size as ≤ size as) i'✝ (j + 1) __do_lift)
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
i j : Nat
b : β
h₁ : j ≤ size as
h₂ : size as ≤ i + j
H : motive j b
hj : j < size as
⊢ SatisfiesM (motive (size as))
    (match i with
    | 0 => pure b
    | Nat.succ i' =>
      let_fun this := (_ : j < size as);
      do
      let __do_lift ← f b as[j]
      foldlM.loop f as (size as) (_ : size as ≤ size as) i' (j + 1) __do_lift)
split
no goals
case h_1
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
j : Nat
b : β
h₁ : j ≤ size as
H : motive j b
hj : j < size as
i✝ : Nat
h₂ : size as ≤ 0 + j
⊢ SatisfiesM (motive (size as)) (pure b)
cases Nat.not_le_of_gt (by simp [hj]) h₂
no goals
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
j : Nat
b : β
h₁ : j ≤ size as
H : motive j b
hj : j < size as
i✝ : Nat
h₂ : size as ≤ 0 + j
⊢ size as > 0 + j
simp [hj]
no goals
case h_2
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
j : Nat
b : β
h₁ : j ≤ size as
H : motive j b
hj : j < size as
i✝ i'✝ : Nat
h₂ : size as ≤ Nat.succ i'✝ + j
⊢ SatisfiesM (motive (size as))
    (let_fun this := (_ : j < size as);
    do
    let __do_lift ← f b as[j]
    foldlM.loop f as (size as) (_ : size as ≤ size as) i'✝ (j + 1) __do_lift)
exact (hf ⟨j, hj⟩ b H).bind fun _ => go hj (by rwa [Nat.succ_add] at h₂)
no goals
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
j : Nat
b : β
h₁ : j ≤ size as
H : motive j b
hj : j < size as
i✝ i'✝ : Nat
h₂ : size as ≤ Nat.succ i'✝ + j
x✝ : β
⊢ size as ≤ i'✝ + ({ val := j, isLt := hj }.val + 1)
rwa [Nat.succ_add] at h₂
no goals
case inr
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
i j : Nat
b : β
h₁ : j ≤ size as
h₂ : size as ≤ i + j
H : motive j b
h✝ : ¬j < size as
⊢ SatisfiesM (motive (size as)) (pure b)
next hj => exact Nat.le_antisymm h₁ (Nat.ge_of_not_lt hj) ▸ .pure H
no goals
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
as : Array α
motive : Nat → β → Prop
init : β
h0 : motive 0 init
f : β → α → m β
hf : ∀ (i : Fin (size as)) (b : β), motive i.val b → SatisfiesM (motive (i.val + 1)) (f b as[i])
i j : Nat
b : β
h₁ : j ≤ size as
h₂ : size as ≤ i + j
H : motive j b
hj : ¬j < size as
⊢ SatisfiesM (motive (size as)) (pure b)
exact Nat.le_antisymm h₁ (Nat.ge_of_not_lt hj) ▸ .pure H