Is production completely lost when losing a wonder race?
Solution 1:
The other answers are no longer correct, as of Gathering Storm (and possibly before).
When failing to complete a wonder in time, you will now receive a notification; it will indicate exactly how much production was "awarded" to the city in question:
"You were not able to complete the world wonder Statue of Liberty in time. However 918 Production has been salvaged from the attempt and was awarded to the city of Texcoco.
The next production you select in the city will be reduced in price by the value of the wonder; and given how expensive wonders are, it is likely to become "free." (Notably, no production can take less than one turn; so it's hugely wasteful to select a cheap unit or something immediately after being refunded for a Wonder; the best options are probably other wonders, high-tech buildings, or Armies/Armadas.)
For instance, after clicking the notification above, here's the production interface in the named city:
Note my city's production, ~90/turn; and the cost of the Helicopter Corps, 1350, taking only 3 turns to produce.