Theorem: Array.SatisfiesM_anyM_iff_exists
File: .lake/packages/batteries/Batteries/Data/Array/Monadic.lean

tactic: refine (SatisfiesM_anyM _ _ _ _ hstart
  (fal := fun j => start ≤ j ∧ ¬ ∃ i : Fin as.size, start ≤ i.1 ∧ i.1 < j ∧ q i)
  (tru := ∃ i : Fin as.size, start ≤ i.1 ∧ i.1 < stop ∧ q i) ?_ ?_).imp ?_
state_before: case inl
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
⊢ SatisfiesM (fun res => res = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i) (anyM p as start stop)
state_after: case inl.refine_1
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
⊢ (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) start

case inl.refine_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
⊢ ∀ (i : Fin as.size),
    ↑i < stop →
      (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i →
        SatisfiesM
          (fun x =>
            bif x then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
            else (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) (↑i + 1))
          (p as[i])

case inl.refine_3
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
⊢ ∀ {a : Bool},
    (bif a then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
      else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i) →
      (a = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i)

tactic: exact ⟨Nat.le_refl _, fun ⟨i, h₁, h₂, _⟩ => (Nat.not_le_of_gt h₂ h₁).elim⟩
state_before: case inl.refine_1
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
⊢ (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) start
state_after: no goals

tactic: refine fun i h₂ ⟨h₁, h₃⟩ => (hp _ h₁ h₂).imp fun hq => ?_
state_before: case inl.refine_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
⊢ ∀ (i : Fin as.size),
    ↑i < stop →
      (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i →
        SatisfiesM
          (fun x =>
            bif x then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
            else (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) (↑i + 1))
          (p as[i])
state_after: case inl.refine_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
a✝ : Bool
hq : a✝ = true ↔ q i
⊢ bif a✝ then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i else (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) (↑i + 1)

tactic: unfold cond
state_before: case inl.refine_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
a✝ : Bool
hq : a✝ = true ↔ q i
⊢ bif a✝ then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i else (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) (↑i + 1)
state_after: case inl.refine_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
a✝ : Bool
hq : a✝ = true ↔ q i
⊢ match a✝ with
  | true => ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  | false => (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) (↑i + 1)

tactic: split <;> simp at hq
state_before: case inl.refine_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
a✝ : Bool
hq : a✝ = true ↔ q i
⊢ match a✝ with
  | true => ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  | false => (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) (↑i + 1)
state_after: case inl.refine_2.h_1
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
c✝ : Bool
hq : q i
⊢ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i

case inl.refine_2.h_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
c✝ : Bool
hq : ¬q i
⊢ start ≤ ↑i + 1 ∧ ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i + 1 ∧ q i_1

tactic: exact ⟨_, h₁, h₂, hq⟩
state_before: case inl.refine_2.h_1
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
c✝ : Bool
hq : q i
⊢ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
state_after: no goals

tactic: refine ⟨Nat.le_succ_of_le h₁, h₃.imp fun ⟨j, h₃, h₄, h₅⟩ => ⟨j, h₃, ?_, h₅⟩⟩
state_before: case inl.refine_2.h_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
c✝ : Bool
hq : ¬q i
⊢ start ≤ ↑i + 1 ∧ ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i + 1 ∧ q i_1
state_after: case inl.refine_2.h_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝¹ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃✝ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
c✝ : Bool
hq : ¬q i
x✝ : ∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i + 1 ∧ q i_1
j : Fin as.size
h₃ : start ≤ ↑j
h₄ : ↑j < ↑i + 1
h₅ : q j
⊢ ↑j < ↑i

tactic: refine Nat.lt_of_le_of_ne (Nat.le_of_lt_succ h₄) fun e => hq (Fin.eq_of_val_eq e ▸ h₅)
state_before: case inl.refine_2.h_2
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
i : Fin as.size
h₂ : ↑i < stop
x✝¹ : (fun j => start ≤ j ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < j ∧ q i) ↑i
h₁ : start ≤ ↑i
h₃✝ : ¬∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i ∧ q i_1
c✝ : Bool
hq : ¬q i
x✝ : ∃ i_1, start ≤ ↑i_1 ∧ ↑i_1 < ↑i + 1 ∧ q i_1
j : Fin as.size
h₃ : start ≤ ↑j
h₄ : ↑j < ↑i + 1
h₅ : q j
⊢ ↑j < ↑i
state_after: no goals

tactic: intro
| true, h => simp only [true_iff]; exact h
| false, h =>
  simp only [false_iff]
  exact h.2.imp fun ⟨j, h₁, h₂, hq⟩ => ⟨j, h₁, Nat.lt_min.2 ⟨h₂, j.2⟩, hq⟩
state_before: case inl.refine_3
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
⊢ ∀ {a : Bool},
    (bif a then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
      else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i) →
      (a = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i)
state_after: no goals

tactic: simp only [true_iff]
state_before: m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
x✝¹ : Bool
x✝ :
  bif x✝¹ then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
h :
  bif true then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
⊢ true = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
state_after: m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
x✝¹ : Bool
x✝ :
  bif x✝¹ then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
h :
  bif true then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
⊢ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i

tactic: exact h
state_before: m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
x✝¹ : Bool
x✝ :
  bif x✝¹ then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
h :
  bif true then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
⊢ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
state_after: no goals

tactic: simp only [false_iff]
state_before: m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
x✝¹ : Bool
x✝ :
  bif x✝¹ then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
h :
  bif false then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
⊢ false = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
state_after: m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
x✝¹ : Bool
x✝ :
  bif x✝¹ then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
h :
  bif false then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
⊢ ¬∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i

tactic: exact h.2.imp fun ⟨j, h₁, h₂, hq⟩ => ⟨j, h₁, Nat.lt_min.2 ⟨h₂, j.2⟩, hq⟩
state_before: m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : start ≤ min stop as.size
x✝¹ : Bool
x✝ :
  bif x✝¹ then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
h :
  bif false then ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
  else start ≤ min stop as.size ∧ ¬∃ i, start ≤ ↑i ∧ ↑i < min stop as.size ∧ q i
⊢ ¬∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
state_after: no goals

tactic: rw [anyM_stop_le_start (h := hstart)]
state_before: case inr
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : min stop as.size ≤ start
⊢ SatisfiesM (fun res => res = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i) (anyM p as start stop)
state_after: case inr
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : min stop as.size ≤ start
⊢ SatisfiesM (fun res => res = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i) (pure false)

tactic: refine .pure ?_
state_before: case inr
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : min stop as.size ≤ start
⊢ SatisfiesM (fun res => res = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i) (pure false)
state_after: case inr
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : min stop as.size ≤ start
⊢ false = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i

tactic: simp
state_before: case inr
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : min stop as.size ≤ start
⊢ false = true ↔ ∃ i, start ≤ ↑i ∧ ↑i < stop ∧ q i
state_after: case inr
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : min stop as.size ≤ start
⊢ ∀ (x : Fin as.size), start ≤ ↑x → ↑x < stop → ¬q x

tactic: intro j h₁ h₂
state_before: case inr
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : min stop as.size ≤ start
⊢ ∀ (x : Fin as.size), start ≤ ↑x → ↑x < stop → ¬q x
state_after: case inr
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : min stop as.size ≤ start
j : Fin as.size
h₁ : start ≤ ↑j
h₂ : ↑j < stop
⊢ ¬q j

tactic: cases Nat.not_lt.2 (Nat.le_trans hstart h₁) (Nat.lt_min.2 ⟨h₂, j.2⟩)
state_before: case inr
m : Type → Type u_1
α : Type u_2
inst✝¹ : Monad m
inst✝ : LawfulMonad m
p : α → m Bool
as : Array α
start stop : Nat
q : Fin as.size → Prop
hp : ∀ (i : Fin as.size), start ≤ ↑i → ↑i < stop → SatisfiesM (fun x => x = true ↔ q i) (p as[i])
hstart : min stop as.size ≤ start
j : Fin as.size
h₁ : start ≤ ↑j
h₂ : ↑j < stop
⊢ ¬q j
state_after: no goals