Theorem: Lean.Data.AC.Context.evalList_sort
File: src/lean/Init/Data/AC.lean

tactic: have h : IsCommutative ctx.op := by simp [ContextInformation.isComm, Option.isSome] at h; cases h₂ : ctx.comm <;> simp [h₂] at h; assumption
state_before: α : Sort u_1
ctx : Context α
h : ContextInformation.isComm ctx = true
e : List Nat
⊢ evalList α ctx (sort e) = evalList α ctx e

tactic: induction e using List.two_step_induction with
| empty => rfl
| single => rfl
| step x y ys ih =>
  simp [evalList_sort_cons ctx h]
  cases h₂ : sort (y :: ys) with
  | nil => simp [sort, sort.loop] at *; apply absurd h₂; apply sort_loop_nonEmpty; apply insert_nonEmpty
  | cons z zs => simp [evalList, ←h₂, ih]
state_before: α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
e : List Nat
h : IsCommutative ctx.op
⊢ evalList α ctx (sort e) = evalList α ctx e

tactic: simp [ContextInformation.isComm, Option.isSome] at h
state_before: α : Sort u_1
ctx : Context α
h : ContextInformation.isComm ctx = true
e : List Nat
⊢ IsCommutative ctx.op

tactic: cases h₂ : ctx.comm <;> simp [h₂] at h
state_before: α : Sort u_1
ctx : Context α
h :
  (match ctx.comm with
    | some val => true
    | none => false) =
    true
e : List Nat
⊢ IsCommutative ctx.op

tactic: assumption
state_before: case some
α : Sort u_1
ctx : Context α
e : List Nat
val✝ : IsCommutative ctx.op
h₂ : ctx.comm = some val✝
h : True
⊢ IsCommutative ctx.op

tactic: rfl
state_before: case empty
α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
h : IsCommutative ctx.op
⊢ evalList α ctx (sort []) = evalList α ctx []

tactic: rfl
state_before: case single
α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
h : IsCommutative ctx.op
a✝ : Nat
⊢ evalList α ctx (sort [a✝]) = evalList α ctx [a✝]

tactic: simp [evalList_sort_cons ctx h]
state_before: case step
α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
h : IsCommutative ctx.op
x y : Nat
ys : List Nat
ih : evalList α ctx (sort (y :: ys)) = evalList α ctx (y :: ys)
⊢ evalList α ctx (sort (x :: y :: ys)) = evalList α ctx (x :: y :: ys)

tactic: cases h₂ : sort (y :: ys) with
| nil => simp [sort, sort.loop] at *; apply absurd h₂; apply sort_loop_nonEmpty; apply insert_nonEmpty
| cons z zs => simp [evalList, ←h₂, ih]
state_before: case step
α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
h : IsCommutative ctx.op
x y : Nat
ys : List Nat
ih : evalList α ctx (sort (y :: ys)) = evalList α ctx (y :: ys)
⊢ evalList α ctx (x :: sort (y :: ys)) = evalList α ctx (x :: y :: ys)

tactic: simp [sort, sort.loop] at *
state_before: case step.nil
α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
h : IsCommutative ctx.op
x y : Nat
ys : List Nat
ih : evalList α ctx (sort (y :: ys)) = evalList α ctx (y :: ys)
h₂ : sort (y :: ys) = []
⊢ evalList α ctx [x] = evalList α ctx (x :: y :: ys)

tactic: apply absurd h₂
state_before: case step.nil
α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
h : IsCommutative ctx.op
x y : Nat
ys : List Nat
ih : evalList α ctx (sort.loop (insert y []) ys) = evalList α ctx (y :: ys)
h₂ : sort.loop (insert y []) ys = []
⊢ evalList α ctx [x] = evalList α ctx (x :: y :: ys)

tactic: apply sort_loop_nonEmpty
state_before: case step.nil
α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
h : IsCommutative ctx.op
x y : Nat
ys : List Nat
ih : evalList α ctx (sort.loop (insert y []) ys) = evalList α ctx (y :: ys)
h₂ : sort.loop (insert y []) ys = []
⊢ ¬sort.loop (insert y []) ys = []

tactic: apply insert_nonEmpty
state_before: case step.nil.h
α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
h : IsCommutative ctx.op
x y : Nat
ys : List Nat
ih : evalList α ctx (sort.loop (insert y []) ys) = evalList α ctx (y :: ys)
h₂ : sort.loop (insert y []) ys = []
⊢ insert y [] ≠ []

tactic: simp [evalList, ←h₂, ih]
state_before: case step.cons
α : Sort u_1
ctx : Context α
h✝ : ContextInformation.isComm ctx = true
h : IsCommutative ctx.op
x y : Nat
ys : List Nat
ih : evalList α ctx (sort (y :: ys)) = evalList α ctx (y :: ys)
z : Nat
zs : List Nat
h₂ : sort (y :: ys) = z :: zs
⊢ evalList α ctx (x :: z :: zs) = evalList α ctx (x :: y :: ys)