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

tactic: simp [sort, sort.loop]
state_before: α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
x : Nat
xs : List Nat
⊢ evalList α ctx (sort (x :: xs)) = evalList α ctx (x :: sort xs)

tactic: generalize [] = ys
state_before: α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
x : Nat
xs : List Nat
⊢ evalList α ctx (sort.loop (insert x []) xs) = evalList α ctx (x :: sort.loop [] xs)

tactic: induction xs generalizing x ys with
| nil => simp [sort.loop, evalList_insert ctx h]
| cons z zs ih =>
  rw [evalList_sort_loop_swap ctx h]; simp [sort.loop, ←ih]; apply evalList_sort_congr ctx h; rw [evalList_insert ctx h]
  cases h₂ : insert x ys with
  | nil => apply absurd h₂; simp [insert_nonEmpty]
  | cons u us =>
    cases h₃ : insert z ys with
    | nil => apply absurd h₃; simp [insert_nonEmpty]
    | cons v vs =>
      simp [evalList, ←h₂, ←h₃, evalList_insert ctx h]
      cases ys
      . simp [evalList, h.1, EvalInformation.evalOp]
      . simp [evalList, EvalInformation.evalOp]; rw [h.1, ctx.assoc.1, h.1 (evalList _ _ _)]
  all_goals simp [insert_nonEmpty]
state_before: α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
x : Nat
xs ys : List Nat
⊢ evalList α ctx (sort.loop (insert x ys) xs) = evalList α ctx (x :: sort.loop ys xs)

tactic: simp [sort.loop, evalList_insert ctx h]
state_before: case nil
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
x : Nat
ys : List Nat
⊢ evalList α ctx (sort.loop (insert x ys) []) = evalList α ctx (x :: sort.loop ys [])

tactic: rw [evalList_sort_loop_swap ctx h]
state_before: case cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ evalList α ctx (sort.loop (insert x ys) (z :: zs)) = evalList α ctx (x :: sort.loop ys (z :: zs))

tactic: simp [sort.loop, ←ih]
state_before: case cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ evalList α ctx (sort.loop (z :: insert x ys) zs) = evalList α ctx (x :: sort.loop ys (z :: zs))

tactic: apply evalList_sort_congr ctx h
state_before: case cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ evalList α ctx (sort.loop (z :: insert x ys) zs) = evalList α ctx (sort.loop (insert x (insert z ys)) zs)

tactic: rw [evalList_insert ctx h]
state_before: case cons.h₂
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ evalList α ctx (z :: insert x ys) = evalList α ctx (insert x (insert z ys))

case cons.h₃
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ z :: insert x ys ≠ []

case cons.h₄
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ insert x (insert z ys) ≠ []

tactic: cases h₂ : insert x ys with
| nil => apply absurd h₂; simp [insert_nonEmpty]
| cons u us =>
  cases h₃ : insert z ys with
  | nil => apply absurd h₃; simp [insert_nonEmpty]
  | cons v vs =>
    simp [evalList, ←h₂, ←h₃, evalList_insert ctx h]
    cases ys
    . simp [evalList, h.1, EvalInformation.evalOp]
    . simp [evalList, EvalInformation.evalOp]; rw [h.1, ctx.assoc.1, h.1 (evalList _ _ _)]
state_before: case cons.h₂
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ evalList α ctx (z :: insert x ys) = evalList α ctx (x :: insert z ys)

case cons.h₃
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ z :: insert x ys ≠ []

case cons.h₄
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ insert x (insert z ys) ≠ []

tactic: all_goals simp [insert_nonEmpty]
state_before: case cons.h₃
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ z :: insert x ys ≠ []

case cons.h₄
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ insert x (insert z ys) ≠ []

tactic: apply absurd h₂
state_before: case cons.h₂.nil
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
h₂ : insert x ys = []
⊢ evalList α ctx [z] = evalList α ctx (x :: insert z ys)

tactic: simp [insert_nonEmpty]
state_before: case cons.h₂.nil
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
h₂ : insert x ys = []
⊢ ¬insert x ys = []

tactic: cases h₃ : insert z ys with
| nil => apply absurd h₃; simp [insert_nonEmpty]
| cons v vs =>
  simp [evalList, ←h₂, ←h₃, evalList_insert ctx h]
  cases ys
  . simp [evalList, h.1, EvalInformation.evalOp]
  . simp [evalList, EvalInformation.evalOp]; rw [h.1, ctx.assoc.1, h.1 (evalList _ _ _)]
state_before: case cons.h₂.cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
u : Nat
us : List Nat
h₂ : insert x ys = u :: us
⊢ evalList α ctx (z :: u :: us) = evalList α ctx (x :: insert z ys)

tactic: apply absurd h₃
state_before: case cons.h₂.cons.nil
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
u : Nat
us : List Nat
h₂ : insert x ys = u :: us
h₃ : insert z ys = []
⊢ evalList α ctx (z :: u :: us) = evalList α ctx [x]

tactic: simp [insert_nonEmpty]
state_before: case cons.h₂.cons.nil
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
u : Nat
us : List Nat
h₂ : insert x ys = u :: us
h₃ : insert z ys = []
⊢ ¬insert z ys = []

tactic: simp [evalList, ←h₂, ←h₃, evalList_insert ctx h]
state_before: case cons.h₂.cons.cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
u : Nat
us : List Nat
h₂ : insert x ys = u :: us
v : Nat
vs : List Nat
h₃ : insert z ys = v :: vs
⊢ evalList α ctx (z :: u :: us) = evalList α ctx (x :: v :: vs)

tactic: cases ys
state_before: case cons.h₂.cons.cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
u : Nat
us : List Nat
h₂ : insert x ys = u :: us
v : Nat
vs : List Nat
h₃ : insert z ys = v :: vs
⊢ EvalInformation.evalOp ctx (EvalInformation.evalVar ctx z) (evalList α ctx (x :: ys)) =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList α ctx (z :: ys))

tactic: . simp [evalList, h.1, EvalInformation.evalOp]
state_before: case cons.h₂.cons.cons.nil
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x u : Nat
us : List Nat
v : Nat
vs : List Nat
h₂ : insert x [] = u :: us
h₃ : insert z [] = v :: vs
⊢ EvalInformation.evalOp ctx (EvalInformation.evalVar ctx z) (evalList α ctx [x]) =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList α ctx [z])

case cons.h₂.cons.cons.cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x u : Nat
us : List Nat
v : Nat
vs : List Nat
head✝ : Nat
tail✝ : List Nat
h₂ : insert x (head✝ :: tail✝) = u :: us
h₃ : insert z (head✝ :: tail✝) = v :: vs
⊢ EvalInformation.evalOp ctx (EvalInformation.evalVar ctx z) (evalList α ctx (x :: head✝ :: tail✝)) =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList α ctx (z :: head✝ :: tail✝))

tactic: . simp [evalList, EvalInformation.evalOp]; rw [h.1, ctx.assoc.1, h.1 (evalList _ _ _)]
state_before: case cons.h₂.cons.cons.cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x u : Nat
us : List Nat
v : Nat
vs : List Nat
head✝ : Nat
tail✝ : List Nat
h₂ : insert x (head✝ :: tail✝) = u :: us
h₃ : insert z (head✝ :: tail✝) = v :: vs
⊢ EvalInformation.evalOp ctx (EvalInformation.evalVar ctx z) (evalList α ctx (x :: head✝ :: tail✝)) =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList α ctx (z :: head✝ :: tail✝))

tactic: simp [evalList, h.1, EvalInformation.evalOp]
state_before: case cons.h₂.cons.cons.nil
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x u : Nat
us : List Nat
v : Nat
vs : List Nat
h₂ : insert x [] = u :: us
h₃ : insert z [] = v :: vs
⊢ EvalInformation.evalOp ctx (EvalInformation.evalVar ctx z) (evalList α ctx [x]) =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList α ctx [z])

tactic: simp [evalList, EvalInformation.evalOp]
state_before: case cons.h₂.cons.cons.cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x u : Nat
us : List Nat
v : Nat
vs : List Nat
head✝ : Nat
tail✝ : List Nat
h₂ : insert x (head✝ :: tail✝) = u :: us
h₃ : insert z (head✝ :: tail✝) = v :: vs
⊢ EvalInformation.evalOp ctx (EvalInformation.evalVar ctx z) (evalList α ctx (x :: head✝ :: tail✝)) =
    EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList α ctx (z :: head✝ :: tail✝))

tactic: rw [h.1, ctx.assoc.1, h.1 (evalList _ _ _)]
state_before: case cons.h₂.cons.cons.cons
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x u : Nat
us : List Nat
v : Nat
vs : List Nat
head✝ : Nat
tail✝ : List Nat
h₂ : insert x (head✝ :: tail✝) = u :: us
h₃ : insert z (head✝ :: tail✝) = v :: vs
⊢ op ctx (EvalInformation.evalVar ctx z) (op ctx (EvalInformation.evalVar ctx x) (evalList α ctx (head✝ :: tail✝))) =
    op ctx (EvalInformation.evalVar ctx x) (op ctx (EvalInformation.evalVar ctx z) (evalList α ctx (head✝ :: tail✝)))

tactic: simp [insert_nonEmpty]
state_before: case cons.h₄
α : Sort u_1
ctx : Context α
h : IsCommutative ctx.op
z : Nat
zs : List Nat
ih : ∀ (x : Nat) (ys : List Nat), evalList α ctx (sort.loop (insert x ys) zs) = evalList α ctx (x :: sort.loop ys zs)
x : Nat
ys : List Nat
⊢ insert x (insert z ys) ≠ []