Theorem: ExceptT.seqLeft_eq
File: src/lean/Init/Control/Lawful.lean

tactic: show (x >>= fun a => y >>= fun _ => pure a) = (const (α := α) β <$> x) >>= fun f => f <$> y
state_before: α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
⊢ (SeqLeft.seqLeft x fun x => y) = Seq.seq (const β <$> x) fun x => y

tactic: rw [← ExceptT.bind_pure_comp]
state_before: α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
⊢ (do
      let a ← x
      let _ ← y
      pure a) =
    do
    let f ← const β <$> x
    f <$> y

tactic: apply ext
state_before: α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
⊢ (do
      let a ← x
      let _ ← y
      pure a) =
    do
    let f ← x >>= pure ∘ const β
    f <$> y

tactic: simp [run_bind]
state_before: case h
α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
⊢ (run do
      let a ← x
      let _ ← y
      pure a) =
    run do
      let f ← x >>= pure ∘ const β
      f <$> y

tactic: apply bind_congr
state_before: case h
α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
⊢ (do
      let x ← run x
      match x with
        | Except.ok x => do
          let x_1 ← run y
          match x_1 with
            | Except.ok x_2 => pure (Except.ok x)
            | Except.error e => pure (Except.error e)
        | Except.error e => pure (Except.error e)) =
    do
    let x ← run x
    let x ←
      match x with
        | Except.ok x => pure (Except.ok (const β x))
        | Except.error e => pure (Except.error e)
    match x with
      | Except.ok x => Except.map x <$> run y
      | Except.error e => pure (Except.error e)

tactic: intro
| Except.error _ => simp
| Except.ok _ =>
  simp [map_eq_pure_bind]; apply bind_congr; intro b;
  cases b <;> simp [comp, Except.map, const]
state_before: case h.h
α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
⊢ ∀ (a : Except ε α),
    (match a with
      | Except.ok x => do
        let x_1 ← run y
        match x_1 with
          | Except.ok x_2 => pure (Except.ok x)
          | Except.error e => pure (Except.error e)
      | Except.error e => pure (Except.error e)) =
      do
      let x ←
        match a with
          | Except.ok x => pure (Except.ok (const β x))
          | Except.error e => pure (Except.error e)
      match x with
        | Except.ok x => Except.map x <$> run y
        | Except.error e => pure (Except.error e)

tactic: simp
state_before: α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
x✝ : Except ε α
a✝ : ε
⊢ (match Except.error a✝ with
    | Except.ok x => do
      let x_1 ← run y
      match x_1 with
        | Except.ok x_2 => pure (Except.ok x)
        | Except.error e => pure (Except.error e)
    | Except.error e => pure (Except.error e)) =
    do
    let x ←
      match Except.error a✝ with
        | Except.ok x => pure (Except.ok (const β x))
        | Except.error e => pure (Except.error e)
    match x with
      | Except.ok x => Except.map x <$> run y
      | Except.error e => pure (Except.error e)

tactic: simp [map_eq_pure_bind]
state_before: α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
x✝ : Except ε α
a✝ : α
⊢ (match Except.ok a✝ with
    | Except.ok x => do
      let x_1 ← run y
      match x_1 with
        | Except.ok x_2 => pure (Except.ok x)
        | Except.error e => pure (Except.error e)
    | Except.error e => pure (Except.error e)) =
    do
    let x ←
      match Except.ok a✝ with
        | Except.ok x => pure (Except.ok (const β x))
        | Except.error e => pure (Except.error e)
    match x with
      | Except.ok x => Except.map x <$> run y
      | Except.error e => pure (Except.error e)

tactic: apply bind_congr
state_before: α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
x✝ : Except ε α
a✝ : α
⊢ (do
      let x ← run y
      match x with
        | Except.ok x => pure (Except.ok a✝)
        | Except.error e => pure (Except.error e)) =
    do
    let a ← run y
    pure (Except.map (const β a✝) a)

tactic: intro b
state_before: case h
α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
x✝ : Except ε α
a✝ : α
⊢ ∀ (a : Except ε β),
    (match a with
      | Except.ok x => pure (Except.ok a✝)
      | Except.error e => pure (Except.error e)) =
      pure (Except.map (const β a✝) a)

tactic: cases b <;> simp [comp, Except.map, const]
state_before: case h
α β ε : Type u
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
x : ExceptT ε m α
y : ExceptT ε m β
x✝ : Except ε α
a✝ : α
b : Except ε β
⊢ (match b with
    | Except.ok x => pure (Except.ok a✝)
    | Except.error e => pure (Except.error e)) =
    pure (Except.map (const β a✝) b)