With any text between the date environment and the \mainmatter command or the next environment, Lyx would consider \mainmatter or the \part environment to be undefined commands.
After some experimentation I discovered an odd solution. If I used the noun style in the title environment, the following commands would be recognised correctly.
I'm curious to find out what's causing this behaviour. I've attached mimimal sample files. Works.lyx uses the noun style in the title environment, Error.lyx does not. Try to export to PDF using View > PDF (pdflatex).
I'm using LyX/Aqua 1.3.5.
Ben
Error.lyx
Description: Binary data
Works.lyx
Description: Binary data