I am trying to prove the following statement by structural induction:
foldr f st (xs++yx) = f (foldr f st xs) (foldr f st ys) (foldr.3)
However I am not even sure how to define foldr, so I am stuck as no definitions have been provided to me. I now believe that foldr can be defined as
foldr f st [] = st (foldr.1)
foldr f st x:xs = f x (foldr f st xs) (foldr.2)
Now I want to start working on the base case passing the empty list to foldr. I have this, but I don't think it is correct.
foldr f st ([]++[]) = f (foldr f st []) (foldr f st [])
LHS:
foldr f st ([]++[]) = foldr f st [] by (++)
foldr f st [] = st by (foldr.1)
RHS:
f (foldr f st []) (foldr f st []) = f st st by (foldr.1)
= st by definition of identity, st = 0
LHS = RHS, therefore base case holds
Now this is what I have for my inductive step:
Assume that:
foldr f st (xs ++ ys) = f (foldr f st xs) (foldr f st ys) (ind. hyp)
Show that:
foldr f st (x:xs ++ ys) = f (foldr f st x:xs) (foldr f st ys) (inductive step)
LHS:
foldr f st (x:xs ++ ys) = f x (foldr f st xs) (foldr f st ys) (by foldr.2)
RHS:
f (foldr f st x:xs) (foldr f st ys) =
= f f x (foldr f st xs) (foldr f st ys) (by foldr.2)
= f x (foldr f st xs) (foldr f st ys)
LHS = RHS, therefore inductive step holds. End of proof.
I am not sure if this proof is valid. I need some help in determining if it correct and if not - what part of it is not.