Is the concatenation operation on a list associative?

619 Views Asked by At

Is the concatenation operation on a list associative?

[] = empty list
l and l' = lists

Let's assume that we have to prove that:

l concat (l' concat []) = (l concat l') concat []

How can I prove it using a prof by induction?

I was thinking that:
base case is: [] concat l' = l'
Step case is = (s:l) concat l' = l'

I am not sure if what I wrote is correct and if the base and step cases are correct.

Thank you

1

There are 1 best solutions below

2
On BEST ANSWER

The easiest way to prove that concatenation is associative is using indices: prove that if $a,b,c$ are lists and $i$ is an index, then $$((a\ \mathrm{concat}\ b)\ \mathrm {concat}\ c)[i]=(a\ \mathrm{concat}\ (b\ \mathrm {concat}\ c))[i]$$ Proving it this way does not require induction.