Theorem: algebra.zipWith_to_fold (Diploma/Order/MonomialOrder.lean)

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
h : List.length l₁ = List.length l₂
⊢ foldl algebra.sum (init₁ + init₂) (zipWith algebra.sum l₁ l₂) =
    algebra.sum (foldl algebra.sum init₁ l₁) (foldl algebra.sum init₂ l₂)
Tactic:
simp [algebra.sum]
State after:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
h : List.length l₁ = List.length l₂
⊢ foldl (fun a b => a + b) (init₁ + init₂) (zipWith (fun a b => a + b) l₁ l₂) =
    foldl (fun a b => a + b) init₁ l₁ + foldl (fun a b => a + b) init₂ l₂

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
h : List.length l₁ = List.length l₂
⊢ foldl (fun a b => a + b) (init₁ + init₂) (zipWith (fun a b => a + b) l₁ l₂) =
    foldl (fun a b => a + b) init₁ l₁ + foldl (fun a b => a + b) init₂ l₂
Tactic:
match l₁, l₂ with
  | [], []       => simp
  | x::xs, y::ys => simp
                    have open_init₂ : init₂ + (x + y) = x + init₂ + y
                    rw [Nat.add_right_comm, Nat.add_comm] 
                    rw [Nat.add_assoc, open_init₂, ← Nat.add_assoc, ←Nat.add_assoc]
                    have size_eq : xs.length = ys.length
                    simp at h
                    exact h
                    have res := zipWith_to_fold (init₁ + x) (init₂ + y) xs ys size_eq
                    simp [sum] at res
                    rw [Nat.add_assoc]
                    exact res
State after:
no goals

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
h : List.length [] = List.length []
⊢ foldl (fun a b => a + b) (init₁ + init₂) (zipWith (fun a b => a + b) [] []) =
    foldl (fun a b => a + b) init₁ [] + foldl (fun a b => a + b) init₂ []
Tactic:
simp
State after:
no goals

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
⊢ foldl (fun a b => a + b) (init₁ + init₂) (zipWith (fun a b => a + b) (x :: xs) (y :: ys)) =
    foldl (fun a b => a + b) init₁ (x :: xs) + foldl (fun a b => a + b) init₂ (y :: ys)
Tactic:
simp
State after:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
⊢ foldl (fun a b => a + b) (init₁ + init₂ + (x + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
⊢ foldl (fun a b => a + b) (init₁ + init₂ + (x + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
have open_init₂ : init₂ + (x + y) = x + init₂ + y
State after:
case open_init₂
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
⊢ init₂ + (x + y) = x + init₂ + y

init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
⊢ foldl (fun a b => a + b) (init₁ + init₂ + (x + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
case open_init₂
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
⊢ init₂ + (x + y) = x + init₂ + y

init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
⊢ foldl (fun a b => a + b) (init₁ + init₂ + (x + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
rw [Nat.add_right_comm, Nat.add_comm]
State after:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
⊢ foldl (fun a b => a + b) (init₁ + init₂ + (x + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
⊢ foldl (fun a b => a + b) (init₁ + init₂ + (x + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
rw [Nat.add_assoc, open_init₂, ← Nat.add_assoc, ←Nat.add_assoc]
State after:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
have size_eq : xs.length = ys.length
State after:
case size_eq
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
⊢ List.length xs = List.length ys

init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
case size_eq
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
⊢ List.length xs = List.length ys

init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
simp at h
State after:
case size_eq
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
open_init₂ : init₂ + (x + y) = x + init₂ + y
h : List.length xs = List.length ys
⊢ List.length xs = List.length ys

init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
case size_eq
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
open_init₂ : init₂ + (x + y) = x + init₂ + y
h : List.length xs = List.length ys
⊢ List.length xs = List.length ys

init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
exact h
State after:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
have res := zipWith_to_fold (init₁ + x) (init₂ + y) xs ys size_eq
State after:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
res :
  foldl algebra.sum (init₁ + x + (init₂ + y)) (zipWith algebra.sum xs ys) =
    algebra.sum (foldl algebra.sum (init₁ + x) xs) (foldl algebra.sum (init₂ + y) ys)
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
res :
  foldl algebra.sum (init₁ + x + (init₂ + y)) (zipWith algebra.sum xs ys) =
    algebra.sum (foldl algebra.sum (init₁ + x) xs) (foldl algebra.sum (init₂ + y) ys)
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
simp [sum] at res
State after:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
res :
  foldl (fun a b => a + b) (init₁ + x + (init₂ + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
res :
  foldl (fun a b => a + b) (init₁ + x + (init₂ + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
⊢ foldl (fun a b => a + b) (init₁ + x + init₂ + y) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
rw [Nat.add_assoc]
State after:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
res :
  foldl (fun a b => a + b) (init₁ + x + (init₂ + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
⊢ foldl (fun a b => a + b) (init₁ + x + (init₂ + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys

State before:
init₁ init₂ : ℕ
l₁ l₂ : List ℕ
x : ℕ
xs : List ℕ
y : ℕ
ys : List ℕ
h : List.length (x :: xs) = List.length (y :: ys)
open_init₂ : init₂ + (x + y) = x + init₂ + y
size_eq : List.length xs = List.length ys
res :
  foldl (fun a b => a + b) (init₁ + x + (init₂ + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
⊢ foldl (fun a b => a + b) (init₁ + x + (init₂ + y)) (zipWith (fun a b => a + b) xs ys) =
    foldl (fun a b => a + b) (init₁ + x) xs + foldl (fun a b => a + b) (init₂ + y) ys
Tactic:
exact res
State after:
no goals