-- Mathlib/.lake/packages/lean4/src/lean/Init/Data/AC.lean
theorem Context.evalList_removeNeutrals (ctx : Context α) (e : List Nat) : evalList α ctx (removeNeutrals ctx e) = evalList α ctx e

Proof state:
case single
α : Sort u_1
ctx : Context α
a✝ : Nat
⊢ evalList α ctx
      (match
        match ContextInformation.isNeutral ctx a✝ with
        | true => []
        | false => [a✝] with
      | [] => [a✝]
      | ys => ys) =
    evalList α ctx [a✝]

Tactic:
split

Result:
case single.h_1
α : Sort u_1
ctx : Context α
a✝ : Nat
x✝ : List Nat
heq✝ :
  (match ContextInformation.isNeutral ctx a✝ with
    | true => []
    | false => [a✝]) =
    []
⊢ evalList α ctx [a✝] = evalList α ctx [a✝]

case single.h_2
α : Sort u_1
ctx : Context α
a✝ : Nat
x✝¹ : List Nat
x✝ :
  (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
      [] →
    False
⊢ evalList α ctx
      (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
    evalList α ctx [a✝]

Proof state:
case step
α : Sort u_1
ctx : Context α
x y : Nat
ys : List Nat
ih : evalList α ctx (removeNeutrals ctx (y :: ys)) = evalList α ctx (y :: ys)
⊢ evalList α ctx (removeNeutrals ctx (x :: y :: ys)) = evalList α ctx (x :: y :: ys)

Tactic:
cases h₁ : ContextInformation.isNeutral ctx x <;>
cases h₂ : ContextInformation.isNeutral ctx y <;>
cases h₃ : removeNeutrals.loop ctx ys
<;> simp [removeNeutrals, removeNeutrals.loop, h₁, h₂, h₃, evalList, ←ih]
<;> (try simp [unwrap_isNeutral h₂ |>.right_id])
<;> (try simp [unwrap_isNeutral h₁ |>.left_id])

Result:
no goals

Proof state:
α : Sort u_1
ctx : Context α
e : List Nat
⊢ evalList α ctx (removeNeutrals ctx e) = evalList α ctx e

Tactic:
induction e using List.two_step_induction with
| empty => rfl
| single =>
  simp [removeNeutrals, removeNeutrals.loop]; split
  case h_1 => rfl
  case h_2 h => split at h <;> simp_all
| step x y ys ih =>
  cases h₁ : ContextInformation.isNeutral ctx x <;>
  cases h₂ : ContextInformation.isNeutral ctx y <;>
  cases h₃ : removeNeutrals.loop ctx ys
  <;> simp [removeNeutrals, removeNeutrals.loop, h₁, h₂, h₃, evalList, ←ih]
  <;> (try simp [unwrap_isNeutral h₂ |>.right_id])
  <;> (try simp [unwrap_isNeutral h₁ |>.left_id])

Result:
no goals

Proof state:
case single.h_2
α : Sort u_1
ctx : Context α
a✝ : Nat
x✝¹ : List Nat
x✝ :
  (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
      [] →
    False
⊢ evalList α ctx
      (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
    evalList α ctx [a✝]

Tactic:
case h_2 h => split at h <;> simp_all

Result:
no goals

Proof state:
case step.true.true.nil
α : Sort u_1
ctx : Context α
x y : Nat
ys : List Nat
ih : evalList α ctx (removeNeutrals ctx (y :: ys)) = evalList α ctx (y :: ys)
h₁ : ContextInformation.isNeutral ctx x = true
h₂ : ContextInformation.isNeutral ctx y = true
h₃ : removeNeutrals.loop ctx ys = []
⊢ EvalInformation.evalVar ctx x =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (EvalInformation.evalVar ctx y)

Tactic:
try simp [unwrap_isNeutral h₂ |>.right_id]

Result:
no goals

Proof state:
case step.true.true.cons
α : Sort u_1
ctx : Context α
x y : Nat
ys : List Nat
ih : evalList α ctx (removeNeutrals ctx (y :: ys)) = evalList α ctx (y :: ys)
h₁ : ContextInformation.isNeutral ctx x = true
h₂ : ContextInformation.isNeutral ctx y = true
head✝ : Nat
tail✝ : List Nat
h₃ : removeNeutrals.loop ctx ys = head✝ :: tail✝
⊢ evalList α ctx (head✝ :: tail✝) =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList α ctx (head✝ :: tail✝))

Tactic:
try simp [unwrap_isNeutral h₁ |>.left_id]

Result:
no goals

Proof state:
case single
α : Sort u_1
ctx : Context α
a✝ : Nat
⊢ evalList α ctx (removeNeutrals ctx [a✝]) = evalList α ctx [a✝]

Tactic:
simp [removeNeutrals, removeNeutrals.loop]

Result:
case single
α : Sort u_1
ctx : Context α
a✝ : Nat
⊢ evalList α ctx
      (match
        match ContextInformation.isNeutral ctx a✝ with
        | true => []
        | false => [a✝] with
      | [] => [a✝]
      | ys => ys) =
    evalList α ctx [a✝]

Proof state:
α : Sort u_1
ctx : Context α
a✝ : Nat
x✝ : List Nat
heq✝ :
  (match ContextInformation.isNeutral ctx a✝ with
    | true => []
    | false => [a✝]) =
    []
⊢ evalList α ctx [a✝] = evalList α ctx [a✝]

Tactic:
rfl

Result:
no goals

Proof state:
case step.true.true.nil
α : Sort u_1
ctx : Context α
x y : Nat
ys : List Nat
ih : evalList α ctx (removeNeutrals ctx (y :: ys)) = evalList α ctx (y :: ys)
h₁ : ContextInformation.isNeutral ctx x = true
h₂ : ContextInformation.isNeutral ctx y = true
h₃ : removeNeutrals.loop ctx ys = []
⊢ EvalInformation.evalVar ctx x =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (EvalInformation.evalVar ctx y)

Tactic:
simp [unwrap_isNeutral h₂ |>.right_id]

Result:
no goals

Proof state:
case single.h_1
α : Sort u_1
ctx : Context α
a✝ : Nat
x✝ : List Nat
heq✝ :
  (match ContextInformation.isNeutral ctx a✝ with
    | true => []
    | false => [a✝]) =
    []
⊢ evalList α ctx [a✝] = evalList α ctx [a✝]

case single.h_2
α : Sort u_1
ctx : Context α
a✝ : Nat
x✝¹ : List Nat
x✝ :
  (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
      [] →
    False
⊢ evalList α ctx
      (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
    evalList α ctx [a✝]

Tactic:
case h_1 => rfl

Result:
case single.h_2
α : Sort u_1
ctx : Context α
a✝ : Nat
x✝¹ : List Nat
x✝ :
  (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
      [] →
    False
⊢ evalList α ctx
      (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
    evalList α ctx [a✝]

Proof state:
case step.true.true.cons
α : Sort u_1
ctx : Context α
x y : Nat
ys : List Nat
ih : evalList α ctx (removeNeutrals ctx (y :: ys)) = evalList α ctx (y :: ys)
h₁ : ContextInformation.isNeutral ctx x = true
h₂ : ContextInformation.isNeutral ctx y = true
head✝ : Nat
tail✝ : List Nat
h₃ : removeNeutrals.loop ctx ys = head✝ :: tail✝
⊢ evalList α ctx (head✝ :: tail✝) =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList α ctx (head✝ :: tail✝))

Tactic:
simp [unwrap_isNeutral h₁ |>.left_id]

Result:
no goals

Proof state:
case empty
α : Sort u_1
ctx : Context α
⊢ evalList α ctx (removeNeutrals ctx []) = evalList α ctx []

Tactic:
rfl

Result:
no goals

Proof state:
α : Sort u_1
ctx : Context α
a✝ : Nat
x✝ : List Nat
h :
  (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
      [] →
    False
⊢ evalList α ctx
      (match ContextInformation.isNeutral ctx a✝ with
      | true => []
      | false => [a✝]) =
    evalList α ctx [a✝]

Tactic:
split at h <;> simp_all

Result:
no goals