Add proof for map and flatten