Theorem: run_bind3 (MLIR/Semantics/Semantics.lean)

State before:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
⊢ run (StateT.bind ma fun x => k x) env =
    match run ma env with
    | Except.ok (a, env') => run (k a) env'
    | Except.error e => Except.error e
Tactic:
simp[run, TopM.bind]
State after:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
⊢ StateT.run (StateT.bind ma fun x => k x) env =
    match StateT.run ma env with
    | Except.ok (a, env') => StateT.run (k a) env'
    | Except.error e => Except.error e

State before:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
⊢ StateT.run (StateT.bind ma fun x => k x) env =
    match StateT.run ma env with
    | Except.ok (a, env') => StateT.run (k a) env'
    | Except.error e => Except.error e
Tactic:
cases H : StateT.run ma env
State after:
case error
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
a✝ : String × SSAEnv Δ
H : StateT.run ma env = Except.error a✝
⊢ StateT.run (StateT.bind ma fun x => k x) env =
    match Except.error a✝ with
    | Except.ok (a, env') => StateT.run (k a) env'
    | Except.error e => Except.error e

case ok
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
a✝ : a × SSAEnv Δ
H : StateT.run ma env = Except.ok a✝
⊢ StateT.run (StateT.bind ma fun x => k x) env =
    match Except.ok a✝ with
    | Except.ok (a, env') => StateT.run (k a) env'
    | Except.error e => Except.error e

State before:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
err : String × SSAEnv Δ
H : StateT.run ma env = Except.error err
⊢ StateT.run (StateT.bind ma fun x => k x) env =
    match Except.error err with
    | Except.ok (a, env') => StateT.run (k a) env'
    | Except.error e => Except.error e
Tactic:
case error err => {
  simp[bind, Except.bind, StateT.bind, StateT.run] at *;
  simp[H];
}
State after:
no goals

State before:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
out : a × SSAEnv Δ
H : StateT.run ma env = Except.ok out
⊢ StateT.run (StateT.bind ma fun x => k x) env =
    match Except.ok out with
    | Except.ok (a, env') => StateT.run (k a) env'
    | Except.error e => Except.error e
Tactic:
case ok out => {
  simp[bind, Except.bind, StateT.bind, StateT.run] at *;
  simp[H];
}
State after:
no goals

State before:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
err : String × SSAEnv Δ
H : StateT.run ma env = Except.error err
⊢ StateT.run (StateT.bind ma fun x => k x) env =
    match Except.error err with
    | Except.ok (a, env') => StateT.run (k a) env'
    | Except.error e => Except.error e
Tactic:
simp[bind, Except.bind, StateT.bind, StateT.run] at *
State after:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
err : String × SSAEnv Δ
H : ma env = Except.error err
⊢ (match ma env with
    | Except.error err => Except.error err
    | Except.ok v => k v.fst v.snd) =
    Except.error err

State before:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
err : String × SSAEnv Δ
H : ma env = Except.error err
⊢ (match ma env with
    | Except.error err => Except.error err
    | Except.ok v => k v.fst v.snd) =
    Except.error err
Tactic:
simp[H]
State after:
no goals

State before:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
out : a × SSAEnv Δ
H : StateT.run ma env = Except.ok out
⊢ StateT.run (StateT.bind ma fun x => k x) env =
    match Except.ok out with
    | Except.ok (a, env') => StateT.run (k a) env'
    | Except.error e => Except.error e
Tactic:
simp[bind, Except.bind, StateT.bind, StateT.run] at *
State after:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
out : a × SSAEnv Δ
H : ma env = Except.ok out
⊢ (match ma env with
    | Except.error err => Except.error err
    | Except.ok v => k v.fst v.snd) =
    k out.fst out.snd

State before:
α₁ σ₁ : Type
ε₁ : σ₁ → Type
δ₁ : Dialect α₁ σ₁ ε₁
α₂ σ₂ : Type
ε₂ : σ₂ → Type
δ₂ : Dialect α₂ σ₂ ε₂
α σ : Type
ε : σ → Type
a b : Type
Δ : Dialect α σ ε
ma : TopM Δ a
k : a → TopM Δ b
env : SSAEnv Δ
out : a × SSAEnv Δ
H : ma env = Except.ok out
⊢ (match ma env with
    | Except.error err => Except.error err
    | Except.ok v => k v.fst v.snd) =
    k out.fst out.snd
Tactic:
simp[H]
State after:
no goals