Theorem: LawfulMonad.mk'
File: Std/Classes/LawfulMonad.lean

tactic: rw [← bind_pure_comp]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
α β : Type u
g : α → β
x : α
⊢ g <$> pure x = pure (g x)

tactic: simp [pure_bind]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
α β : Type u
g : α → β
x : α
⊢ (do
      let y ← pure x
      pure (g y)) =
    pure (g x)

tactic: simp [← bind_pure_comp, bind_assoc, pure_bind]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
⊢ ∀ {α β γ : Type u} (g : α → β) (h : β → γ) (x : m α), (h ∘ g) <$> x = h <$> g <$> x

tactic: intros
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
⊢ ∀ {α β : Type u} (g : α → β) (x : m α), (Seq.seq (pure g) fun x_1 => x) = g <$> x

tactic: rw [← bind_map]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
α✝ β✝ : Type u
g✝ : α✝ → β✝
x✝ : m α✝
⊢ (Seq.seq (pure g✝) fun x => x✝) = g✝ <$> x✝

tactic: simp [pure_bind]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
α✝ β✝ : Type u
g✝ : α✝ → β✝
x✝ : m α✝
⊢ (do
      let x ← pure g✝
      x <$> x✝) =
    g✝ <$> x✝

tactic: intros
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
⊢ ∀ {α β : Type u} (g : m (α → β)) (x : α), (Seq.seq g fun x_1 => pure x) = (fun h => h x) <$> g

tactic: rw [← bind_map]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
α✝ β✝ : Type u
g✝ : m (α✝ → β✝)
x✝ : α✝
⊢ (Seq.seq g✝ fun x => pure x✝) = (fun h => h x✝) <$> g✝

tactic: simp [map_pure, bind_pure_comp]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
α✝ β✝ : Type u
g✝ : m (α✝ → β✝)
x✝ : α✝
⊢ (do
      let x ← g✝
      x <$> pure x✝) =
    (fun h => h x✝) <$> g✝

tactic: simp [← bind_pure_comp, ← bind_map, bind_assoc, pure_bind]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
⊢ ∀ {α β γ : Type u} (x : m α) (g : m (α → β)) (h : m (β → γ)),
    (Seq.seq h fun x_1 => Seq.seq g fun x_2 => x) = Seq.seq (Seq.seq (Function.comp <$> h) fun x => g) fun x_1 => x

tactic: simp [seqLeft_eq, ← bind_map, ← bind_pure_comp, pure_bind, bind_assoc]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
⊢ ∀ {α β : Type u} (x : m α) (y : m β), (SeqLeft.seqLeft x fun x => y) = Seq.seq (Function.const β <$> x) fun x => y

tactic: rw [seqRight_eq, ← bind_map, ← bind_pure_comp, bind_assoc]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
α✝ β✝ : Type u
x : m α✝
y : m β✝
⊢ (SeqRight.seqRight x fun x => y) = Seq.seq (Function.const α✝ id <$> x) fun x => y

tactic: simp [pure_bind, id_map]
state_before: m : Type u → Type v
inst✝ : Monad m
id_map : ∀ {α : Type u} (x : m α), id <$> x = x
pure_bind : ∀ {α β : Type u} (x : α) (f : α → m β), pure x >>= f = f x
bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), x >>= f >>= g = x >>= fun x => f x >>= g
map_const : autoParam (∀ {α β : Type u} (x : α) (y : m β), Functor.mapConst x y = Function.const β x <$> y) _auto✝
seqLeft_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqLeft.seqLeft x fun x => y) = do
        let a ← x
        let _ ← y
        pure a)
    _auto✝
seqRight_eq :
  autoParam
    (∀ {α β : Type u} (x : m α) (y : m β),
      (SeqRight.seqRight x fun x => y) = do
        let _ ← x
        y)
    _auto✝
bind_pure_comp :
  autoParam
    (∀ {α β : Type u} (f : α → β) (x : m α),
      (do
          let y ← x
          pure (f y)) =
        f <$> x)
    _auto✝
bind_map :
  autoParam
    (∀ {α β : Type u} (f : m (α → β)) (x : m α),
      (do
          let x_1 ← f
          x_1 <$> x) =
        Seq.seq f fun x_1 => x)
    _auto✝
map_pure : ∀ {α β : Type u} (g : α → β) (x : α), g <$> pure x = pure (g x)
α✝ β✝ : Type u
x : m α✝
y : m β✝
⊢ (do
      let _ ← x
      y) =
    do
    let x ← x
    let x ← pure (Function.const α✝ id x)
    x <$> y